code-server
Version:
Run VS Code on a remote server.
402 lines (355 loc) • 165 kB
JavaScript
/*!--------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
export function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
export var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
}
return __assign.apply(this, arguments);
}
export function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
export function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
export function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
export function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _, done = false;
for (var i = decorators.length - 1; i >= 0; i--) {
var context = {};
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if (_ = accept(result.get)) descriptor.get = _;
if (_ = accept(result.set)) descriptor.set = _;
if (_ = accept(result.init)) initializers.unshift(_);
}
else if (_ = accept(result)) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
export function __runInitializers(thisArg, initializers, value) {
var useValue = arguments.length > 2;
for (var i = 0; i < initializers.length; i++) {
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
}
return useValue ? value : void 0;
};
export function __propKey(x) {
return typeof x === "symbol" ? x : "".concat(x);
};
export function __setFunctionName(f, name, prefix) {
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
};
export function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
export function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
export function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
export var __createBinding = Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
export function __exportStar(m, o) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
}
export function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
export function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
/** @deprecated */
export function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/** @deprecated */
export function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
export function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
export function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
export function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
export function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
}
export function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
export function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __setModuleDefault = Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
};
export function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
}
export function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
export function __classPrivateFieldGet(receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}
export function __classPrivateFieldSet(receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}
export function __classPrivateFieldIn(state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
}
export function __addDisposableResource(env, value, async) {
if (value !== null && value !== void 0) {
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
var dispose, inner;
if (async) {
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
dispose = value[Symbol.asyncDispose];
}
if (dispose === void 0) {
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
dispose = value[Symbol.dispose];
if (async) inner = dispose;
}
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
env.stack.push({ value: value, dispose: dispose, async: async });
}
else if (async) {
env.stack.push({ async: true });
}
return value;
}
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
export function __disposeResources(env) {
function fail(e) {
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
env.hasError = true;
}
function next() {
while (env.stack.length) {
var rec = env.stack.pop();
try {
var result = rec.dispose && rec.dispose.call(rec.value);
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
}
catch (e) {
fail(e);
}
}
if (env.hasError) throw env.error;
}
return next();
}
export default {
__extends: __extends,
__assign: __assign,
__rest: __rest,
__decorate: __decorate,
__param: __param,
__metadata: __metadata,
__awaiter: __awaiter,
__generator: __generator,
__createBinding: __createBinding,
__exportStar: __exportStar,
__values: __values,
__read: __read,
__spread: __spread,
__spreadArrays: __spreadArrays,
__spreadArray: __spreadArray,
__await: __await,
__asyncGenerator: __asyncGenerator,
__asyncDelegator: __asyncDelegator,
__asyncValues: __asyncValues,
__makeTemplateObject: __makeTemplateObject,
__importStar: __importStar,
__importDefault: __importDefault,
__classPrivateFieldGet: __classPrivateFieldGet,
__classPrivateFieldSet: __classPrivateFieldSet,
__classPrivateFieldIn: __classPrivateFieldIn,
__addDisposableResource: __addDisposableResource,
__disposeResources: __disposeResources,
};
var dt=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?De.isErrorNoTelemetry(e)?new De(e.message+`
`+e.stack):new Error(e.message+`
`+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)}},vr=new dt;function Y(n){xr(n)||vr.onUnexpectedError(n)}function Ke(n){if(n instanceof Error){let{name:e,message:t,cause:r}=n,i=n.stacktrace||n.stack;return{$isError:!0,name:e,message:t,stack:i,noTelemetry:De.isErrorNoTelemetry(n),cause:r?Ke(r):void 0,code:n.code}}return n}var ft="Canceled";function xr(n){return n instanceof ye?!0:n instanceof Error&&n.name===ft&&n.message===ft}var ye=class extends Error{constructor(){super(ft),this.name=this.message}},un=class n extends Error{static{this._name="PendingMigrationError"}static is(e){return e instanceof n||e instanceof Error&&e.name===n._name}constructor(e){super(e),this.name=n._name}};var De=class n extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof n)return e;let t=new n;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},ge=class n extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,n.prototype)}};function pt(){return globalThis._VSCODE_NLS_LANGUAGE}var Bi=pt()==="pseudo"||typeof document<"u"&&document.location&&typeof document.location.hash=="string"&&document.location.hash.indexOf("pseudo=true")>=0;var Ie="en",je=!1,ze=!1,Se=!1,Er=!1,dn=!1,ht=!1,wr=!1,Rr=!1,Ar=!1,kr=!1,$e,qe=Ie,cn=Ie,Pr,re,ie=globalThis,H;typeof ie.vscode<"u"&&typeof ie.vscode.process<"u"?H=ie.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(H=process);var fn=typeof H?.versions?.electron=="string",Lr=fn&&H?.type==="renderer";if(typeof H=="object"){je=H.platform==="win32",ze=H.platform==="darwin",Se=H.platform==="linux",Er=Se&&!!H.env.SNAP&&!!H.env.SNAP_REVISION,wr=fn,Ar=!!H.env.CI||!!H.env.BUILD_ARTIFACTSTAGINGDIRECTORY||!!H.env.GITHUB_WORKSPACE,$e=Ie,qe=Ie;let n=H.env.VSCODE_NLS_CONFIG;if(n)try{let e=JSON.parse(n);$e=e.userLocale,cn=e.osLocale,qe=e.resolvedLanguage||Ie,Pr=e.languagePack?.translationsConfigFile}catch{}dn=!0}else typeof navigator=="object"&&!Lr?(re=navigator.userAgent,je=re.indexOf("Windows")>=0,ze=re.indexOf("Macintosh")>=0,Rr=(re.indexOf("Macintosh")>=0||re.indexOf("iPad")>=0||re.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Se=re.indexOf("Linux")>=0,kr=re?.indexOf("Mobi")>=0,ht=!0,qe=pt()||Ie,$e=navigator.language.toLowerCase(),cn=$e):console.error("Unable to resolve platform.");var mt=0;ze?mt=1:je?mt=3:Se&&(mt=2);var X=je,pn=ze,mn=Se;var hn=dn;var Ee=ht,Dr=ht&&typeof ie.importScripts=="function",gn=Dr?ie.origin:void 0;var Z=re,ae=qe,Sr;(r=>{function n(){return ae}r.value=n;function e(){return ae.length===2?ae==="en":ae.length>=3?ae[0]==="e"&&ae[1]==="n"&&ae[2]==="-":!1}r.isDefaultVariant=e;function t(){return ae==="en"}r.isDefault=t})(Sr||={});var Ur=typeof ie.postMessage=="function"&&!ie.importScripts,bn=(()=>{if(Ur){let n=[];ie.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let r=0,i=n.length;r<i;r++){let s=n[r];if(s.id===t.data.vscodeScheduleAsyncWork){n.splice(r,1),s.callback();return}}});let e=0;return t=>{let r=++e;n.push({id:r,callback:t}),ie.postMessage({vscodeScheduleAsyncWork:r},"*")}}return n=>setTimeout(n)})();var Or=!!(Z&&Z.indexOf("Chrome")>=0),Ki=!!(Z&&Z.indexOf("Firefox")>=0),$i=!!(!Or&&Z&&Z.indexOf("Safari")>=0),qi=!!(Z&&Z.indexOf("Edg/")>=0),ji=!!(Z&&Z.indexOf("Android")>=0);function yn(n,e){let t=Object.create(null);for(let r of n){let i=e(r),s=t[i];s||(s=t[i]=[]),s.push(r)}return t}var vn,xn,_n=class{constructor(e,t){this.toKey=t;this._map=new Map;this[vn]="SetWithKey";for(let r of e)this.add(r)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(r=>e.call(t,r,r,this))}[(xn=Symbol.iterator,vn=Symbol.toStringTag,xn)](){return this.values()}};function Nr(n,e,t=0,r=n.length){let i=t,s=r;for(;i<s;){let o=Math.floor((i+s)/2);e(n[o])?i=o+1:s=o}return i-1}var In=class n{constructor(e){this._array=e;this._findLastMonotonousLastIdx=0}static{this.assertInvariants=!1}findLastMonotonous(e){if(n.assertInvariants){if(this._prevFindLastPredicate){for(let r of this._array)if(this._prevFindLastPredicate(r)&&!e(r))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=e}let t=Nr(this._array,e,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=t+1,t===-1?void 0:this._array[t]}};var wn;(l=>{function n(a){return a<0}l.isLessThan=n;function e(a){return a<=0}l.isLessThanOrEqual=e;function t(a){return a>0}l.isGreaterThan=t;function r(a){return a===0}l.isNeitherLessOrGreaterThan=r,l.greaterThan=1,l.lessThan=-1,l.neitherLessOrGreaterThan=0})(wn||={});function Rn(n,e){return(t,r)=>e(n(t),n(r))}var An=(n,e)=>n-e;var En=class n{constructor(e){this.iterate=e}static{this.empty=new n(e=>{})}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(e){return new n(t=>this.iterate(r=>e(r)?t(r):!0))}map(e){return new n(t=>this.iterate(r=>t(e(r))))}some(e){let t=!1;return this.iterate(r=>(t=e(r),!t)),t}findFirst(e){let t;return this.iterate(r=>e(r)?(t=r,!1):!0),t}findLast(e){let t;return this.iterate(r=>(e(r)&&(t=r),!0)),t}findLastMaxBy(e){let t,r=!0;return this.iterate(i=>((r||wn.isGreaterThan(e(i,t)))&&(r=!1,t=i),!0)),t}};var gt=class{constructor(e,t){this.uri=e;this.value=t}};function Mr(n){return Array.isArray(n)}var Ln,Ue=class n{constructor(e,t){this[Ln]="ResourceMap";if(e instanceof n)this.map=new Map(e.map),this.toKey=t??n.defaultToKey;else if(Mr(e)){this.map=new Map,this.toKey=t??n.defaultToKey;for(let[r,i]of e)this.set(r,i)}else this.map=new Map,this.toKey=e??n.defaultToKey}static{this.defaultToKey=e=>e.toString()}set(e,t){return this.map.set(this.toKey(e),new gt(e,t)),this}get(e){return this.map.get(this.toKey(e))?.value}has(e){return this.map.has(this.toKey(e))}get size(){return this.map.size}clear(){this.map.clear()}delete(e){return this.map.delete(this.toKey(e))}forEach(e,t){typeof t<"u"&&(e=e.bind(t));for(let[r,i]of this.map)e(i.value,i.uri,this)}*values(){for(let e of this.map.values())yield e.value}*keys(){for(let e of this.map.values())yield e.uri}*entries(){for(let e of this.map.values())yield[e.uri,e.value]}*[(Ln=Symbol.toStringTag,Symbol.iterator)](){for(let[,e]of this.map)yield[e.uri,e.value]}},Dn,kn=class{constructor(e,t){this[Dn]="ResourceSet";!e||typeof e=="function"?this._map=new Ue(e):(this._map=new Ue(t),e.forEach(this.add,this))}get size(){return this._map.size}add(e){return this._map.set(e,e),this}clear(){this._map.clear()}delete(e){return this._map.delete(e)}forEach(e,t){this._map.forEach((r,i)=>e.call(t,i,i,this))}has(e){return this._map.has(e)}entries(){return this._map.entries()}keys(){return this._map.keys()}values(){return this._map.keys()}[(Dn=Symbol.toStringTag,Symbol.iterator)](){return this.keys()}};var Sn,Pn=class{constructor(){this[Sn]="LinkedMap";this._map=new Map,this._head=void 0,this._tail=void 0,this._size=0,this._state=0}clear(){this._map.clear(),this._head=void 0,this._tail=void 0,this._size=0,this._state++}isEmpty(){return!this._head&&!this._tail}get size(){return this._size}get first(){return this._head?.value}get last(){return this._tail?.value}has(e){return this._map.has(e)}get(e,t=0){let r=this._map.get(e);if(r)return t!==0&&this.touch(r,t),r.value}set(e,t,r=0){let i=this._map.get(e);if(i)i.value=t,r!==0&&this.touch(i,r);else{switch(i={key:e,value:t,next:void 0,previous:void 0},r){case 0:this.addItemLast(i);break;case 1:this.addItemFirst(i);break;case 2:this.addItemLast(i);break;default:this.addItemLast(i);break}this._map.set(e,i),this._size++}return this}delete(e){return!!this.remove(e)}remove(e){let t=this._map.get(e);if(t)return this._map.delete(e),this.removeItem(t),this._size--,t.value}shift(){if(!this._head&&!this._tail)return;if(!this._head||!this._tail)throw new Error("Invalid list");let e=this._head;return this._map.delete(e.key),this.removeItem(e),this._size--,e.value}forEach(e,t){let r=this._state,i=this._head;for(;i;){if(t?e.bind(t)(i.value,i.key,this):e(i.value,i.key,this),this._state!==r)throw new Error("LinkedMap got modified during iteration.");i=i.next}}keys(){let e=this,t=this._state,r=this._head,i={[Symbol.iterator](){return i},next(){if(e._state!==t)throw new Error("LinkedMap got modified during iteration.");if(r){let s={value:r.key,done:!1};return r=r.next,s}else return{value:void 0,done:!0}}};return i}values(){let e=this,t=this._state,r=this._head,i={[Symbol.iterator](){return i},next(){if(e._state!==t)throw new Error("LinkedMap got modified during iteration.");if(r){let s={value:r.value,done:!1};return r=r.next,s}else return{value:void 0,done:!0}}};return i}entries(){let e=this,t=this._state,r=this._head,i={[Symbol.iterator](){return i},next(){if(e._state!==t)throw new Error("LinkedMap got modified during iteration.");if(r){let s={value:[r.key,r.value],done:!1};return r=r.next,s}else return{value:void 0,done:!0}}};return i}[(Sn=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld(e){if(e>=this.size)return;if(e===0){this.clear();return}let t=this._head,r=this.size;for(;t&&r>e;)this._map.delete(t.key),t=t.next,r--;this._head=t,this._size=r,t&&(t.previous=void 0),this._state++}trimNew(e){if(e>=this.size)return;if(e===0){this.clear();return}let t=this._tail,r=this.size;for(;t&&r>e;)this._map.delete(t.key),t=t.previous,r--;this._tail=t,this._size=r,t&&(t.next=void 0),this._state++}addItemFirst(e){if(!this._head&&!this._tail)this._tail=e;else if(this._head)e.next=this._head,this._head.previous=e;else throw new Error("Invalid list");this._head=e,this._state++}addItemLast(e){if(!this._head&&!this._tail)this._head=e;else if(this._tail)e.previous=this._tail,this._tail.next=e;else throw new Error("Invalid list");this._tail=e,this._state++}removeItem(e){if(e===this._head&&e===this._tail)this._head=void 0,this._tail=void 0;else if(e===this._head){if(!e.next)throw new Error("Invalid list");e.next.previous=void 0,this._head=e.next}else if(e===this._tail){if(!e.previous)throw new Error("Invalid list");e.previous.next=void 0,this._tail=e.previous}else{let t=e.next,r=e.previous;if(!t||!r)throw new Error("Invalid list");t.previous=r,r.next=t}e.next=void 0,e.previous=void 0,this._state++}touch(e,t){if(!this._head||!this._tail)throw new Error("Invalid list");if(!(t!==1&&t!==2)){if(t===1){if(e===this._head)return;let r=e.next,i=e.previous;e===this._tail?(i.next=void 0,this._tail=i):(r.previous=i,i.next=r),e.previous=void 0,e.next=this._head,this._head.previous=e,this._head=e,this._state++}else if(t===2){if(e===this._tail)return;let r=e.next,i=e.previous;e===this._head?(r.previous=void 0,this._head=r):(r.previous=i,i.next=r),e.next=void 0,e.previous=this._tail,this._tail.next=e,this._tail=e,this._state++}}}toJSON(){let e=[];return this.forEach((t,r)=>{e.push([r,t])}),e}fromJSON(e){this.clear();for(let[t,r]of e)this.set(t,r)}};var He=class{constructor(){this.map=new Map}add(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}delete(e,t){let r=this.map.get(e);r&&(r.delete(t),r.size===0&&this.map.delete(e))}forEach(e,t){let r=this.map.get(e);r&&r.forEach(t)}get(e){let t=this.map.get(e);return t||new Set}};function Un(n){return!!n&&typeof n[Symbol.iterator]=="function"}var Oe;(ct=>{function n(T){return!!T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}ct.is=n;let e=Object.freeze([]);function t(){return e}ct.empty=t;function*r(T){yield T}ct.single=r;function i(T){return n(T)?T:r(T)}ct.wrap=i;function s(T){return T??e}ct.from=s;function*o(T){for(let x=T.length-1;x>=0;x--)yield T[x]}ct.reverse=o;function l(T){return!T||T[Symbol.iterator]().next().done===!0}ct.isEmpty=l;function a(T){return T[Symbol.iterator]().next().value}ct.first=a;function u(T,x){let w=0;for(let K of T)if(x(K,w++))return!0;return!1}ct.some=u;function f(T,x){let w=0;for(let K of T)if(!x(K,w++))return!1;return!0}ct.every=f;function c(T,x){for(let w of T)if(x(w))return w}ct.find=c;function*m(T,x){for(let w of T)x(w)&&(yield w)}ct.filter=m;function*P(T,x){let w=0;for(let K of T)yield x(K,w++)}ct.map=P;function*N(T,x){let w=0;for(let K of T)yield*x(K,w++)}ct.flatMap=N;function*V(...T){for(let x of T)Un(x)?yield*x:yield x}ct.concat=V;function j(T,x,w){let K=w;for(let pe of T)K=x(K,pe);return K}ct.reduce=j;function te(T){let x=0;for(let w of T)x++;return x}ct.length=te;function*fe(T,x,w=T.length){for(x<-T.length&&(x=0),x<0&&(x+=T.length),w<0?w+=T.length:w>T.length&&(w=T.length);x<w;x++)yield T[x]}ct.slice=fe;function z(T,x=Number.POSITIVE_INFINITY){let w=[];if(x===0)return[w,T];let K=T[Symbol.iterator]();for(let pe=0;pe<x;pe++){let Be=K.next();if(Be.done)return[w,ct.empty()];w.push(Be.value)}return[w,{[Symbol.iterator](){return K}}]}ct.consume=z;async function xe(T){let x=[];for await(let w of T)x.push(w);return x}ct.asyncToArray=xe;async function ut(T){let x=[];for await(let w of T)x=x.concat(w);return x}ct.asyncToArrayFlat=ut})(Oe||={});var Wr=!1,we=null;var On=class n{constructor(){this.livingDisposables=new Map}static{this.idx=0}getDisposableData(e){let t=this.livingDisposables.get(e);return t||(t={parent:null,source:null,isSingleton:!1,value:e,idx:n.idx++},this.livingDisposables.set(e,t)),t}trackDisposable(e){let t=this.getDisposableData(e);t.source||(t.source=new Error().stack)}setParent(e,t){let r=this.getDisposableData(e);r.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let r=t.get(e);if(r)return r;let i=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,i),i}getTrackedDisposables(){let e=new Map;return[...this.livingDisposables.entries()].filter(([,r])=>r.source!==null&&!this.getRootParent(r,e).isSingleton).flatMap(([r])=>r)}computeLeakingDisposables(e=10,t){let r;if(t)r=t;else{let a=new Map,u=[...this.livingDisposables.values()].filter(c=>c.source!==null&&!this.getRootParent(c,a).isSingleton);if(u.length===0)return;let f=new Set(u.map(c=>c.value));if(r=u.filter(c=>!(c.parent&&f.has(c.parent))),r.length===0)throw new Error("There are cyclic diposable chains!")}if(!r)return;function i(a){function u(c,m){for(;c.length>0&&m.some(P=>typeof P=="string"?P===c[0]:c[0].match(P));)c.shift()}let f=a.source.split(`
`).map(c=>c.trim().replace("at ","")).filter(c=>c!=="");return u(f,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),f.reverse()}let s=new He;for(let a of r){let u=i(a);for(let f=0;f<=u.length;f++)s.add(u.slice(0,f).join(`
`),a)}r.sort(Rn(a=>a.idx,An));let o="",l=0;for(let a of r.slice(0,e)){l++;let u=i(a),f=[];for(let c=0;c<u.length;c++){let m=u[c];m=`(shared with ${s.get(u.slice(0,c+1).join(`
`)).size}/${r.length} leaks) at ${m}`;let N=s.get(u.slice(0,c).join(`
`)),V=yn([...N].map(j=>i(j)[c]),j=>j);delete V[u[c]];for(let[j,te]of Object.entries(V))te&&f.unshift(` - stacktraces of ${te.length} other leaks continue with ${j}`);f.unshift(m)}o+=`
==================== Leaking disposable ${l}/${r.length}: ${a.value.constructor.name} ====================
${f.join(`
`)}
============================================================
`}return r.length>e&&(o+=`
... and ${r.length-e} more leaking disposables
`),{leaks:r,details:o}}};function Vr(n){we=n}if(Wr){let n="__is_disposable_tracked__";Vr(new class{trackDisposable(e){let t=new Error("Potentially leaked disposable").stack;setTimeout(()=>{e[n]||console.log(t)},3e3)}setParent(e,t){if(e&&e!==C.None)try{e[n]=!0}catch{}}markAsDisposed(e){if(e&&e!==C.None)try{e[n]=!0}catch{}}markAsSingleton(e){}})}function _t(n){return we?.trackDisposable(n),n}function vt(n){we?.markAsDisposed(n)}function bt(n,e){we?.setParent(n,e)}function Br(n,e){if(we)for(let t of n)we.setParent(t,e)}function xt(n){if(Oe.is(n)){let e=[];for(let t of n)if(t)try{t.dispose()}catch(r){e.push(r)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(n)?[]:n}else if(n)return n.dispose(),n}function Nn(...n){let e=be(()=>xt(n));return Br(n,e),e}var Tt=class{constructor(e){this._isDisposed=!1,this._fn=e,_t(this)}dispose(){if(!this._isDisposed){if(!this._fn)throw new Error("Unbound disposable context: Need to use an arrow function to preserve the value of this");this._isDisposed=!0,vt(this),this._fn()}}};function be(n){return new Tt(n)}var ue=class n{constructor(){this._toDispose=new Set;this._isDisposed=!1;_t(this)}static{this.DISABLE_DISPOSED_WARNING=!1}dispose(){this._isDisposed||(vt(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{xt(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e||e===C.None)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return bt(e,this),this._isDisposed?n.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(e),e}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.delete(e)&&bt(e,null)}assertNotDisposed(){this._isDisposed&&Y(new ge("Object disposed"))}},C=class{constructor(){this._store=new ue;_t(this),bt(this._store,this)}static{this.None=Object.freeze({dispose(){}})}dispose(){vt(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};var L=class n{static{this.Undefined=new n(void 0)}constructor(e){this.element=e,this.next=n.Undefined,this.prev=n.Undefined}},Ne=class{constructor(){this._first=L.Undefined;this._last=L.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new L(e);if(this._first===L.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(r))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}peek(){if(this._last!==L.Undefined)return this._last.element}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}};var Te,yt=globalThis.vscode;if(typeof yt<"u"&&typeof yt.process<"u"){let n=yt.process;Te={get platform(){return n.platform},get arch(){return n.arch},get env(){return n.env},cwd(){return n.cwd()}}}else typeof process<"u"&&typeof process?.versions?.node=="string"?Te={get platform(){return process.platform},get arch(){return process.arch},get env(){return process.env},cwd(){return process.env.VSCODE_CWD||process.cwd()}}:Te={get platform(){return X?"win32":pn?"darwin":"linux"},get arch(){},get env(){return{}},cwd(){return"/"}};var Me=Te.cwd,Ge=Te.env,Mn=Te.platform,bs=Te.arch;var $r=globalThis.performance.now.bind(globalThis.performance),Re=class n{static create(e){return new n(e)}constructor(e){this._now=e===!1?Date.now:$r,this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}};var Fn=!1,jr=!1,zr=100,Wn=6e4;function Vn(){return!!Ge.VSCODE_DEV}var Fe;(me=>{me.None=()=>C.None;function e(g){if(jr){let{onDidAddListener:d}=g,p=ke.create(),h=0;g.onDidAddListener=()=>{++h===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),p.print()),d?.()}}}function t(g,d,p){return P(g,()=>{},0,void 0,d??!0,void 0,p)}me.defer=t;function r(g){return(d,p=null,h)=>{let b=!1,_;return _=g(y=>{if(!b)return _?_.dispose():b=!0,d.call(p,y)},null,h),b&&_.dispose(),_}}me.once=r;function i(g,d){return me.once(me.filter(g,d))}me.onceIf=i;function s(g,d,p){return c((h,b=null,_)=>g(y=>h.call(b,d(y)),null,_),p)}me.map=s;function o(g,d,p){return c((h,b=null,_)=>g(y=>{d(y),h.call(b,y)},null,_),p)}me.forEach=o;function l(g,d,p){return c((h,b=null,_)=>g(y=>d(y)&&h.call(b,y),null,_),p)}me.filter=l;function a(g){return g}me.signal=a;function u(...g){return(d,p=null,h)=>{let b=Nn(...g.map(_=>_(y=>d.call(p,y))));return m(b,h)}}me.any=u;function f(g,d,p,h){let b=p;return s(g,_=>(b=d(b,_),b),h)}me.reduce=f;function c(g,d){let p,h={onWillAddFirstListener(){p=g(b.fire,b)},onDidRemoveLastListener(){p?.dispose()}};d||e(h);let b=new q(h);return d?.add(b),b.event}function m(g,d){return d instanceof Array?d.push(g):d&&d.add(g),g}function P(g,d,p=100,h=!1,b=!1,_,y){let M,A,B,F=0,$,ne={leakWarningThreshold:_,onWillAddFirstListener(){M=g(ln=>{F++,A=d(A,ln),h&&!B&&(he.fire(A),A=void 0),$=()=>{let an=A;A=void 0,B=void 0,(!h||F>1)&&he.fire(an),F=0},typeof p=="number"?(B&&clearTimeout(B),B=setTimeout($,p)):B===void 0&&(B=null,queueMicrotask($))})},onWillRemoveListener(){b&&F>0&&$?.()},onDidRemoveLastListener(){$=void 0,M.dispose()}};y||e(ne);let he=new q(ne);return y?.add(he),he.event}me.debounce=P;function N(g,d=0,p,h){return me.debounce(g,(b,_)=>b?(b.push(_),b):[_],d,void 0,p??!0,void 0,h)}me.accumulate=N;function V(g,d,p=100,h=!0,b=!0,_,y){let M,A,B,F=0,$={leakWarningThreshold:_,onWillAddFirstListener(){M=g(he=>{F++,A=d(A,he),B===void 0&&(h&&(ne.fire(A),A=void 0,F=0),typeof p=="number"?B=setTimeout(()=>{b&&F>0&&ne.fire(A),A=void 0,B=void 0,F=0},p):(B=0,queueMicrotask(()=>{b&&F>0&&ne.fire(A),A=void 0,B=void 0,F=0})))})},onDidRemoveLastListener(){M.dispose()}};y||e($);let ne=new q($);return y?.add(ne),ne.event}me.throttle=V;function j(g,d=(h,b)=>h===b,p){let h=!0,b;return l(g,_=>{let y=h||!d(_,b);return h=!1,b=_,y},p)}me.latch=j;function te(g,d,p){return[me.filter(g,d,p),me.filter(g,h=>!d(h),p)]}me.split=te;function fe(g,d,p=!1,h=[],b){let _=h.slice(),y;Vn()&&(y={stack:ke.create(),timerId:setTimeout(()=>{_&&_.length>0&&y&&!y.warned&&(y.warned=!0,console.warn(`[Event.buffer][${d}] potential LEAK detected: ${_.length} events buffered for ${Wn/1e3}s without being consumed. Buffered here:`),y.stack.print())},Wn),warned:!1},b&&b.add(be(()=>clearTimeout(y.timerId))));let M=()=>{y&&clearTimeout(y.timerId)},A=g($=>{_?(_.push($),Vn()&&y&&!y.warned&&_.length>=zr&&(y.warned=!0,console.warn(`[Event.buffer][${d}] potential LEAK detected: ${_.length} events buffered without being consumed. Buffered here:`),y.stack.print())):F.fire($)});b&&b.add(A);let B=()=>{_?.forEach($=>F.fire($)),_=null,M()},F=new q({onWillAddFirstListener(){A||(A=g($=>F.fire($)),b&&b.add(A))},onDidAddFirstListener(){_&&(p?setTimeout(B):B())},onDidRemoveLastListener(){A&&A.dispose(),A=null,M()}});return b&&b.add(F),F.event}me.buffer=fe;function z(g,d){return(h,b,_)=>{let y=d(new ut);return g(function(M){let A=y.evaluate(M);A!==xe&&h.call(b,A)},void 0,_)}}me.chain=z;let xe=Symbol("HaltChainable");class ut{constructor(){this.steps=[]}map(d){return this.steps.push(d),this}forEach(d){return this.steps.push(p=>(d(p),p)),this}filter(d){return this.steps.push(p=>d(p)?p:xe),this}reduce(d,p){let h=p;return this.steps.push(b=>(h=d(h,b),h)),this}latch(d=(p,h)=>p===h){let p=!0,h;return this.steps.push(b=>{let _=p||!d(b,h);return p=!1,h=b,_?b:xe}),this}evaluate(d){for(let p of this.steps)if(d=p(d),d===xe)break;return d}}function ct(g,d,p=h=>h){let h=(...M)=>y.fire(p(...M)),b=()=>g.on(d,h),_=()=>g.removeListener(d,h),y=new q({onWillAddFirstListener:b,onDidRemoveLastListener:_});return y.event}me.fromNodeEventEmitter=ct;function T(g,d,p=h=>h){let h=(...M)=>y.fire(p(...M)),b=()=>g.addEventListener(d,h),_=()=>g.removeEventListener(d,h),y=new q({onWillAddFirstListener:b,onDidRemoveLastListener:_});return y.event}me.fromDOMEventEmitter=T;function x(g,d){let p,h,b=new Promise(_=>{h=r(g)(_),At(h,d),p=()=>{Kn(h,d)}});return b.cancel=p,d&&b.finally(()=>Kn(h,d)),b}me.toPromise=x;function w(g,d){return g(p=>d.fire(p))}me.forward=w;function K(g,d,p){return d(p),g(h=>d(h))}me.runAndSubscribe=K;class pe{constructor(d,p){this._observable=d;this._counter=0;this._hasChanged=!1;let h={onWillAddFirstListener:()=>{d.addObserver(this),this._observable.reportChanges()},onDidRemoveLastListener:()=>{d.removeObserver(this)}};p||e(h),this.emitter=new q(h),p&&p.add(this.emitter)}beginUpdate(d){this._counter++}handlePossibleChange(d){}handleChange(d,p){this._hasChanged=!0}endUpdate(d){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Be(g,d){return new pe(g,d).emitter.event}me.fromObservable=Be;function _r(g){return(d,p,h)=>{let b=0,_=!1,y={beginUpdate(){b++},endUpdate(){b--,b===0&&(g.reportChanges(),_&&(_=!1,d.call(p)))},handlePossibleChange(){},handleChange(){_=!0}};g.addObserver(y),g.reportChanges();let M={dispose(){g.removeObserver(y)}};return At(M,h),M}}me.fromObservableLight=_r})(Fe||={});var It=class n{constructor(e){this.listenerCount=0;this.invocationCount=0;this.elapsedOverall=0;this.durations=[];this.name=`${e}_${n._idPool++}`,n.all.add(this)}static{this.all=new Set}static{this._idPool=0}start(e){this._stopWatch=new Re,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}}},Bn=-1;var Et=class n{constructor(e,t,r=(n._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e;this.threshold=t;this.name=r;this._warnCountdown=0}static{this._idPool=1}dispose(){this._stacks?.clear()}check(e,t){let r=this.threshold;if(r<=0||t<r)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[s,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(s);let a=o/t>.3?"dominated":"popular",u=new Qe(a,l,s,t);this._errorHandler(u)}return()=>{let s=this._stacks.get(e.value)||0;this._stacks.set(e.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[r,i]of this._stacks)(!e||t<i)&&(e=[r,i],t=i);return e}},ke=class n{constructor(e){this.value=e}static create(){let e=new Error;return new n(e.stack??"")}print(){console.warn(this.value.split(`
`).slice(2).join(`
`))}},Qe=class n extends Error{constructor(e,t,r,i){super(`potential listener LEAK detected, ${e}`),this.name="ListenerLeakError",this.kind=e,this.listenerCount=i,this.details=t,this.stack=r}static is(e){return e instanceof n||e instanceof Error&&typeof e.kind=="string"&&typeof e.listenerCount=="number"}},wt=class extends Qe{constructor(e,t,r,i){super(e,t,r,i),this.name="ListenerRefusalError"}},Hr=0,Ae=class{constructor(e){this.value=e;this.id=Hr++}},Gr=2,Qr=(n,e)=>{if(n instanceof Ae)e(n);else for(let t=0;t<n.length;t++){let r=n[t];r&&e(r)}},q=class{constructor(e){this._size=0;this._options=e,this._leakageMon=Bn>0||this._options?.leakWarningThreshold?new Et(e?.onListenerError??Y,this._options?.leakWarningThreshold??Bn):void 0,this._perfMon=this._options?._profName?new It(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Fn){let e=this._listeners;queueMicrotask(()=>{Qr(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let u=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],f=u[1]/this._size>.3?"dominated":"popular",c=new wt(f,`${a}. HINT: Stack shows most frequent listener (${u[1]}-times)`,u[0],this._size);return(this._options?.onListenerError||Y)(c),C.None}if(this._disposed)return C.None;t&&(e=e.bind(t));let i=new Ae(e),s,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=ke.create(),s=this._leakageMon.check(i.stack,this._size+1)),Fn&&(i.stack=o??ke.create()),this._listeners?this._listeners instanceof Ae?(this._deliveryQueue??=new Rt,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._options?.onDidAddListener?.(this),this._size++;let l=be(()=>{s?.(),this._removeListener(i)});return At(l,r),l},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,r=t.indexOf(e);if(r===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[r]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Gr<=t.length){let s=0;for(let o=0;o<t.length;o++)t[o]?t[s++]=t[o]:i&&s<this._deliveryQueue.end&&(this._deliveryQueue.end--,s<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=s}}_deliver(e,t){if(!e)return;let r=this._options?.onListenerError||Y;if(!r){e.value(t);return}try{e.value(t)}catch(i){r(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Ae)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}};var Rt=class{constructor(){this.i=-1;this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}};function At(n,e){e instanceof ue?e.add(n):Array.isArray(e)&&e.push(n)}function Kn(n,e){if(e instanceof ue)e.delete(n);else if(Array.isArray(e)){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}n.dispose()}var $n=Object.freeze(