paneful 0.9.19 → 0.9.20

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.
@@ -59,7 +59,7 @@ var e,t,i,r,s,n,o,a,l;!function(){const e=document.createElement("link").relList
59
59
  * Fabrice Bellard's javascript vt100 for jslinux:
60
60
  * http://bellard.org/jslinux/
61
61
  * Copyright (c) 2011 Fabrice Bellard
62
- */function tb(e){(function(e){return e instanceof ob||e instanceof Error&&e.name===ib&&e.message===ib})(e)||eb.onUnexpectedError(e)}var ib="Canceled";var rb,sb,nb,ob=class extends Error{constructor(){super(ib),this.name=this.message}},ab=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function lb(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function cb(e){if(nb.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(dg){t.push(dg)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function hb(...e){return ub(()=>cb(e))}function ub(e){return{dispose:lb(()=>{e()})}}(sb=rb||(rb={})).isLessThan=function(e){return e<0},sb.isLessThanOrEqual=function(e){return e<=0},sb.isGreaterThan=function(e){return e>0},sb.isNeitherLessOrGreaterThan=function(e){return 0===e},sb.greaterThan=1,sb.lessThan=-1,sb.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(nb||(nb={}));var db=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{cb(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};db.DISABLE_DISPOSED_WARNING=!1;var fb=db,pb=class{constructor(){this._store=new fb,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};pb.None=Object.freeze({dispose(){}});var gb,_b=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},mb=globalThis.performance&&"function"==typeof globalThis.performance.now,vb=class e{static create(t){return new e(t)}constructor(e){this._now=mb&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new Tb({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,c,h,u=0,d=new Tb({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!c&&(d.fire(l),l=void 0),h=()=>{let e=l;l=void 0,c=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(c),c=setTimeout(h,i)):void 0===c&&(c=0,queueMicrotask(h))})},onWillRemoveListener(){s&&u>0&&(null==h||h())},onDidRemoveLastListener(){h=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>pb.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>{let s=hb(...e.map(e=>e(e=>t.call(i,e))));return function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(s,r)}},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new Tb({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Tb({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Tb({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new Tb;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Tb(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof fb?r.add(a):Array.isArray(r)&&r.push(a),a}}})(gb||(gb={}));var bb=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new vb,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};bb.all=new Set,bb._idPool=0;var yb=bb,xb=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new kb(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};xb._idPool=1;var wb,Sb=xb,Cb=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},kb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Eb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Lb=0,Rb=class{constructor(e){this.value=e,this.id=Lb++}},Tb=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new Sb((null==e?void 0:e.onListenerError)??tb,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new yb(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new Eb(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||tb)(i),pb.None}if(this._disposed)return pb.None;t&&(e=e.bind(t));let l,c=new Rb(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(c.stack=Cb.create(),l=this._leakageMon.check(c.stack,this._size+1)),this._listeners?this._listeners instanceof Rb?(this._deliveryQueue??(this._deliveryQueue=new Mb),this._listeners=[this._listeners,c]):this._listeners.push(c):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=c,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let h=ub(()=>{null==l||l(),this._removeListener(c)});return i instanceof fb?i.add(h):Array.isArray(i)&&i.push(h),h}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||tb;if(r)try{e.value(t)}catch(mp){r(mp)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof Rb)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},Mb=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}},Pb=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Db||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:gb.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Pb})})(wb||(wb={}));var Ab,Nb,Db=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?Pb:(this._emitter||(this._emitter=new Tb),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ib="en",Bb=Ib,Ob=globalThis;typeof Ob.vscode<"u"&&typeof Ob.vscode.process<"u"?Nb=Ob.vscode.process:typeof process<"u"&&"string"==typeof(null==(r=null==process?void 0:process.versions)?void 0:r.node)&&(Nb=process);var jb="string"==typeof(null==(s=null==Nb?void 0:Nb.versions)?void 0:s.electron)&&"renderer"===(null==Nb?void 0:Nb.type);if("object"==typeof Nb){Nb.platform,Nb.platform,"linux"===Nb.platform&&!!Nb.env.SNAP&&Nb.env.SNAP_REVISION,!!Nb.env.CI||Nb.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Bb=Ib;let e=Nb.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Bb=t.resolvedLanguage||Ib,null==(n=t.languagePack)?void 0:n.translationsConfigFile}catch{}}else"object"!=typeof navigator||jb?console.error("Unable to resolve platform."):((Ab=navigator.userAgent).indexOf("Windows"),Ab.indexOf("Macintosh"),(Ab.indexOf("Macintosh")>=0||Ab.indexOf("iPad")>=0||Ab.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Ab.indexOf("Linux")>=0,null==Ab||Ab.indexOf("Mobi"),Bb=globalThis._VSCODE_NLS_LANGUAGE||Ib,navigator.language.toLowerCase());var zb,Fb=Ab,$b=Bb;(e=>{e.value=function(){return $b},e.isDefaultVariant=function(){return 2===$b.length?"en"===$b:$b.length>=3&&("e"===$b[0]&&"n"===$b[1]&&"-"===$b[2])},e.isDefault=function(){return"en"===$b}})(zb||(zb={}));var Wb="function"==typeof Ob.postMessage&&!Ob.importScripts;(()=>{if(Wb){let e=[];Ob.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),Ob.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var Hb,Ub,qb=!!(Fb&&Fb.indexOf("Chrome")>=0);function Kb(e,t=0,i){let r=setTimeout(()=>{e()},t);return ub(()=>{clearTimeout(r)})}Fb&&Fb.indexOf("Firefox"),!qb&&Fb&&Fb.indexOf("Safari"),Fb&&Fb.indexOf("Edg/"),Fb&&Fb.indexOf("Android"),(Ub=Hb||(Hb={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},Ub.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(vt){i(vt)}})};var Vb=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Tb,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(mp){this.reject(mp)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await gb.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Vb.EMPTY=Vb.fromArray([]);var Gb=class extends pb{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new _b),this._linesCacheDisposables=this._register(new _b),this._register(ub(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=hb(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Kb(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){var t;return null==(t=this._linesCache)?void 0:t[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){var i;let r=[],s=[0],n=this._terminal.buffer.active.getLine(e);for(;n;){let o=this._terminal.buffer.active.getLine(e+1),a=!!o&&o.isWrapped,l=n.translateToString(!a&&t);if(a&&o){let e=n.getCell(n.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===(null==(i=o.getCell(0))?void 0:i.getWidth())&&(l=l.slice(0,-1))}if(r.push(l),!a)break;s.push(s[s.length-1]+l.length),e++,n=o}return[r.join(""),s]}},Yb=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return!this._lastSearchOptions||!!e&&(this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord)}shouldUpdateHighlighting(e,t){return!!(null==t?void 0:t.decorations)&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||this.didOptionsChange(t))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Xb=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,r){if(!e||0===e.length)return void this._terminal.clearSelection();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let s={startRow:t,startCol:i},n=this._findInLine(e,s,r);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(s.startRow=o,s.startCol=0,n=this._findInLine(e,s,r),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=0,n=0;r&&(i===e?(s=r.end.x,n=r.end.y):(s=r.start.x,n=r.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:s},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&0!==n)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&r&&(o.startRow=r.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a,l={startRow:s,startCol:n};if(r&&(l.startRow=s=r.start.y,l.startCol=n=r.start.x,i!==e&&(a=this._findInLine(e,l,t,!1),a||(l.startRow=s=r.end.y,l.startCol=n=r.end.x))),a||(a=this._findInLine(e,l,t,o)),!a){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let i=s-1;i>=0&&(l.startRow=i,a=this._findInLine(e,l,t,o),!a);i--);}if(!a&&s!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let c=this._terminal.buffer.active.baseY+this._terminal.rows-1;c>=s&&(l.startRow=c,a=this._findInLine(e,l,t,o),!a);c--);return a}_isWholeWord(e,t,i){return(0===e||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},r=!1){var s;let n=t.startRow,o=t.startCol;if(null==(s=this._terminal.buffer.active.getLine(n))?void 0:s.isWrapped)return r?void(t.startCol+=this._terminal.cols):(t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i));let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,c]=a,h=this._bufferColsToStringOffset(n,o),u=e,d=l;i.regex||(u=i.caseSensitive?e:e.toLowerCase(),d=i.caseSensitive?l:l.toLowerCase());let f=-1;if(i.regex){let t,s=RegExp(u,i.caseSensitive?"g":"gi");if(r)for(;t=s.exec(d.slice(0,h));)f=s.lastIndex-t[0].length,e=t[0],s.lastIndex-=e.length-1;else t=s.exec(d.slice(h)),t&&t[0].length>0&&(f=h+(s.lastIndex-t[0].length),e=t[0])}else r?h-u.length>=0&&(f=d.lastIndexOf(u,h-u.length)):f=d.indexOf(u,h);if(f>=0){if(i.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let s=f-c[t],o=f+e.length-c[r],a=this._stringLengthToBufferSize(n+t,s);return{term:e,col:a,row:n+t,size:this._stringLengthToBufferSize(n+r,o)-a+this._terminal.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let r=0;r<t;r++){let e=i.getCell(r);if(!e)break;let s=e.getChars();s.length>1&&(t-=s.length-1);let n=i.getCell(r+1);n&&0===n.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,r=0,s=this._terminal.buffer.active.getLine(i);for(;t>0&&s;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=s.getCell(e);if(!t)break;t.getWidth()&&(r+=0===t.getCode()?1:t.getChars().length)}if(i++,s=this._terminal.buffer.active.getLine(i),s&&!s.isWrapped)break;t-=this._terminal.cols}return r}},Zb=class extends pb{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ub(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let e=this._createResultDecorations(i,t,!1);if(e)for(let t of e)this._storeDecoration(t,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){cb(i)}}}clearHighlightDecorations(){cb(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let r=[],s=e.col,n=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let e=Math.min(this._terminal.cols-s,n);r.push([o,s,e]),s=0,n-=e,o++}let a=[];for(let l of r){let e=this._terminal.registerMarker(l[0]),r=this._terminal.registerDecoration({marker:e,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(r){let s=[];s.push(e),s.push(r.onRender(e=>this._applyStyles(e,i?t.activeMatchBorder:t.matchBorder,!1))),s.push(r.onDispose(()=>cb(s))),a.push(r)}}return 0===a.length?void 0:a}},Qb=class extends pb{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Tb)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Jb=class extends pb{constructor(e){super(),this._highlightTimeout=this._register(new _b),this._lineCache=this._register(new _b),this._state=new Yb,this._resultTracker=this._register(new Qb),this._highlightLimit=(null==e?void 0:e.highlightLimit)??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Gb(e),this._engine=new Xb(e,this._lineCache.value),this._decorationManager=new Zb(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ub(()=>this.clearDecorations()))}_updateMatches(){var e;this._highlightTimeout.clear(),this._state.cachedSearchTerm&&(null==(e=this._state.lastSearchOptions)?void 0:e.decorations)&&(this._highlightTimeout.value=Kb(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){var t;this._resultTracker.clearSelectedDecoration(),null==(t=this._decorationManager)||t.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e))return void this.clearDecorations();this.clearDecorations(!0);let i,r=[],s=this._engine.find(e,0,0,t);for(;s&&((null==i?void 0:i.row)!==s.row||(null==i?void 0:i.col)!==s.col)&&!(r.length>=this._highlightLimit);)i=s,r.push(i),s=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(r,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(r,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!(null==e?void 0:e.decorations))}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},ey=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?oy.isErrorNoTelemetry(e)?new oy(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+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)}};function ty(e){(function(e){return e instanceof ny||e instanceof Error&&e.name===iy&&e.message===iy})(e)||ey.onUnexpectedError(e)}var iy="Canceled";var ry,sy,ny=class extends Error{constructor(){super(iy),this.name=this.message}},oy=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function ay(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function ly(e){if(sy.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(dg){t.push(dg)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function cy(...e){return hy(()=>ly(e))}function hy(e){return{dispose:ay(()=>{e()})}}(e=>{e.isLessThan=function(e){return e<0},e.isLessThanOrEqual=function(e){return e<=0},e.isGreaterThan=function(e){return e>0},e.isNeitherLessOrGreaterThan=function(e){return 0===e},e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(ry||(ry={})),(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(sy||(sy={}));var uy=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{ly(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};uy.DISABLE_DISPOSED_WARNING=!1;var dy=uy,fy=class{constructor(){this._store=new dy,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};fy.None=Object.freeze({dispose(){}});var py=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},gy=typeof process<"u"&&"title"in process,_y=gy?"node":navigator.userAgent,my=gy?"node":navigator.platform,vy=_y.includes("Firefox"),by=_y.includes("Edge"),yy=/^((?!chrome|android).)*safari/i.test(_y);my.indexOf("Linux");var xy,wy,Sy,Cy,ky,Ey=0,Ly=0,Ry=0,Ty=0,My={css:"#00000000",rgba:0};function Py(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ay(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function Ny(e){if(!e)throw new Error("value must not be falsy");return e}function Dy(e){return 57508<=e&&e<=57558}function Iy(e){return Dy(e)||function(e){return 9472<=e&&e<=9631}(e)}function By(e,t,i=0){return(e-(2*Math.round(t)-i))%(2*Math.round(t))}(e=>{e.toCss=function(e,t,i,r){return void 0!==r?`#${Py(e)}${Py(t)}${Py(i)}${Py(r)}`:`#${Py(e)}${Py(t)}${Py(i)}`},e.toRgba=function(e,t,i,r=255){return(e<<24|t<<16|i<<8|r)>>>0},e.toColor=function(t,i,r,s){return{css:e.toCss(t,i,r,s),rgba:e.toRgba(t,i,r,s)}}})(xy||(xy={})),(e=>{function t(e,t){return Ty=Math.round(255*t),[Ey,Ly,Ry]=ky.toChannels(e.rgba),{css:xy.toCss(Ey,Ly,Ry,Ty),rgba:xy.toRgba(Ey,Ly,Ry,Ty)}}e.blend=function(e,t){if(1===(Ty=(255&t.rgba)/255))return{css:t.css,rgba:t.rgba};let i=t.rgba>>24&255,r=t.rgba>>16&255,s=t.rgba>>8&255,n=e.rgba>>24&255,o=e.rgba>>16&255,a=e.rgba>>8&255;return Ey=n+Math.round((i-n)*Ty),Ly=o+Math.round((r-o)*Ty),Ry=a+Math.round((s-a)*Ty),{css:xy.toCss(Ey,Ly,Ry),rgba:xy.toRgba(Ey,Ly,Ry)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){let r=ky.ensureContrastRatio(e.rgba,t.rgba,i);if(r)return xy.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[Ey,Ly,Ry]=ky.toChannels(t),{css:xy.toCss(Ey,Ly,Ry),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return t(e,(Ty=255&e.rgba)*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}})(wy||(wy={})),(e=>{let t,i;try{let e=document.createElement("canvas");e.width=1,e.height=1;let r=e.getContext("2d",{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Ey=parseInt(e.slice(1,2).repeat(2),16),Ly=parseInt(e.slice(2,3).repeat(2),16),Ry=parseInt(e.slice(3,4).repeat(2),16),xy.toColor(Ey,Ly,Ry);case 5:return Ey=parseInt(e.slice(1,2).repeat(2),16),Ly=parseInt(e.slice(2,3).repeat(2),16),Ry=parseInt(e.slice(3,4).repeat(2),16),Ty=parseInt(e.slice(4,5).repeat(2),16),xy.toColor(Ey,Ly,Ry,Ty);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Ey=parseInt(r[1]),Ly=parseInt(r[2]),Ry=parseInt(r[3]),Ty=Math.round(255*(void 0===r[5]?1:parseFloat(r[5]))),xy.toColor(Ey,Ly,Ry,Ty);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ey,Ly,Ry,Ty]=t.getImageData(0,0,1,1).data,255!==Ty)throw new Error("css.toColor: Unsupported css format");return{rgba:xy.toRgba(Ey,Ly,Ry,Ty),css:e}}})(Sy||(Sy={})),(e=>{function t(e,t,i){let r=e/255,s=t/255,n=i/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t})(Cy||(Cy={})),(e=>{function t(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));for(;c<i&&(o>0||a>0||l>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}function i(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));for(;c<i&&(o<255||a<255||l<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(1===(Ty=(255&t)/255))return t;let i=t>>24&255,r=t>>16&255,s=t>>8&255,n=e>>24&255,o=e>>16&255,a=e>>8&255;return Ey=n+Math.round((i-n)*Ty),Ly=o+Math.round((r-o)*Ty),Ry=a+Math.round((s-a)*Ty),xy.toRgba(Ey,Ly,Ry)},e.ensureContrastRatio=function(e,r,s){let n=Cy.relativeLuminance(e>>8),o=Cy.relativeLuminance(r>>8);if(Ay(n,o)<s){if(o<n){let o=t(e,r,s),a=Ay(n,Cy.relativeLuminance(o>>8));if(a<s){let t=i(e,r,s);return a>Ay(n,Cy.relativeLuminance(t>>8))?o:t}return o}let a=i(e,r,s),l=Ay(n,Cy.relativeLuminance(a>>8));if(l<s){let i=t(e,r,s);return l>Ay(n,Cy.relativeLuminance(i>>8))?a:i}return a}},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}})(ky||(ky={}));var Oy,jy=0,zy=0,Fy=!1,$y=!1,Wy=!1,Hy=0,Uy=class{constructor(e,t,i,r,s,n){this._terminal=e,this._optionService=t,this._selectionRenderModel=i,this._decorationService=r,this._coreBrowserService=s,this._themeService=n,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=268435456&e.bg?e.extended.ext:0,zy=0,jy=0,$y=!1,Fy=!1,Wy=!1,Oy=this._themeService.colors,Hy=0,0!==e.getCode()&&4===e.extended.underlineStyle){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Hy=t*r%(2*Math.round(e))}if(this._decorationService.forEachDecorationAtCell(t,i,"bottom",e=>{e.backgroundColorRGB&&(zy=e.backgroundColorRGB.rgba>>8&16777215,$y=!0),e.foregroundColorRGB&&(jy=e.foregroundColorRGB.rgba>>8&16777215,Fy=!0)}),Wy=this._selectionRenderModel.isCellSelected(this._terminal,t,i)){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:zy=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:zy=(16777215&this.result.fg)<<8|255;break;default:zy=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:zy=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:zy=(16777215&this.result.bg)<<8|255}zy=ky.blend(zy,4294967040&(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else zy=(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if($y=!0,Oy.selectionForeground&&(jy=Oy.selectionForeground.rgba>>8&16777215,Fy=!0),Iy(e.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))jy=(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:jy=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:jy=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:jy=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:jy=(16777215&this.result.fg)<<8|255;break;default:jy=this._themeService.colors.foreground.rgba}jy=ky.blend(jy,4294967040&(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}Fy=!0}}this._decorationService.forEachDecorationAtCell(t,i,"top",e=>{e.backgroundColorRGB&&(zy=e.backgroundColorRGB.rgba>>8&16777215,$y=!0),e.foregroundColorRGB&&(jy=e.foregroundColorRGB.rgba>>8&16777215,Fy=!0)}),$y&&(zy=Wy?-16777216&e.bg&-134217729|zy|50331648:-16777216&e.bg|zy|50331648),Fy&&(jy=-16777216&e.fg&-67108865|jy|50331648),67108864&this.result.fg&&($y&&!Fy&&(jy=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&Oy.background.rgba>>8|50331648,Fy=!0),!$y&&Fy&&(zy=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&Oy.foreground.rgba>>8|50331648,$y=!0)),Oy=void 0,this.result.bg=$y?zy:this.result.bg,this.result.fg=Fy?jy:this.result.fg,this.result.ext&=536870911,this.result.ext|=Hy<<29&3758096384}},qy=vy||by?"bottom":"ideographic",Ky={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{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}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{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}],"🮖":[{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}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Vy={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Gy={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{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`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{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`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{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`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{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`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{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`},"╠":{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`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{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`},"╣":{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`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{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`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{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`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{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`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{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"},"┉":{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"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},Yy={"":{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},"":{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},"":{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},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{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},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{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},"":{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},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};function Xy(e,t,i,r,s,n,o,a){let l=Ky[t];if(l)return function(e,t,i,r,s,n){for(let o=0;o<t.length;o++){let a=t[o],l=s/8,c=n/8;e.fillRect(i+a.x*l,r+a.y*c,a.w*l,a.h*c)}}(e,l,i,r,s,n),!0;let c=Vy[t];if(c)return function(e,t,i,r,s,n){let o=Zy.get(t);o||(o=new Map,Zy.set(t,o));let a=e.fillStyle;if("string"!=typeof a)throw new Error(`Unexpected fillStyle type "${a}"`);let l=o.get(a);if(!l){let i=t[0].length,r=t.length,s=e.canvas.ownerDocument.createElement("canvas");s.width=i,s.height=r;let n,c,h,u,d=Ny(s.getContext("2d")),f=new ImageData(i,r);if(a.startsWith("#"))n=parseInt(a.slice(1,3),16),c=parseInt(a.slice(3,5),16),h=parseInt(a.slice(5,7),16),u=a.length>7&&parseInt(a.slice(7,9),16)||1;else{if(!a.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);[n,c,h,u]=a.substring(5,a.length-1).split(",").map(e=>parseFloat(e))}for(let e=0;e<r;e++)for(let r=0;r<i;r++)f.data[4*(e*i+r)]=n,f.data[4*(e*i+r)+1]=c,f.data[4*(e*i+r)+2]=h,f.data[4*(e*i+r)+3]=t[e][r]*(255*u);d.putImageData(f,0,0),l=Ny(e.createPattern(s,null)),o.set(a,l)}e.fillStyle=l,e.fillRect(i,r,s,n)}(e,c,i,r,s,n),!0;let h=Gy[t];if(h)return function(e,t,i,r,s,n,o){e.strokeStyle=e.fillStyle;for(let[a,l]of Object.entries(t)){let t;if(e.beginPath(),e.lineWidth=o*Number.parseInt(a),"function"==typeof l){t=l(.15,.15/n*s)}else t=l;for(let a of t.split(" ")){let t=a[0],l=Jy[t];if(!l){console.error(`Could not find drawing instructions for "${t}"`);continue}let c=a.substring(1).split(",");!c[0]||!c[1]||l(e,ex(c,s,n,i,r,!0,o))}e.stroke(),e.closePath()}}(e,h,i,r,s,n,a),!0;let u=Yy[t];return!!u&&(function(e,t,i,r,s,n,o,a){let l=new Path2D;l.rect(i,r,s,n),e.clip(l),e.beginPath();let c=o/12;e.lineWidth=a*c;for(let h of t.d.split(" ")){let o=h[0],l=Jy[o];if(!l){console.error(`Could not find drawing instructions for "${o}"`);continue}let u=h.substring(1).split(",");!u[0]||!u[1]||l(e,ex(u,s,n,i,r,!1,a,(t.leftPadding??0)*(c/2),(t.rightPadding??0)*(c/2)))}1===t.type?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}(e,u,i,r,s,n,o,a),!0)}Yy[""]=Yy[""],Yy[""]=Yy[""];var Zy=new Map;function Qy(e,t,i=0){return Math.max(Math.min(e,t),i)}var Jy={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 ex(e,t,i,r,s,n,o,a=0,l=0){let c=e.map(e=>parseFloat(e)||parseInt(e));if(c.length<2)throw new Error("Too few arguments for instruction");for(let h=0;h<c.length;h+=2)c[h]*=t-a*o-l*o,n&&0!==c[h]&&(c[h]=Qy(Math.round(c[h]+.5)-.5,t,0)),c[h]+=r+a*o;for(let h=1;h<c.length;h+=2)c[h]*=i,n&&0!==c[h]&&(c[h]=Qy(Math.round(c[h]+.5)-.5,i,0)),c[h]+=s;return c}var tx,ix=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={}}},rx=class{constructor(){this._data=new ix}set(e,t,i,r,s){this._data.get(e,t)||this._data.set(e,t,new ix),this._data.get(e,t).set(i,r,s)}get(e,t,i,r){var s;return null==(s=this._data.get(e,t))?void 0:s.get(i,r)}clear(){this._data.clear()}},sx=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(),1.5*i>s)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=s}this.clear()}},nx=!gy&&"requestIdleCallback"in window?class extends sx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:class extends sx{_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())}}},ox=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ax}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ax=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},lx=globalThis.performance&&"function"==typeof globalThis.performance.now,cx=class e{static create(t){return new e(t)}constructor(e){this._now=lx&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new yx({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,c,h,u=0,d=new yx({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!c&&(d.fire(l),l=void 0),h=()=>{let e=l;l=void 0,c=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(c),c=setTimeout(h,i)):void 0===c&&(c=0,queueMicrotask(h))})},onWillRemoveListener(){s&&u>0&&(null==h||h())},onDidRemoveLastListener(){h=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>fy.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(cy(...e.map(e=>e(e=>t.call(i,e)))),r)},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new yx({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new yx({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new yx({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new yx;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new yx(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof dy?r.add(a):Array.isArray(r)&&r.push(a),a}}})(tx||(tx={}));var hx=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new cx,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};hx.all=new Set,hx._idPool=0;var ux=hx,dx=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new _x(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};dx._idPool=1;var fx,px=dx,gx=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},_x=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},mx=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},vx=0,bx=class{constructor(e){this.value=e,this.id=vx++}},yx=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new px((null==e?void 0:e.onListenerError)??ty,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new ux(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new mx(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||ty)(i),fy.None}if(this._disposed)return fy.None;t&&(e=e.bind(t));let l,c=new bx(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(c.stack=gx.create(),l=this._leakageMon.check(c.stack,this._size+1)),this._listeners?this._listeners instanceof bx?(this._deliveryQueue??(this._deliveryQueue=new xx),this._listeners=[this._listeners,c]):this._listeners.push(c):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=c,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let h=hy(()=>{null==l||l(),this._removeListener(c)});return i instanceof dy?i.add(h):Array.isArray(i)&&i.push(h),h}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||ty;if(r)try{e.value(t)}catch(s){r(s)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof bx)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},xx=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}},wx={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}},Sx=class e{constructor(e,t,i){this._document=e,this._config=t,this._unicodeService=i,this._didWarmUp=!1,this._cacheMap=new rx,this._cacheMapCombined=new rx,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new ox,this._textureSize=512,this._onAddTextureAtlasCanvas=new yx,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new yx,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Ex(e,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=Ny(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new nx;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(0!==this._pages[0].currentRow.x||0!==this._pages[0].currentRow.y){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>2*t.canvas.width<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width!==e.canvas.width?t.canvas.width-e.canvas.width:t.percentageUsed-e.percentageUsed),i=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)i=e,r=t[e].canvas.width;else if(e-i===3)break;let s=t.slice(i,i+4),n=s.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-s.length,a=this._mergePages(s,o);a.version++;for(let e=n.length-1;e>=0;e--)this._deletePage(n[e]);this.pages.push(a),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(a.canvas)}let t=new Cx(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let i=2*e[0].canvas.width,r=new Cx(this._document,i,e);for(let[s,n]of e.entries()){let e=s*n.canvas.width%i,o=Math.floor(s/2)*n.canvas.height;r.ctx.drawImage(n.canvas,e,o);for(let r of n.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/i,r.sizeClipSpace.y=r.size.y/i,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/i,r.texturePositionClipSpace.y=r.texturePosition.y/i;this._onRemoveTextureAtlasCanvas.fire(n.canvas);let a=this._activePages.indexOf(n);-1!==a&&this._activePages.splice(a,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMapCombined,e,t,i,r,s,n)}getRasterizedGlyph(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMap,e,t,i,r,s,n)}_getFromCacheMap(e,t,i,r,s,n,o){return(fx=e.get(t,i,r,s))||(fx=this._drawToCache(t,i,r,s,n,o),e.set(t,i,r,s,fx)),fx}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,i,r){if(this._config.allowTransparency)return My;let s;switch(e){case 16777216:case 33554432:s=this._getColorFromAnsiIndex(t);break;case 50331648:let e=ox.toColorRGB(t);s=xy.toColor(e[0],e[1],e[2]);break;default:s=i?wy.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(s=wy.opaque(s)),s}_getForegroundColor(e,t,i,r,s,n,o,a,l,c){let h,u=this._getMinimumContrastColor(e,t,i,r,s,n,o,l,a,c);if(u)return u;switch(s){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&l&&n<8&&(n+=8),h=this._getColorFromAnsiIndex(n);break;case 50331648:let e=ox.toColorRGB(n);h=xy.toColor(e[0],e[1],e[2]);break;default:h=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(h=wy.opaque(h)),a&&(h=wy.multiplyOpacity(h,.5)),h}_resolveBackgroundRgba(e,t,i){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,i,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,i,r,s,n,o,a,l,c){if(1===this._config.minimumContrastRatio||c)return;let h=this._getContrastCache(l),u=h.getColor(e,r);if(void 0!==u)return u||void 0;let d=this._resolveBackgroundRgba(t,i,o),f=this._resolveForegroundRgba(s,n,o,a),p=ky.ensureContrastRatio(d,f,this._config.minimumContrastRatio/(l?2:1));if(!p)return void h.setColor(e,r,null);let g=xy.toColor(p>>24&255,p>>16&255,p>>8&255);return h.setColor(e,r,g),g}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,i,r,s,n,o){let a="number"==typeof t?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+4,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let c=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<c&&(this._tmpCanvas.height=c),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=s,this._workAttributeData.isInvisible())return wx;let h=!!this._workAttributeData.isBold(),u=!!this._workAttributeData.isInverse(),d=!!this._workAttributeData.isDim(),f=!!this._workAttributeData.isItalic(),p=!!this._workAttributeData.isUnderline(),g=!!this._workAttributeData.isStrikethrough(),_=!!this._workAttributeData.isOverline(),m=this._workAttributeData.getFgColor(),v=this._workAttributeData.getFgColorMode(),b=this._workAttributeData.getBgColor(),y=this._workAttributeData.getBgColorMode();if(u){let e=m;m=b,b=e;let t=v;v=y,y=t}let x=this._getBackgroundColor(y,b,u,d);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let w=h?this._config.fontWeightBold:this._config.fontWeight,S=f?"italic":"";this._tmpCtx.font=`${S} ${w} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=qy;let C=1===a.length&&Dy(a.charCodeAt(0)),k=1===a.length&&function(e){return 57520<=e&&e<=57527}(a.charCodeAt(0)),E=this._getForegroundColor(i,y,b,r,v,m,u,d,h,Iy(a.charCodeAt(0)));this._tmpCtx.fillStyle=E.css;let L=k?0:4,R=!1;!1!==this._config.customGlyphs&&(R=Xy(this._tmpCtx,a,L,L,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let T,M=!C;if(T="number"==typeof t?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),p){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())M=!1,this._tmpCtx.strokeStyle=`rgb(${ox.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{M=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let i=L,r=Math.ceil(L+this._config.deviceCharHeight)-t-(n?2*e:0),s=r+e,o=r+2*e,l=this._workAttributeData.getUnderlineVariantOffset();for(let n=0;n<T;n++){this._tmpCtx.save();let a=i+n*this._config.deviceCellWidth,c=i+(n+1)*this._config.deviceCellWidth,h=a+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(c,r),this._tmpCtx.moveTo(a,o),this._tmpCtx.lineTo(c,o);break;case 3:let i=e<=1?o:Math.ceil(L+this._config.deviceCharHeight-e/2)-t,n=e<=1?r:Math.ceil(L+this._config.deviceCharHeight+e/2)-t,u=new Path2D;u.rect(a,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(u),this._tmpCtx.moveTo(a-this._config.deviceCellWidth/2,s),this._tmpCtx.bezierCurveTo(a-this._config.deviceCellWidth/2,n,a,n,a,s),this._tmpCtx.bezierCurveTo(a,i,h,i,h,s),this._tmpCtx.bezierCurveTo(h,n,c,n,c,s),this._tmpCtx.bezierCurveTo(c,i,c+this._config.deviceCellWidth/2,i,c+this._config.deviceCellWidth/2,s);break;case 4:let d=0===l?0:l>=e?2*e-l:e-l;!1==!(l>=e)||0===d?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a+d,r),this._tmpCtx.lineTo(c,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(a+d,r),this._tmpCtx.moveTo(a+d+e,r),this._tmpCtx.lineTo(c,r)),l=By(c-a,e,l);break;case 5:let f=.6,p=.3,g=c-a,_=Math.floor(f*g),m=Math.floor(p*g),v=g-_-m;this._tmpCtx.setLineDash([_,m,v]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(c,r);break;default:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(c,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!R&&this._config.fontSize>=12&&!this._config.allowTransparency&&" "!==a){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let t=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(i,r-Math.ceil(e/2),this._config.deviceCellWidth*T,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(a,L,L+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(_){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(L,L+t),this._tmpCtx.lineTo(L+this._config.deviceCharWidth*T,L+t),this._tmpCtx.stroke()}if(R||this._tmpCtx.fillText(a,L,L+this._config.deviceCharHeight),"_"===a&&!this._config.allowTransparency){let e=kx(this._tmpCtx.getImageData(L,L,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,M);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,L,L+this._config.deviceCharHeight-t),e=kx(this._tmpCtx.getImageData(L,L,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,M),e);t++);}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(L,L+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(L+this._config.deviceCharWidth*T,L+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let P,A=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(P=this._config.allowTransparency?function(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}(A):kx(A,x,E,M),P)return wx;let N,D,I=this._findGlyphBoundingBox(A,this._workBoundingBox,l,k,R,L);for(;;){if(0===this._activePages.length){let e=this._createNewPage();N=e,D=e.currentRow,D.height=I.size.y;break}N=this._activePages[this._activePages.length-1],D=N.currentRow;for(let e of this._activePages)I.size.y<=e.currentRow.height&&(N=e,D=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=D.height&&I.size.y<=t.height&&(N=this._activePages[e],D=t);if(I.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Cx(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),N=this._overflowSizePage,D=this._overflowSizePage.currentRow,D.x+I.size.x>=N.canvas.width&&(D.x=0,D.y+=D.height,D.height=0);break}if(D.y+I.size.y>=N.canvas.height||D.height>I.size.y+2){let t=!1;if(N.currentRow.y+N.currentRow.height+I.size.y>=N.canvas.height){let i;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+I.size.y<e.canvas.height){i=e;break}if(i)N=i;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&D.y+I.size.y<=N.canvas.height&&D.height>=I.size.y&&D.x+I.size.x<=N.canvas.width)t=!0;else{let e=this._createNewPage();N=e,D=e.currentRow,D.height=I.size.y,t=!0}}t||(N.currentRow.height>0&&N.fixedRows.push(N.currentRow),D={x:0,y:N.currentRow.y+N.currentRow.height,height:I.size.y},N.fixedRows.push(D),N.currentRow={x:0,y:D.y+D.height,height:0})}if(D.x+I.size.x<=N.canvas.width)break;D===N.currentRow?(D.x=0,D.y+=D.height,D.height=0):N.fixedRows.splice(N.fixedRows.indexOf(D),1)}return I.texturePage=this._pages.indexOf(N),I.texturePosition.x=D.x,I.texturePosition.y=D.y,I.texturePositionClipSpace.x=D.x/N.canvas.width,I.texturePositionClipSpace.y=D.y/N.canvas.height,I.sizeClipSpace.x/=N.canvas.width,I.sizeClipSpace.y/=N.canvas.height,D.height=Math.max(D.height,I.size.y),D.x+=I.size.x,N.ctx.putImageData(A,I.texturePosition.x-this._workBoundingBox.left,I.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,I.size.x,I.size.y),N.addGlyph(I),N.version++,I}_findGlyphBoundingBox(e,t,i,r,s,n){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,a=r?this._config.deviceCellWidth:i,l=!1;for(let c=0;c<o;c++){for(let i=0;i<a;i++){let r=c*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.top=c,l=!0;break}}if(l)break}t.left=0,l=!1;for(let c=0;c<n+a;c++){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*c+3;if(0!==e.data[r]){t.left=c,l=!0;break}}if(l)break}t.right=a,l=!1;for(let c=n+a-1;c>=n;c--){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*c+3;if(0!==e.data[r]){t.right=c,l=!0;break}}if(l)break}t.bottom=o,l=!1;for(let c=o-1;c>=0;c--){for(let i=0;i<a;i++){let r=c*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.bottom=c,l=!0;break}}if(l)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+n+(r||s?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+n+(r||s?1===this._config.lineHeight?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Cx=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=Ex(e,t,t),this.ctx=Ny(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 kx(e,t,i,r){let s=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,c=i.rgba>>>8&255,h=Math.floor((Math.abs(s-a)+Math.abs(n-l)+Math.abs(o-c))/12),u=!0;for(let d=0;d<e.data.length;d+=4)e.data[d]===s&&e.data[d+1]===n&&e.data[d+2]===o||r&&Math.abs(e.data[d]-s)+Math.abs(e.data[d+1]-n)+Math.abs(e.data[d+2]-o)<h?e.data[d+3]=0:u=!1;return u}function Ex(e,t,i){let r=e.createElement("canvas");return r.width=t,r.height=i,r}function Lx(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}var Rx=[];function Tx(e,t,i,r,s,n,o,a,l){let c=function(e,t,i,r,s,n,o,a){let l={foreground:n.foreground,background:n.background,cursor:My,cursorAccent:My,selectionForeground:My,selectionBackgroundTransparent:My,selectionBackgroundOpaque:My,selectionInactiveBackgroundTransparent:My,selectionInactiveBackgroundOpaque:My,overviewRulerBorder:My,scrollbarSliderBackground:My,scrollbarSliderHoverBackground:My,scrollbarSliderActiveBackground:My,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:o,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}}(r,s,n,o,t,i,a,l);for(let d=0;d<Rx.length;d++){let t=Rx[d],i=t.ownedBy.indexOf(e);if(i>=0){if(Lx(t.config,c))return t.atlas;1===t.ownedBy.length?(t.atlas.dispose(),Rx.splice(d,1)):t.ownedBy.splice(i,1);break}}for(let d=0;d<Rx.length;d++){let t=Rx[d];if(Lx(t.config,c))return t.ownedBy.push(e),t.atlas}let h=e._core,u={atlas:new Sx(document,c,h.unicodeService),config:c,ownedBy:[e]};return Rx.push(u),u.atlas}function Mx(e){for(let t=0;t<Rx.length;t++){let i=Rx[t].ownedBy.indexOf(e);if(-1!==i){1===Rx[t].ownedBy.length?(Rx[t].atlas.dispose(),Rx.splice(t,1)):Rx[t].ownedBy.splice(i,1);break}}}var Px=600,Ax=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=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Px-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0)return void this._restartInterval(e)}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 e=Px-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(e)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Px)},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 Nx(e,t,i){let r=new t.ResizeObserver(t=>{let s=t.find(t=>t.target===e);if(!s)return;if(!("devicePixelContentBoxSize"in s))return null==r||r.disconnect(),void(r=void 0);let n=s.devicePixelContentBoxSize[0].inlineSize,o=s.devicePixelContentBoxSize[0].blockSize;n>0&&o>0&&i(n,o)});try{r.observe(e,{box:["device-pixel-content-box"]})}catch{r.disconnect(),r=void 0}return hy(()=>null==r?void 0:r.disconnect())}var Dx=class e extends ox{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ax,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(2===e[1].length){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ix=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Bx(e,t,i){let r=Ny(e.createProgram());if(e.attachShader(r,Ny(Ox(e,e.VERTEX_SHADER,t))),e.attachShader(r,Ny(Ox(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 Ox(e,t,i){let r=Ny(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)}var jx=class{constructor(e){this.texture=e,this.version=-1}};var zx,Fx=11,$x=Fx*Float32Array.BYTES_PER_ELEMENT,Wx=0,Hx=0,Ux=0,qx=class extends fy{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;void 0===Sx.maxAtlasPages&&(Sx.maxAtlasPages=Math.min(32,Ny(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),Sx.maxTextureSize=Ny(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=Ny(Bx(s,"#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in float a_texpage;\nlayout (location = 5) in vec2 a_texcoord;\nlayout (location = 6) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\nflat out int v_texpage;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texpage = int(a_texpage);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",function(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\nprecision lowp float;\n\nin vec2 v_texcoord;\nflat in int v_texpage;\n\nuniform sampler2D u_texture[${e}];\n\nout vec4 outColor;\n\nvoid main() {\n if (v_texpage == 0) {\n outColor = texture(u_texture[0], v_texcoord);\n } ${t}\n}`}(Sx.maxAtlasPages))),this._register(hy(()=>s.deleteProgram(this._program))),this._projectionLocation=Ny(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Ny(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Ny(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(hy(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,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(hy(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=Ny(s.createBuffer()),this._register(hy(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,$x,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,$x,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,$x,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,$x,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,$x,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,$x,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let c=new Int32Array(Sx.maxAtlasPages);for(let h=0;h<Sx.maxAtlasPages;h++)c[h]=h;s.uniform1iv(this._textureLocation,c),s.uniformMatrix4fv(this._projectionLocation,!1,Ix),this._atlasTextures=[];for(let h=0;h<Sx.maxAtlasPages;h++){let e=new jx(Ny(s.createTexture()));this._register(hy(()=>s.deleteTexture(e.texture))),s.activeTexture(s.TEXTURE0+h),s.bindTexture(s.TEXTURE_2D,e.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[h]=e}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,i,r,s,n,o,a,l){this._updateCell(this._vertices.attributes,e,t,i,r,s,n,o,a,l)}_updateCell(e,t,i,r,s,n,o,a,l,c){Wx=(i*this._terminal.cols+t)*Fx,0!==r&&void 0!==r?this._atlas&&(zx=a&&a.length>1?this._atlas.getRasterizedGlyphCombinedChar(a,s,n,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,s,n,o,!1,this._terminal.element),Hx=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==c&&zx.offset.x>Hx?(Ux=zx.offset.x-Hx,e[Wx]=-(zx.offset.x-Ux)+this._dimensions.device.char.left,e[Wx+1]=-zx.offset.y+this._dimensions.device.char.top,e[Wx+2]=(zx.size.x-Ux)/this._dimensions.device.canvas.width,e[Wx+3]=zx.size.y/this._dimensions.device.canvas.height,e[Wx+4]=zx.texturePage,e[Wx+5]=zx.texturePositionClipSpace.x+Ux/this._atlas.pages[zx.texturePage].canvas.width,e[Wx+6]=zx.texturePositionClipSpace.y,e[Wx+7]=zx.sizeClipSpace.x-Ux/this._atlas.pages[zx.texturePage].canvas.width,e[Wx+8]=zx.sizeClipSpace.y):(e[Wx]=-zx.offset.x+this._dimensions.device.char.left,e[Wx+1]=-zx.offset.y+this._dimensions.device.char.top,e[Wx+2]=zx.size.x/this._dimensions.device.canvas.width,e[Wx+3]=zx.size.y/this._dimensions.device.canvas.height,e[Wx+4]=zx.texturePage,e[Wx+5]=zx.texturePositionClipSpace.x,e[Wx+6]=zx.texturePositionClipSpace.y,e[Wx+7]=zx.sizeClipSpace.x,e[Wx+8]=zx.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(e,t,i,r){return 1===t&&i>Math.ceil(1.5*r)&&void 0!==e&&e>255&&!function(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}(e)&&!Dy(e)&&!function(e){return 57344<=e&&e<=63743}(e)}(r,l,zx.size.x,this._dimensions.device.cell.width)&&(e[Wx+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):e.fill(0,Wx,Wx+Fx-1-2)}clear(){let e=this._terminal,t=e.cols*e.rows*Fx;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 t=0;t<e.cols;t++)this._vertices.attributes[i+9]=t/e.cols,this._vertices.attributes[i+10]=r/e.rows,i+=Fx}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 t=s*this._terminal.cols*Fx,n=this._vertices.attributes.subarray(t,t+e.lineLengths[s]*Fx);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/Fx)}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}},Kx=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])return void this.clear();let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,a=Math.max(n,0),l=Math.min(o,e.rows-1);a>=e.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,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)}};var Vx=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new Kx}resize(e,t){let i=e*t*4;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)}},Gx=8*Float32Array.BYTES_PER_ELEMENT,Yx=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},Xx=0,Zx=0,Qx=0,Jx=0,ew=0,tw=0,iw=0,rw=class extends fy{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._themeService=r,this._vertices=new Yx,this._verticesCursor=new Yx;let s=this._gl;this._program=Ny(Bx(s,"#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec4 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\n\nout vec4 v_color;\n\nvoid main() {\n vec2 zeroToOne = a_position + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}","#version 300 es\nprecision lowp float;\n\nin vec4 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = v_color;\n}")),this._register(hy(()=>s.deleteProgram(this._program))),this._projectionLocation=Ny(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(hy(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,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(hy(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=Ny(s.createBuffer()),this._register(hy(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,Gx,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Gx,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,Gx,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),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,Ix),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,i,r,s,n,o,a,l,c,h,u,d=this._terminal,f=this._vertices,p=1;for(t=0;t<d.rows;t++){for(r=-1,s=0,n=0,o=!1,i=0;i<d.cols;i++)a=4*(t*d.cols+i),l=e.cells[a+1],c=e.cells[a+2],h=!!(67108864&c),(l!==s||c!==n&&(o||h))&&((0!==s||o&&0!==n)&&(u=8*p++,this._updateRectangle(f,u,n,s,r,i,t)),r=i,s=l,n=c,o=h);(0!==s||o&&0!==n)&&(u=8*p++,this._updateRectangle(f,u,n,s,r,d.cols,t))}f.count=p}updateCursor(e){let t=this._verticesCursor,i=e.cursor;if(!i||"block"===i.style)return void(t.count=0);let r,s=0;("bar"===i.style||"outline"===i.style)&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,"bar"===i.style?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),("underline"===i.style||"outline"===i.style)&&(r=8*s++,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)),"outline"===i.style&&(r=8*s++,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=8*s++,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,n,o){if(67108864&i)switch(50331648&i){case 16777216:case 33554432:Xx=this._themeService.colors.ansi[255&i].rgba;break;case 50331648:Xx=(16777215&i)<<8;break;default:Xx=this._themeService.colors.foreground.rgba}else switch(50331648&r){case 16777216:case 33554432:Xx=this._themeService.colors.ansi[255&r].rgba;break;case 50331648:Xx=(16777215&r)<<8;break;default:Xx=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=function(e,t){let i=Math.min(2*e.length,t),r=new Float32Array(i);for(let s=0;s<e.length;s++)r[s]=e[s];return r}(e.attributes,this._terminal.rows*this._terminal.cols*8)),Zx=s*this._dimensions.device.cell.width,Qx=o*this._dimensions.device.cell.height,Jx=(Xx>>24&255)/255,ew=(Xx>>16&255)/255,tw=(Xx>>8&255)/255,iw=1,this._addRectangle(e.attributes,t,Zx,Qx,(n-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Jx,ew,tw,iw)}_addRectangle(e,t,i,r,s,n,o,a,l,c){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]=n/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=a,e[t+6]=l,e[t+7]=c}_addRectangleFloat(e,t,i,r,s,n,o){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]=n/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(255&e.rgba)/255])}},sw=class extends fy{constructor(e,t,i,r,s,n,o,a){super(),this._container=t,this._alpha=s,this._coreBrowserService=n,this._optionsService=o,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(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(hy(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Ny(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=Tx(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=qy,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){return`${i?"italic":""} ${t?e.options.fontWeightBold:e.options.fontWeight} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},nw=class extends sw{constructor(e,t,i,r,s,n,o){super(i,e,"link",t,!0,s,n,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}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(257===e.fg?this._ctx.fillStyle=this._themeService.colors.background.css:void 0!==e.fg&&function(e){return 16777216==(50331648&e)||33554432==(50331648&e)}(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()}},ow="object"==typeof window?window:globalThis,aw=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new yx,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new yx,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}};aw.INSTANCE=new aw;var lw=aw;lw.INSTANCE.onDidChangeZoomLevel,lw.INSTANCE.onDidChangeFullscreen;var cw="object"==typeof navigator?navigator.userAgent:"";cw.indexOf("Firefox"),cw.indexOf("AppleWebKit"),!(cw.indexOf("Chrome")>=0)&&cw.indexOf("Safari"),cw.indexOf("Electron/"),cw.indexOf("Android");var hw=!1;if("function"==typeof ow.matchMedia){let e=ow.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ow.matchMedia("(display-mode: fullscreen)");hw=e.matches,function(e,t,i){"string"==typeof t&&(t=e.matchMedia(t)),t.addEventListener("change",i)}(ow,e,({matches:e})=>{hw&&t.matches||(hw=e)})}var uw,dw,fw="en",pw=!1,gw=fw,_w=globalThis;typeof _w.vscode<"u"&&typeof _w.vscode.process<"u"?dw=_w.vscode.process:typeof process<"u"&&"string"==typeof(null==(o=null==process?void 0:process.versions)?void 0:o.node)&&(dw=process);var mw="string"==typeof(null==(a=null==dw?void 0:dw.versions)?void 0:a.electron)&&"renderer"===(null==dw?void 0:dw.type);if("object"==typeof dw){dw.platform,dw.platform,"linux"===dw.platform&&!!dw.env.SNAP&&dw.env.SNAP_REVISION,!!dw.env.CI||dw.env.BUILD_ARTIFACTSTAGINGDIRECTORY,gw=fw;let e=dw.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,gw=t.resolvedLanguage||fw,null==(l=t.languagePack)?void 0:l.translationsConfigFile}catch{}pw=!0}else"object"!=typeof navigator||mw?console.error("Unable to resolve platform."):((uw=navigator.userAgent).indexOf("Windows"),uw.indexOf("Macintosh"),(uw.indexOf("Macintosh")>=0||uw.indexOf("iPad")>=0||uw.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,uw.indexOf("Linux")>=0,null==uw||uw.indexOf("Mobi"),gw=globalThis._VSCODE_NLS_LANGUAGE||fw,navigator.language.toLowerCase());var vw,bw=pw,yw=uw,xw=gw;(e=>{e.value=function(){return xw},e.isDefaultVariant=function(){return 2===xw.length?"en"===xw:xw.length>=3&&("e"===xw[0]&&"n"===xw[1]&&"-"===xw[2])},e.isDefault=function(){return"en"===xw}})(vw||(vw={}));var ww="function"==typeof _w.postMessage&&!_w.importScripts;(()=>{if(ww){let e=[];_w.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),_w.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var Sw=!!(yw&&yw.indexOf("Chrome")>=0);yw&&yw.indexOf("Firefox"),!Sw&&yw&&yw.indexOf("Safari"),yw&&yw.indexOf("Edg/"),yw&&yw.indexOf("Android");var Cw="object"==typeof navigator?navigator:{};bw||document.queryCommandSupported&&document.queryCommandSupported("copy")||Cw&&Cw.clipboard&&Cw.clipboard.writeText,bw||Cw&&Cw.clipboard&&Cw.clipboard.readText;var kw,Ew,Lw=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}},Rw=new Lw,Tw=new Lw,Mw=new Lw;new Array(230),(Ew=kw||(kw={})).toString=function(e){return Rw.keyCodeToStr(e)},Ew.fromString=function(e){return Rw.strToKeyCode(e)},Ew.toUserSettingsUS=function(e){return Tw.keyCodeToStr(e)},Ew.toUserSettingsGeneral=function(e){return Mw.keyCodeToStr(e)},Ew.fromUserSettings=function(e){return Tw.strToKeyCode(e)||Mw.strToKeyCode(e)},Ew.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Rw.keyCodeToStr(e)};var Pw,Aw=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Dw||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:tx.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Aw})})(Pw||(Pw={}));var Nw,Dw=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?Aw:(this._emitter||(this._emitter=new yx),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};(e=>{e.settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},e.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(Ew){i(Ew)}})}})(Nw||(Nw={}));var Iw=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new yx,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(i){this.reject(i)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await tx.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Iw.EMPTY=Iw.fromArray([]);var{getWindow:Bw}=function(){let e=new Map,t={window:ow,disposables:new dy};e.set(ow.vscodeWindowId,t);let i=new yx,r=new yx,s=new yx;return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return fy.None;let n=new dy,o={window:t,disposables:n.add(new dy)};return e.set(t.vscodeWindowId,o),n.add(hy(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),n.add(jw(t,zw.BEFORE_UNLOAD,()=>{s.fire(t)})),i.fire(o),n},getWindows:()=>e.values(),getWindowsCount:()=>e.size,getWindowId:e=>e.vscodeWindowId,hasWindow:t=>e.has(t),getWindowById:function(i,r){return("number"==typeof i?e.get(i):void 0)??(r?t:void 0)},getWindow(e){var t;let i=e;if(null==(t=null==i?void 0:i.ownerDocument)?void 0:t.defaultView)return i.ownerDocument.defaultView.window;let r=e;return(null==r?void 0:r.view)?r.view.window:ow},getDocument:e=>Bw(e).document}}(),Ow=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 jw(e,t,i,r){return new Ow(e,t,i,r)}var zw={BEFORE_UNLOAD:"beforeunload"},Fw=class extends fy{constructor(e,t,i,r,s,n,o,a,l){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=n,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new py,this._charAtlasDisposable=this._register(new py),this._observerDisposable=this._register(new py),this._model=new Vx,this._workCell=new Dx,this._workCell2=new Dx,this._rectangleRenderer=this._register(new py),this._glyphRenderer=this._register(new py),this._onChangeTextureAtlas=this._register(new yx),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yx),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yx),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new yx),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new yx),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let c={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",c),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Uy(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new nw(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(jw(this._canvas,"webglcontextlost",e=>{console.log("webglcontextlost event received"),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(e)},3e3)})),this._register(jw(this._canvas,"webglcontextrestored",e=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Mx(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Nx(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=Nx(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(hy(()=>{var e;for(let t of this._renderLayers)t.dispose();null==(e=this._canvas.parentElement)||e.removeChild(this._canvas),Mx(this._terminal)}))}get textureAtlas(){var e;return null==(e=this._charAtlas)?void 0:e.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){var i,r,s,n;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let o of this._renderLayers)o.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`,null==(i=this._rectangleRenderer.value)||i.setDimensions(this.dimensions),null==(r=this._rectangleRenderer.value)||r.handleResize(),null==(s=this._glyphRenderer.value)||s.setDimensions(this.dimensions),null==(n=this._glyphRenderer.value)||n.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var e;for(let t of this._renderLayers)t.handleBlur(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.pause(),this._requestRedrawViewport()}handleFocus(){var e;for(let t of this._renderLayers)t.handleFocus(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.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(){var e;for(let t of this._renderLayers)t.handleCursorMove(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new rw(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new qx(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);let t=Tx(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!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=cy(tx.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),tx.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),null==(e=this._glyphRenderer.value)||e.setAtlas(this._charAtlas)}_clearModel(e){var t;this._model.clear(),e&&(null==(t=this._glyphRenderer.value)||t.clear())}clearTextureAtlas(){var e;null==(e=this._charAtlas)||e.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var e;this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){var i;if(!this._isAttached){if(!((null==(i=this._core.screenElement)?void 0:i.isConnected)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let r of this._renderLayers)r.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 Ax(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let i,r,s,n,o,a,l,c,h,u,d,f,p,g,_,m=this._core,v=this._workCell,b=0,y=!0;e=Ww(e,m.rows-1,0),t=Ww(t,m.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??m.options.cursorStyle??"block",w=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,S=w-m.buffer.ydisp,C=Math.min(this._terminal.buffer.active.cursorX,m.cols-1),k=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let L=!1;for(r=e;r<=t;r++)for(s=r+m.buffer.ydisp,n=m.buffer.lines.get(s),this._model.lineLengths[r]=0,h=w===s,b=0,o=this._characterJoinerService.getJoinedCharacters(s),g=0;g<m.cols;g++){if(i=this._cellColorResolver.result.bg,n.loadCell(g,v),0===g&&(i=this._cellColorResolver.result.bg),a=!1,y=g>=b,l=g,o.length>0&&g===o[0][0]&&y){c=o.shift();let e=this._model.selection.isCellSelected(this._terminal,c[0],s);for(p=c[0]+1;p<c[1];p++)y&&(y=e===this._model.selection.isCellSelected(this._terminal,p,s));y&&(y=!h||C<c[0]||C>=c[1]),y?(a=!0,v=new $w(v,n.translateToString(!0,c[0],c[1]),c[1]-c[0]),l=c[1]-1):b=c[1]}if(u=v.getChars(),d=v.getCode(),p=4*(r*m.cols+g),this._cellColorResolver.resolve(v,g,s,this.dimensions.device.cell.width),E&&s===w&&(g===C&&(this._model.cursor={x:C,y:S,width:v.getWidth(),style:this._coreBrowserService.isFocused?x:m.options.cursorInactiveStyle,cursorWidth:m.options.cursorWidth,dpr:this._devicePixelRatio},k=C+v.getWidth()-1),g>=C&&g<=k&&(this._coreBrowserService.isFocused&&"block"===x||!1===this._coreBrowserService.isFocused&&"block"===m.options.cursorInactiveStyle)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),0!==d&&(this._model.lineLengths[r]=g+1),(this._model.cells[p]!==d||this._model.cells[p+1]!==this._cellColorResolver.result.bg||this._model.cells[p+2]!==this._cellColorResolver.result.fg||this._model.cells[p+3]!==this._cellColorResolver.result.ext)&&(L=!0,u.length>1&&(d|=2147483648),this._model.cells[p]=d,this._model.cells[p+1]=this._cellColorResolver.result.bg,this._model.cells[p+2]=this._cellColorResolver.result.fg,this._model.cells[p+3]=this._cellColorResolver.result.ext,f=v.getWidth(),this._glyphRenderer.value.updateCell(g,r,d,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,u,f,i),a)){for(v=this._workCell,g++;g<=l;g++)_=4*(r*m.cols+g),this._glyphRenderer.value.updateCell(g,r,0,0,0,0,"",0,0),this._model.cells[_]=0,this._model.cells[_+1]=this._cellColorResolver.result.bg,this._model.cells[_+2]=this._cellColorResolver.result.fg,this._model.cells[_+3]=this._cellColorResolver.result.ext;g--}}L&&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=1===this._optionsService.rawOptions.lineHeight?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})}},$w=class extends ox{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 Ww(e,t,i=0){return Math.max(Math.min(e,t),i)}var Hw="di$target",Uw="di$dependencies",qw=new Map;function Kw(e){if(qw.has(e))return qw.get(e);let t=function(e,i,r){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[Hw]===t?t[Uw].push({id:e,index:i}):(t[Uw]=[{id:e,index:i}],t[Hw]=t)}(t,e,r)};return t._id=e,qw.set(e,t),t}Kw("BufferService"),Kw("CoreMouseService"),Kw("CoreService"),Kw("CharsetService"),Kw("InstantiationService"),Kw("LogService");var Vw=Kw("OptionsService");Kw("OscLinkService"),Kw("UnicodeService"),Kw("DecorationService");var Gw={trace:0,debug:1,info:2,warn:3,error:4,off:5},Yw=class extends fy{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Gw[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Yw=((e,t)=>{for(var i,r=t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=i(r)||r);return r})([((e,t)=>(i,r)=>t(i,r,e))(0,Vw)],Yw);var Xw=class extends fy{constructor(e){if(yy&&function(){if(!yy)return 0;let e=_y.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new yx),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yx),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yx),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new yx),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element)return void this._register(t.onWillOpen(()=>this.activate(e)));this._terminal=e;let i=t.coreService,r=t.optionsService,s=t,n=s._renderService,o=s._characterJoinerService,a=s._charSizeService,l=s._coreBrowserService,c=s._decorationService;s._logService;let h=s._themeService;this._renderer=this._register(new Fw(e,o,a,l,i,c,r,h,this._preserveDrawingBuffer)),this._register(tx.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(tx.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(tx.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(tx.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(hy(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){var e;return null==(e=this._renderer)?void 0:e.textureAtlas}clearTextureAtlas(){var e;null==(e=this._renderer)||e.clearTextureAtlas()}};function Zw(e,t){if("Enter"===e.key&&e.shiftKey)return"keydown"===e.type&&t("\n"),!0;if(e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&"keydown"===e.type){if("ArrowLeft"===e.key)return t(""),!0;if("ArrowRight"===e.key)return t(""),!0;if("Backspace"===e.key)return t(""),!0}return!1}function Qw(e){var t;const i=t=>{var i;const r=e.getSelection();if(!r)return;const s=r.split("\n").map(e=>e.trimEnd()).join("\n");null==(i=t.clipboardData)||i.setData("text/plain",s),t.preventDefault()};return null==(t=e.element)||t.addEventListener("copy",i),()=>{var t;null==(t=e.element)||t.removeEventListener("copy",i)}}function Jw(){return"light"===fd(md.getState().theme)?Xu:Yu}const eS=new Set,tS=new Map,iS=new Map,rS=new Map,sS=new Map,nS=new Map;function oS(e){const t="light"===fd(md.getState().theme);e.options.theme=Jw(),e.options.minimumContrastRatio=t?7:1}let aS=md.getState().theme;function lS(e,t){if(!sS.has(e))try{const i=new Xw;i.onContextLoss(()=>{i.dispose(),sS.delete(e)}),t.loadAddon(i),sS.set(e,i)}catch{}}function cS(e){const t=sS.get(e);t&&(t.dispose(),sS.delete(e))}md.subscribe(e=>{if(e.theme!==aS){aS=e.theme;for(const e of nS.values())oS(e)}});let hS=md.getState().gpuRendering;function uS(e,t){nS.set(e,t)}function dS(e){nS.delete(e)}function fS(e){return iS.get(e)}md.subscribe(e=>{if(e.gpuRendering!==hS){hS=e.gpuRendering;for(const[t,i]of nS)e.gpuRendering?lS(t,i):cS(t)}});const pS=new Map;function gS(e){eS.delete(e),tS.delete(e),rS.delete(e),iS.delete(e),cS(e),nS.delete(e)}let _S=null;function mS(e){(null==_S?void 0:_S.readyState)===WebSocket.OPEN&&_S.send(JSON.stringify(e))}function vS(){const e=md(e=>e.setConnectionStatus),t=Gu(e=>e.addProject),i=Gu(e=>e.setActiveProject),r=Y.useRef(),s=Y.useCallback(()=>{if((null==_S?void 0:_S.readyState)===WebSocket.OPEN||(null==_S?void 0:_S.readyState)===WebSocket.CONNECTING)return;e("connecting");const n=new WebSocket(`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws`);_S=n,n.onopen=()=>{e("connected"),mS({type:"editor:sync",enabled:md.getState().editorSyncEnabled})},n.onmessage=e=>{var r,s;try{const n=JSON.parse(e.data);if("pty:output"===n.type){const e=Uu.getState().sessions[n.terminalId];if(null==e?void 0:e.terminal){const t=e.terminal,i=t.buffer.active,r=i.viewportY>=i.baseY-1;t.write(n.data,()=>{r&&t.scrollToBottom()})}const t=function(e){const t=pS.get(e);return void 0!==t?(pS.delete(e),t):null}(n.terminalId);return void(t&&mS({type:"pty:input",terminalId:n.terminalId,data:t}))}if("pty:exit"===n.type){const e=n.terminalId,t=Uu.getState().sessions[e],i=null==t?void 0:t.projectId;if(null==(r=null==t?void 0:t.terminal)||r.dispose(),Uu.getState().removeSession(e),gS(e),i){ud.getState().removePaneFromProject(i,e),Gu.getState().removeTerminalFromProject(i,e);const t=Zu(ud.getState().getLayout(i)),r=md.getState().focusedTerminalId;if(r===e&&t.length>0){const e=t[0];md.getState().setFocusedTerminal(e);const i=Uu.getState().sessions[e];null==(s=null==i?void 0:i.terminal)||s.focus()}else r===e&&md.getState().setFocusedTerminal(null)}return}if("project:spawned"===n.type){const e=Object.values(Gu.getState().projects).find(e=>e.cwd===n.cwd);return void(e?i(e.id):(t({id:n.projectId,name:n.name,cwd:n.cwd,terminalIds:[]}),i(n.projectId)))}if("port:status"===n.type)return void Uu.getState().setActivePorts(n.ports);if("claude:status"===n.type)return void Uu.getState().setClaudeStatus(n.statuses);if("git:branch"===n.type)return void Uu.getState().setGitBranches(n.branches);if("inbox:paste"===n.type){const e=md.getState().focusedTerminalId;if(e&&n.files.length>0){mS({type:"pty:input",terminalId:e,data:n.files.map(e=>"'"+e.replace(/'/g,"'\\''")+"'").join(" ")})}return}if("editor:status"===n.type)return void Uu.getState().setEditorNeedsAccessibility(n.needsAccessibility);if("sc:status"===n.type)return void xd.getState().setStatus(n.projectId,n.status);if("sc:diff"===n.type){const e=vd(n.projectId,n.file,n.kind);return void xd.getState().setDiff(e,{diff:n.diff,binary:n.binary,truncated:n.truncated})}if("schedule:jobs"===n.type)return void Sd.getState().setJobs(n.jobs);if("schedule:runs"===n.type)return void Sd.getState().setRuns(n.runs);if("schedule:run:update"===n.type)return void Sd.getState().upsertRun(n.run);if("schedule:fire"===n.type)return void Sd.getState().showFireToast(n.jobName,"",n.runId);if("schedule:run:log"===n.type)return void Sd.getState().setRunLog(n.runId,n.log);if("schedule:run:output"===n.type)return void Sd.getState().appendRunOutput(n.runId,n.data);if("sc:action:result"===n.type)return xd.getState().setActionResult(n.action,n.ok,n.error),void(n.ok&&"commit"===n.action&&xd.getState().setCommitDraft(n.projectId,""));if("editor:active"===n.type){if(!md.getState().editorSyncEnabled)return;const{projects:e,activeProjectId:t}=Gu.getState(),r=Object.values(e).find(e=>{const t=e.cwd.replace(/\/$/,"").split("/").pop();return e.name===n.projectName||t===n.projectName});r&&r.id!==t&&(md.getState().showSyncToast(r.name),i(r.id))}}catch{}},n.onclose=()=>{e("disconnected"),Uu.getState().setActivePorts({}),Uu.getState().setClaudeStatus({}),Uu.getState().setGitBranches({}),Uu.getState().setEditorNeedsAccessibility(!1),_S=null,r.current=setTimeout(s,2e3)},n.onerror=()=>{n.close()}},[e,t,i]);Y.useEffect(()=>(s(),()=>{clearTimeout(r.current)}),[s])}const bS=new Set(["n","w","t","d","r","f","p","g"]);const yS=Hu()((e,t)=>({favourites:{},addFavourite:i=>{e(e=>({favourites:{...e.favourites,[i.id]:i}})),Vu({favourites:{...t().favourites}})},updateFavourite:(i,r)=>{e(e=>{const t=e.favourites[i];return t?{favourites:{...e.favourites,[i]:{...t,...r}}}:e}),Vu({favourites:{...t().favourites}})},removeFavourite:i=>{e(e=>{const{[i]:t,...r}=e.favourites;return{favourites:r}}),Vu({favourites:{...t().favourites}})},hydrateFromServer:async()=>{try{const t=await fetch("/api/settings"),i=await t.json();i.favourites&&e({favourites:i.favourites})}catch{}}})),xS=(...e)=>e.filter((e,t,i)=>Boolean(e)&&i.indexOf(e)===t).join(" ");
62
+ */function tb(e){(function(e){return e instanceof ob||e instanceof Error&&e.name===ib&&e.message===ib})(e)||eb.onUnexpectedError(e)}var ib="Canceled";var rb,sb,nb,ob=class extends Error{constructor(){super(ib),this.name=this.message}},ab=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function lb(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function cb(e){if(nb.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(dg){t.push(dg)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function hb(...e){return ub(()=>cb(e))}function ub(e){return{dispose:lb(()=>{e()})}}(sb=rb||(rb={})).isLessThan=function(e){return e<0},sb.isLessThanOrEqual=function(e){return e<=0},sb.isGreaterThan=function(e){return e>0},sb.isNeitherLessOrGreaterThan=function(e){return 0===e},sb.greaterThan=1,sb.lessThan=-1,sb.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(nb||(nb={}));var db=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{cb(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};db.DISABLE_DISPOSED_WARNING=!1;var fb=db,pb=class{constructor(){this._store=new fb,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};pb.None=Object.freeze({dispose(){}});var gb,_b=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},mb=globalThis.performance&&"function"==typeof globalThis.performance.now,vb=class e{static create(t){return new e(t)}constructor(e){this._now=mb&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new Tb({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,c,h,u=0,d=new Tb({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!c&&(d.fire(l),l=void 0),h=()=>{let e=l;l=void 0,c=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(c),c=setTimeout(h,i)):void 0===c&&(c=0,queueMicrotask(h))})},onWillRemoveListener(){s&&u>0&&(null==h||h())},onDidRemoveLastListener(){h=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>pb.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>{let s=hb(...e.map(e=>e(e=>t.call(i,e))));return function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(s,r)}},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new Tb({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Tb({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Tb({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new Tb;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Tb(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof fb?r.add(a):Array.isArray(r)&&r.push(a),a}}})(gb||(gb={}));var bb=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new vb,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};bb.all=new Set,bb._idPool=0;var yb=bb,xb=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new kb(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};xb._idPool=1;var wb,Sb=xb,Cb=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},kb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Eb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Lb=0,Rb=class{constructor(e){this.value=e,this.id=Lb++}},Tb=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new Sb((null==e?void 0:e.onListenerError)??tb,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new yb(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new Eb(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||tb)(i),pb.None}if(this._disposed)return pb.None;t&&(e=e.bind(t));let l,c=new Rb(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(c.stack=Cb.create(),l=this._leakageMon.check(c.stack,this._size+1)),this._listeners?this._listeners instanceof Rb?(this._deliveryQueue??(this._deliveryQueue=new Mb),this._listeners=[this._listeners,c]):this._listeners.push(c):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=c,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let h=ub(()=>{null==l||l(),this._removeListener(c)});return i instanceof fb?i.add(h):Array.isArray(i)&&i.push(h),h}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||tb;if(r)try{e.value(t)}catch(mp){r(mp)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof Rb)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},Mb=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}},Pb=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Db||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:gb.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Pb})})(wb||(wb={}));var Ab,Nb,Db=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?Pb:(this._emitter||(this._emitter=new Tb),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ib="en",Bb=Ib,Ob=globalThis;typeof Ob.vscode<"u"&&typeof Ob.vscode.process<"u"?Nb=Ob.vscode.process:typeof process<"u"&&"string"==typeof(null==(r=null==process?void 0:process.versions)?void 0:r.node)&&(Nb=process);var jb="string"==typeof(null==(s=null==Nb?void 0:Nb.versions)?void 0:s.electron)&&"renderer"===(null==Nb?void 0:Nb.type);if("object"==typeof Nb){Nb.platform,Nb.platform,"linux"===Nb.platform&&!!Nb.env.SNAP&&Nb.env.SNAP_REVISION,!!Nb.env.CI||Nb.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Bb=Ib;let e=Nb.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Bb=t.resolvedLanguage||Ib,null==(n=t.languagePack)?void 0:n.translationsConfigFile}catch{}}else"object"!=typeof navigator||jb?console.error("Unable to resolve platform."):((Ab=navigator.userAgent).indexOf("Windows"),Ab.indexOf("Macintosh"),(Ab.indexOf("Macintosh")>=0||Ab.indexOf("iPad")>=0||Ab.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Ab.indexOf("Linux")>=0,null==Ab||Ab.indexOf("Mobi"),Bb=globalThis._VSCODE_NLS_LANGUAGE||Ib,navigator.language.toLowerCase());var zb,Fb=Ab,$b=Bb;(e=>{e.value=function(){return $b},e.isDefaultVariant=function(){return 2===$b.length?"en"===$b:$b.length>=3&&("e"===$b[0]&&"n"===$b[1]&&"-"===$b[2])},e.isDefault=function(){return"en"===$b}})(zb||(zb={}));var Wb="function"==typeof Ob.postMessage&&!Ob.importScripts;(()=>{if(Wb){let e=[];Ob.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),Ob.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var Hb,Ub,qb=!!(Fb&&Fb.indexOf("Chrome")>=0);function Kb(e,t=0,i){let r=setTimeout(()=>{e()},t);return ub(()=>{clearTimeout(r)})}Fb&&Fb.indexOf("Firefox"),!qb&&Fb&&Fb.indexOf("Safari"),Fb&&Fb.indexOf("Edg/"),Fb&&Fb.indexOf("Android"),(Ub=Hb||(Hb={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},Ub.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(vt){i(vt)}})};var Vb=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Tb,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(mp){this.reject(mp)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await gb.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Vb.EMPTY=Vb.fromArray([]);var Gb=class extends pb{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new _b),this._linesCacheDisposables=this._register(new _b),this._register(ub(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=hb(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Kb(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){var t;return null==(t=this._linesCache)?void 0:t[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){var i;let r=[],s=[0],n=this._terminal.buffer.active.getLine(e);for(;n;){let o=this._terminal.buffer.active.getLine(e+1),a=!!o&&o.isWrapped,l=n.translateToString(!a&&t);if(a&&o){let e=n.getCell(n.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===(null==(i=o.getCell(0))?void 0:i.getWidth())&&(l=l.slice(0,-1))}if(r.push(l),!a)break;s.push(s[s.length-1]+l.length),e++,n=o}return[r.join(""),s]}},Yb=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return!this._lastSearchOptions||!!e&&(this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord)}shouldUpdateHighlighting(e,t){return!!(null==t?void 0:t.decorations)&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||this.didOptionsChange(t))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Xb=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,r){if(!e||0===e.length)return void this._terminal.clearSelection();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let s={startRow:t,startCol:i},n=this._findInLine(e,s,r);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(s.startRow=o,s.startCol=0,n=this._findInLine(e,s,r),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=0,n=0;r&&(i===e?(s=r.end.x,n=r.end.y):(s=r.start.x,n=r.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:s},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&0!==n)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&r&&(o.startRow=r.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a,l={startRow:s,startCol:n};if(r&&(l.startRow=s=r.start.y,l.startCol=n=r.start.x,i!==e&&(a=this._findInLine(e,l,t,!1),a||(l.startRow=s=r.end.y,l.startCol=n=r.end.x))),a||(a=this._findInLine(e,l,t,o)),!a){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let i=s-1;i>=0&&(l.startRow=i,a=this._findInLine(e,l,t,o),!a);i--);}if(!a&&s!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let c=this._terminal.buffer.active.baseY+this._terminal.rows-1;c>=s&&(l.startRow=c,a=this._findInLine(e,l,t,o),!a);c--);return a}_isWholeWord(e,t,i){return(0===e||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},r=!1){var s;let n=t.startRow,o=t.startCol;if(null==(s=this._terminal.buffer.active.getLine(n))?void 0:s.isWrapped)return r?void(t.startCol+=this._terminal.cols):(t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i));let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,c]=a,h=this._bufferColsToStringOffset(n,o),u=e,d=l;i.regex||(u=i.caseSensitive?e:e.toLowerCase(),d=i.caseSensitive?l:l.toLowerCase());let f=-1;if(i.regex){let t,s=RegExp(u,i.caseSensitive?"g":"gi");if(r)for(;t=s.exec(d.slice(0,h));)f=s.lastIndex-t[0].length,e=t[0],s.lastIndex-=e.length-1;else t=s.exec(d.slice(h)),t&&t[0].length>0&&(f=h+(s.lastIndex-t[0].length),e=t[0])}else r?h-u.length>=0&&(f=d.lastIndexOf(u,h-u.length)):f=d.indexOf(u,h);if(f>=0){if(i.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let s=f-c[t],o=f+e.length-c[r],a=this._stringLengthToBufferSize(n+t,s);return{term:e,col:a,row:n+t,size:this._stringLengthToBufferSize(n+r,o)-a+this._terminal.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let r=0;r<t;r++){let e=i.getCell(r);if(!e)break;let s=e.getChars();s.length>1&&(t-=s.length-1);let n=i.getCell(r+1);n&&0===n.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,r=0,s=this._terminal.buffer.active.getLine(i);for(;t>0&&s;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=s.getCell(e);if(!t)break;t.getWidth()&&(r+=0===t.getCode()?1:t.getChars().length)}if(i++,s=this._terminal.buffer.active.getLine(i),s&&!s.isWrapped)break;t-=this._terminal.cols}return r}},Zb=class extends pb{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ub(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let e=this._createResultDecorations(i,t,!1);if(e)for(let t of e)this._storeDecoration(t,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){cb(i)}}}clearHighlightDecorations(){cb(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let r=[],s=e.col,n=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let e=Math.min(this._terminal.cols-s,n);r.push([o,s,e]),s=0,n-=e,o++}let a=[];for(let l of r){let e=this._terminal.registerMarker(l[0]),r=this._terminal.registerDecoration({marker:e,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(r){let s=[];s.push(e),s.push(r.onRender(e=>this._applyStyles(e,i?t.activeMatchBorder:t.matchBorder,!1))),s.push(r.onDispose(()=>cb(s))),a.push(r)}}return 0===a.length?void 0:a}},Qb=class extends pb{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Tb)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Jb=class extends pb{constructor(e){super(),this._highlightTimeout=this._register(new _b),this._lineCache=this._register(new _b),this._state=new Yb,this._resultTracker=this._register(new Qb),this._highlightLimit=(null==e?void 0:e.highlightLimit)??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Gb(e),this._engine=new Xb(e,this._lineCache.value),this._decorationManager=new Zb(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ub(()=>this.clearDecorations()))}_updateMatches(){var e;this._highlightTimeout.clear(),this._state.cachedSearchTerm&&(null==(e=this._state.lastSearchOptions)?void 0:e.decorations)&&(this._highlightTimeout.value=Kb(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){var t;this._resultTracker.clearSelectedDecoration(),null==(t=this._decorationManager)||t.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e))return void this.clearDecorations();this.clearDecorations(!0);let i,r=[],s=this._engine.find(e,0,0,t);for(;s&&((null==i?void 0:i.row)!==s.row||(null==i?void 0:i.col)!==s.col)&&!(r.length>=this._highlightLimit);)i=s,r.push(i),s=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(r,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(r,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!(null==e?void 0:e.decorations))}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},ey=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?oy.isErrorNoTelemetry(e)?new oy(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+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)}};function ty(e){(function(e){return e instanceof ny||e instanceof Error&&e.name===iy&&e.message===iy})(e)||ey.onUnexpectedError(e)}var iy="Canceled";var ry,sy,ny=class extends Error{constructor(){super(iy),this.name=this.message}},oy=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function ay(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function ly(e){if(sy.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(dg){t.push(dg)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function cy(...e){return hy(()=>ly(e))}function hy(e){return{dispose:ay(()=>{e()})}}(e=>{e.isLessThan=function(e){return e<0},e.isLessThanOrEqual=function(e){return e<=0},e.isGreaterThan=function(e){return e>0},e.isNeitherLessOrGreaterThan=function(e){return 0===e},e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(ry||(ry={})),(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(sy||(sy={}));var uy=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{ly(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};uy.DISABLE_DISPOSED_WARNING=!1;var dy=uy,fy=class{constructor(){this._store=new dy,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};fy.None=Object.freeze({dispose(){}});var py=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},gy=typeof process<"u"&&"title"in process,_y=gy?"node":navigator.userAgent,my=gy?"node":navigator.platform,vy=_y.includes("Firefox"),by=_y.includes("Edge"),yy=/^((?!chrome|android).)*safari/i.test(_y);my.indexOf("Linux");var xy,wy,Sy,Cy,ky,Ey=0,Ly=0,Ry=0,Ty=0,My={css:"#00000000",rgba:0};function Py(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ay(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function Ny(e){if(!e)throw new Error("value must not be falsy");return e}function Dy(e){return 57508<=e&&e<=57558}function Iy(e){return Dy(e)||function(e){return 9472<=e&&e<=9631}(e)}function By(e,t,i=0){return(e-(2*Math.round(t)-i))%(2*Math.round(t))}(e=>{e.toCss=function(e,t,i,r){return void 0!==r?`#${Py(e)}${Py(t)}${Py(i)}${Py(r)}`:`#${Py(e)}${Py(t)}${Py(i)}`},e.toRgba=function(e,t,i,r=255){return(e<<24|t<<16|i<<8|r)>>>0},e.toColor=function(t,i,r,s){return{css:e.toCss(t,i,r,s),rgba:e.toRgba(t,i,r,s)}}})(xy||(xy={})),(e=>{function t(e,t){return Ty=Math.round(255*t),[Ey,Ly,Ry]=ky.toChannels(e.rgba),{css:xy.toCss(Ey,Ly,Ry,Ty),rgba:xy.toRgba(Ey,Ly,Ry,Ty)}}e.blend=function(e,t){if(1===(Ty=(255&t.rgba)/255))return{css:t.css,rgba:t.rgba};let i=t.rgba>>24&255,r=t.rgba>>16&255,s=t.rgba>>8&255,n=e.rgba>>24&255,o=e.rgba>>16&255,a=e.rgba>>8&255;return Ey=n+Math.round((i-n)*Ty),Ly=o+Math.round((r-o)*Ty),Ry=a+Math.round((s-a)*Ty),{css:xy.toCss(Ey,Ly,Ry),rgba:xy.toRgba(Ey,Ly,Ry)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){let r=ky.ensureContrastRatio(e.rgba,t.rgba,i);if(r)return xy.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[Ey,Ly,Ry]=ky.toChannels(t),{css:xy.toCss(Ey,Ly,Ry),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return t(e,(Ty=255&e.rgba)*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}})(wy||(wy={})),(e=>{let t,i;try{let e=document.createElement("canvas");e.width=1,e.height=1;let r=e.getContext("2d",{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Ey=parseInt(e.slice(1,2).repeat(2),16),Ly=parseInt(e.slice(2,3).repeat(2),16),Ry=parseInt(e.slice(3,4).repeat(2),16),xy.toColor(Ey,Ly,Ry);case 5:return Ey=parseInt(e.slice(1,2).repeat(2),16),Ly=parseInt(e.slice(2,3).repeat(2),16),Ry=parseInt(e.slice(3,4).repeat(2),16),Ty=parseInt(e.slice(4,5).repeat(2),16),xy.toColor(Ey,Ly,Ry,Ty);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Ey=parseInt(r[1]),Ly=parseInt(r[2]),Ry=parseInt(r[3]),Ty=Math.round(255*(void 0===r[5]?1:parseFloat(r[5]))),xy.toColor(Ey,Ly,Ry,Ty);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ey,Ly,Ry,Ty]=t.getImageData(0,0,1,1).data,255!==Ty)throw new Error("css.toColor: Unsupported css format");return{rgba:xy.toRgba(Ey,Ly,Ry,Ty),css:e}}})(Sy||(Sy={})),(e=>{function t(e,t,i){let r=e/255,s=t/255,n=i/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t})(Cy||(Cy={})),(e=>{function t(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));for(;c<i&&(o>0||a>0||l>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}function i(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));for(;c<i&&(o<255||a<255||l<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),c=Ay(Cy.relativeLuminance2(o,a,l),Cy.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(1===(Ty=(255&t)/255))return t;let i=t>>24&255,r=t>>16&255,s=t>>8&255,n=e>>24&255,o=e>>16&255,a=e>>8&255;return Ey=n+Math.round((i-n)*Ty),Ly=o+Math.round((r-o)*Ty),Ry=a+Math.round((s-a)*Ty),xy.toRgba(Ey,Ly,Ry)},e.ensureContrastRatio=function(e,r,s){let n=Cy.relativeLuminance(e>>8),o=Cy.relativeLuminance(r>>8);if(Ay(n,o)<s){if(o<n){let o=t(e,r,s),a=Ay(n,Cy.relativeLuminance(o>>8));if(a<s){let t=i(e,r,s);return a>Ay(n,Cy.relativeLuminance(t>>8))?o:t}return o}let a=i(e,r,s),l=Ay(n,Cy.relativeLuminance(a>>8));if(l<s){let i=t(e,r,s);return l>Ay(n,Cy.relativeLuminance(i>>8))?a:i}return a}},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}})(ky||(ky={}));var Oy,jy=0,zy=0,Fy=!1,$y=!1,Wy=!1,Hy=0,Uy=class{constructor(e,t,i,r,s,n){this._terminal=e,this._optionService=t,this._selectionRenderModel=i,this._decorationService=r,this._coreBrowserService=s,this._themeService=n,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=268435456&e.bg?e.extended.ext:0,zy=0,jy=0,$y=!1,Fy=!1,Wy=!1,Oy=this._themeService.colors,Hy=0,0!==e.getCode()&&4===e.extended.underlineStyle){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Hy=t*r%(2*Math.round(e))}if(this._decorationService.forEachDecorationAtCell(t,i,"bottom",e=>{e.backgroundColorRGB&&(zy=e.backgroundColorRGB.rgba>>8&16777215,$y=!0),e.foregroundColorRGB&&(jy=e.foregroundColorRGB.rgba>>8&16777215,Fy=!0)}),Wy=this._selectionRenderModel.isCellSelected(this._terminal,t,i)){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:zy=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:zy=(16777215&this.result.fg)<<8|255;break;default:zy=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:zy=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:zy=(16777215&this.result.bg)<<8|255}zy=ky.blend(zy,4294967040&(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else zy=(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if($y=!0,Oy.selectionForeground&&(jy=Oy.selectionForeground.rgba>>8&16777215,Fy=!0),Iy(e.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))jy=(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:jy=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:jy=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:jy=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:jy=(16777215&this.result.fg)<<8|255;break;default:jy=this._themeService.colors.foreground.rgba}jy=ky.blend(jy,4294967040&(this._coreBrowserService.isFocused?Oy.selectionBackgroundOpaque:Oy.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}Fy=!0}}this._decorationService.forEachDecorationAtCell(t,i,"top",e=>{e.backgroundColorRGB&&(zy=e.backgroundColorRGB.rgba>>8&16777215,$y=!0),e.foregroundColorRGB&&(jy=e.foregroundColorRGB.rgba>>8&16777215,Fy=!0)}),$y&&(zy=Wy?-16777216&e.bg&-134217729|zy|50331648:-16777216&e.bg|zy|50331648),Fy&&(jy=-16777216&e.fg&-67108865|jy|50331648),67108864&this.result.fg&&($y&&!Fy&&(jy=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&Oy.background.rgba>>8|50331648,Fy=!0),!$y&&Fy&&(zy=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&Oy.foreground.rgba>>8|50331648,$y=!0)),Oy=void 0,this.result.bg=$y?zy:this.result.bg,this.result.fg=Fy?jy:this.result.fg,this.result.ext&=536870911,this.result.ext|=Hy<<29&3758096384}},qy=vy||by?"bottom":"ideographic",Ky={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{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}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{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}],"🮖":[{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}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Vy={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Gy={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{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`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{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`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{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`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{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`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{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`},"╠":{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`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{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`},"╣":{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`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{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`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{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`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{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`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{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"},"┉":{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"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},Yy={"":{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},"":{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},"":{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},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{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},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{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},"":{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},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};function Xy(e,t,i,r,s,n,o,a){let l=Ky[t];if(l)return function(e,t,i,r,s,n){for(let o=0;o<t.length;o++){let a=t[o],l=s/8,c=n/8;e.fillRect(i+a.x*l,r+a.y*c,a.w*l,a.h*c)}}(e,l,i,r,s,n),!0;let c=Vy[t];if(c)return function(e,t,i,r,s,n){let o=Zy.get(t);o||(o=new Map,Zy.set(t,o));let a=e.fillStyle;if("string"!=typeof a)throw new Error(`Unexpected fillStyle type "${a}"`);let l=o.get(a);if(!l){let i=t[0].length,r=t.length,s=e.canvas.ownerDocument.createElement("canvas");s.width=i,s.height=r;let n,c,h,u,d=Ny(s.getContext("2d")),f=new ImageData(i,r);if(a.startsWith("#"))n=parseInt(a.slice(1,3),16),c=parseInt(a.slice(3,5),16),h=parseInt(a.slice(5,7),16),u=a.length>7&&parseInt(a.slice(7,9),16)||1;else{if(!a.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);[n,c,h,u]=a.substring(5,a.length-1).split(",").map(e=>parseFloat(e))}for(let e=0;e<r;e++)for(let r=0;r<i;r++)f.data[4*(e*i+r)]=n,f.data[4*(e*i+r)+1]=c,f.data[4*(e*i+r)+2]=h,f.data[4*(e*i+r)+3]=t[e][r]*(255*u);d.putImageData(f,0,0),l=Ny(e.createPattern(s,null)),o.set(a,l)}e.fillStyle=l,e.fillRect(i,r,s,n)}(e,c,i,r,s,n),!0;let h=Gy[t];if(h)return function(e,t,i,r,s,n,o){e.strokeStyle=e.fillStyle;for(let[a,l]of Object.entries(t)){let t;if(e.beginPath(),e.lineWidth=o*Number.parseInt(a),"function"==typeof l){t=l(.15,.15/n*s)}else t=l;for(let a of t.split(" ")){let t=a[0],l=Jy[t];if(!l){console.error(`Could not find drawing instructions for "${t}"`);continue}let c=a.substring(1).split(",");!c[0]||!c[1]||l(e,ex(c,s,n,i,r,!0,o))}e.stroke(),e.closePath()}}(e,h,i,r,s,n,a),!0;let u=Yy[t];return!!u&&(function(e,t,i,r,s,n,o,a){let l=new Path2D;l.rect(i,r,s,n),e.clip(l),e.beginPath();let c=o/12;e.lineWidth=a*c;for(let h of t.d.split(" ")){let o=h[0],l=Jy[o];if(!l){console.error(`Could not find drawing instructions for "${o}"`);continue}let u=h.substring(1).split(",");!u[0]||!u[1]||l(e,ex(u,s,n,i,r,!1,a,(t.leftPadding??0)*(c/2),(t.rightPadding??0)*(c/2)))}1===t.type?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}(e,u,i,r,s,n,o,a),!0)}Yy[""]=Yy[""],Yy[""]=Yy[""];var Zy=new Map;function Qy(e,t,i=0){return Math.max(Math.min(e,t),i)}var Jy={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 ex(e,t,i,r,s,n,o,a=0,l=0){let c=e.map(e=>parseFloat(e)||parseInt(e));if(c.length<2)throw new Error("Too few arguments for instruction");for(let h=0;h<c.length;h+=2)c[h]*=t-a*o-l*o,n&&0!==c[h]&&(c[h]=Qy(Math.round(c[h]+.5)-.5,t,0)),c[h]+=r+a*o;for(let h=1;h<c.length;h+=2)c[h]*=i,n&&0!==c[h]&&(c[h]=Qy(Math.round(c[h]+.5)-.5,i,0)),c[h]+=s;return c}var tx,ix=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={}}},rx=class{constructor(){this._data=new ix}set(e,t,i,r,s){this._data.get(e,t)||this._data.set(e,t,new ix),this._data.get(e,t).set(i,r,s)}get(e,t,i,r){var s;return null==(s=this._data.get(e,t))?void 0:s.get(i,r)}clear(){this._data.clear()}},sx=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(),1.5*i>s)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=s}this.clear()}},nx=!gy&&"requestIdleCallback"in window?class extends sx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:class extends sx{_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())}}},ox=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ax}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ax=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},lx=globalThis.performance&&"function"==typeof globalThis.performance.now,cx=class e{static create(t){return new e(t)}constructor(e){this._now=lx&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new yx({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,c,h,u=0,d=new yx({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!c&&(d.fire(l),l=void 0),h=()=>{let e=l;l=void 0,c=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(c),c=setTimeout(h,i)):void 0===c&&(c=0,queueMicrotask(h))})},onWillRemoveListener(){s&&u>0&&(null==h||h())},onDidRemoveLastListener(){h=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>fy.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(cy(...e.map(e=>e(e=>t.call(i,e)))),r)},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new yx({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new yx({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new yx({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new yx;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new yx(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof dy?r.add(a):Array.isArray(r)&&r.push(a),a}}})(tx||(tx={}));var hx=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new cx,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};hx.all=new Set,hx._idPool=0;var ux=hx,dx=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new _x(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};dx._idPool=1;var fx,px=dx,gx=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},_x=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},mx=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},vx=0,bx=class{constructor(e){this.value=e,this.id=vx++}},yx=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new px((null==e?void 0:e.onListenerError)??ty,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new ux(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new mx(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||ty)(i),fy.None}if(this._disposed)return fy.None;t&&(e=e.bind(t));let l,c=new bx(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(c.stack=gx.create(),l=this._leakageMon.check(c.stack,this._size+1)),this._listeners?this._listeners instanceof bx?(this._deliveryQueue??(this._deliveryQueue=new xx),this._listeners=[this._listeners,c]):this._listeners.push(c):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=c,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let h=hy(()=>{null==l||l(),this._removeListener(c)});return i instanceof dy?i.add(h):Array.isArray(i)&&i.push(h),h}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||ty;if(r)try{e.value(t)}catch(s){r(s)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof bx)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},xx=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}},wx={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}},Sx=class e{constructor(e,t,i){this._document=e,this._config=t,this._unicodeService=i,this._didWarmUp=!1,this._cacheMap=new rx,this._cacheMapCombined=new rx,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new ox,this._textureSize=512,this._onAddTextureAtlasCanvas=new yx,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new yx,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Ex(e,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=Ny(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new nx;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(0!==this._pages[0].currentRow.x||0!==this._pages[0].currentRow.y){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>2*t.canvas.width<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width!==e.canvas.width?t.canvas.width-e.canvas.width:t.percentageUsed-e.percentageUsed),i=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)i=e,r=t[e].canvas.width;else if(e-i===3)break;let s=t.slice(i,i+4),n=s.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-s.length,a=this._mergePages(s,o);a.version++;for(let e=n.length-1;e>=0;e--)this._deletePage(n[e]);this.pages.push(a),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(a.canvas)}let t=new Cx(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let i=2*e[0].canvas.width,r=new Cx(this._document,i,e);for(let[s,n]of e.entries()){let e=s*n.canvas.width%i,o=Math.floor(s/2)*n.canvas.height;r.ctx.drawImage(n.canvas,e,o);for(let r of n.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/i,r.sizeClipSpace.y=r.size.y/i,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/i,r.texturePositionClipSpace.y=r.texturePosition.y/i;this._onRemoveTextureAtlasCanvas.fire(n.canvas);let a=this._activePages.indexOf(n);-1!==a&&this._activePages.splice(a,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMapCombined,e,t,i,r,s,n)}getRasterizedGlyph(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMap,e,t,i,r,s,n)}_getFromCacheMap(e,t,i,r,s,n,o){return(fx=e.get(t,i,r,s))||(fx=this._drawToCache(t,i,r,s,n,o),e.set(t,i,r,s,fx)),fx}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,i,r){if(this._config.allowTransparency)return My;let s;switch(e){case 16777216:case 33554432:s=this._getColorFromAnsiIndex(t);break;case 50331648:let e=ox.toColorRGB(t);s=xy.toColor(e[0],e[1],e[2]);break;default:s=i?wy.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(s=wy.opaque(s)),s}_getForegroundColor(e,t,i,r,s,n,o,a,l,c){let h,u=this._getMinimumContrastColor(e,t,i,r,s,n,o,l,a,c);if(u)return u;switch(s){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&l&&n<8&&(n+=8),h=this._getColorFromAnsiIndex(n);break;case 50331648:let e=ox.toColorRGB(n);h=xy.toColor(e[0],e[1],e[2]);break;default:h=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(h=wy.opaque(h)),a&&(h=wy.multiplyOpacity(h,.5)),h}_resolveBackgroundRgba(e,t,i){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,i,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,i,r,s,n,o,a,l,c){if(1===this._config.minimumContrastRatio||c)return;let h=this._getContrastCache(l),u=h.getColor(e,r);if(void 0!==u)return u||void 0;let d=this._resolveBackgroundRgba(t,i,o),f=this._resolveForegroundRgba(s,n,o,a),p=ky.ensureContrastRatio(d,f,this._config.minimumContrastRatio/(l?2:1));if(!p)return void h.setColor(e,r,null);let g=xy.toColor(p>>24&255,p>>16&255,p>>8&255);return h.setColor(e,r,g),g}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,i,r,s,n,o){let a="number"==typeof t?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+4,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let c=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<c&&(this._tmpCanvas.height=c),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=s,this._workAttributeData.isInvisible())return wx;let h=!!this._workAttributeData.isBold(),u=!!this._workAttributeData.isInverse(),d=!!this._workAttributeData.isDim(),f=!!this._workAttributeData.isItalic(),p=!!this._workAttributeData.isUnderline(),g=!!this._workAttributeData.isStrikethrough(),_=!!this._workAttributeData.isOverline(),m=this._workAttributeData.getFgColor(),v=this._workAttributeData.getFgColorMode(),b=this._workAttributeData.getBgColor(),y=this._workAttributeData.getBgColorMode();if(u){let e=m;m=b,b=e;let t=v;v=y,y=t}let x=this._getBackgroundColor(y,b,u,d);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let w=h?this._config.fontWeightBold:this._config.fontWeight,S=f?"italic":"";this._tmpCtx.font=`${S} ${w} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=qy;let C=1===a.length&&Dy(a.charCodeAt(0)),k=1===a.length&&function(e){return 57520<=e&&e<=57527}(a.charCodeAt(0)),E=this._getForegroundColor(i,y,b,r,v,m,u,d,h,Iy(a.charCodeAt(0)));this._tmpCtx.fillStyle=E.css;let L=k?0:4,R=!1;!1!==this._config.customGlyphs&&(R=Xy(this._tmpCtx,a,L,L,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let T,M=!C;if(T="number"==typeof t?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),p){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())M=!1,this._tmpCtx.strokeStyle=`rgb(${ox.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{M=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let i=L,r=Math.ceil(L+this._config.deviceCharHeight)-t-(n?2*e:0),s=r+e,o=r+2*e,l=this._workAttributeData.getUnderlineVariantOffset();for(let n=0;n<T;n++){this._tmpCtx.save();let a=i+n*this._config.deviceCellWidth,c=i+(n+1)*this._config.deviceCellWidth,h=a+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(c,r),this._tmpCtx.moveTo(a,o),this._tmpCtx.lineTo(c,o);break;case 3:let i=e<=1?o:Math.ceil(L+this._config.deviceCharHeight-e/2)-t,n=e<=1?r:Math.ceil(L+this._config.deviceCharHeight+e/2)-t,u=new Path2D;u.rect(a,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(u),this._tmpCtx.moveTo(a-this._config.deviceCellWidth/2,s),this._tmpCtx.bezierCurveTo(a-this._config.deviceCellWidth/2,n,a,n,a,s),this._tmpCtx.bezierCurveTo(a,i,h,i,h,s),this._tmpCtx.bezierCurveTo(h,n,c,n,c,s),this._tmpCtx.bezierCurveTo(c,i,c+this._config.deviceCellWidth/2,i,c+this._config.deviceCellWidth/2,s);break;case 4:let d=0===l?0:l>=e?2*e-l:e-l;!1==!(l>=e)||0===d?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a+d,r),this._tmpCtx.lineTo(c,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(a+d,r),this._tmpCtx.moveTo(a+d+e,r),this._tmpCtx.lineTo(c,r)),l=By(c-a,e,l);break;case 5:let f=.6,p=.3,g=c-a,_=Math.floor(f*g),m=Math.floor(p*g),v=g-_-m;this._tmpCtx.setLineDash([_,m,v]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(c,r);break;default:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(c,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!R&&this._config.fontSize>=12&&!this._config.allowTransparency&&" "!==a){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let t=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(i,r-Math.ceil(e/2),this._config.deviceCellWidth*T,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(a,L,L+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(_){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(L,L+t),this._tmpCtx.lineTo(L+this._config.deviceCharWidth*T,L+t),this._tmpCtx.stroke()}if(R||this._tmpCtx.fillText(a,L,L+this._config.deviceCharHeight),"_"===a&&!this._config.allowTransparency){let e=kx(this._tmpCtx.getImageData(L,L,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,M);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,L,L+this._config.deviceCharHeight-t),e=kx(this._tmpCtx.getImageData(L,L,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,M),e);t++);}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(L,L+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(L+this._config.deviceCharWidth*T,L+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let P,A=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(P=this._config.allowTransparency?function(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}(A):kx(A,x,E,M),P)return wx;let N,D,I=this._findGlyphBoundingBox(A,this._workBoundingBox,l,k,R,L);for(;;){if(0===this._activePages.length){let e=this._createNewPage();N=e,D=e.currentRow,D.height=I.size.y;break}N=this._activePages[this._activePages.length-1],D=N.currentRow;for(let e of this._activePages)I.size.y<=e.currentRow.height&&(N=e,D=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=D.height&&I.size.y<=t.height&&(N=this._activePages[e],D=t);if(I.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Cx(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),N=this._overflowSizePage,D=this._overflowSizePage.currentRow,D.x+I.size.x>=N.canvas.width&&(D.x=0,D.y+=D.height,D.height=0);break}if(D.y+I.size.y>=N.canvas.height||D.height>I.size.y+2){let t=!1;if(N.currentRow.y+N.currentRow.height+I.size.y>=N.canvas.height){let i;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+I.size.y<e.canvas.height){i=e;break}if(i)N=i;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&D.y+I.size.y<=N.canvas.height&&D.height>=I.size.y&&D.x+I.size.x<=N.canvas.width)t=!0;else{let e=this._createNewPage();N=e,D=e.currentRow,D.height=I.size.y,t=!0}}t||(N.currentRow.height>0&&N.fixedRows.push(N.currentRow),D={x:0,y:N.currentRow.y+N.currentRow.height,height:I.size.y},N.fixedRows.push(D),N.currentRow={x:0,y:D.y+D.height,height:0})}if(D.x+I.size.x<=N.canvas.width)break;D===N.currentRow?(D.x=0,D.y+=D.height,D.height=0):N.fixedRows.splice(N.fixedRows.indexOf(D),1)}return I.texturePage=this._pages.indexOf(N),I.texturePosition.x=D.x,I.texturePosition.y=D.y,I.texturePositionClipSpace.x=D.x/N.canvas.width,I.texturePositionClipSpace.y=D.y/N.canvas.height,I.sizeClipSpace.x/=N.canvas.width,I.sizeClipSpace.y/=N.canvas.height,D.height=Math.max(D.height,I.size.y),D.x+=I.size.x,N.ctx.putImageData(A,I.texturePosition.x-this._workBoundingBox.left,I.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,I.size.x,I.size.y),N.addGlyph(I),N.version++,I}_findGlyphBoundingBox(e,t,i,r,s,n){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,a=r?this._config.deviceCellWidth:i,l=!1;for(let c=0;c<o;c++){for(let i=0;i<a;i++){let r=c*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.top=c,l=!0;break}}if(l)break}t.left=0,l=!1;for(let c=0;c<n+a;c++){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*c+3;if(0!==e.data[r]){t.left=c,l=!0;break}}if(l)break}t.right=a,l=!1;for(let c=n+a-1;c>=n;c--){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*c+3;if(0!==e.data[r]){t.right=c,l=!0;break}}if(l)break}t.bottom=o,l=!1;for(let c=o-1;c>=0;c--){for(let i=0;i<a;i++){let r=c*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.bottom=c,l=!0;break}}if(l)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+n+(r||s?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+n+(r||s?1===this._config.lineHeight?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Cx=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=Ex(e,t,t),this.ctx=Ny(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 kx(e,t,i,r){let s=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,c=i.rgba>>>8&255,h=Math.floor((Math.abs(s-a)+Math.abs(n-l)+Math.abs(o-c))/12),u=!0;for(let d=0;d<e.data.length;d+=4)e.data[d]===s&&e.data[d+1]===n&&e.data[d+2]===o||r&&Math.abs(e.data[d]-s)+Math.abs(e.data[d+1]-n)+Math.abs(e.data[d+2]-o)<h?e.data[d+3]=0:u=!1;return u}function Ex(e,t,i){let r=e.createElement("canvas");return r.width=t,r.height=i,r}function Lx(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}var Rx=[];function Tx(e,t,i,r,s,n,o,a,l){let c=function(e,t,i,r,s,n,o,a){let l={foreground:n.foreground,background:n.background,cursor:My,cursorAccent:My,selectionForeground:My,selectionBackgroundTransparent:My,selectionBackgroundOpaque:My,selectionInactiveBackgroundTransparent:My,selectionInactiveBackgroundOpaque:My,overviewRulerBorder:My,scrollbarSliderBackground:My,scrollbarSliderHoverBackground:My,scrollbarSliderActiveBackground:My,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:o,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}}(r,s,n,o,t,i,a,l);for(let d=0;d<Rx.length;d++){let t=Rx[d],i=t.ownedBy.indexOf(e);if(i>=0){if(Lx(t.config,c))return t.atlas;1===t.ownedBy.length?(t.atlas.dispose(),Rx.splice(d,1)):t.ownedBy.splice(i,1);break}}for(let d=0;d<Rx.length;d++){let t=Rx[d];if(Lx(t.config,c))return t.ownedBy.push(e),t.atlas}let h=e._core,u={atlas:new Sx(document,c,h.unicodeService),config:c,ownedBy:[e]};return Rx.push(u),u.atlas}function Mx(e){for(let t=0;t<Rx.length;t++){let i=Rx[t].ownedBy.indexOf(e);if(-1!==i){1===Rx[t].ownedBy.length?(Rx[t].atlas.dispose(),Rx.splice(t,1)):Rx[t].ownedBy.splice(i,1);break}}}var Px=600,Ax=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=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Px-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0)return void this._restartInterval(e)}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 e=Px-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(e)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Px)},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 Nx(e,t,i){let r=new t.ResizeObserver(t=>{let s=t.find(t=>t.target===e);if(!s)return;if(!("devicePixelContentBoxSize"in s))return null==r||r.disconnect(),void(r=void 0);let n=s.devicePixelContentBoxSize[0].inlineSize,o=s.devicePixelContentBoxSize[0].blockSize;n>0&&o>0&&i(n,o)});try{r.observe(e,{box:["device-pixel-content-box"]})}catch{r.disconnect(),r=void 0}return hy(()=>null==r?void 0:r.disconnect())}var Dx=class e extends ox{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ax,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(2===e[1].length){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ix=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Bx(e,t,i){let r=Ny(e.createProgram());if(e.attachShader(r,Ny(Ox(e,e.VERTEX_SHADER,t))),e.attachShader(r,Ny(Ox(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 Ox(e,t,i){let r=Ny(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)}var jx=class{constructor(e){this.texture=e,this.version=-1}};var zx,Fx=11,$x=Fx*Float32Array.BYTES_PER_ELEMENT,Wx=0,Hx=0,Ux=0,qx=class extends fy{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;void 0===Sx.maxAtlasPages&&(Sx.maxAtlasPages=Math.min(32,Ny(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),Sx.maxTextureSize=Ny(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=Ny(Bx(s,"#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in float a_texpage;\nlayout (location = 5) in vec2 a_texcoord;\nlayout (location = 6) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\nflat out int v_texpage;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texpage = int(a_texpage);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",function(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\nprecision lowp float;\n\nin vec2 v_texcoord;\nflat in int v_texpage;\n\nuniform sampler2D u_texture[${e}];\n\nout vec4 outColor;\n\nvoid main() {\n if (v_texpage == 0) {\n outColor = texture(u_texture[0], v_texcoord);\n } ${t}\n}`}(Sx.maxAtlasPages))),this._register(hy(()=>s.deleteProgram(this._program))),this._projectionLocation=Ny(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Ny(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Ny(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(hy(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,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(hy(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=Ny(s.createBuffer()),this._register(hy(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,$x,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,$x,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,$x,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,$x,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,$x,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,$x,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let c=new Int32Array(Sx.maxAtlasPages);for(let h=0;h<Sx.maxAtlasPages;h++)c[h]=h;s.uniform1iv(this._textureLocation,c),s.uniformMatrix4fv(this._projectionLocation,!1,Ix),this._atlasTextures=[];for(let h=0;h<Sx.maxAtlasPages;h++){let e=new jx(Ny(s.createTexture()));this._register(hy(()=>s.deleteTexture(e.texture))),s.activeTexture(s.TEXTURE0+h),s.bindTexture(s.TEXTURE_2D,e.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[h]=e}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,i,r,s,n,o,a,l){this._updateCell(this._vertices.attributes,e,t,i,r,s,n,o,a,l)}_updateCell(e,t,i,r,s,n,o,a,l,c){Wx=(i*this._terminal.cols+t)*Fx,0!==r&&void 0!==r?this._atlas&&(zx=a&&a.length>1?this._atlas.getRasterizedGlyphCombinedChar(a,s,n,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,s,n,o,!1,this._terminal.element),Hx=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==c&&zx.offset.x>Hx?(Ux=zx.offset.x-Hx,e[Wx]=-(zx.offset.x-Ux)+this._dimensions.device.char.left,e[Wx+1]=-zx.offset.y+this._dimensions.device.char.top,e[Wx+2]=(zx.size.x-Ux)/this._dimensions.device.canvas.width,e[Wx+3]=zx.size.y/this._dimensions.device.canvas.height,e[Wx+4]=zx.texturePage,e[Wx+5]=zx.texturePositionClipSpace.x+Ux/this._atlas.pages[zx.texturePage].canvas.width,e[Wx+6]=zx.texturePositionClipSpace.y,e[Wx+7]=zx.sizeClipSpace.x-Ux/this._atlas.pages[zx.texturePage].canvas.width,e[Wx+8]=zx.sizeClipSpace.y):(e[Wx]=-zx.offset.x+this._dimensions.device.char.left,e[Wx+1]=-zx.offset.y+this._dimensions.device.char.top,e[Wx+2]=zx.size.x/this._dimensions.device.canvas.width,e[Wx+3]=zx.size.y/this._dimensions.device.canvas.height,e[Wx+4]=zx.texturePage,e[Wx+5]=zx.texturePositionClipSpace.x,e[Wx+6]=zx.texturePositionClipSpace.y,e[Wx+7]=zx.sizeClipSpace.x,e[Wx+8]=zx.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(e,t,i,r){return 1===t&&i>Math.ceil(1.5*r)&&void 0!==e&&e>255&&!function(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}(e)&&!Dy(e)&&!function(e){return 57344<=e&&e<=63743}(e)}(r,l,zx.size.x,this._dimensions.device.cell.width)&&(e[Wx+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):e.fill(0,Wx,Wx+Fx-1-2)}clear(){let e=this._terminal,t=e.cols*e.rows*Fx;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 t=0;t<e.cols;t++)this._vertices.attributes[i+9]=t/e.cols,this._vertices.attributes[i+10]=r/e.rows,i+=Fx}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 t=s*this._terminal.cols*Fx,n=this._vertices.attributes.subarray(t,t+e.lineLengths[s]*Fx);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/Fx)}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}},Kx=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])return void this.clear();let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,a=Math.max(n,0),l=Math.min(o,e.rows-1);a>=e.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,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)}};var Vx=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new Kx}resize(e,t){let i=e*t*4;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)}},Gx=8*Float32Array.BYTES_PER_ELEMENT,Yx=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},Xx=0,Zx=0,Qx=0,Jx=0,ew=0,tw=0,iw=0,rw=class extends fy{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._themeService=r,this._vertices=new Yx,this._verticesCursor=new Yx;let s=this._gl;this._program=Ny(Bx(s,"#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec4 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\n\nout vec4 v_color;\n\nvoid main() {\n vec2 zeroToOne = a_position + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}","#version 300 es\nprecision lowp float;\n\nin vec4 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = v_color;\n}")),this._register(hy(()=>s.deleteProgram(this._program))),this._projectionLocation=Ny(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(hy(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,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(hy(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=Ny(s.createBuffer()),this._register(hy(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,Gx,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Gx,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,Gx,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),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,Ix),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,i,r,s,n,o,a,l,c,h,u,d=this._terminal,f=this._vertices,p=1;for(t=0;t<d.rows;t++){for(r=-1,s=0,n=0,o=!1,i=0;i<d.cols;i++)a=4*(t*d.cols+i),l=e.cells[a+1],c=e.cells[a+2],h=!!(67108864&c),(l!==s||c!==n&&(o||h))&&((0!==s||o&&0!==n)&&(u=8*p++,this._updateRectangle(f,u,n,s,r,i,t)),r=i,s=l,n=c,o=h);(0!==s||o&&0!==n)&&(u=8*p++,this._updateRectangle(f,u,n,s,r,d.cols,t))}f.count=p}updateCursor(e){let t=this._verticesCursor,i=e.cursor;if(!i||"block"===i.style)return void(t.count=0);let r,s=0;("bar"===i.style||"outline"===i.style)&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,"bar"===i.style?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),("underline"===i.style||"outline"===i.style)&&(r=8*s++,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)),"outline"===i.style&&(r=8*s++,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=8*s++,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,n,o){if(67108864&i)switch(50331648&i){case 16777216:case 33554432:Xx=this._themeService.colors.ansi[255&i].rgba;break;case 50331648:Xx=(16777215&i)<<8;break;default:Xx=this._themeService.colors.foreground.rgba}else switch(50331648&r){case 16777216:case 33554432:Xx=this._themeService.colors.ansi[255&r].rgba;break;case 50331648:Xx=(16777215&r)<<8;break;default:Xx=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=function(e,t){let i=Math.min(2*e.length,t),r=new Float32Array(i);for(let s=0;s<e.length;s++)r[s]=e[s];return r}(e.attributes,this._terminal.rows*this._terminal.cols*8)),Zx=s*this._dimensions.device.cell.width,Qx=o*this._dimensions.device.cell.height,Jx=(Xx>>24&255)/255,ew=(Xx>>16&255)/255,tw=(Xx>>8&255)/255,iw=1,this._addRectangle(e.attributes,t,Zx,Qx,(n-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Jx,ew,tw,iw)}_addRectangle(e,t,i,r,s,n,o,a,l,c){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]=n/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=a,e[t+6]=l,e[t+7]=c}_addRectangleFloat(e,t,i,r,s,n,o){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]=n/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(255&e.rgba)/255])}},sw=class extends fy{constructor(e,t,i,r,s,n,o,a){super(),this._container=t,this._alpha=s,this._coreBrowserService=n,this._optionsService=o,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(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(hy(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Ny(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=Tx(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=qy,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){return`${i?"italic":""} ${t?e.options.fontWeightBold:e.options.fontWeight} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},nw=class extends sw{constructor(e,t,i,r,s,n,o){super(i,e,"link",t,!0,s,n,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}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(257===e.fg?this._ctx.fillStyle=this._themeService.colors.background.css:void 0!==e.fg&&function(e){return 16777216==(50331648&e)||33554432==(50331648&e)}(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()}},ow="object"==typeof window?window:globalThis,aw=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new yx,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new yx,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}};aw.INSTANCE=new aw;var lw=aw;lw.INSTANCE.onDidChangeZoomLevel,lw.INSTANCE.onDidChangeFullscreen;var cw="object"==typeof navigator?navigator.userAgent:"";cw.indexOf("Firefox"),cw.indexOf("AppleWebKit"),!(cw.indexOf("Chrome")>=0)&&cw.indexOf("Safari"),cw.indexOf("Electron/"),cw.indexOf("Android");var hw=!1;if("function"==typeof ow.matchMedia){let e=ow.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ow.matchMedia("(display-mode: fullscreen)");hw=e.matches,function(e,t,i){"string"==typeof t&&(t=e.matchMedia(t)),t.addEventListener("change",i)}(ow,e,({matches:e})=>{hw&&t.matches||(hw=e)})}var uw,dw,fw="en",pw=!1,gw=fw,_w=globalThis;typeof _w.vscode<"u"&&typeof _w.vscode.process<"u"?dw=_w.vscode.process:typeof process<"u"&&"string"==typeof(null==(o=null==process?void 0:process.versions)?void 0:o.node)&&(dw=process);var mw="string"==typeof(null==(a=null==dw?void 0:dw.versions)?void 0:a.electron)&&"renderer"===(null==dw?void 0:dw.type);if("object"==typeof dw){dw.platform,dw.platform,"linux"===dw.platform&&!!dw.env.SNAP&&dw.env.SNAP_REVISION,!!dw.env.CI||dw.env.BUILD_ARTIFACTSTAGINGDIRECTORY,gw=fw;let e=dw.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,gw=t.resolvedLanguage||fw,null==(l=t.languagePack)?void 0:l.translationsConfigFile}catch{}pw=!0}else"object"!=typeof navigator||mw?console.error("Unable to resolve platform."):((uw=navigator.userAgent).indexOf("Windows"),uw.indexOf("Macintosh"),(uw.indexOf("Macintosh")>=0||uw.indexOf("iPad")>=0||uw.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,uw.indexOf("Linux")>=0,null==uw||uw.indexOf("Mobi"),gw=globalThis._VSCODE_NLS_LANGUAGE||fw,navigator.language.toLowerCase());var vw,bw=pw,yw=uw,xw=gw;(e=>{e.value=function(){return xw},e.isDefaultVariant=function(){return 2===xw.length?"en"===xw:xw.length>=3&&("e"===xw[0]&&"n"===xw[1]&&"-"===xw[2])},e.isDefault=function(){return"en"===xw}})(vw||(vw={}));var ww="function"==typeof _w.postMessage&&!_w.importScripts;(()=>{if(ww){let e=[];_w.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),_w.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var Sw=!!(yw&&yw.indexOf("Chrome")>=0);yw&&yw.indexOf("Firefox"),!Sw&&yw&&yw.indexOf("Safari"),yw&&yw.indexOf("Edg/"),yw&&yw.indexOf("Android");var Cw="object"==typeof navigator?navigator:{};bw||document.queryCommandSupported&&document.queryCommandSupported("copy")||Cw&&Cw.clipboard&&Cw.clipboard.writeText,bw||Cw&&Cw.clipboard&&Cw.clipboard.readText;var kw,Ew,Lw=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}},Rw=new Lw,Tw=new Lw,Mw=new Lw;new Array(230),(Ew=kw||(kw={})).toString=function(e){return Rw.keyCodeToStr(e)},Ew.fromString=function(e){return Rw.strToKeyCode(e)},Ew.toUserSettingsUS=function(e){return Tw.keyCodeToStr(e)},Ew.toUserSettingsGeneral=function(e){return Mw.keyCodeToStr(e)},Ew.fromUserSettings=function(e){return Tw.strToKeyCode(e)||Mw.strToKeyCode(e)},Ew.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Rw.keyCodeToStr(e)};var Pw,Aw=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Dw||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:tx.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Aw})})(Pw||(Pw={}));var Nw,Dw=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?Aw:(this._emitter||(this._emitter=new yx),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};(e=>{e.settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},e.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(Ew){i(Ew)}})}})(Nw||(Nw={}));var Iw=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new yx,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(i){this.reject(i)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await tx.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Iw.EMPTY=Iw.fromArray([]);var{getWindow:Bw}=function(){let e=new Map,t={window:ow,disposables:new dy};e.set(ow.vscodeWindowId,t);let i=new yx,r=new yx,s=new yx;return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return fy.None;let n=new dy,o={window:t,disposables:n.add(new dy)};return e.set(t.vscodeWindowId,o),n.add(hy(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),n.add(jw(t,zw.BEFORE_UNLOAD,()=>{s.fire(t)})),i.fire(o),n},getWindows:()=>e.values(),getWindowsCount:()=>e.size,getWindowId:e=>e.vscodeWindowId,hasWindow:t=>e.has(t),getWindowById:function(i,r){return("number"==typeof i?e.get(i):void 0)??(r?t:void 0)},getWindow(e){var t;let i=e;if(null==(t=null==i?void 0:i.ownerDocument)?void 0:t.defaultView)return i.ownerDocument.defaultView.window;let r=e;return(null==r?void 0:r.view)?r.view.window:ow},getDocument:e=>Bw(e).document}}(),Ow=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 jw(e,t,i,r){return new Ow(e,t,i,r)}var zw={BEFORE_UNLOAD:"beforeunload"},Fw=class extends fy{constructor(e,t,i,r,s,n,o,a,l){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=n,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new py,this._charAtlasDisposable=this._register(new py),this._observerDisposable=this._register(new py),this._model=new Vx,this._workCell=new Dx,this._workCell2=new Dx,this._rectangleRenderer=this._register(new py),this._glyphRenderer=this._register(new py),this._onChangeTextureAtlas=this._register(new yx),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yx),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yx),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new yx),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new yx),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let c={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",c),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Uy(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new nw(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(jw(this._canvas,"webglcontextlost",e=>{console.log("webglcontextlost event received"),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(e)},3e3)})),this._register(jw(this._canvas,"webglcontextrestored",e=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Mx(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Nx(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=Nx(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(hy(()=>{var e;for(let t of this._renderLayers)t.dispose();null==(e=this._canvas.parentElement)||e.removeChild(this._canvas),Mx(this._terminal)}))}get textureAtlas(){var e;return null==(e=this._charAtlas)?void 0:e.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){var i,r,s,n;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let o of this._renderLayers)o.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`,null==(i=this._rectangleRenderer.value)||i.setDimensions(this.dimensions),null==(r=this._rectangleRenderer.value)||r.handleResize(),null==(s=this._glyphRenderer.value)||s.setDimensions(this.dimensions),null==(n=this._glyphRenderer.value)||n.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var e;for(let t of this._renderLayers)t.handleBlur(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.pause(),this._requestRedrawViewport()}handleFocus(){var e;for(let t of this._renderLayers)t.handleFocus(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.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(){var e;for(let t of this._renderLayers)t.handleCursorMove(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new rw(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new qx(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);let t=Tx(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!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=cy(tx.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),tx.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),null==(e=this._glyphRenderer.value)||e.setAtlas(this._charAtlas)}_clearModel(e){var t;this._model.clear(),e&&(null==(t=this._glyphRenderer.value)||t.clear())}clearTextureAtlas(){var e;null==(e=this._charAtlas)||e.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var e;this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){var i;if(!this._isAttached){if(!((null==(i=this._core.screenElement)?void 0:i.isConnected)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let r of this._renderLayers)r.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 Ax(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let i,r,s,n,o,a,l,c,h,u,d,f,p,g,_,m=this._core,v=this._workCell,b=0,y=!0;e=Ww(e,m.rows-1,0),t=Ww(t,m.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??m.options.cursorStyle??"block",w=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,S=w-m.buffer.ydisp,C=Math.min(this._terminal.buffer.active.cursorX,m.cols-1),k=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let L=!1;for(r=e;r<=t;r++)for(s=r+m.buffer.ydisp,n=m.buffer.lines.get(s),this._model.lineLengths[r]=0,h=w===s,b=0,o=this._characterJoinerService.getJoinedCharacters(s),g=0;g<m.cols;g++){if(i=this._cellColorResolver.result.bg,n.loadCell(g,v),0===g&&(i=this._cellColorResolver.result.bg),a=!1,y=g>=b,l=g,o.length>0&&g===o[0][0]&&y){c=o.shift();let e=this._model.selection.isCellSelected(this._terminal,c[0],s);for(p=c[0]+1;p<c[1];p++)y&&(y=e===this._model.selection.isCellSelected(this._terminal,p,s));y&&(y=!h||C<c[0]||C>=c[1]),y?(a=!0,v=new $w(v,n.translateToString(!0,c[0],c[1]),c[1]-c[0]),l=c[1]-1):b=c[1]}if(u=v.getChars(),d=v.getCode(),p=4*(r*m.cols+g),this._cellColorResolver.resolve(v,g,s,this.dimensions.device.cell.width),E&&s===w&&(g===C&&(this._model.cursor={x:C,y:S,width:v.getWidth(),style:this._coreBrowserService.isFocused?x:m.options.cursorInactiveStyle,cursorWidth:m.options.cursorWidth,dpr:this._devicePixelRatio},k=C+v.getWidth()-1),g>=C&&g<=k&&(this._coreBrowserService.isFocused&&"block"===x||!1===this._coreBrowserService.isFocused&&"block"===m.options.cursorInactiveStyle)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),0!==d&&(this._model.lineLengths[r]=g+1),(this._model.cells[p]!==d||this._model.cells[p+1]!==this._cellColorResolver.result.bg||this._model.cells[p+2]!==this._cellColorResolver.result.fg||this._model.cells[p+3]!==this._cellColorResolver.result.ext)&&(L=!0,u.length>1&&(d|=2147483648),this._model.cells[p]=d,this._model.cells[p+1]=this._cellColorResolver.result.bg,this._model.cells[p+2]=this._cellColorResolver.result.fg,this._model.cells[p+3]=this._cellColorResolver.result.ext,f=v.getWidth(),this._glyphRenderer.value.updateCell(g,r,d,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,u,f,i),a)){for(v=this._workCell,g++;g<=l;g++)_=4*(r*m.cols+g),this._glyphRenderer.value.updateCell(g,r,0,0,0,0,"",0,0),this._model.cells[_]=0,this._model.cells[_+1]=this._cellColorResolver.result.bg,this._model.cells[_+2]=this._cellColorResolver.result.fg,this._model.cells[_+3]=this._cellColorResolver.result.ext;g--}}L&&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=1===this._optionsService.rawOptions.lineHeight?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})}},$w=class extends ox{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 Ww(e,t,i=0){return Math.max(Math.min(e,t),i)}var Hw="di$target",Uw="di$dependencies",qw=new Map;function Kw(e){if(qw.has(e))return qw.get(e);let t=function(e,i,r){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[Hw]===t?t[Uw].push({id:e,index:i}):(t[Uw]=[{id:e,index:i}],t[Hw]=t)}(t,e,r)};return t._id=e,qw.set(e,t),t}Kw("BufferService"),Kw("CoreMouseService"),Kw("CoreService"),Kw("CharsetService"),Kw("InstantiationService"),Kw("LogService");var Vw=Kw("OptionsService");Kw("OscLinkService"),Kw("UnicodeService"),Kw("DecorationService");var Gw={trace:0,debug:1,info:2,warn:3,error:4,off:5},Yw=class extends fy{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Gw[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Yw=((e,t)=>{for(var i,r=t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=i(r)||r);return r})([((e,t)=>(i,r)=>t(i,r,e))(0,Vw)],Yw);var Xw=class extends fy{constructor(e){if(yy&&function(){if(!yy)return 0;let e=_y.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new yx),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yx),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yx),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new yx),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element)return void this._register(t.onWillOpen(()=>this.activate(e)));this._terminal=e;let i=t.coreService,r=t.optionsService,s=t,n=s._renderService,o=s._characterJoinerService,a=s._charSizeService,l=s._coreBrowserService,c=s._decorationService;s._logService;let h=s._themeService;this._renderer=this._register(new Fw(e,o,a,l,i,c,r,h,this._preserveDrawingBuffer)),this._register(tx.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(tx.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(tx.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(tx.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(hy(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){var e;return null==(e=this._renderer)?void 0:e.textureAtlas}clearTextureAtlas(){var e;null==(e=this._renderer)||e.clearTextureAtlas()}};function Zw(e,t){if("Enter"===e.key&&e.shiftKey)return"keydown"===e.type&&t("[200~\n[201~"),!0;if(e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&"keydown"===e.type){if("ArrowLeft"===e.key)return t(""),!0;if("ArrowRight"===e.key)return t(""),!0;if("Backspace"===e.key)return t(""),!0}return!1}function Qw(e){var t;const i=t=>{var i;const r=e.getSelection();if(!r)return;const s=r.split("\n").map(e=>e.trimEnd()).join("\n");null==(i=t.clipboardData)||i.setData("text/plain",s),t.preventDefault()};return null==(t=e.element)||t.addEventListener("copy",i),()=>{var t;null==(t=e.element)||t.removeEventListener("copy",i)}}function Jw(){return"light"===fd(md.getState().theme)?Xu:Yu}const eS=new Set,tS=new Map,iS=new Map,rS=new Map,sS=new Map,nS=new Map;function oS(e){const t="light"===fd(md.getState().theme);e.options.theme=Jw(),e.options.minimumContrastRatio=t?7:1}let aS=md.getState().theme;function lS(e,t){if(!sS.has(e))try{const i=new Xw;i.onContextLoss(()=>{i.dispose(),sS.delete(e)}),t.loadAddon(i),sS.set(e,i)}catch{}}function cS(e){const t=sS.get(e);t&&(t.dispose(),sS.delete(e))}md.subscribe(e=>{if(e.theme!==aS){aS=e.theme;for(const e of nS.values())oS(e)}});let hS=md.getState().gpuRendering;function uS(e,t){nS.set(e,t)}function dS(e){nS.delete(e)}function fS(e){return iS.get(e)}md.subscribe(e=>{if(e.gpuRendering!==hS){hS=e.gpuRendering;for(const[t,i]of nS)e.gpuRendering?lS(t,i):cS(t)}});const pS=new Map;function gS(e){eS.delete(e),tS.delete(e),rS.delete(e),iS.delete(e),cS(e),nS.delete(e)}let _S=null;function mS(e){(null==_S?void 0:_S.readyState)===WebSocket.OPEN&&_S.send(JSON.stringify(e))}function vS(){const e=md(e=>e.setConnectionStatus),t=Gu(e=>e.addProject),i=Gu(e=>e.setActiveProject),r=Y.useRef(),s=Y.useCallback(()=>{if((null==_S?void 0:_S.readyState)===WebSocket.OPEN||(null==_S?void 0:_S.readyState)===WebSocket.CONNECTING)return;e("connecting");const n=new WebSocket(`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws`);_S=n,n.onopen=()=>{e("connected"),mS({type:"editor:sync",enabled:md.getState().editorSyncEnabled})},n.onmessage=e=>{var r,s;try{const n=JSON.parse(e.data);if("pty:output"===n.type){const e=Uu.getState().sessions[n.terminalId];if(null==e?void 0:e.terminal){const t=e.terminal,i=t.buffer.active,r=i.viewportY>=i.baseY-1;t.write(n.data,()=>{r&&t.scrollToBottom()})}const t=function(e){const t=pS.get(e);return void 0!==t?(pS.delete(e),t):null}(n.terminalId);return void(t&&mS({type:"pty:input",terminalId:n.terminalId,data:t}))}if("pty:exit"===n.type){const e=n.terminalId,t=Uu.getState().sessions[e],i=null==t?void 0:t.projectId;if(null==(r=null==t?void 0:t.terminal)||r.dispose(),Uu.getState().removeSession(e),gS(e),i){ud.getState().removePaneFromProject(i,e),Gu.getState().removeTerminalFromProject(i,e);const t=Zu(ud.getState().getLayout(i)),r=md.getState().focusedTerminalId;if(r===e&&t.length>0){const e=t[0];md.getState().setFocusedTerminal(e);const i=Uu.getState().sessions[e];null==(s=null==i?void 0:i.terminal)||s.focus()}else r===e&&md.getState().setFocusedTerminal(null)}return}if("project:spawned"===n.type){const e=Object.values(Gu.getState().projects).find(e=>e.cwd===n.cwd);return void(e?i(e.id):(t({id:n.projectId,name:n.name,cwd:n.cwd,terminalIds:[]}),i(n.projectId)))}if("port:status"===n.type)return void Uu.getState().setActivePorts(n.ports);if("claude:status"===n.type)return void Uu.getState().setClaudeStatus(n.statuses);if("git:branch"===n.type)return void Uu.getState().setGitBranches(n.branches);if("inbox:paste"===n.type){const e=md.getState().focusedTerminalId;if(e&&n.files.length>0){mS({type:"pty:input",terminalId:e,data:n.files.map(e=>"'"+e.replace(/'/g,"'\\''")+"'").join(" ")})}return}if("editor:status"===n.type)return void Uu.getState().setEditorNeedsAccessibility(n.needsAccessibility);if("sc:status"===n.type)return void xd.getState().setStatus(n.projectId,n.status);if("sc:diff"===n.type){const e=vd(n.projectId,n.file,n.kind);return void xd.getState().setDiff(e,{diff:n.diff,binary:n.binary,truncated:n.truncated})}if("schedule:jobs"===n.type)return void Sd.getState().setJobs(n.jobs);if("schedule:runs"===n.type)return void Sd.getState().setRuns(n.runs);if("schedule:run:update"===n.type)return void Sd.getState().upsertRun(n.run);if("schedule:fire"===n.type)return void Sd.getState().showFireToast(n.jobName,"",n.runId);if("schedule:run:log"===n.type)return void Sd.getState().setRunLog(n.runId,n.log);if("schedule:run:output"===n.type)return void Sd.getState().appendRunOutput(n.runId,n.data);if("sc:action:result"===n.type)return xd.getState().setActionResult(n.action,n.ok,n.error),void(n.ok&&"commit"===n.action&&xd.getState().setCommitDraft(n.projectId,""));if("editor:active"===n.type){if(!md.getState().editorSyncEnabled)return;const{projects:e,activeProjectId:t}=Gu.getState(),r=Object.values(e).find(e=>{const t=e.cwd.replace(/\/$/,"").split("/").pop();return e.name===n.projectName||t===n.projectName});r&&r.id!==t&&(md.getState().showSyncToast(r.name),i(r.id))}}catch{}},n.onclose=()=>{e("disconnected"),Uu.getState().setActivePorts({}),Uu.getState().setClaudeStatus({}),Uu.getState().setGitBranches({}),Uu.getState().setEditorNeedsAccessibility(!1),_S=null,r.current=setTimeout(s,2e3)},n.onerror=()=>{n.close()}},[e,t,i]);Y.useEffect(()=>(s(),()=>{clearTimeout(r.current)}),[s])}const bS=new Set(["n","w","t","d","r","f","p","g"]);const yS=Hu()((e,t)=>({favourites:{},addFavourite:i=>{e(e=>({favourites:{...e.favourites,[i.id]:i}})),Vu({favourites:{...t().favourites}})},updateFavourite:(i,r)=>{e(e=>{const t=e.favourites[i];return t?{favourites:{...e.favourites,[i]:{...t,...r}}}:e}),Vu({favourites:{...t().favourites}})},removeFavourite:i=>{e(e=>{const{[i]:t,...r}=e.favourites;return{favourites:r}}),Vu({favourites:{...t().favourites}})},hydrateFromServer:async()=>{try{const t=await fetch("/api/settings"),i=await t.json();i.favourites&&e({favourites:i.favourites})}catch{}}})),xS=(...e)=>e.filter((e,t,i)=>Boolean(e)&&i.indexOf(e)===t).join(" ");
63
63
  /**
64
64
  * @license lucide-react v0.400.0 - ISC
65
65
  *
@@ -15,7 +15,7 @@
15
15
  document.documentElement.setAttribute('data-theme', t);
16
16
  })();
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-gI76jzKp.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-eFW4nICJ.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/index-BCSI40O7.css">
20
20
  </head>
21
21
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paneful",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "description": "A fast, GPU-accelerated terminal manager with split panes, project organization, editor sync, and AI agent detection. Native macOS app or browser.",
5
5
  "type": "module",
6
6
  "bin": {