/*!--------------------------------------------------------
 * 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 fd=Object.defineProperty;var hd=Object.getOwnPropertyDescriptor;var P=(r,e,t,n)=>{for(var i=n>1?void 0:n?hd(e,t):e,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&fd(e,t,i),i},Se=(r,e)=>(t,n)=>e(t,n,r);function gd(r,e,t=0,n=r.length){let i=t,s=n;for(;i<s;){let o=Math.floor((i+s)/2);e(r[o])?i=o+1:s=o}return i-1}var qa=class r{constructor(e){this._array=e;this._findLastMonotonousLastIdx=0}static{this.assertInvariants=!1}findLastMonotonous(e){if(r.assertInvariants){if(this._prevFindLastPredicate){for(let n of this._array)if(this._prevFindLastPredicate(n)&&!e(n))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=e}let t=gd(this._array,e,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=t+1,t===-1?void 0:this._array[t]}};var zs=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Je.isErrorNoTelemetry(e)?new Je(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)}},Ka=new zs;function It(r){Ka.onUnexpectedError(r)}function Z(r){md(r)||Ka.onUnexpectedError(r)}var Gr="Canceled";function md(r){return r instanceof _e?!0:r instanceof Error&&r.name===Gr&&r.message===Gr}var _e=class extends Error{constructor(){super(Gr),this.name=this.message}},$a=class r extends Error{static{this._name="PendingMigrationError"}static is(e){return e instanceof r||e instanceof Error&&e.name===r._name}constructor(e){super(e),this.name=r._name}};function Qr(){let r=new Error(Gr);return r.name=r.message,r}function Jr(r){return r?new Error(`Illegal state: ${r}`):new Error("Illegal state")}var Je=class r extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof r)return e;let t=new r;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},H=class r extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,r.prototype)}};function Zn(r,e,t=(n,i)=>n===i){if(r===e)return!0;if(!r||!e||r.length!==e.length)return!1;for(let n=0,i=r.length;n<i;n++)if(!t(r[n],e[n]))return!1;return!0}function Yr(r){return r.filter(e=>!!e)}function js(r,e){return r.push(e),()=>vd(r,e)}function vd(r,e){let t=r.indexOf(e);if(t>-1)return r.splice(t,1),e}function Hs(r,e){let t;if(typeof e=="number"){let n=e;t=()=>{let i=Math.sin(n++)*179426549;return i-Math.floor(i)}}else t=Math.random;for(let n=r.length-1;n>0;n-=1){let i=Math.floor(t()*(n+1)),s=r[n];r[n]=r[i],r[i]=s}}function Ha(r){return r[Math.floor(Math.random()*r.length)]}var Ga;(a=>{function r(l){return l<0}a.isLessThan=r;function e(l){return l<=0}a.isLessThanOrEqual=e;function t(l){return l>0}a.isGreaterThan=t;function n(l){return l===0}a.isNeitherLessOrGreaterThan=n,a.greaterThan=1,a.lessThan=-1,a.neitherLessOrGreaterThan=0})(Ga||={});function Qa(r,e){return(t,n)=>e(r(t),r(n))}var Ja=(r,e)=>r-e;var ja=class r{constructor(e){this.iterate=e}static{this.empty=new r(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 r(t=>this.iterate(n=>e(n)?t(n):!0))}map(e){return new r(t=>this.iterate(n=>t(e(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(i=>((n||Ga.isGreaterThan(e(i,t)))&&(n=!1,t=i),!0)),t}};function tl(r,e){let t=Object.create(null);for(let n of r){let i=e(n),s=t[i];s||(s=t[i]=[]),s.push(n)}return t}var Za,el,Xa=class{constructor(e,t){this.toKey=t;this._map=new Map;this[Za]="SetWithKey";for(let n of e)this.add(n)}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(n=>e.call(t,n,n,this))}[(el=Symbol.iterator,Za=Symbol.toStringTag,el)](){return this.values()}};function an(r,e){let t=this,n=!1,i;return function(){if(n)return i;if(n=!0,e)try{i=r.apply(t,arguments)}finally{e()}else i=r.apply(t,arguments);return i}}var Gs=class{constructor(e,t){this.uri=e;this.value=t}};function bd(r){return Array.isArray(r)}var rl,rt=class r{constructor(e,t){this[rl]="ResourceMap";if(e instanceof r)this.map=new Map(e.map),this.toKey=t??r.defaultToKey;else if(bd(e)){this.map=new Map,this.toKey=t??r.defaultToKey;for(let[n,i]of e)this.set(n,i)}else this.map=new Map,this.toKey=e??r.defaultToKey}static{this.defaultToKey=e=>e.toString()}set(e,t){return this.map.set(this.toKey(e),new Gs(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[n,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]}*[(rl=Symbol.toStringTag,Symbol.iterator)](){for(let[,e]of this.map)yield[e.uri,e.value]}},il,nl=class{constructor(e,t){this[il]="ResourceSet";!e||typeof e=="function"?this._map=new rt(e):(this._map=new rt(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((n,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()}[(il=Symbol.toStringTag,Symbol.iterator)](){return this.keys()}};var sl,Qs=class{constructor(){this[sl]="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 n=this._map.get(e);if(n)return t!==0&&this.touch(n,t),n.value}set(e,t,n=0){let i=this._map.get(e);if(i)i.value=t,n!==0&&this.touch(i,n);else{switch(i={key:e,value:t,next:void 0,previous:void 0},n){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 n=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!==n)throw new Error("LinkedMap got modified during iteration.");i=i.next}}keys(){let e=this,t=this._state,n=this._head,i={[Symbol.iterator](){return i},next(){if(e._state!==t)throw new Error("LinkedMap got modified during iteration.");if(n){let s={value:n.key,done:!1};return n=n.next,s}else return{value:void 0,done:!0}}};return i}values(){let e=this,t=this._state,n=this._head,i={[Symbol.iterator](){return i},next(){if(e._state!==t)throw new Error("LinkedMap got modified during iteration.");if(n){let s={value:n.value,done:!1};return n=n.next,s}else return{value:void 0,done:!0}}};return i}entries(){let e=this,t=this._state,n=this._head,i={[Symbol.iterator](){return i},next(){if(e._state!==t)throw new Error("LinkedMap got modified during iteration.");if(n){let s={value:[n.key,n.value],done:!1};return n=n.next,s}else return{value:void 0,done:!0}}};return i}[(sl=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld(e){if(e>=this.size)return;if(e===0){this.clear();return}let t=this._head,n=this.size;for(;t&&n>e;)this._map.delete(t.key),t=t.next,n--;this._head=t,this._size=n,t&&(t.previous=void 0),this._state++}trimNew(e){if(e>=this.size)return;if(e===0){this.clear();return}let t=this._tail,n=this.size;for(;t&&n>e;)this._map.delete(t.key),t=t.previous,n--;this._tail=t,this._size=n,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,n=e.previous;if(!t||!n)throw new Error("Invalid list");t.previous=n,n.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 n=e.next,i=e.previous;e===this._tail?(i.next=void 0,this._tail=i):(n.previous=i,i.next=n),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 n=e.next,i=e.previous;e===this._head?(n.previous=void 0,this._head=n):(n.previous=i,i.next=n),e.next=void 0,e.previous=this._tail,this._tail.next=e,this._tail=e,this._state++}}}toJSON(){let e=[];return this.forEach((t,n)=>{e.push([n,t])}),e}fromJSON(e){this.clear();for(let[t,n]of e)this.set(t,n)}},Js=class extends Qs{constructor(e,t=1){super(),this._limit=e,this._ratio=Math.min(Math.max(0,t),1)}get limit(){return this._limit}set limit(e){this._limit=e,this.checkTrim()}get ratio(){return this._ratio}set ratio(e){this._ratio=Math.min(Math.max(0,e),1),this.checkTrim()}get(e,t=2){return super.get(e,t)}peek(e){return super.get(e,0)}set(e,t){return super.set(e,t,2),this}checkTrim(){this.size>this._limit&&this.trim(Math.round(this._limit*this._ratio))}},Tt=class extends Js{constructor(e,t=1){super(e,t)}trim(e){this.trimOld(e)}set(e,t){return super.set(e,t),this.checkTrim(),this}};var Xr=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){let t=this.map.get(e);return t||new Set}};function Zr(r,e="unexpected state"){if(!r)throw typeof e=="string"?new H(`Assertion Failed: ${e}`):e}function er(r){if(!r()){debugger;r(),Z(new H("Assertion Failed"))}}function Ut(r){return typeof r=="string"}function tr(r){return typeof r=="number"&&!isNaN(r)}function ol(r){return!!r&&typeof r[Symbol.iterator]=="function"}function yd(r){return typeof r>"u"}function ln(r){return!ei(r)}function ei(r){return yd(r)||r===null}function al(r,e){if(!r)throw new Error(e?`Unexpected type, expected '${e}'`:"Unexpected type")}function Ys(r){return typeof r=="function"}var nr;(Ks=>{function r(E){return!!E&&typeof E=="object"&&typeof E[Symbol.iterator]=="function"}Ks.is=r;let e=Object.freeze([]);function t(){return e}Ks.empty=t;function*n(E){yield E}Ks.single=n;function i(E){return r(E)?E:n(E)}Ks.wrap=i;function s(E){return E??e}Ks.from=s;function*o(E){for(let k=E.length-1;k>=0;k--)yield E[k]}Ks.reverse=o;function a(E){return!E||E[Symbol.iterator]().next().done===!0}Ks.isEmpty=a;function l(E){return E[Symbol.iterator]().next().value}Ks.first=l;function c(E,k){let q=0;for(let Ie of E)if(k(Ie,q++))return!0;return!1}Ks.some=c;function d(E,k){let q=0;for(let Ie of E)if(!k(Ie,q++))return!1;return!0}Ks.every=d;function u(E,k){for(let q of E)if(k(q))return q}Ks.find=u;function*p(E,k){for(let q of E)k(q)&&(yield q)}Ks.filter=p;function*h(E,k){let q=0;for(let Ie of E)yield k(Ie,q++)}Ks.map=h;function*g(E,k){let q=0;for(let Ie of E)yield*k(Ie,q++)}Ks.flatMap=g;function*b(...E){for(let k of E)ol(k)?yield*k:yield k}Ks.concat=b;function W(E,k,q){let Ie=q;for(let Lt of E)Ie=k(Ie,Lt);return Ie}Ks.reduce=W;function j(E){let k=0;for(let q of E)k++;return k}Ks.length=j;function*Pe(E,k,q=E.length){for(k<-E.length&&(k=0),k<0&&(k+=E.length),q<0?q+=E.length:q>E.length&&(q=E.length);k<q;k++)yield E[k]}Ks.slice=Pe;function me(E,k=Number.POSITIVE_INFINITY){let q=[];if(k===0)return[q,E];let Ie=E[Symbol.iterator]();for(let Lt=0;Lt<k;Lt++){let Hr=Ie.next();if(Hr.done)return[q,Ks.empty()];q.push(Hr.value)}return[q,{[Symbol.iterator](){return Ie}}]}Ks.consume=me;async function yt(E){let k=[];for await(let q of E)k.push(q);return k}Ks.asyncToArray=yt;async function jr(E){let k=[];for await(let q of E)k=k.concat(q);return k}Ks.asyncToArrayFlat=jr})(nr||={});var Id=!1,cn=null;var cl=class r{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:r.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 n=this.getDisposableData(e);n.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let n=t.get(e);if(n)return n;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(([,n])=>n.source!==null&&!this.getRootParent(n,e).isSingleton).flatMap(([n])=>n)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let l=new Map,c=[...this.livingDisposables.values()].filter(u=>u.source!==null&&!this.getRootParent(u,l).isSingleton);if(c.length===0)return;let d=new Set(c.map(u=>u.value));if(n=c.filter(u=>!(u.parent&&d.has(u.parent))),n.length===0)throw new Error("There are cyclic diposable chains!")}if(!n)return;function i(l){function c(u,p){for(;u.length>0&&p.some(h=>typeof h=="string"?h===u[0]:u[0].match(h));)u.shift()}let d=l.source.split(`
`).map(u=>u.trim().replace("at ","")).filter(u=>u!=="");return c(d,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),d.reverse()}let s=new Xr;for(let l of n){let c=i(l);for(let d=0;d<=c.length;d++)s.add(c.slice(0,d).join(`
`),l)}n.sort(Qa(l=>l.idx,Ja));let o="",a=0;for(let l of n.slice(0,e)){a++;let c=i(l),d=[];for(let u=0;u<c.length;u++){let p=c[u];p=`(shared with ${s.get(c.slice(0,u+1).join(`
`)).size}/${n.length} leaks) at ${p}`;let g=s.get(c.slice(0,u).join(`
`)),b=tl([...g].map(W=>i(W)[u]),W=>W);delete b[c[u]];for(let[W,j]of Object.entries(b))j&&d.unshift(`    - stacktraces of ${j.length} other leaks continue with ${W}`);d.unshift(p)}o+=`


==================== Leaking disposable ${a}/${n.length}: ${l.value.constructor.name} ====================
${d.join(`
`)}
============================================================

`}return n.length>e&&(o+=`


... and ${n.length-e} more leaking disposables

`),{leaks:n,details:o}}};function Td(r){cn=r}if(Id){let r="__is_disposable_tracked__";Td(new class{trackDisposable(e){let t=new Error("Potentially leaked disposable").stack;setTimeout(()=>{e[r]||console.log(t)},3e3)}setParent(e,t){if(e&&e!==A.None)try{e[r]=!0}catch{}}markAsDisposed(e){if(e&&e!==A.None)try{e[r]=!0}catch{}}markAsSingleton(e){}})}function _t(r){return cn?.trackDisposable(r),r}function xt(r){cn?.markAsDisposed(r)}function Nt(r,e){cn?.setParent(r,e)}function Sd(r,e){if(cn)for(let t of r)cn.setParent(t,e)}function ni(r){return typeof r=="object"&&r!==null&&typeof r.dispose=="function"&&r.dispose.length===0}function xe(r){if(nr.is(r)){let e=[];for(let t of r)if(t)try{t.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(r)?[]:r}else if(r)return r.dispose(),r}function ul(...r){let e=O(()=>xe(r));return Sd(r,e),e}var Xs=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,xt(this),this._fn()}}};function O(r){return new Xs(r)}var D=class r{constructor(){this._toDispose=new Set;this._isDisposed=!1;_t(this)}static{this.DISABLE_DISPOSED_WARNING=!1}dispose(){this._isDisposed||(xt(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{xe(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e||e===A.None)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return Nt(e,this),this._isDisposed?r.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)&&Nt(e,null)}assertNotDisposed(){this._isDisposed&&Z(new H("Object disposed"))}},A=class{constructor(){this._store=new D;_t(this),Nt(this._store,this)}static{this.None=Object.freeze({dispose(){}})}dispose(){xt(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}},St=class{constructor(){this._isDisposed=!1;_t(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Nt(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,xt(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Nt(e,null),e}};var ti=class{constructor(){this.references=new Map}acquire(e,...t){let n=this.references.get(e);n||(n={counter:0,object:this.createReferencedObject(e,...t)},this.references.set(e,n));let{object:i}=n,s=an(()=>{--n.counter===0&&(this.destroyReferencedObject(e,n.object),this.references.delete(e))});return n.counter++,{object:i,dispose:s}}};var Ye=class{constructor(e=new Map){this._isDisposed=!1;this._store=e,_t(this)}dispose(){xt(this),this._isDisposed=!0,this.clearAndDisposeAll()}clearAndDisposeAll(){if(this._store.size)try{xe(this._store.values())}finally{this._store.clear()}}has(e){return this._store.has(e)}get size(){return this._store.size}get(e){return this._store.get(e)}set(e,t,n=!1){this._isDisposed&&console.warn(new Error("Trying to add a disposable to a DisposableMap that has already been disposed of. The added object will be leaked!").stack),n||this._store.get(e)?.dispose(),this._store.set(e,t),Nt(t,this)}deleteAndDispose(e){this._store.get(e)?.dispose(),this._store.delete(e)}deleteAndLeak(e){let t=this._store.get(e);return t&&Nt(t,null),this._store.delete(e),t}keys(){return this._store.keys()}values(){return this._store.values()}[Symbol.iterator](){return this._store[Symbol.iterator]()}};function dl(r,e){return r.then(t=>(e.isDisposed?t.dispose():e.add(t),t))}var G=class r{static{this.Undefined=new r(void 0)}constructor(e){this.element=e,this.next=r.Undefined,this.prev=r.Undefined}},rr=class{constructor(){this._first=G.Undefined;this._last=G.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===G.Undefined}clear(){let e=this._first;for(;e!==G.Undefined;){let t=e.next;e.prev=G.Undefined,e.next=G.Undefined,e=t}this._first=G.Undefined,this._last=G.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new G(e);if(this._first===G.Undefined)this._first=n,this._last=n;else if(t){let s=this._last;this._last=n,n.prev=s,s.next=n}else{let s=this._first;this._first=n,n.next=s,s.prev=n}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(n))}}shift(){if(this._first!==G.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==G.Undefined){let e=this._last.element;return this._remove(this._last),e}}peek(){if(this._last!==G.Undefined)return this._last.element}_remove(e){if(e.prev!==G.Undefined&&e.next!==G.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===G.Undefined&&e.next===G.Undefined?(this._first=G.Undefined,this._last=G.Undefined):e.next===G.Undefined?(this._last=this._last.prev,this._last.next=G.Undefined):e.prev===G.Undefined&&(this._first=this._first.next,this._first.prev=G.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==G.Undefined;)yield e.element,e=e.next}};function _d(){return globalThis._VSCODE_NLS_MESSAGES}function Zs(){return globalThis._VSCODE_NLS_LANGUAGE}var xd=Zs()==="pseudo"||typeof document<"u"&&document.location&&typeof document.location.hash=="string"&&document.location.hash.indexOf("pseudo=true")>=0;function pl(r,e){let t;return e.length===0?t=r:t=r.replace(/\{(\d+)\}/g,(n,i)=>{let s=i[0],o=e[s],a=n;return typeof o=="string"?a=o:(typeof o=="number"||typeof o=="boolean"||o===void 0||o===null)&&(a=String(o)),a}),xd&&(t="\uFF3B"+t.replace(/[aouei]/g,"$&$&")+"\uFF3D"),t}function f(r,e,...t){return pl(typeof r=="number"?Ed(r,e):e,t)}function Ed(r,e){let t=_d()?.[r];if(typeof t!="string"){if(typeof e=="string")return e;throw new Error(`!!! NLS MISSING: ${r} !!!`)}return t}var Mt="en",si=!1,oi=!1,ir=!1,Rd=!1,hl=!1,no=!1,wd=!1,Cd=!1,Pd=!1,Dd=!1,ri,ii=Mt,fl=Mt,Ad,it,st=globalThis,De;typeof st.vscode<"u"&&typeof st.vscode.process<"u"?De=st.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(De=process);var gl=typeof De?.versions?.electron=="string",kd=gl&&De?.type==="renderer";if(typeof De=="object"){si=De.platform==="win32",oi=De.platform==="darwin",ir=De.platform==="linux",Rd=ir&&!!De.env.SNAP&&!!De.env.SNAP_REVISION,wd=gl,Pd=!!De.env.CI||!!De.env.BUILD_ARTIFACTSTAGINGDIRECTORY||!!De.env.GITHUB_WORKSPACE,ri=Mt,ii=Mt;let r=De.env.VSCODE_NLS_CONFIG;if(r)try{let e=JSON.parse(r);ri=e.userLocale,fl=e.osLocale,ii=e.resolvedLanguage||Mt,Ad=e.languagePack?.translationsConfigFile}catch{}hl=!0}else typeof navigator=="object"&&!kd?(it=navigator.userAgent,si=it.indexOf("Windows")>=0,oi=it.indexOf("Macintosh")>=0,Cd=(it.indexOf("Macintosh")>=0||it.indexOf("iPad")>=0||it.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ir=it.indexOf("Linux")>=0,Dd=it?.indexOf("Mobi")>=0,no=!0,ii=Zs()||Mt,ri=navigator.language.toLowerCase(),fl=ri):console.error("Unable to resolve platform.");var to=0;oi?to=1:si?to=3:ir&&(to=2);var $=si,$e=oi,te=ir;var ml=hl;var un=no,Ld=no&&typeof st.importScripts=="function",vl=Ld?st.origin:void 0;var Xe=it,Et=ii,Od;(n=>{function r(){return Et}n.value=r;function e(){return Et.length===2?Et==="en":Et.length>=3?Et[0]==="e"&&Et[1]==="n"&&Et[2]==="-":!1}n.isDefaultVariant=e;function t(){return Et==="en"}n.isDefault=t})(Od||={});var Fd=typeof st.postMessage=="function"&&!st.importScripts,bl=(()=>{if(Fd){let r=[];st.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,i=r.length;n<i;n++){let s=r[n];if(s.id===t.data.vscodeScheduleAsyncWork){r.splice(n,1),s.callback();return}}});let e=0;return t=>{let n=++e;r.push({id:n,callback:t}),st.postMessage({vscodeScheduleAsyncWork:n},"*")}}return r=>setTimeout(r)})();var ro=!!(Xe&&Xe.indexOf("Chrome")>=0),yl=!!(Xe&&Xe.indexOf("Firefox")>=0),Il=!!(!ro&&Xe&&Xe.indexOf("Safari")>=0),Tl=!!(Xe&&Xe.indexOf("Edg/")>=0),yg=!!(Xe&&Xe.indexOf("Android")>=0);var Wt,io=globalThis.vscode;if(typeof io<"u"&&typeof io.process<"u"){let r=io.process;Wt={get platform(){return r.platform},get arch(){return r.arch},get env(){return r.env},cwd(){return r.cwd()}}}else typeof process<"u"&&typeof process?.versions?.node=="string"?Wt={get platform(){return process.platform},get arch(){return process.arch},get env(){return process.env},cwd(){return process.env.VSCODE_CWD||process.cwd()}}:Wt={get platform(){return $?"win32":$e?"darwin":"linux"},get arch(){},get env(){return{}},cwd(){return"/"}};var dn=Wt.cwd,pe=Wt.env,_l=Wt.platform,Sg=Wt.arch;var Ud=globalThis.performance.now.bind(globalThis.performance),ai=class r{static create(e){return new r(e)}constructor(e){this._now=e===!1?Date.now:Ud,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 El=!1,Nd=!1,Md=100,Rl=6e4;function wl(){return!!pe.VSCODE_DEV}var V;(Ot=>{Ot.None=()=>A.None;function e(S){if(Nd){let{onDidAddListener:v}=S,y=fn.create(),T=0;S.onDidAddListener=()=>{++T===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),y.print()),v?.()}}}function t(S,v,y){return h(S,()=>{},0,void 0,v??!0,void 0,y)}Ot.defer=t;function n(S){return(v,y=null,T)=>{let _=!1,R;return R=S(L=>{if(!_)return R?R.dispose():_=!0,v.call(y,L)},null,T),_&&R.dispose(),R}}Ot.once=n;function i(S,v){return Ot.once(Ot.filter(S,v))}Ot.onceIf=i;function s(S,v,y){return u((T,_=null,R)=>S(L=>T.call(_,v(L)),null,R),y)}Ot.map=s;function o(S,v,y){return u((T,_=null,R)=>S(L=>{v(L),T.call(_,L)},null,R),y)}Ot.forEach=o;function a(S,v,y){return u((T,_=null,R)=>S(L=>v(L)&&T.call(_,L),null,R),y)}Ot.filter=a;function l(S){return S}Ot.signal=l;function c(...S){return(v,y=null,T)=>{let _=ul(...S.map(R=>R(L=>v.call(y,L))));return p(_,T)}}Ot.any=c;function d(S,v,y,T){let _=y;return s(S,R=>(_=v(_,R),_),T)}Ot.reduce=d;function u(S,v){let y,T={onWillAddFirstListener(){y=S(_.fire,_)},onDidRemoveLastListener(){y?.dispose()}};v||e(T);let _=new I(T);return v?.add(_),_.event}function p(S,v){return v instanceof Array?v.push(S):v&&v.add(S),S}function h(S,v,y=100,T=!1,_=!1,R,L){let ue,K,ve,de=0,Te,nt={leakWarningThreshold:R,onWillAddFirstListener(){ue=S(Ba=>{de++,K=v(K,Ba),T&&!ve&&(Ft.fire(K),K=void 0),Te=()=>{let Va=K;K=void 0,ve=void 0,(!T||de>1)&&Ft.fire(Va),de=0},typeof y=="number"?(ve&&clearTimeout(ve),ve=setTimeout(Te,y)):ve===void 0&&(ve=null,queueMicrotask(Te))})},onWillRemoveListener(){_&&de>0&&Te?.()},onDidRemoveLastListener(){Te=void 0,ue.dispose()}};L||e(nt);let Ft=new I(nt);return L?.add(Ft),Ft.event}Ot.debounce=h;function g(S,v=0,y,T){return Ot.debounce(S,(_,R)=>_?(_.push(R),_):[R],v,void 0,y??!0,void 0,T)}Ot.accumulate=g;function b(S,v,y=100,T=!0,_=!0,R,L){let ue,K,ve,de=0,Te={leakWarningThreshold:R,onWillAddFirstListener(){ue=S(Ft=>{de++,K=v(K,Ft),ve===void 0&&(T&&(nt.fire(K),K=void 0,de=0),typeof y=="number"?ve=setTimeout(()=>{_&&de>0&&nt.fire(K),K=void 0,ve=void 0,de=0},y):(ve=0,queueMicrotask(()=>{_&&de>0&&nt.fire(K),K=void 0,ve=void 0,de=0})))})},onDidRemoveLastListener(){ue.dispose()}};L||e(Te);let nt=new I(Te);return L?.add(nt),nt.event}Ot.throttle=b;function W(S,v=(T,_)=>T===_,y){let T=!0,_;return a(S,R=>{let L=T||!v(R,_);return T=!1,_=R,L},y)}Ot.latch=W;function j(S,v,y){return[Ot.filter(S,v,y),Ot.filter(S,T=>!v(T),y)]}Ot.split=j;function Pe(S,v,y=!1,T=[],_){let R=T.slice(),L;wl()&&(L={stack:fn.create(),timerId:setTimeout(()=>{R&&R.length>0&&L&&!L.warned&&(L.warned=!0,console.warn(`[Event.buffer][${v}] potential LEAK detected: ${R.length} events buffered for ${Rl/1e3}s without being consumed. Buffered here:`),L.stack.print())},Rl),warned:!1},_&&_.add(O(()=>clearTimeout(L.timerId))));let ue=()=>{L&&clearTimeout(L.timerId)},K=S(Te=>{R?(R.push(Te),wl()&&L&&!L.warned&&R.length>=Md&&(L.warned=!0,console.warn(`[Event.buffer][${v}] potential LEAK detected: ${R.length} events buffered without being consumed. Buffered here:`),L.stack.print())):de.fire(Te)});_&&_.add(K);let ve=()=>{R?.forEach(Te=>de.fire(Te)),R=null,ue()},de=new I({onWillAddFirstListener(){K||(K=S(Te=>de.fire(Te)),_&&_.add(K))},onDidAddFirstListener(){R&&(y?setTimeout(ve):ve())},onDidRemoveLastListener(){K&&K.dispose(),K=null,ue()}});return _&&_.add(de),de.event}Ot.buffer=Pe;function me(S,v){return(T,_,R)=>{let L=v(new jr);return S(function(ue){let K=L.evaluate(ue);K!==yt&&T.call(_,K)},void 0,R)}}Ot.chain=me;let yt=Symbol("HaltChainable");class jr{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(y=>(v(y),y)),this}filter(v){return this.steps.push(y=>v(y)?y:yt),this}reduce(v,y){let T=y;return this.steps.push(_=>(T=v(T,_),T)),this}latch(v=(y,T)=>y===T){let y=!0,T;return this.steps.push(_=>{let R=y||!v(_,T);return y=!1,T=_,R?_:yt}),this}evaluate(v){for(let y of this.steps)if(v=y(v),v===yt)break;return v}}function Ks(S,v,y=T=>T){let T=(...ue)=>L.fire(y(...ue)),_=()=>S.on(v,T),R=()=>S.removeListener(v,T),L=new I({onWillAddFirstListener:_,onDidRemoveLastListener:R});return L.event}Ot.fromNodeEventEmitter=Ks;function E(S,v,y=T=>T){let T=(...ue)=>L.fire(y(...ue)),_=()=>S.addEventListener(v,T),R=()=>S.removeEventListener(v,T),L=new I({onWillAddFirstListener:_,onDidRemoveLastListener:R});return L.event}Ot.fromDOMEventEmitter=E;function k(S,v){let y,T,_=new Promise(R=>{T=n(S)(R),uo(T,v),y=()=>{Pl(T,v)}});return _.cancel=y,v&&_.finally(()=>Pl(T,v)),_}Ot.toPromise=k;function q(S,v){return S(y=>v.fire(y))}Ot.forward=q;function Ie(S,v,y){return v(y),S(T=>v(T))}Ot.runAndSubscribe=Ie;class Lt{constructor(v,y){this._observable=v;this._counter=0;this._hasChanged=!1;let T={onWillAddFirstListener:()=>{v.addObserver(this),this._observable.reportChanges()},onDidRemoveLastListener:()=>{v.removeObserver(this)}};y||e(T),this.emitter=new I(T),y&&y.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,y){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Hr(S,v){return new Lt(S,v).emitter.event}Ot.fromObservable=Hr;function pd(S){return(v,y,T)=>{let _=0,R=!1,L={beginUpdate(){_++},endUpdate(){_--,_===0&&(S.reportChanges(),R&&(R=!1,v.call(y)))},handlePossibleChange(){},handleChange(){R=!0}};S.addObserver(L),S.reportChanges();let ue={dispose(){S.removeObserver(L)}};return uo(ue,T),ue}}Ot.fromObservableLight=pd})(V||={});var so=class r{constructor(e){this.listenerCount=0;this.invocationCount=0;this.elapsedOverall=0;this.durations=[];this.name=`${e}_${r._idPool++}`,r.all.add(this)}static{this.all=new Set}static{this._idPool=0}start(e){this._stopWatch=new ai,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}}},Cl=-1;var oo=class r{constructor(e,t,n=(r._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e;this.threshold=t;this.name=n;this._warnCountdown=0}static{this._idPool=1}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)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=n*.5;let[s,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(s);let l=o/t>.3?"dominated":"popular",c=new ao(l,a,s);this._errorHandler(c)}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[n,i]of this._stacks)(!e||t<i)&&(e=[n,i],t=i);return e}},fn=class r{constructor(e){this.value=e}static create(){let e=new Error;return new r(e.stack??"")}print(){console.warn(this.value.split(`
`).slice(2).join(`
`))}},ao=class extends Error{constructor(e,t,n){super(`potential listener LEAK detected, ${e}`),this.name="ListenerLeakError",this.details=t,this.stack=n}},lo=class extends Error{constructor(e,t,n){super(`potential listener LEAK detected, ${e} (REFUSED to add)`),this.name="ListenerRefusalError",this.details=t,this.stack=n}},Wd=0,pn=class{constructor(e){this.value=e;this.id=Wd++}},Bd=2,Vd=(r,e)=>{if(r instanceof pn)e(r);else for(let t=0;t<r.length;t++){let n=r[t];n&&e(n)}},I=class{constructor(e){this._size=0;this._options=e,this._leakageMon=Cl>0||this._options?.leakWarningThreshold?new oo(e?.onListenerError??Z,this._options?.leakWarningThreshold??Cl):void 0,this._perfMon=this._options?._profName?new so(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(El){let e=this._listeners;queueMicrotask(()=>{Vd(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,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let l=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(l);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],d=c[1]/this._size>.3?"dominated":"popular",u=new lo(d,`${l}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(this._options?.onListenerError||Z)(u),A.None}if(this._disposed)return A.None;t&&(e=e.bind(t));let i=new pn(e),s,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=fn.create(),s=this._leakageMon.check(i.stack,this._size+1)),El&&(i.stack=o??fn.create()),this._listeners?this._listeners instanceof pn?(this._deliveryQueue??=new co,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 a=O(()=>{s?.(),this._removeListener(i)});return uo(a,n),a},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,n=t.indexOf(e);if(n===-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[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Bd<=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 n=this._options?.onListenerError||Z;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(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 pn)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 co=class{constructor(){this.i=-1;this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}};var li=class{constructor(){this.hasListeners=!1;this.events=[];this.emitter=new I({onWillAddFirstListener:()=>this.onFirstListenerAdd(),onDidRemoveLastListener:()=>this.onLastListenerRemove()})}get event(){return this.emitter.event}add(e){let t={event:e,listener:null};return this.events.push(t),this.hasListeners&&this.hook(t),O(an(()=>{this.hasListeners&&this.unhook(t);let i=this.events.indexOf(t);this.events.splice(i,1)}))}onFirstListenerAdd(){this.hasListeners=!0,this.events.forEach(e=>this.hook(e))}onLastListenerRemove(){this.hasListeners=!1,this.events.forEach(e=>this.unhook(e))}hook(e){e.listener=e.event(t=>this.emitter.fire(t))}unhook(e){e.listener?.dispose(),e.listener=null}dispose(){this.emitter.dispose();for(let e of this.events)e.listener?.dispose();this.events=[]}};var sr=class{constructor(){this.listening=!1;this.inputEvent=V.None;this.inputEventListener=A.None;this.emitter=new I({onDidAddFirstListener:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onDidRemoveLastListener:()=>{this.listening=!1,this.inputEventListener.dispose()}});this.event=this.emitter.event}set input(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}};function uo(r,e){e instanceof D?e.add(r):Array.isArray(e)&&e.push(r)}function Pl(r,e){if(e instanceof D)e.delete(r);else if(Array.isArray(e)){let t=e.indexOf(r);t!==-1&&e.splice(t,1)}r.dispose()}var Dl=Object.freeze(function(r,e){let t=setTimeout(r.bind(e),0);return{dispose(){clearTimeout(t)}}}),Ke;(n=>{function r(i){return i===n.None||i===n.Cancelled||i instanceof hn?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}n.isCancellationToken=r,n.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:V.None}),n.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Dl})})(Ke||={});var hn=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?Dl:(this._emitter||(this._emitter=new I),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ee=class{constructor(e){this._token=void 0;this._parentListener=void 0;this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}get token(){return this._token||(this._token=new hn),this._token}cancel(){this._token?this._token instanceof hn&&this._token.cancel():this._token=Ke.Cancelled}dispose(e=!1){e&&this.cancel(),this._parentListener?.dispose(),this._token?this._token instanceof hn&&this._token.dispose():this._token=Ke.None}};var qd=65,$d=97,Kd=90,zd=122,Bt=46,fe=47,Ae=92,ot=58,jd=63,ci=class extends Error{constructor(e,t,n){let i;typeof t=="string"&&t.indexOf("not ")===0?(i="must not be",t=t.replace(/^not /,"")):i="must be";let s=e.indexOf(".")!==-1?"property":"argument",o=`The "${e}" ${s} ${i} of type ${t}`;o+=`. Received type ${typeof n}`,super(o),this.code="ERR_INVALID_ARG_TYPE"}};function Hd(r,e){if(r===null||typeof r!="object")throw new ci(e,"Object",r)}function ne(r,e){if(typeof r!="string")throw new ci(e,"string",r)}var ke=_l==="win32";function F(r){return r===fe||r===Ae}function po(r){return r===fe}function at(r){return r>=qd&&r<=Kd||r>=$d&&r<=zd}function ui(r,e,t,n){let i="",s=0,o=-1,a=0,l=0;for(let c=0;c<=r.length;++c){if(c<r.length)l=r.charCodeAt(c);else{if(n(l))break;l=fe}if(n(l)){if(!(o===c-1||a===1))if(a===2){if(i.length<2||s!==2||i.charCodeAt(i.length-1)!==Bt||i.charCodeAt(i.length-2)!==Bt){if(i.length>2){let d=i.lastIndexOf(t);d===-1?(i="",s=0):(i=i.slice(0,d),s=i.length-1-i.lastIndexOf(t)),o=c,a=0;continue}else if(i.length!==0){i="",s=0,o=c,a=0;continue}}e&&(i+=i.length>0?`${t}..`:"..",s=2)}else i.length>0?i+=`${t}${r.slice(o+1,c)}`:i=r.slice(o+1,c),s=c-o-1;o=c,a=0}else l===Bt&&a!==-1?++a:a=-1}return i}function Gd(r){return r?`${r[0]==="."?"":"."}${r}`:""}function Al(r,e){Hd(e,"pathObject");let t=e.dir||e.root,n=e.base||`${e.name||""}${Gd(e.ext)}`;return t?t===e.root?`${t}${n}`:`${t}${r}${n}`:n}var re={resolve(...r){let e="",t="",n=!1;for(let i=r.length-1;i>=-1;i--){let s;if(i>=0){if(s=r[i],ne(s,`paths[${i}]`),s.length===0)continue}else e.length===0?s=dn():(s=pe[`=${e}`]||dn(),(s===void 0||s.slice(0,2).toLowerCase()!==e.toLowerCase()&&s.charCodeAt(2)===Ae)&&(s=`${e}\\`));let o=s.length,a=0,l="",c=!1,d=s.charCodeAt(0);if(o===1)F(d)&&(a=1,c=!0);else if(F(d))if(c=!0,F(s.charCodeAt(1))){let u=2,p=u;for(;u<o&&!F(s.charCodeAt(u));)u++;if(u<o&&u!==p){let h=s.slice(p,u);for(p=u;u<o&&F(s.charCodeAt(u));)u++;if(u<o&&u!==p){for(p=u;u<o&&!F(s.charCodeAt(u));)u++;(u===o||u!==p)&&(l=`\\\\${h}\\${s.slice(p,u)}`,a=u)}}}else a=1;else at(d)&&s.charCodeAt(1)===ot&&(l=s.slice(0,2),a=2,o>2&&F(s.charCodeAt(2))&&(c=!0,a=3));if(l.length>0)if(e.length>0){if(l.toLowerCase()!==e.toLowerCase())continue}else e=l;if(n){if(e.length>0)break}else if(t=`${s.slice(a)}\\${t}`,n=c,c&&e.length>0)break}return t=ui(t,!n,"\\",F),n?`${e}\\${t}`:`${e}${t}`||"."},normalize(r){ne(r,"path");let e=r.length;if(e===0)return".";let t=0,n,i=!1,s=r.charCodeAt(0);if(e===1)return po(s)?"\\":r;if(F(s))if(i=!0,F(r.charCodeAt(1))){let a=2,l=a;for(;a<e&&!F(r.charCodeAt(a));)a++;if(a<e&&a!==l){let c=r.slice(l,a);for(l=a;a<e&&F(r.charCodeAt(a));)a++;if(a<e&&a!==l){for(l=a;a<e&&!F(r.charCodeAt(a));)a++;if(a===e)return`\\\\${c}\\${r.slice(l)}\\`;a!==l&&(n=`\\\\${c}\\${r.slice(l,a)}`,t=a)}}}else t=1;else at(s)&&r.charCodeAt(1)===ot&&(n=r.slice(0,2),t=2,e>2&&F(r.charCodeAt(2))&&(i=!0,t=3));let o=t<e?ui(r.slice(t),!i,"\\",F):"";if(o.length===0&&!i&&(o="."),o.length>0&&F(r.charCodeAt(e-1))&&(o+="\\"),!i&&n===void 0&&r.includes(":")){if(o.length>=2&&at(o.charCodeAt(0))&&o.charCodeAt(1)===ot)return`.\\${o}`;let a=r.indexOf(":");do if(a===e-1||F(r.charCodeAt(a+1)))return`.\\${o}`;while((a=r.indexOf(":",a+1))!==-1)}return n===void 0?i?`\\${o}`:o:i?`${n}\\${o}`:`${n}${o}`},isAbsolute(r){ne(r,"path");let e=r.length;if(e===0)return!1;let t=r.charCodeAt(0);return F(t)||e>2&&at(t)&&r.charCodeAt(1)===ot&&F(r.charCodeAt(2))},join(...r){if(r.length===0)return".";let e,t;for(let s=0;s<r.length;++s){let o=r[s];ne(o,"path"),o.length>0&&(e===void 0?e=t=o:e+=`\\${o}`)}if(e===void 0)return".";let n=!0,i=0;if(typeof t=="string"&&F(t.charCodeAt(0))){++i;let s=t.length;s>1&&F(t.charCodeAt(1))&&(++i,s>2&&(F(t.charCodeAt(2))?++i:n=!1))}if(n){for(;i<e.length&&F(e.charCodeAt(i));)i++;i>=2&&(e=`\\${e.slice(i)}`)}return re.normalize(e)},relative(r,e){if(ne(r,"from"),ne(e,"to"),r===e)return"";let t=re.resolve(r),n=re.resolve(e);if(t===n||(r=t.toLowerCase(),e=n.toLowerCase(),r===e))return"";if(t.length!==r.length||n.length!==e.length){let g=t.split("\\"),b=n.split("\\");g[g.length-1]===""&&g.pop(),b[b.length-1]===""&&b.pop();let W=g.length,j=b.length,Pe=W<j?W:j,me;for(me=0;me<Pe&&g[me].toLowerCase()===b[me].toLowerCase();me++);return me===0?n:me===Pe?j>Pe?b.slice(me).join("\\"):W>Pe?"..\\".repeat(W-1-me)+"..":"":"..\\".repeat(W-me)+b.slice(me).join("\\")}let i=0;for(;i<r.length&&r.charCodeAt(i)===Ae;)i++;let s=r.length;for(;s-1>i&&r.charCodeAt(s-1)===Ae;)s--;let o=s-i,a=0;for(;a<e.length&&e.charCodeAt(a)===Ae;)a++;let l=e.length;for(;l-1>a&&e.charCodeAt(l-1)===Ae;)l--;let c=l-a,d=o<c?o:c,u=-1,p=0;for(;p<d;p++){let g=r.charCodeAt(i+p);if(g!==e.charCodeAt(a+p))break;g===Ae&&(u=p)}if(p!==d){if(u===-1)return n}else{if(c>d){if(e.charCodeAt(a+p)===Ae)return n.slice(a+p+1);if(p===2)return n.slice(a+p)}o>d&&(r.charCodeAt(i+p)===Ae?u=p:p===2&&(u=3)),u===-1&&(u=0)}let h="";for(p=i+u+1;p<=s;++p)(p===s||r.charCodeAt(p)===Ae)&&(h+=h.length===0?"..":"\\..");return a+=u,h.length>0?`${h}${n.slice(a,l)}`:(n.charCodeAt(a)===Ae&&++a,n.slice(a,l))},toNamespacedPath(r){if(typeof r!="string"||r.length===0)return r;let e=re.resolve(r);if(e.length<=2)return r;if(e.charCodeAt(0)===Ae){if(e.charCodeAt(1)===Ae){let t=e.charCodeAt(2);if(t!==jd&&t!==Bt)return`\\\\?\\UNC\\${e.slice(2)}`}}else if(at(e.charCodeAt(0))&&e.charCodeAt(1)===ot&&e.charCodeAt(2)===Ae)return`\\\\?\\${e}`;return e},dirname(r){ne(r,"path");let e=r.length;if(e===0)return".";let t=-1,n=0,i=r.charCodeAt(0);if(e===1)return F(i)?r:".";if(F(i)){if(t=n=1,F(r.charCodeAt(1))){let a=2,l=a;for(;a<e&&!F(r.charCodeAt(a));)a++;if(a<e&&a!==l){for(l=a;a<e&&F(r.charCodeAt(a));)a++;if(a<e&&a!==l){for(l=a;a<e&&!F(r.charCodeAt(a));)a++;if(a===e)return r;a!==l&&(t=n=a+1)}}}}else at(i)&&r.charCodeAt(1)===ot&&(t=e>2&&F(r.charCodeAt(2))?3:2,n=t);let s=-1,o=!0;for(let a=e-1;a>=n;--a)if(F(r.charCodeAt(a))){if(!o){s=a;break}}else o=!1;if(s===-1){if(t===-1)return".";s=t}return r.slice(0,s)},basename(r,e){e!==void 0&&ne(e,"suffix"),ne(r,"path");let t=0,n=-1,i=!0,s;if(r.length>=2&&at(r.charCodeAt(0))&&r.charCodeAt(1)===ot&&(t=2),e!==void 0&&e.length>0&&e.length<=r.length){if(e===r)return"";let o=e.length-1,a=-1;for(s=r.length-1;s>=t;--s){let l=r.charCodeAt(s);if(F(l)){if(!i){t=s+1;break}}else a===-1&&(i=!1,a=s+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(n=s):(o=-1,n=a))}return t===n?n=a:n===-1&&(n=r.length),r.slice(t,n)}for(s=r.length-1;s>=t;--s)if(F(r.charCodeAt(s))){if(!i){t=s+1;break}}else n===-1&&(i=!1,n=s+1);return n===-1?"":r.slice(t,n)},extname(r){ne(r,"path");let e=0,t=-1,n=0,i=-1,s=!0,o=0;r.length>=2&&r.charCodeAt(1)===ot&&at(r.charCodeAt(0))&&(e=n=2);for(let a=r.length-1;a>=e;--a){let l=r.charCodeAt(a);if(F(l)){if(!s){n=a+1;break}continue}i===-1&&(s=!1,i=a+1),l===Bt?t===-1?t=a:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===n+1?"":r.slice(t,i)},format:Al.bind(null,"\\"),parse(r){ne(r,"path");let e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;let t=r.length,n=0,i=r.charCodeAt(0);if(t===1)return F(i)?(e.root=e.dir=r,e):(e.base=e.name=r,e);if(F(i)){if(n=1,F(r.charCodeAt(1))){let u=2,p=u;for(;u<t&&!F(r.charCodeAt(u));)u++;if(u<t&&u!==p){for(p=u;u<t&&F(r.charCodeAt(u));)u++;if(u<t&&u!==p){for(p=u;u<t&&!F(r.charCodeAt(u));)u++;u===t?n=u:u!==p&&(n=u+1)}}}}else if(at(i)&&r.charCodeAt(1)===ot){if(t<=2)return e.root=e.dir=r,e;if(n=2,F(r.charCodeAt(2))){if(t===3)return e.root=e.dir=r,e;n=3}}n>0&&(e.root=r.slice(0,n));let s=-1,o=n,a=-1,l=!0,c=r.length-1,d=0;for(;c>=n;--c){if(i=r.charCodeAt(c),F(i)){if(!l){o=c+1;break}continue}a===-1&&(l=!1,a=c+1),i===Bt?s===-1?s=c:d!==1&&(d=1):s!==-1&&(d=-1)}return a!==-1&&(s===-1||d===0||d===1&&s===a-1&&s===o+1?e.base=e.name=r.slice(o,a):(e.name=r.slice(o,s),e.base=r.slice(o,a),e.ext=r.slice(s,a))),o>0&&o!==n?e.dir=r.slice(0,o-1):e.dir=e.root,e},sep:"\\",delimiter:";",win32:null,posix:null},Qd=(()=>{if(ke){let r=/\\/g;return()=>{let e=dn().replace(r,"/");return e.slice(e.indexOf("/"))}}return()=>dn()})(),U={resolve(...r){let e="",t=!1;for(let n=r.length-1;n>=0&&!t;n--){let i=r[n];ne(i,`paths[${n}]`),i.length!==0&&(e=`${i}/${e}`,t=i.charCodeAt(0)===fe)}if(!t){let n=Qd();e=`${n}/${e}`,t=n.charCodeAt(0)===fe}return e=ui(e,!t,"/",po),t?`/${e}`:e.length>0?e:"."},normalize(r){if(ne(r,"path"),r.length===0)return".";let e=r.charCodeAt(0)===fe,t=r.charCodeAt(r.length-1)===fe;return r=ui(r,!e,"/",po),r.length===0?e?"/":t?"./":".":(t&&(r+="/"),e?`/${r}`:r)},isAbsolute(r){return ne(r,"path"),r.length>0&&r.charCodeAt(0)===fe},join(...r){if(r.length===0)return".";let e=[];for(let t=0;t<r.length;++t){let n=r[t];ne(n,"path"),n.length>0&&e.push(n)}return e.length===0?".":U.normalize(e.join("/"))},relative(r,e){if(ne(r,"from"),ne(e,"to"),r===e||(r=U.resolve(r),e=U.resolve(e),r===e))return"";let t=1,n=r.length,i=n-t,s=1,o=e.length-s,a=i<o?i:o,l=-1,c=0;for(;c<a;c++){let u=r.charCodeAt(t+c);if(u!==e.charCodeAt(s+c))break;u===fe&&(l=c)}if(c===a)if(o>a){if(e.charCodeAt(s+c)===fe)return e.slice(s+c+1);if(c===0)return e.slice(s+c)}else i>a&&(r.charCodeAt(t+c)===fe?l=c:c===0&&(l=0));let d="";for(c=t+l+1;c<=n;++c)(c===n||r.charCodeAt(c)===fe)&&(d+=d.length===0?"..":"/..");return`${d}${e.slice(s+l)}`},toNamespacedPath(r){return r},dirname(r){if(ne(r,"path"),r.length===0)return".";let e=r.charCodeAt(0)===fe,t=-1,n=!0;for(let i=r.length-1;i>=1;--i)if(r.charCodeAt(i)===fe){if(!n){t=i;break}}else n=!1;return t===-1?e?"/":".":e&&t===1?"//":r.slice(0,t)},basename(r,e){e!==void 0&&ne(e,"suffix"),ne(r,"path");let t=0,n=-1,i=!0,s;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e===r)return"";let o=e.length-1,a=-1;for(s=r.length-1;s>=0;--s){let l=r.charCodeAt(s);if(l===fe){if(!i){t=s+1;break}}else a===-1&&(i=!1,a=s+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(n=s):(o=-1,n=a))}return t===n?n=a:n===-1&&(n=r.length),r.slice(t,n)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===fe){if(!i){t=s+1;break}}else n===-1&&(i=!1,n=s+1);return n===-1?"":r.slice(t,n)},extname(r){ne(r,"path");let e=-1,t=0,n=-1,i=!0,s=0;for(let o=r.length-1;o>=0;--o){let a=r[o];if(a==="/"){if(!i){t=o+1;break}continue}n===-1&&(i=!1,n=o+1),a==="."?e===-1?e=o:s!==1&&(s=1):e!==-1&&(s=-1)}return e===-1||n===-1||s===0||s===1&&e===n-1&&e===t+1?"":r.slice(e,n)},format:Al.bind(null,"/"),parse(r){ne(r,"path");let e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;let t=r.charCodeAt(0)===fe,n;t?(e.root="/",n=1):n=0;let i=-1,s=0,o=-1,a=!0,l=r.length-1,c=0;for(;l>=n;--l){let d=r.charCodeAt(l);if(d===fe){if(!a){s=l+1;break}continue}o===-1&&(a=!1,o=l+1),d===Bt?i===-1?i=l:c!==1&&(c=1):i!==-1&&(c=-1)}if(o!==-1){let d=s===0&&t?1:s;i===-1||c===0||c===1&&i===o-1&&i===s+1?e.base=e.name=r.slice(d,o):(e.name=r.slice(d,i),e.base=r.slice(d,o),e.ext=r.slice(i,o))}return s>0?e.dir=r.slice(0,s-1):t&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};U.win32=re.win32=re;U.posix=re.posix=U;var Me=ke?re.normalize:U.normalize,di=ke?re.isAbsolute:U.isAbsolute,J=ke?re.join:U.join,Vt=ke?re.resolve:U.resolve,kl=ke?re.relative:U.relative,be=ke?re.dirname:U.dirname,We=ke?re.basename:U.basename,Ll=ke?re.extname:U.extname,Wg=ke?re.format:U.format,Bg=ke?re.parse:U.parse,Vg=ke?re.toNamespacedPath:U.toNamespacedPath,ie=ke?re.sep:U.sep,fo=ke?re.delimiter:U.delimiter;function Jd(r){return r}var fi=class{constructor(e,t){this.lastCache=void 0;this.lastArgKey=void 0;typeof e=="function"?(this._fn=e,this._computeKey=Jd):(this._fn=t,this._computeKey=e.getCacheKey)}get(e){let t=this._computeKey(e);return this.lastArgKey!==t&&(this.lastArgKey=t,this.lastCache=this._fn(e)),this.lastCache}};var Ce=class{constructor(e){this.executor=e;this._state=0}get hasValue(){return this._state===2}get value(){if(this._state===0){this._state=1;try{this._value=this.executor()}catch(e){this._error=e}finally{this._state=2}}else if(this._state===1)throw new Error("Cannot read the value of a lazy that is being initialized");if(this._error)throw this._error;return this._value}get rawValue(){return this._value}};function Ml(r){return!r||typeof r!="string"?!0:r.trim().length===0}function ho(r){return r.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g,"\\$&")}function Wl(r,e){if(!r||!e)return r;let t=e.length,n=0;if(t===1){let i=e.charCodeAt(0);for(;n<r.length&&r.charCodeAt(n)===i;)n++}else for(;r.startsWith(e,n);)n+=t;return r.substring(n)}function or(r,e){if(!r||!e)return r;let t=e.length,n=r.length;if(t===1){let s=n,o=e.charCodeAt(0);for(;s>0&&r.charCodeAt(s-1)===o;)s--;return r.substring(0,s)}let i=n;for(;i>0&&r.endsWith(e,i);)i-=t;return r.substring(0,i)}function ar(r,e){return r<e?-1:r>e?1:0}function hi(r,e,t=0,n=r.length,i=0,s=e.length){for(;t<n&&i<s;t++,i++){let l=r.charCodeAt(t),c=e.charCodeAt(i);if(l<c)return-1;if(l>c)return 1}let o=n-t,a=s-i;return o<a?-1:o>a?1:0}function go(r,e){return $t(r,e,0,r.length,0,e.length)}function $t(r,e,t=0,n=r.length,i=0,s=e.length){for(;t<n&&i<s;t++,i++){let l=r.charCodeAt(t),c=e.charCodeAt(i);if(l===c)continue;if(l>=128||c>=128)return hi(r.toLowerCase(),e.toLowerCase(),t,n,i,s);Ol(l)&&(l-=32),Ol(c)&&(c-=32);let d=l-c;if(d!==0)return d}let o=n-t,a=s-i;return o<a?-1:o>a?1:0}function Ol(r){return r>=97&&r<=122}function mo(r){return r>=65&&r<=90}function Kt(r,e){return r.length===e.length&&$t(r,e)===0}function lr(r,e){let t=e.length;return t<=r.length&&$t(r,e,0,t)===0}function Bl(r,e){let t=r.length,n=t-e.length;return n>=0&&$t(r,e,n,t)===0}function Vl(r){return 55296<=r&&r<=56319}function vo(r){return 56320<=r&&r<=57343}function ql(r,e){return(r-55296<<10)+(e-56320)+65536}var Yd=/(?:\x1b\[|\x9b)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~]/,Xd=/(?:\x1b\]|\x9d).*?(?:\x1b\\|\x07|\x9c)/,Zd=/\x1b(?:[ #%\(\)\*\+\-\.\/]?[a-zA-Z0-9\|}~@])/,Xg=new RegExp("(?:"+[Yd.source,Xd.source,Zd.source].join("|")+")","g");var Zg=String.fromCharCode(65279);var Fl=class r{static{this._INSTANCE=null}static getInstance(){return r._INSTANCE||(r._INSTANCE=new r),r._INSTANCE}constructor(){this._data=ep()}getGraphemeBreakType(e){if(e<32)return e===10?3:e===13?2:4;if(e<127)return 0;let t=this._data,n=t.length/3,i=1;for(;i<=n;)if(e<t[3*i])i=2*i;else if(e>t[3*i+1])i=2*i+1;else return t[3*i+2];return 0}};function ep(){return JSON.parse("[0,0,0,51229,51255,12,44061,44087,12,127462,127487,6,7083,7085,5,47645,47671,12,54813,54839,12,128678,128678,14,3270,3270,5,9919,9923,14,45853,45879,12,49437,49463,12,53021,53047,12,71216,71218,7,128398,128399,14,129360,129374,14,2519,2519,5,4448,4519,9,9742,9742,14,12336,12336,14,44957,44983,12,46749,46775,12,48541,48567,12,50333,50359,12,52125,52151,12,53917,53943,12,69888,69890,5,73018,73018,5,127990,127990,14,128558,128559,14,128759,128760,14,129653,129655,14,2027,2035,5,2891,2892,7,3761,3761,5,6683,6683,5,8293,8293,4,9825,9826,14,9999,9999,14,43452,43453,5,44509,44535,12,45405,45431,12,46301,46327,12,47197,47223,12,48093,48119,12,48989,49015,12,49885,49911,12,50781,50807,12,51677,51703,12,52573,52599,12,53469,53495,12,54365,54391,12,65279,65279,4,70471,70472,7,72145,72147,7,119173,119179,5,127799,127818,14,128240,128244,14,128512,128512,14,128652,128652,14,128721,128722,14,129292,129292,14,129445,129450,14,129734,129743,14,1476,1477,5,2366,2368,7,2750,2752,7,3076,3076,5,3415,3415,5,4141,4144,5,6109,6109,5,6964,6964,5,7394,7400,5,9197,9198,14,9770,9770,14,9877,9877,14,9968,9969,14,10084,10084,14,43052,43052,5,43713,43713,5,44285,44311,12,44733,44759,12,45181,45207,12,45629,45655,12,46077,46103,12,46525,46551,12,46973,46999,12,47421,47447,12,47869,47895,12,48317,48343,12,48765,48791,12,49213,49239,12,49661,49687,12,50109,50135,12,50557,50583,12,51005,51031,12,51453,51479,12,51901,51927,12,52349,52375,12,52797,52823,12,53245,53271,12,53693,53719,12,54141,54167,12,54589,54615,12,55037,55063,12,69506,69509,5,70191,70193,5,70841,70841,7,71463,71467,5,72330,72342,5,94031,94031,5,123628,123631,5,127763,127765,14,127941,127941,14,128043,128062,14,128302,128317,14,128465,128467,14,128539,128539,14,128640,128640,14,128662,128662,14,128703,128703,14,128745,128745,14,129004,129007,14,129329,129330,14,129402,129402,14,129483,129483,14,129686,129704,14,130048,131069,14,173,173,4,1757,1757,1,2200,2207,5,2434,2435,7,2631,2632,5,2817,2817,5,3008,3008,5,3201,3201,5,3387,3388,5,3542,3542,5,3902,3903,7,4190,4192,5,6002,6003,5,6439,6440,5,6765,6770,7,7019,7027,5,7154,7155,7,8205,8205,13,8505,8505,14,9654,9654,14,9757,9757,14,9792,9792,14,9852,9853,14,9890,9894,14,9937,9937,14,9981,9981,14,10035,10036,14,11035,11036,14,42654,42655,5,43346,43347,7,43587,43587,5,44006,44007,7,44173,44199,12,44397,44423,12,44621,44647,12,44845,44871,12,45069,45095,12,45293,45319,12,45517,45543,12,45741,45767,12,45965,45991,12,46189,46215,12,46413,46439,12,46637,46663,12,46861,46887,12,47085,47111,12,47309,47335,12,47533,47559,12,47757,47783,12,47981,48007,12,48205,48231,12,48429,48455,12,48653,48679,12,48877,48903,12,49101,49127,12,49325,49351,12,49549,49575,12,49773,49799,12,49997,50023,12,50221,50247,12,50445,50471,12,50669,50695,12,50893,50919,12,51117,51143,12,51341,51367,12,51565,51591,12,51789,51815,12,52013,52039,12,52237,52263,12,52461,52487,12,52685,52711,12,52909,52935,12,53133,53159,12,53357,53383,12,53581,53607,12,53805,53831,12,54029,54055,12,54253,54279,12,54477,54503,12,54701,54727,12,54925,54951,12,55149,55175,12,68101,68102,5,69762,69762,7,70067,70069,7,70371,70378,5,70720,70721,7,71087,71087,5,71341,71341,5,71995,71996,5,72249,72249,7,72850,72871,5,73109,73109,5,118576,118598,5,121505,121519,5,127245,127247,14,127568,127569,14,127777,127777,14,127872,127891,14,127956,127967,14,128015,128016,14,128110,128172,14,128259,128259,14,128367,128368,14,128424,128424,14,128488,128488,14,128530,128532,14,128550,128551,14,128566,128566,14,128647,128647,14,128656,128656,14,128667,128673,14,128691,128693,14,128715,128715,14,128728,128732,14,128752,128752,14,128765,128767,14,129096,129103,14,129311,129311,14,129344,129349,14,129394,129394,14,129413,129425,14,129466,129471,14,129511,129535,14,129664,129666,14,129719,129722,14,129760,129767,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2307,2307,7,2382,2383,7,2497,2500,5,2563,2563,7,2677,2677,5,2763,2764,7,2879,2879,5,2914,2915,5,3021,3021,5,3142,3144,5,3263,3263,5,3285,3286,5,3398,3400,7,3530,3530,5,3633,3633,5,3864,3865,5,3974,3975,5,4155,4156,7,4229,4230,5,5909,5909,7,6078,6085,7,6277,6278,5,6451,6456,7,6744,6750,5,6846,6846,5,6972,6972,5,7074,7077,5,7146,7148,7,7222,7223,5,7416,7417,5,8234,8238,4,8417,8417,5,9000,9000,14,9203,9203,14,9730,9731,14,9748,9749,14,9762,9763,14,9776,9783,14,9800,9811,14,9831,9831,14,9872,9873,14,9882,9882,14,9900,9903,14,9929,9933,14,9941,9960,14,9974,9974,14,9989,9989,14,10006,10006,14,10062,10062,14,10160,10160,14,11647,11647,5,12953,12953,14,43019,43019,5,43232,43249,5,43443,43443,5,43567,43568,7,43696,43696,5,43765,43765,7,44013,44013,5,44117,44143,12,44229,44255,12,44341,44367,12,44453,44479,12,44565,44591,12,44677,44703,12,44789,44815,12,44901,44927,12,45013,45039,12,45125,45151,12,45237,45263,12,45349,45375,12,45461,45487,12,45573,45599,12,45685,45711,12,45797,45823,12,45909,45935,12,46021,46047,12,46133,46159,12,46245,46271,12,46357,46383,12,46469,46495,12,46581,46607,12,46693,46719,12,46805,46831,12,46917,46943,12,47029,47055,12,47141,47167,12,47253,47279,12,47365,47391,12,47477,47503,12,47589,47615,12,47701,47727,12,47813,47839,12,47925,47951,12,48037,48063,12,48149,48175,12,48261,48287,12,48373,48399,12,48485,48511,12,48597,48623,12,48709,48735,12,48821,48847,12,48933,48959,12,49045,49071,12,49157,49183,12,49269,49295,12,49381,49407,12,49493,49519,12,49605,49631,12,49717,49743,12,49829,49855,12,49941,49967,12,50053,50079,12,50165,50191,12,50277,50303,12,50389,50415,12,50501,50527,12,50613,50639,12,50725,50751,12,50837,50863,12,50949,50975,12,51061,51087,12,51173,51199,12,51285,51311,12,51397,51423,12,51509,51535,12,51621,51647,12,51733,51759,12,51845,51871,12,51957,51983,12,52069,52095,12,52181,52207,12,52293,52319,12,52405,52431,12,52517,52543,12,52629,52655,12,52741,52767,12,52853,52879,12,52965,52991,12,53077,53103,12,53189,53215,12,53301,53327,12,53413,53439,12,53525,53551,12,53637,53663,12,53749,53775,12,53861,53887,12,53973,53999,12,54085,54111,12,54197,54223,12,54309,54335,12,54421,54447,12,54533,54559,12,54645,54671,12,54757,54783,12,54869,54895,12,54981,55007,12,55093,55119,12,55243,55291,10,66045,66045,5,68325,68326,5,69688,69702,5,69817,69818,5,69957,69958,7,70089,70092,5,70198,70199,5,70462,70462,5,70502,70508,5,70750,70750,5,70846,70846,7,71100,71101,5,71230,71230,7,71351,71351,5,71737,71738,5,72000,72000,7,72160,72160,5,72273,72278,5,72752,72758,5,72882,72883,5,73031,73031,5,73461,73462,7,94192,94193,7,119149,119149,7,121403,121452,5,122915,122916,5,126980,126980,14,127358,127359,14,127535,127535,14,127759,127759,14,127771,127771,14,127792,127793,14,127825,127867,14,127897,127899,14,127945,127945,14,127985,127986,14,128000,128007,14,128021,128021,14,128066,128100,14,128184,128235,14,128249,128252,14,128266,128276,14,128335,128335,14,128379,128390,14,128407,128419,14,128444,128444,14,128481,128481,14,128499,128499,14,128526,128526,14,128536,128536,14,128543,128543,14,128556,128556,14,128564,128564,14,128577,128580,14,128643,128645,14,128649,128649,14,128654,128654,14,128660,128660,14,128664,128664,14,128675,128675,14,128686,128689,14,128695,128696,14,128705,128709,14,128717,128719,14,128725,128725,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129009,129023,14,129160,129167,14,129296,129304,14,129320,129327,14,129340,129342,14,129356,129356,14,129388,129392,14,129399,129400,14,129404,129407,14,129432,129442,14,129454,129455,14,129473,129474,14,129485,129487,14,129648,129651,14,129659,129660,14,129671,129679,14,129709,129711,14,129728,129730,14,129751,129753,14,129776,129782,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2274,2274,1,2363,2363,7,2377,2380,7,2402,2403,5,2494,2494,5,2507,2508,7,2558,2558,5,2622,2624,7,2641,2641,5,2691,2691,7,2759,2760,5,2786,2787,5,2876,2876,5,2881,2884,5,2901,2902,5,3006,3006,5,3014,3016,7,3072,3072,5,3134,3136,5,3157,3158,5,3260,3260,5,3266,3266,5,3274,3275,7,3328,3329,5,3391,3392,7,3405,3405,5,3457,3457,5,3536,3537,7,3551,3551,5,3636,3642,5,3764,3772,5,3895,3895,5,3967,3967,7,3993,4028,5,4146,4151,5,4182,4183,7,4226,4226,5,4253,4253,5,4957,4959,5,5940,5940,7,6070,6070,7,6087,6088,7,6158,6158,4,6432,6434,5,6448,6449,7,6679,6680,5,6742,6742,5,6754,6754,5,6783,6783,5,6912,6915,5,6966,6970,5,6978,6978,5,7042,7042,7,7080,7081,5,7143,7143,7,7150,7150,7,7212,7219,5,7380,7392,5,7412,7412,5,8203,8203,4,8232,8232,4,8265,8265,14,8400,8412,5,8421,8432,5,8617,8618,14,9167,9167,14,9200,9200,14,9410,9410,14,9723,9726,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9774,14,9786,9786,14,9794,9794,14,9823,9823,14,9828,9828,14,9833,9850,14,9855,9855,14,9875,9875,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9935,9935,14,9939,9939,14,9962,9962,14,9972,9972,14,9978,9978,14,9986,9986,14,9997,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10133,10135,14,10548,10549,14,11093,11093,14,12330,12333,5,12441,12442,5,42608,42610,5,43010,43010,5,43045,43046,5,43188,43203,7,43302,43309,5,43392,43394,5,43446,43449,5,43493,43493,5,43571,43572,7,43597,43597,7,43703,43704,5,43756,43757,5,44003,44004,7,44009,44010,7,44033,44059,12,44089,44115,12,44145,44171,12,44201,44227,12,44257,44283,12,44313,44339,12,44369,44395,12,44425,44451,12,44481,44507,12,44537,44563,12,44593,44619,12,44649,44675,12,44705,44731,12,44761,44787,12,44817,44843,12,44873,44899,12,44929,44955,12,44985,45011,12,45041,45067,12,45097,45123,12,45153,45179,12,45209,45235,12,45265,45291,12,45321,45347,12,45377,45403,12,45433,45459,12,45489,45515,12,45545,45571,12,45601,45627,12,45657,45683,12,45713,45739,12,45769,45795,12,45825,45851,12,45881,45907,12,45937,45963,12,45993,46019,12,46049,46075,12,46105,46131,12,46161,46187,12,46217,46243,12,46273,46299,12,46329,46355,12,46385,46411,12,46441,46467,12,46497,46523,12,46553,46579,12,46609,46635,12,46665,46691,12,46721,46747,12,46777,46803,12,46833,46859,12,46889,46915,12,46945,46971,12,47001,47027,12,47057,47083,12,47113,47139,12,47169,47195,12,47225,47251,12,47281,47307,12,47337,47363,12,47393,47419,12,47449,47475,12,47505,47531,12,47561,47587,12,47617,47643,12,47673,47699,12,47729,47755,12,47785,47811,12,47841,47867,12,47897,47923,12,47953,47979,12,48009,48035,12,48065,48091,12,48121,48147,12,48177,48203,12,48233,48259,12,48289,48315,12,48345,48371,12,48401,48427,12,48457,48483,12,48513,48539,12,48569,48595,12,48625,48651,12,48681,48707,12,48737,48763,12,48793,48819,12,48849,48875,12,48905,48931,12,48961,48987,12,49017,49043,12,49073,49099,12,49129,49155,12,49185,49211,12,49241,49267,12,49297,49323,12,49353,49379,12,49409,49435,12,49465,49491,12,49521,49547,12,49577,49603,12,49633,49659,12,49689,49715,12,49745,49771,12,49801,49827,12,49857,49883,12,49913,49939,12,49969,49995,12,50025,50051,12,50081,50107,12,50137,50163,12,50193,50219,12,50249,50275,12,50305,50331,12,50361,50387,12,50417,50443,12,50473,50499,12,50529,50555,12,50585,50611,12,50641,50667,12,50697,50723,12,50753,50779,12,50809,50835,12,50865,50891,12,50921,50947,12,50977,51003,12,51033,51059,12,51089,51115,12,51145,51171,12,51201,51227,12,51257,51283,12,51313,51339,12,51369,51395,12,51425,51451,12,51481,51507,12,51537,51563,12,51593,51619,12,51649,51675,12,51705,51731,12,51761,51787,12,51817,51843,12,51873,51899,12,51929,51955,12,51985,52011,12,52041,52067,12,52097,52123,12,52153,52179,12,52209,52235,12,52265,52291,12,52321,52347,12,52377,52403,12,52433,52459,12,52489,52515,12,52545,52571,12,52601,52627,12,52657,52683,12,52713,52739,12,52769,52795,12,52825,52851,12,52881,52907,12,52937,52963,12,52993,53019,12,53049,53075,12,53105,53131,12,53161,53187,12,53217,53243,12,53273,53299,12,53329,53355,12,53385,53411,12,53441,53467,12,53497,53523,12,53553,53579,12,53609,53635,12,53665,53691,12,53721,53747,12,53777,53803,12,53833,53859,12,53889,53915,12,53945,53971,12,54001,54027,12,54057,54083,12,54113,54139,12,54169,54195,12,54225,54251,12,54281,54307,12,54337,54363,12,54393,54419,12,54449,54475,12,54505,54531,12,54561,54587,12,54617,54643,12,54673,54699,12,54729,54755,12,54785,54811,12,54841,54867,12,54897,54923,12,54953,54979,12,55009,55035,12,55065,55091,12,55121,55147,12,55177,55203,12,65024,65039,5,65520,65528,4,66422,66426,5,68152,68154,5,69291,69292,5,69633,69633,5,69747,69748,5,69811,69814,5,69826,69826,5,69932,69932,7,70016,70017,5,70079,70080,7,70095,70095,5,70196,70196,5,70367,70367,5,70402,70403,7,70464,70464,5,70487,70487,5,70709,70711,7,70725,70725,7,70833,70834,7,70843,70844,7,70849,70849,7,71090,71093,5,71103,71104,5,71227,71228,7,71339,71339,5,71344,71349,5,71458,71461,5,71727,71735,5,71985,71989,7,71998,71998,5,72002,72002,7,72154,72155,5,72193,72202,5,72251,72254,5,72281,72283,5,72344,72345,5,72766,72766,7,72874,72880,5,72885,72886,5,73023,73029,5,73104,73105,5,73111,73111,5,92912,92916,5,94095,94098,5,113824,113827,4,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,125252,125258,5,127183,127183,14,127340,127343,14,127377,127386,14,127491,127503,14,127548,127551,14,127744,127756,14,127761,127761,14,127769,127769,14,127773,127774,14,127780,127788,14,127796,127797,14,127820,127823,14,127869,127869,14,127894,127895,14,127902,127903,14,127943,127943,14,127947,127950,14,127972,127972,14,127988,127988,14,127992,127994,14,128009,128011,14,128019,128019,14,128023,128041,14,128064,128064,14,128102,128107,14,128174,128181,14,128238,128238,14,128246,128247,14,128254,128254,14,128264,128264,14,128278,128299,14,128329,128330,14,128348,128359,14,128371,128377,14,128392,128393,14,128401,128404,14,128421,128421,14,128433,128434,14,128450,128452,14,128476,128478,14,128483,128483,14,128495,128495,14,128506,128506,14,128519,128520,14,128528,128528,14,128534,128534,14,128538,128538,14,128540,128542,14,128544,128549,14,128552,128555,14,128557,128557,14,128560,128563,14,128565,128565,14,128567,128576,14,128581,128591,14,128641,128642,14,128646,128646,14,128648,128648,14,128650,128651,14,128653,128653,14,128655,128655,14,128657,128659,14,128661,128661,14,128663,128663,14,128665,128666,14,128674,128674,14,128676,128677,14,128679,128685,14,128690,128690,14,128694,128694,14,128697,128702,14,128704,128704,14,128710,128714,14,128716,128716,14,128720,128720,14,128723,128724,14,128726,128727,14,128733,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129008,129008,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129661,129663,14,129667,129670,14,129680,129685,14,129705,129708,14,129712,129718,14,129723,129727,14,129731,129733,14,129744,129750,14,129754,129759,14,129768,129775,14,129783,129791,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2192,2193,1,2250,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3132,3132,5,3137,3140,7,3146,3149,5,3170,3171,5,3202,3203,7,3262,3262,7,3264,3265,7,3267,3268,7,3271,3272,7,3276,3277,5,3298,3299,5,3330,3331,7,3390,3390,5,3393,3396,5,3402,3404,7,3406,3406,1,3426,3427,5,3458,3459,7,3535,3535,5,3538,3540,5,3544,3550,7,3570,3571,7,3635,3635,7,3655,3662,5,3763,3763,7,3784,3789,5,3893,3893,5,3897,3897,5,3953,3966,5,3968,3972,5,3981,3991,5,4038,4038,5,4145,4145,7,4153,4154,5,4157,4158,5,4184,4185,5,4209,4212,5,4228,4228,7,4237,4237,5,4352,4447,8,4520,4607,10,5906,5908,5,5938,5939,5,5970,5971,5,6068,6069,5,6071,6077,5,6086,6086,5,6089,6099,5,6155,6157,5,6159,6159,5,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6862,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7679,5,8204,8204,5,8206,8207,4,8233,8233,4,8252,8252,14,8288,8292,4,8294,8303,4,8413,8416,5,8418,8420,5,8482,8482,14,8596,8601,14,8986,8987,14,9096,9096,14,9193,9196,14,9199,9199,14,9201,9202,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9729,14,9732,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9775,9775,14,9784,9785,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9874,14,9876,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9934,14,9936,9936,14,9938,9938,14,9940,9940,14,9961,9961,14,9963,9967,14,9970,9971,14,9973,9973,14,9975,9977,14,9979,9980,14,9982,9985,14,9987,9988,14,9992,9996,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10083,14,10085,10087,14,10145,10145,14,10175,10175,14,11013,11015,14,11088,11088,14,11503,11505,5,11744,11775,5,12334,12335,5,12349,12349,14,12951,12951,14,42607,42607,5,42612,42621,5,42736,42737,5,43014,43014,5,43043,43044,7,43047,43047,7,43136,43137,7,43204,43205,5,43263,43263,5,43335,43345,5,43360,43388,8,43395,43395,7,43444,43445,7,43450,43451,7,43454,43456,7,43561,43566,5,43569,43570,5,43573,43574,5,43596,43596,5,43644,43644,5,43698,43700,5,43710,43711,5,43755,43755,7,43758,43759,7,43766,43766,5,44005,44005,5,44008,44008,5,44012,44012,7,44032,44032,11,44060,44060,11,44088,44088,11,44116,44116,11,44144,44144,11,44172,44172,11,44200,44200,11,44228,44228,11,44256,44256,11,44284,44284,11,44312,44312,11,44340,44340,11,44368,44368,11,44396,44396,11,44424,44424,11,44452,44452,11,44480,44480,11,44508,44508,11,44536,44536,11,44564,44564,11,44592,44592,11,44620,44620,11,44648,44648,11,44676,44676,11,44704,44704,11,44732,44732,11,44760,44760,11,44788,44788,11,44816,44816,11,44844,44844,11,44872,44872,11,44900,44900,11,44928,44928,11,44956,44956,11,44984,44984,11,45012,45012,11,45040,45040,11,45068,45068,11,45096,45096,11,45124,45124,11,45152,45152,11,45180,45180,11,45208,45208,11,45236,45236,11,45264,45264,11,45292,45292,11,45320,45320,11,45348,45348,11,45376,45376,11,45404,45404,11,45432,45432,11,45460,45460,11,45488,45488,11,45516,45516,11,45544,45544,11,45572,45572,11,45600,45600,11,45628,45628,11,45656,45656,11,45684,45684,11,45712,45712,11,45740,45740,11,45768,45768,11,45796,45796,11,45824,45824,11,45852,45852,11,45880,45880,11,45908,45908,11,45936,45936,11,45964,45964,11,45992,45992,11,46020,46020,11,46048,46048,11,46076,46076,11,46104,46104,11,46132,46132,11,46160,46160,11,46188,46188,11,46216,46216,11,46244,46244,11,46272,46272,11,46300,46300,11,46328,46328,11,46356,46356,11,46384,46384,11,46412,46412,11,46440,46440,11,46468,46468,11,46496,46496,11,46524,46524,11,46552,46552,11,46580,46580,11,46608,46608,11,46636,46636,11,46664,46664,11,46692,46692,11,46720,46720,11,46748,46748,11,46776,46776,11,46804,46804,11,46832,46832,11,46860,46860,11,46888,46888,11,46916,46916,11,46944,46944,11,46972,46972,11,47000,47000,11,47028,47028,11,47056,47056,11,47084,47084,11,47112,47112,11,47140,47140,11,47168,47168,11,47196,47196,11,47224,47224,11,47252,47252,11,47280,47280,11,47308,47308,11,47336,47336,11,47364,47364,11,47392,47392,11,47420,47420,11,47448,47448,11,47476,47476,11,47504,47504,11,47532,47532,11,47560,47560,11,47588,47588,11,47616,47616,11,47644,47644,11,47672,47672,11,47700,47700,11,47728,47728,11,47756,47756,11,47784,47784,11,47812,47812,11,47840,47840,11,47868,47868,11,47896,47896,11,47924,47924,11,47952,47952,11,47980,47980,11,48008,48008,11,48036,48036,11,48064,48064,11,48092,48092,11,48120,48120,11,48148,48148,11,48176,48176,11,48204,48204,11,48232,48232,11,48260,48260,11,48288,48288,11,48316,48316,11,48344,48344,11,48372,48372,11,48400,48400,11,48428,48428,11,48456,48456,11,48484,48484,11,48512,48512,11,48540,48540,11,48568,48568,11,48596,48596,11,48624,48624,11,48652,48652,11,48680,48680,11,48708,48708,11,48736,48736,11,48764,48764,11,48792,48792,11,48820,48820,11,48848,48848,11,48876,48876,11,48904,48904,11,48932,48932,11,48960,48960,11,48988,48988,11,49016,49016,11,49044,49044,11,49072,49072,11,49100,49100,11,49128,49128,11,49156,49156,11,49184,49184,11,49212,49212,11,49240,49240,11,49268,49268,11,49296,49296,11,49324,49324,11,49352,49352,11,49380,49380,11,49408,49408,11,49436,49436,11,49464,49464,11,49492,49492,11,49520,49520,11,49548,49548,11,49576,49576,11,49604,49604,11,49632,49632,11,49660,49660,11,49688,49688,11,49716,49716,11,49744,49744,11,49772,49772,11,49800,49800,11,49828,49828,11,49856,49856,11,49884,49884,11,49912,49912,11,49940,49940,11,49968,49968,11,49996,49996,11,50024,50024,11,50052,50052,11,50080,50080,11,50108,50108,11,50136,50136,11,50164,50164,11,50192,50192,11,50220,50220,11,50248,50248,11,50276,50276,11,50304,50304,11,50332,50332,11,50360,50360,11,50388,50388,11,50416,50416,11,50444,50444,11,50472,50472,11,50500,50500,11,50528,50528,11,50556,50556,11,50584,50584,11,50612,50612,11,50640,50640,11,50668,50668,11,50696,50696,11,50724,50724,11,50752,50752,11,50780,50780,11,50808,50808,11,50836,50836,11,50864,50864,11,50892,50892,11,50920,50920,11,50948,50948,11,50976,50976,11,51004,51004,11,51032,51032,11,51060,51060,11,51088,51088,11,51116,51116,11,51144,51144,11,51172,51172,11,51200,51200,11,51228,51228,11,51256,51256,11,51284,51284,11,51312,51312,11,51340,51340,11,51368,51368,11,51396,51396,11,51424,51424,11,51452,51452,11,51480,51480,11,51508,51508,11,51536,51536,11,51564,51564,11,51592,51592,11,51620,51620,11,51648,51648,11,51676,51676,11,51704,51704,11,51732,51732,11,51760,51760,11,51788,51788,11,51816,51816,11,51844,51844,11,51872,51872,11,51900,51900,11,51928,51928,11,51956,51956,11,51984,51984,11,52012,52012,11,52040,52040,11,52068,52068,11,52096,52096,11,52124,52124,11,52152,52152,11,52180,52180,11,52208,52208,11,52236,52236,11,52264,52264,11,52292,52292,11,52320,52320,11,52348,52348,11,52376,52376,11,52404,52404,11,52432,52432,11,52460,52460,11,52488,52488,11,52516,52516,11,52544,52544,11,52572,52572,11,52600,52600,11,52628,52628,11,52656,52656,11,52684,52684,11,52712,52712,11,52740,52740,11,52768,52768,11,52796,52796,11,52824,52824,11,52852,52852,11,52880,52880,11,52908,52908,11,52936,52936,11,52964,52964,11,52992,52992,11,53020,53020,11,53048,53048,11,53076,53076,11,53104,53104,11,53132,53132,11,53160,53160,11,53188,53188,11,53216,53216,11,53244,53244,11,53272,53272,11,53300,53300,11,53328,53328,11,53356,53356,11,53384,53384,11,53412,53412,11,53440,53440,11,53468,53468,11,53496,53496,11,53524,53524,11,53552,53552,11,53580,53580,11,53608,53608,11,53636,53636,11,53664,53664,11,53692,53692,11,53720,53720,11,53748,53748,11,53776,53776,11,53804,53804,11,53832,53832,11,53860,53860,11,53888,53888,11,53916,53916,11,53944,53944,11,53972,53972,11,54000,54000,11,54028,54028,11,54056,54056,11,54084,54084,11,54112,54112,11,54140,54140,11,54168,54168,11,54196,54196,11,54224,54224,11,54252,54252,11,54280,54280,11,54308,54308,11,54336,54336,11,54364,54364,11,54392,54392,11,54420,54420,11,54448,54448,11,54476,54476,11,54504,54504,11,54532,54532,11,54560,54560,11,54588,54588,11,54616,54616,11,54644,54644,11,54672,54672,11,54700,54700,11,54728,54728,11,54756,54756,11,54784,54784,11,54812,54812,11,54840,54840,11,54868,54868,11,54896,54896,11,54924,54924,11,54952,54952,11,54980,54980,11,55008,55008,11,55036,55036,11,55064,55064,11,55092,55092,11,55120,55120,11,55148,55148,11,55176,55176,11,55216,55238,9,64286,64286,5,65056,65071,5,65438,65439,5,65529,65531,4,66272,66272,5,68097,68099,5,68108,68111,5,68159,68159,5,68900,68903,5,69446,69456,5,69632,69632,7,69634,69634,7,69744,69744,5,69759,69761,5,69808,69810,7,69815,69816,7,69821,69821,1,69837,69837,1,69927,69931,5,69933,69940,5,70003,70003,5,70018,70018,7,70070,70078,5,70082,70083,1,70094,70094,7,70188,70190,7,70194,70195,7,70197,70197,7,70206,70206,5,70368,70370,7,70400,70401,5,70459,70460,5,70463,70463,7,70465,70468,7,70475,70477,7,70498,70499,7,70512,70516,5,70712,70719,5,70722,70724,5,70726,70726,5,70832,70832,5,70835,70840,5,70842,70842,5,70845,70845,5,70847,70848,5,70850,70851,5,71088,71089,7,71096,71099,7,71102,71102,7,71132,71133,5,71219,71226,5,71229,71229,5,71231,71232,5,71340,71340,7,71342,71343,7,71350,71350,7,71453,71455,5,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,118528,118573,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123566,123566,5,125136,125142,5,126976,126979,14,126981,127182,14,127184,127231,14,127279,127279,14,127344,127345,14,127374,127374,14,127405,127461,14,127489,127490,14,127514,127514,14,127538,127546,14,127561,127567,14,127570,127743,14,127757,127758,14,127760,127760,14,127762,127762,14,127766,127768,14,127770,127770,14,127772,127772,14,127775,127776,14,127778,127779,14,127789,127791,14,127794,127795,14,127798,127798,14,127819,127819,14,127824,127824,14,127868,127868,14,127870,127871,14,127892,127893,14,127896,127896,14,127900,127901,14,127904,127940,14,127942,127942,14,127944,127944,14,127946,127946,14,127951,127955,14,127968,127971,14,127973,127984,14,127987,127987,14,127989,127989,14,127991,127991,14,127995,127999,5,128008,128008,14,128012,128014,14,128017,128018,14,128020,128020,14,128022,128022,14,128042,128042,14,128063,128063,14,128065,128065,14,128101,128101,14,128108,128109,14,128173,128173,14,128182,128183,14,128236,128237,14,128239,128239,14,128245,128245,14,128248,128248,14,128253,128253,14,128255,128258,14,128260,128263,14,128265,128265,14,128277,128277,14,128300,128301,14,128326,128328,14,128331,128334,14,128336,128347,14,128360,128366,14,128369,128370,14,128378,128378,14,128391,128391,14,128394,128397,14,128400,128400,14,128405,128406,14,128420,128420,14,128422,128423,14,128425,128432,14,128435,128443,14,128445,128449,14,128453,128464,14,128468,128475,14,128479,128480,14,128482,128482,14,128484,128487,14,128489,128494,14,128496,128498,14,128500,128505,14,128507,128511,14,128513,128518,14,128521,128525,14,128527,128527,14,128529,128529,14,128533,128533,14,128535,128535,14,128537,128537,14]")}var Ul=class r{constructor(e){this.confusableDictionary=e}static{this.ambiguousCharacterData=new Ce(()=>JSON.parse('{"_common":[8232,32,8233,32,5760,32,8192,32,8193,32,8194,32,8195,32,8196,32,8197,32,8198,32,8200,32,8201,32,8202,32,8287,32,8199,32,8239,32,2042,95,65101,95,65102,95,65103,95,8208,45,8209,45,8210,45,65112,45,1748,45,8259,45,727,45,8722,45,10134,45,11450,45,1549,44,1643,44,184,44,42233,44,894,59,2307,58,2691,58,1417,58,1795,58,1796,58,5868,58,65072,58,6147,58,6153,58,8282,58,1475,58,760,58,42889,58,8758,58,720,58,42237,58,451,33,11601,33,660,63,577,63,2429,63,5038,63,42731,63,119149,46,8228,46,1793,46,1794,46,42510,46,68176,46,1632,46,1776,46,42232,46,1373,96,65287,96,8219,96,1523,96,8242,96,1370,96,8175,96,65344,96,900,96,8189,96,8125,96,8127,96,8190,96,697,96,884,96,712,96,714,96,715,96,756,96,699,96,701,96,700,96,702,96,42892,96,1497,96,2036,96,2037,96,5194,96,5836,96,94033,96,94034,96,65339,91,10088,40,10098,40,12308,40,64830,40,65341,93,10089,41,10099,41,12309,41,64831,41,10100,123,119060,123,10101,125,65342,94,8270,42,1645,42,8727,42,66335,42,5941,47,8257,47,8725,47,8260,47,9585,47,10187,47,10744,47,119354,47,12755,47,12339,47,11462,47,20031,47,12035,47,65340,92,65128,92,8726,92,10189,92,10741,92,10745,92,119311,92,119355,92,12756,92,20022,92,12034,92,42872,38,708,94,710,94,5869,43,10133,43,66203,43,8249,60,10094,60,706,60,119350,60,5176,60,5810,60,5120,61,11840,61,12448,61,42239,61,8250,62,10095,62,707,62,119351,62,5171,62,94015,62,8275,126,732,126,8128,126,8764,126,65372,124,65293,45,118002,50,120784,50,120794,50,120804,50,120814,50,120824,50,130034,50,42842,50,423,50,1000,50,42564,50,5311,50,42735,50,119302,51,118003,51,120785,51,120795,51,120805,51,120815,51,120825,51,130035,51,42923,51,540,51,439,51,42858,51,11468,51,1248,51,94011,51,71882,51,118004,52,120786,52,120796,52,120806,52,120816,52,120826,52,130036,52,5070,52,71855,52,118005,53,120787,53,120797,53,120807,53,120817,53,120827,53,130037,53,444,53,71867,53,118006,54,120788,54,120798,54,120808,54,120818,54,120828,54,130038,54,11474,54,5102,54,71893,54,119314,55,118007,55,120789,55,120799,55,120809,55,120819,55,120829,55,130039,55,66770,55,71878,55,2819,56,2538,56,2666,56,125131,56,118008,56,120790,56,120800,56,120810,56,120820,56,120830,56,130040,56,547,56,546,56,66330,56,2663,57,2920,57,2541,57,3437,57,118009,57,120791,57,120801,57,120811,57,120821,57,120831,57,130041,57,42862,57,11466,57,71884,57,71852,57,71894,57,9082,97,65345,97,119834,97,119886,97,119938,97,119990,97,120042,97,120094,97,120146,97,120198,97,120250,97,120302,97,120354,97,120406,97,120458,97,593,97,945,97,120514,97,120572,97,120630,97,120688,97,120746,97,65313,65,117974,65,119808,65,119860,65,119912,65,119964,65,120016,65,120068,65,120120,65,120172,65,120224,65,120276,65,120328,65,120380,65,120432,65,913,65,120488,65,120546,65,120604,65,120662,65,120720,65,5034,65,5573,65,42222,65,94016,65,66208,65,119835,98,119887,98,119939,98,119991,98,120043,98,120095,98,120147,98,120199,98,120251,98,120303,98,120355,98,120407,98,120459,98,388,98,5071,98,5234,98,5551,98,65314,66,8492,66,117975,66,119809,66,119861,66,119913,66,120017,66,120069,66,120121,66,120173,66,120225,66,120277,66,120329,66,120381,66,120433,66,42932,66,914,66,120489,66,120547,66,120605,66,120663,66,120721,66,5108,66,5623,66,42192,66,66178,66,66209,66,66305,66,65347,99,8573,99,119836,99,119888,99,119940,99,119992,99,120044,99,120096,99,120148,99,120200,99,120252,99,120304,99,120356,99,120408,99,120460,99,7428,99,1010,99,11429,99,43951,99,66621,99,128844,67,71913,67,71922,67,65315,67,8557,67,8450,67,8493,67,117976,67,119810,67,119862,67,119914,67,119966,67,120018,67,120174,67,120226,67,120278,67,120330,67,120382,67,120434,67,1017,67,11428,67,5087,67,42202,67,66210,67,66306,67,66581,67,66844,67,8574,100,8518,100,119837,100,119889,100,119941,100,119993,100,120045,100,120097,100,120149,100,120201,100,120253,100,120305,100,120357,100,120409,100,120461,100,1281,100,5095,100,5231,100,42194,100,8558,68,8517,68,117977,68,119811,68,119863,68,119915,68,119967,68,120019,68,120071,68,120123,68,120175,68,120227,68,120279,68,120331,68,120383,68,120435,68,5024,68,5598,68,5610,68,42195,68,8494,101,65349,101,8495,101,8519,101,119838,101,119890,101,119942,101,120046,101,120098,101,120150,101,120202,101,120254,101,120306,101,120358,101,120410,101,120462,101,43826,101,1213,101,8959,69,65317,69,8496,69,117978,69,119812,69,119864,69,119916,69,120020,69,120072,69,120124,69,120176,69,120228,69,120280,69,120332,69,120384,69,120436,69,917,69,120492,69,120550,69,120608,69,120666,69,120724,69,11577,69,5036,69,42224,69,71846,69,71854,69,66182,69,119839,102,119891,102,119943,102,119995,102,120047,102,120099,102,120151,102,120203,102,120255,102,120307,102,120359,102,120411,102,120463,102,43829,102,42905,102,383,102,7837,102,1412,102,119315,70,8497,70,117979,70,119813,70,119865,70,119917,70,120021,70,120073,70,120125,70,120177,70,120229,70,120281,70,120333,70,120385,70,120437,70,42904,70,988,70,120778,70,5556,70,42205,70,71874,70,71842,70,66183,70,66213,70,66853,70,65351,103,8458,103,119840,103,119892,103,119944,103,120048,103,120100,103,120152,103,120204,103,120256,103,120308,103,120360,103,120412,103,120464,103,609,103,7555,103,397,103,1409,103,117980,71,119814,71,119866,71,119918,71,119970,71,120022,71,120074,71,120126,71,120178,71,120230,71,120282,71,120334,71,120386,71,120438,71,1292,71,5056,71,5107,71,42198,71,65352,104,8462,104,119841,104,119945,104,119997,104,120049,104,120101,104,120153,104,120205,104,120257,104,120309,104,120361,104,120413,104,120465,104,1211,104,1392,104,5058,104,65320,72,8459,72,8460,72,8461,72,117981,72,119815,72,119867,72,119919,72,120023,72,120179,72,120231,72,120283,72,120335,72,120387,72,120439,72,919,72,120494,72,120552,72,120610,72,120668,72,120726,72,11406,72,5051,72,5500,72,42215,72,66255,72,731,105,9075,105,65353,105,8560,105,8505,105,8520,105,119842,105,119894,105,119946,105,119998,105,120050,105,120102,105,120154,105,120206,105,120258,105,120310,105,120362,105,120414,105,120466,105,120484,105,618,105,617,105,953,105,8126,105,890,105,120522,105,120580,105,120638,105,120696,105,120754,105,1110,105,42567,105,1231,105,43893,105,5029,105,71875,105,65354,106,8521,106,119843,106,119895,106,119947,106,119999,106,120051,106,120103,106,120155,106,120207,106,120259,106,120311,106,120363,106,120415,106,120467,106,1011,106,1112,106,65322,74,117983,74,119817,74,119869,74,119921,74,119973,74,120025,74,120077,74,120129,74,120181,74,120233,74,120285,74,120337,74,120389,74,120441,74,42930,74,895,74,1032,74,5035,74,5261,74,42201,74,119844,107,119896,107,119948,107,120000,107,120052,107,120104,107,120156,107,120208,107,120260,107,120312,107,120364,107,120416,107,120468,107,8490,75,65323,75,117984,75,119818,75,119870,75,119922,75,119974,75,120026,75,120078,75,120130,75,120182,75,120234,75,120286,75,120338,75,120390,75,120442,75,922,75,120497,75,120555,75,120613,75,120671,75,120729,75,11412,75,5094,75,5845,75,42199,75,66840,75,1472,108,8739,73,9213,73,65512,73,1633,108,1777,73,66336,108,125127,108,118001,108,120783,73,120793,73,120803,73,120813,73,120823,73,130033,73,65321,73,8544,73,8464,73,8465,73,117982,108,119816,73,119868,73,119920,73,120024,73,120128,73,120180,73,120232,73,120284,73,120336,73,120388,73,120440,73,65356,108,8572,73,8467,108,119845,108,119897,108,119949,108,120001,108,120053,108,120105,73,120157,73,120209,73,120261,73,120313,73,120365,73,120417,73,120469,73,448,73,120496,73,120554,73,120612,73,120670,73,120728,73,11410,73,1030,73,1216,73,1493,108,1503,108,1575,108,126464,108,126592,108,65166,108,65165,108,1994,108,11599,73,5825,73,42226,73,93992,73,66186,124,66313,124,119338,76,8556,76,8466,76,117985,76,119819,76,119871,76,119923,76,120027,76,120079,76,120131,76,120183,76,120235,76,120287,76,120339,76,120391,76,120443,76,11472,76,5086,76,5290,76,42209,76,93974,76,71843,76,71858,76,66587,76,66854,76,65325,77,8559,77,8499,77,117986,77,119820,77,119872,77,119924,77,120028,77,120080,77,120132,77,120184,77,120236,77,120288,77,120340,77,120392,77,120444,77,924,77,120499,77,120557,77,120615,77,120673,77,120731,77,1018,77,11416,77,5047,77,5616,77,5846,77,42207,77,66224,77,66321,77,119847,110,119899,110,119951,110,120003,110,120055,110,120107,110,120159,110,120211,110,120263,110,120315,110,120367,110,120419,110,120471,110,1400,110,1404,110,65326,78,8469,78,117987,78,119821,78,119873,78,119925,78,119977,78,120029,78,120081,78,120185,78,120237,78,120289,78,120341,78,120393,78,120445,78,925,78,120500,78,120558,78,120616,78,120674,78,120732,78,11418,78,42208,78,66835,78,3074,111,3202,111,3330,111,3458,111,2406,111,2662,111,2790,111,3046,111,3174,111,3302,111,3430,111,3664,111,3792,111,4160,111,1637,111,1781,111,65359,111,8500,111,119848,111,119900,111,119952,111,120056,111,120108,111,120160,111,120212,111,120264,111,120316,111,120368,111,120420,111,120472,111,7439,111,7441,111,43837,111,959,111,120528,111,120586,111,120644,111,120702,111,120760,111,963,111,120532,111,120590,111,120648,111,120706,111,120764,111,11423,111,4351,111,1413,111,1505,111,1607,111,126500,111,126564,111,126596,111,65259,111,65260,111,65258,111,65257,111,1726,111,64428,111,64429,111,64427,111,64426,111,1729,111,64424,111,64425,111,64423,111,64422,111,1749,111,3360,111,4125,111,66794,111,71880,111,71895,111,66604,111,1984,79,2534,79,2918,79,12295,79,70864,79,71904,79,118000,79,120782,79,120792,79,120802,79,120812,79,120822,79,130032,79,65327,79,117988,79,119822,79,119874,79,119926,79,119978,79,120030,79,120082,79,120134,79,120186,79,120238,79,120290,79,120342,79,120394,79,120446,79,927,79,120502,79,120560,79,120618,79,120676,79,120734,79,11422,79,1365,79,11604,79,4816,79,2848,79,66754,79,42227,79,71861,79,66194,79,66219,79,66564,79,66838,79,9076,112,65360,112,119849,112,119901,112,119953,112,120005,112,120057,112,120109,112,120161,112,120213,112,120265,112,120317,112,120369,112,120421,112,120473,112,961,112,120530,112,120544,112,120588,112,120602,112,120646,112,120660,112,120704,112,120718,112,120762,112,120776,112,11427,112,65328,80,8473,80,117989,80,119823,80,119875,80,119927,80,119979,80,120031,80,120083,80,120187,80,120239,80,120291,80,120343,80,120395,80,120447,80,929,80,120504,80,120562,80,120620,80,120678,80,120736,80,11426,80,5090,80,5229,80,42193,80,66197,80,119850,113,119902,113,119954,113,120006,113,120058,113,120110,113,120162,113,120214,113,120266,113,120318,113,120370,113,120422,113,120474,113,1307,113,1379,113,1382,113,8474,81,117990,81,119824,81,119876,81,119928,81,119980,81,120032,81,120084,81,120188,81,120240,81,120292,81,120344,81,120396,81,120448,81,11605,81,119851,114,119903,114,119955,114,120007,114,120059,114,120111,114,120163,114,120215,114,120267,114,120319,114,120371,114,120423,114,120475,114,43847,114,43848,114,7462,114,11397,114,43905,114,119318,82,8475,82,8476,82,8477,82,117991,82,119825,82,119877,82,119929,82,120033,82,120189,82,120241,82,120293,82,120345,82,120397,82,120449,82,422,82,5025,82,5074,82,66740,82,5511,82,42211,82,94005,82,65363,115,119852,115,119904,115,119956,115,120008,115,120060,115,120112,115,120164,115,120216,115,120268,115,120320,115,120372,115,120424,115,120476,115,42801,115,445,115,1109,115,43946,115,71873,115,66632,115,65331,83,117992,83,119826,83,119878,83,119930,83,119982,83,120034,83,120086,83,120138,83,120190,83,120242,83,120294,83,120346,83,120398,83,120450,83,1029,83,1359,83,5077,83,5082,83,42210,83,94010,83,66198,83,66592,83,119853,116,119905,116,119957,116,120009,116,120061,116,120113,116,120165,116,120217,116,120269,116,120321,116,120373,116,120425,116,120477,116,8868,84,10201,84,128872,84,65332,84,117993,84,119827,84,119879,84,119931,84,119983,84,120035,84,120087,84,120139,84,120191,84,120243,84,120295,84,120347,84,120399,84,120451,84,932,84,120507,84,120565,84,120623,84,120681,84,120739,84,11430,84,5026,84,42196,84,93962,84,71868,84,66199,84,66225,84,66325,84,119854,117,119906,117,119958,117,120010,117,120062,117,120114,117,120166,117,120218,117,120270,117,120322,117,120374,117,120426,117,120478,117,42911,117,7452,117,43854,117,43858,117,651,117,965,117,120534,117,120592,117,120650,117,120708,117,120766,117,1405,117,66806,117,71896,117,8746,85,8899,85,117994,85,119828,85,119880,85,119932,85,119984,85,120036,85,120088,85,120140,85,120192,85,120244,85,120296,85,120348,85,120400,85,120452,85,1357,85,4608,85,66766,85,5196,85,42228,85,94018,85,71864,85,8744,118,8897,118,65366,118,8564,118,119855,118,119907,118,119959,118,120011,118,120063,118,120115,118,120167,118,120219,118,120271,118,120323,118,120375,118,120427,118,120479,118,7456,118,957,118,120526,118,120584,118,120642,118,120700,118,120758,118,1141,118,1496,118,71430,118,43945,118,71872,118,119309,86,1639,86,1783,86,8548,86,117995,86,119829,86,119881,86,119933,86,119985,86,120037,86,120089,86,120141,86,120193,86,120245,86,120297,86,120349,86,120401,86,120453,86,1140,86,11576,86,5081,86,5167,86,42719,86,42214,86,93960,86,71840,86,66845,86,623,119,119856,119,119908,119,119960,119,120012,119,120064,119,120116,119,120168,119,120220,119,120272,119,120324,119,120376,119,120428,119,120480,119,7457,119,1121,119,1309,119,1377,119,71434,119,71438,119,71439,119,43907,119,71910,87,71919,87,117996,87,119830,87,119882,87,119934,87,119986,87,120038,87,120090,87,120142,87,120194,87,120246,87,120298,87,120350,87,120402,87,120454,87,1308,87,5043,87,5076,87,42218,87,5742,120,10539,120,10540,120,10799,120,65368,120,8569,120,119857,120,119909,120,119961,120,120013,120,120065,120,120117,120,120169,120,120221,120,120273,120,120325,120,120377,120,120429,120,120481,120,5441,120,5501,120,5741,88,9587,88,66338,88,71916,88,65336,88,8553,88,117997,88,119831,88,119883,88,119935,88,119987,88,120039,88,120091,88,120143,88,120195,88,120247,88,120299,88,120351,88,120403,88,120455,88,42931,88,935,88,120510,88,120568,88,120626,88,120684,88,120742,88,11436,88,11613,88,5815,88,42219,88,66192,88,66228,88,66327,88,66855,88,611,121,7564,121,65369,121,119858,121,119910,121,119962,121,120014,121,120066,121,120118,121,120170,121,120222,121,120274,121,120326,121,120378,121,120430,121,120482,121,655,121,7935,121,43866,121,947,121,8509,121,120516,121,120574,121,120632,121,120690,121,120748,121,1199,121,4327,121,71900,121,65337,89,117998,89,119832,89,119884,89,119936,89,119988,89,120040,89,120092,89,120144,89,120196,89,120248,89,120300,89,120352,89,120404,89,120456,89,933,89,978,89,120508,89,120566,89,120624,89,120682,89,120740,89,11432,89,1198,89,5033,89,5053,89,42220,89,94019,89,71844,89,66226,89,119859,122,119911,122,119963,122,120015,122,120067,122,120119,122,120171,122,120223,122,120275,122,120327,122,120379,122,120431,122,120483,122,7458,122,43923,122,71876,122,71909,90,66293,90,65338,90,8484,90,8488,90,117999,90,119833,90,119885,90,119937,90,119989,90,120041,90,120197,90,120249,90,120301,90,120353,90,120405,90,120457,90,918,90,120493,90,120551,90,120609,90,120667,90,120725,90,5059,90,42204,90,71849,90,65282,34,65283,35,65284,36,65285,37,65286,38,65290,42,65291,43,65294,46,65295,47,65296,48,65298,50,65299,51,65300,52,65301,53,65302,54,65303,55,65304,56,65305,57,65308,60,65309,61,65310,62,65312,64,65316,68,65318,70,65319,71,65324,76,65329,81,65330,82,65333,85,65334,86,65335,87,65343,95,65346,98,65348,100,65350,102,65355,107,65357,109,65358,110,65361,113,65362,114,65364,116,65365,117,65367,119,65370,122,65371,123,65373,125,119846,109],"_default":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"cs":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"de":[65374,126,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"es":[8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"fr":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"it":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"ja":[8211,45,8218,44,65281,33,8216,96,8245,96,180,96,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65292,44,65297,49,65307,59],"ko":[8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"pl":[65374,126,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"pt-BR":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"qps-ploc":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"ru":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,305,105,921,73,1009,112,215,120,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"tr":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"zh-hans":[160,32,65374,126,8218,44,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65297,49],"zh-hant":[8211,45,65374,126,8218,44,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89]}'))}static{this.cache=new fi(e=>{let t=e.split(",");function n(u){let p=new Map;for(let h=0;h<u.length;h+=2)p.set(u[h],u[h+1]);return p}function i(u,p){let h=new Map(u);for(let[g,b]of p)h.set(g,b);return h}function s(u,p){if(!u)return p;let h=new Map;for(let[g,b]of u)p.has(g)&&h.set(g,b);return h}let o=this.ambiguousCharacterData.value,a=t.filter(u=>!u.startsWith("_")&&Object.hasOwn(o,u));a.length===0&&(a=["_default"]);let l;for(let u of a){let p=n(o[u]);l=s(l,p)}let c=n(o._common),d=i(c,l);return new r(d)})}static getInstance(e){return r.cache.get(Array.from(e).join(","))}static{this._locales=new Ce(()=>Object.keys(r.ambiguousCharacterData.value).filter(e=>!e.startsWith("_")))}static getLocales(){return r._locales.value}isAmbiguous(e){return this.confusableDictionary.has(e)}containsAmbiguousCharacter(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(typeof n=="number"&&this.isAmbiguous(n))return!0}return!1}getPrimaryConfusable(e){return this.confusableDictionary.get(e)}getConfusableCodePoints(){return new Set(this.confusableDictionary.keys())}},Nl=class r{static getRawData(){return JSON.parse('{"_common":[11,12,13,127,847,1564,4447,4448,6068,6069,6155,6156,6157,6158,7355,7356,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8204,8205,8206,8207,8234,8235,8236,8237,8238,8239,8287,8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,10240,12644,65024,65025,65026,65027,65028,65029,65030,65031,65032,65033,65034,65035,65036,65037,65038,65039,65279,65440,65520,65521,65522,65523,65524,65525,65526,65527,65528,65532,78844,119155,119156,119157,119158,119159,119160,119161,119162,917504,917505,917506,917507,917508,917509,917510,917511,917512,917513,917514,917515,917516,917517,917518,917519,917520,917521,917522,917523,917524,917525,917526,917527,917528,917529,917530,917531,917532,917533,917534,917535,917536,917537,917538,917539,917540,917541,917542,917543,917544,917545,917546,917547,917548,917549,917550,917551,917552,917553,917554,917555,917556,917557,917558,917559,917560,917561,917562,917563,917564,917565,917566,917567,917568,917569,917570,917571,917572,917573,917574,917575,917576,917577,917578,917579,917580,917581,917582,917583,917584,917585,917586,917587,917588,917589,917590,917591,917592,917593,917594,917595,917596,917597,917598,917599,917600,917601,917602,917603,917604,917605,917606,917607,917608,917609,917610,917611,917612,917613,917614,917615,917616,917617,917618,917619,917620,917621,917622,917623,917624,917625,917626,917627,917628,917629,917630,917631,917760,917761,917762,917763,917764,917765,917766,917767,917768,917769,917770,917771,917772,917773,917774,917775,917776,917777,917778,917779,917780,917781,917782,917783,917784,917785,917786,917787,917788,917789,917790,917791,917792,917793,917794,917795,917796,917797,917798,917799,917800,917801,917802,917803,917804,917805,917806,917807,917808,917809,917810,917811,917812,917813,917814,917815,917816,917817,917818,917819,917820,917821,917822,917823,917824,917825,917826,917827,917828,917829,917830,917831,917832,917833,917834,917835,917836,917837,917838,917839,917840,917841,917842,917843,917844,917845,917846,917847,917848,917849,917850,917851,917852,917853,917854,917855,917856,917857,917858,917859,917860,917861,917862,917863,917864,917865,917866,917867,917868,917869,917870,917871,917872,917873,917874,917875,917876,917877,917878,917879,917880,917881,917882,917883,917884,917885,917886,917887,917888,917889,917890,917891,917892,917893,917894,917895,917896,917897,917898,917899,917900,917901,917902,917903,917904,917905,917906,917907,917908,917909,917910,917911,917912,917913,917914,917915,917916,917917,917918,917919,917920,917921,917922,917923,917924,917925,917926,917927,917928,917929,917930,917931,917932,917933,917934,917935,917936,917937,917938,917939,917940,917941,917942,917943,917944,917945,917946,917947,917948,917949,917950,917951,917952,917953,917954,917955,917956,917957,917958,917959,917960,917961,917962,917963,917964,917965,917966,917967,917968,917969,917970,917971,917972,917973,917974,917975,917976,917977,917978,917979,917980,917981,917982,917983,917984,917985,917986,917987,917988,917989,917990,917991,917992,917993,917994,917995,917996,917997,917998,917999],"cs":[173,8203,12288],"de":[173,8203,12288],"es":[8203,12288],"fr":[173,8203,12288],"it":[160,173,12288],"ja":[173],"ko":[173,12288],"pl":[173,8203,12288],"pt-BR":[173,8203,12288],"qps-ploc":[160,173,8203,12288],"ru":[173,12288],"tr":[160,173,8203,12288],"zh-hans":[160,173,8203,12288],"zh-hant":[173,12288]}')}static{this._data=void 0}static getData(){return this._data||(this._data=new Set([...Object.values(r.getRawData())].flat())),this._data}static isInvisibleCharacter(e){return r.getData().has(e)}static containsInvisibleCharacter(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(typeof n=="number"&&(r.isInvisibleCharacter(n)||n===32))return!0}return!1}static get codePoints(){return r.getData()}};function Rt(r){return r===47||r===92}function bo(r){return r.replace(/[\\/]/g,U.sep)}function Kl(r){return r.indexOf("/")===-1&&(r=bo(r)),/^[a-zA-Z]:(\/|$)/.test(r)&&(r="/"+r),r}function yo(r,e=U.sep){if(!r)return"";let t=r.length,n=r.charCodeAt(0);if(Rt(n)){if(Rt(r.charCodeAt(1))&&!Rt(r.charCodeAt(2))){let s=3,o=s;for(;s<t&&!Rt(r.charCodeAt(s));s++);if(o!==s&&!Rt(r.charCodeAt(s+1))){for(s+=1;s<t;s++)if(Rt(r.charCodeAt(s)))return r.slice(0,s+1).replace(/[\\/]/g,e)}}return e}else if(zl(n)&&r.charCodeAt(1)===58)return Rt(r.charCodeAt(2))?r.slice(0,2)+e:r.slice(0,2);let i=r.indexOf("://");if(i!==-1){for(i+=3;i<t;i++)if(Rt(r.charCodeAt(i)))return r.slice(0,i+1)}return""}function gn(r,e,t){let n=r===e;return!t||n?n:!r||!e?!1:Kt(r,e)}function lt(r,e,t,n=ie){if(r===e)return!0;if(!r||!e||e.length>r.length)return!1;if(t){if(!lr(r,e))return!1;if(e.length===r.length)return!0;let s=e.length;return e.charAt(e.length-1)===n&&s--,r.charAt(s)===n}return e.charAt(e.length-1)!==n&&(e+=n),r.indexOf(e)===0}function zl(r){return r>=65&&r<=90||r>=97&&r<=122}function jl(r){return $?(r=or(r,ie),r.endsWith(":")&&(r+=ie)):(r=or(r,ie),r||(r=ie)),r}function Io(r){let e=Me(r);return $?r.length>3?!1:tp(e)&&(r.length===2||e.charCodeAt(2)===92):e===U.sep}function tp(r,e=$){return e?zl(r.charCodeAt(0))&&r.charCodeAt(1)===58:!1}var np="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",rp="BDEFGHIJKMOQRSTUVWXYZbdefghijkmoqrstuvwxyz0123456789";function Hl(r,e,t=8){let n="";for(let s=0;s<t;s++){let o;s===0&&$&&!e&&(t===3||t===4)?o=rp:o=np,n+=o.charAt(Math.floor(Math.random()*o.length))}let i;return e?i=`${e}-${n}`:i=n,r?J(r,i):i}var sp=/^\w[\w\d+.-]*$/,op=/^\//,ap=/^\/\//;function lp(r,e){if(!r.scheme&&e)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${r.authority}", path: "${r.path}", query: "${r.query}", fragment: "${r.fragment}"}`);if(r.scheme&&!sp.test(r.scheme)){let t=[...r.scheme.matchAll(/[^\w\d+.-]/gu)],n=t.length>0?` Found '${t[0][0]}' at index ${t[0].index} (${t.length} total)`:"";throw new Error(`[UriError]: Scheme contains illegal characters.${n} (len:${r.scheme.length})`)}if(r.path){if(r.authority){if(!op.test(r.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(ap.test(r.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}}function cp(r,e){return!r&&!e?"file":r}function up(r,e){switch(r){case"https":case"http":case"file":e?e[0]!==ze&&(e=ze+e):e=ze;break}return e}var z="",ze="/",dp=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,m=class r{static isUri(e){return e instanceof r?!0:!e||typeof e!="object"?!1:typeof e.authority=="string"&&typeof e.fragment=="string"&&typeof e.path=="string"&&typeof e.query=="string"&&typeof e.scheme=="string"&&typeof e.fsPath=="string"&&typeof e.with=="function"&&typeof e.toString=="function"}constructor(e,t,n,i,s,o=!1){typeof e=="object"?(this.scheme=e.scheme||z,this.authority=e.authority||z,this.path=e.path||z,this.query=e.query||z,this.fragment=e.fragment||z):(this.scheme=cp(e,o),this.authority=t||z,this.path=up(this.scheme,n||z),this.query=i||z,this.fragment=s||z,lp(this,o))}get fsPath(){return cr(this,!1)}with(e){if(!e)return this;let{scheme:t,authority:n,path:i,query:s,fragment:o}=e;return t===void 0?t=this.scheme:t===null&&(t=z),n===void 0?n=this.authority:n===null&&(n=z),i===void 0?i=this.path:i===null&&(i=z),s===void 0?s=this.query:s===null&&(s=z),o===void 0?o=this.fragment:o===null&&(o=z),t===this.scheme&&n===this.authority&&i===this.path&&s===this.query&&o===this.fragment?this:new wt(t,n,i,s,o)}static parse(e,t=!1){let n=dp.exec(e);return n?new wt(n[2]||z,gi(n[4]||z),gi(n[5]||z),gi(n[7]||z),gi(n[9]||z),t):new wt(z,z,z,z,z)}static file(e){let t=z;if($&&(e=e.replace(/\\/g,ze)),e[0]===ze&&e[1]===ze){let n=e.indexOf(ze,2);n===-1?(t=e.substring(2),e=ze):(t=e.substring(2,n),e=e.substring(n)||ze)}return new wt("file",t,e,z,z)}static from(e,t){return new wt(e.scheme,e.authority,e.path,e.query,e.fragment,t)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPath on URI without path");let n;return $&&e.scheme==="file"?n=r.file(re.join(cr(e,!0),...t)).path:n=U.join(e.path,...t),e.with({path:n})}toString(e=!1){return To(this,e)}toJSON(){return this}static revive(e){if(e){if(e instanceof r)return e;{let t=new wt(e);return t._formatted=e.external??null,t._fsPath=e._sep===Yl?e.fsPath??null:null,t}}else return e}[Symbol.for("debug.description")](){return`URI(${this.toString()})`}};var Yl=$?1:void 0,wt=class extends m{constructor(){super(...arguments);this._formatted=null;this._fsPath=null}get fsPath(){return this._fsPath||(this._fsPath=cr(this,!1)),this._fsPath}toString(t=!1){return t?To(this,!0):(this._formatted||(this._formatted=To(this,!1)),this._formatted)}toJSON(){let t={$mid:1};return this._fsPath&&(t.fsPath=this._fsPath,t._sep=Yl),this._formatted&&(t.external=this._formatted),this.path&&(t.path=this.path),this.scheme&&(t.scheme=this.scheme),this.authority&&(t.authority=this.authority),this.query&&(t.query=this.query),this.fragment&&(t.fragment=this.fragment),t}},Xl={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function Gl(r,e,t){let n,i=-1;for(let s=0;s<r.length;s++){let o=r.charCodeAt(s);if(o>=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||o===45||o===46||o===95||o===126||e&&o===47||t&&o===91||t&&o===93||t&&o===58)i!==-1&&(n+=encodeURIComponent(r.substring(i,s)),i=-1),n!==void 0&&(n+=r.charAt(s));else{n===void 0&&(n=r.substr(0,s));let a=Xl[o];a!==void 0?(i!==-1&&(n+=encodeURIComponent(r.substring(i,s)),i=-1),n+=a):i===-1&&(i=s)}}return i!==-1&&(n+=encodeURIComponent(r.substring(i))),n!==void 0?n:r}function pp(r){let e;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n===35||n===63?(e===void 0&&(e=r.substr(0,t)),e+=Xl[n]):e!==void 0&&(e+=r[t])}return e!==void 0?e:r}function cr(r,e){let t;return r.authority&&r.path.length>1&&r.scheme==="file"?t=`//${r.authority}${r.path}`:r.path.charCodeAt(0)===47&&(r.path.charCodeAt(1)>=65&&r.path.charCodeAt(1)<=90||r.path.charCodeAt(1)>=97&&r.path.charCodeAt(1)<=122)&&r.path.charCodeAt(2)===58?e?t=r.path.substr(1):t=r.path[1].toLowerCase()+r.path.substr(2):t=r.path,$&&(t=t.replace(/\//g,"\\")),t}function To(r,e){let t=e?pp:Gl,n="",{scheme:i,authority:s,path:o,query:a,fragment:l}=r;if(i&&(n+=i,n+=":"),(s||i==="file")&&(n+=ze,n+=ze),s){let c=s.indexOf("@");if(c!==-1){let d=s.substr(0,c);s=s.substr(c+1),c=d.lastIndexOf(":"),c===-1?n+=t(d,!1,!1):(n+=t(d.substr(0,c),!1,!1),n+=":",n+=t(d.substr(c+1),!1,!0)),n+="@"}s=s.toLowerCase(),c=s.lastIndexOf(":"),c===-1?n+=t(s,!1,!0):(n+=t(s.substr(0,c),!1,!0),n+=s.substr(c))}if(o){if(o.length>=3&&o.charCodeAt(0)===47&&o.charCodeAt(2)===58){let c=o.charCodeAt(1);c>=65&&c<=90&&(o=`/${String.fromCharCode(c+32)}:${o.substr(3)}`)}else if(o.length>=2&&o.charCodeAt(1)===58){let c=o.charCodeAt(0);c>=65&&c<=90&&(o=`${String.fromCharCode(c+32)}:${o.substr(2)}`)}n+=t(o,!0,!1)}return a&&(n+="?",n+=t(a,!1,!1)),l&&(n+="#",n+=e?l:Gl(l,!1,!1)),n}function Zl(r){try{return decodeURIComponent(r)}catch{return r.length>3?r.substr(0,3)+Zl(r.substr(3)):r}}var Ql=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function gi(r){return r.match(Ql)?r.replace(Ql,e=>Zl(e)):r}var Y;(C=>(C.inMemory="inmemory",C.vscode="vscode",C.internal="private",C.walkThrough="walkThrough",C.walkThroughSnippet="walkThroughSnippet",C.http="http",C.https="https",C.file="file",C.mailto="mailto",C.untitled="untitled",C.data="data",C.command="command",C.vscodeRemote="vscode-remote",C.vscodeRemoteResource="vscode-remote-resource",C.vscodeManagedRemoteResource="vscode-managed-remote-resource",C.vscodeUserData="vscode-userdata",C.vscodeCustomEditor="vscode-custom-editor",C.vscodeNotebookCell="vscode-notebook-cell",C.vscodeNotebookCellMetadata="vscode-notebook-cell-metadata",C.vscodeNotebookCellMetadataDiff="vscode-notebook-cell-metadata-diff",C.vscodeNotebookCellOutput="vscode-notebook-cell-output",C.vscodeNotebookCellOutputDiff="vscode-notebook-cell-output-diff",C.vscodeNotebookMetadata="vscode-notebook-metadata",C.vscodeInteractiveInput="vscode-interactive-input",C.vscodeSettings="vscode-settings",C.vscodeWorkspaceTrust="vscode-workspace-trust",C.vscodeTerminal="vscode-terminal",C.vscodeImageCarousel="vscode-image-carousel",C.vscodeChatCodeBlock="vscode-chat-code-block",C.vscodeChatCodeCompareBlock="vscode-chat-code-compare-block",C.vscodeChatEditor="vscode-chat-editor",C.vscodeChatInput="chatSessionInput",C.vscodeLocalChatSession="vscode-chat-session",C.webviewPanel="webview-panel",C.vscodeWebview="vscode-webview",C.vscodeBrowser="vscode-browser",C.extension="extension",C.vscodeFileResource="vscode-file",C.tmp="tmp",C.vsls="vsls",C.vscodeSourceControl="vscode-scm",C.commentsInput="comment",C.codeSetting="code-setting",C.outputChannel="output",C.accessibleView="accessible-view",C.chatEditingSnapshotScheme="chat-editing-snapshot-text-model",C.chatEditingModel="chat-editing-text-model",C.copilotPr="copilot-pr"))(Y||={});var xo="tkn",So=class{constructor(){this._hosts=Object.create(null);this._ports=Object.create(null);this._connectionTokens=Object.create(null);this._preferredWebSchema="http";this._delegate=null;this._serverRootPath="/"}setPreferredWebSchema(e){this._preferredWebSchema=e}setDelegate(e){this._delegate=e}setServerRootPath(e,t){this._serverRootPath=U.join(t??"/",hp(e))}getServerRootPath(){return this._serverRootPath}get _remoteResourcesPath(){return U.join(this._serverRootPath,Y.vscodeRemoteResource)}set(e,t,n){this._hosts[e]=t,this._ports[e]=n}setConnectionToken(e,t){this._connectionTokens[e]=t}getPreferredWebSchema(){return this._preferredWebSchema}rewrite(e){if(this._delegate)try{return this._delegate(e)}catch(a){return Z(a),e}let t=e.authority,n=this._hosts[t];n&&n.indexOf(":")!==-1&&n.indexOf("[")===-1&&(n=`[${n}]`);let i=this._ports[t],s=this._connectionTokens[t],o=`path=${encodeURIComponent(e.path)}`;return typeof s=="string"&&(o+=`&${xo}=${encodeURIComponent(s)}`),m.from({scheme:un?this._preferredWebSchema:Y.vscodeRemoteResource,authority:`${n}:${i}`,path:this._remoteResourcesPath,query:o})}},fp=new So;function hp(r){return`${r.quality??"oss"}-${r.commit??"dev"}`}var gp="vscode-app",_o=class r{static{this.FALLBACK_AUTHORITY=gp}asBrowserUri(e){let t=this.toUri(e);return this.uriToBrowserUri(t)}uriToBrowserUri(e){return e.scheme===Y.vscodeRemote?fp.rewrite(e):e.scheme===Y.file&&(ml||vl===`${Y.vscodeFileResource}://${r.FALLBACK_AUTHORITY}`)?e.with({scheme:Y.vscodeFileResource,authority:e.authority||r.FALLBACK_AUTHORITY,query:null,fragment:null}):e}asFileUri(e){let t=this.toUri(e);return this.uriToFileUri(t)}uriToFileUri(e){return e.scheme===Y.vscodeFileResource?e.with({scheme:Y.file,authority:e.authority!==r.FALLBACK_AUTHORITY?e.authority:null,query:null,fragment:null}):e}toUri(e){if(m.isUri(e))return e;if(globalThis._VSCODE_FILE_ROOT){let t=globalThis._VSCODE_FILE_ROOT;if(/^\w[\w\d+.-]*:\/\//.test(t))return m.joinPath(m.parse(t,!0),e);let n=J(t,e);return m.file(n)}throw new Error("Cannot determine URI for module id!")}},Ct=new _o,pm=Object.freeze({"Cache-Control":"no-cache, no-store"}),fm=Object.freeze({"Document-Policy":"include-js-call-stacks-in-crash-reports"}),mp;(s=>{let r=new Map([["1",{"Cross-Origin-Opener-Policy":"same-origin"}],["2",{"Cross-Origin-Embedder-Policy":"require-corp"}],["3",{"Cross-Origin-Opener-Policy":"same-origin","Cross-Origin-Embedder-Policy":"require-corp"}]]);s.CoopAndCoep=Object.freeze(r.get("3"));let t="vscode-coi";function n(o){let a;typeof o=="string"?a=new URL(o).searchParams:o instanceof URL?a=o.searchParams:m.isUri(o)&&(a=new URL(o.toString(!0)).searchParams);let l=a?.get(t);if(l)return r.get(l)}s.getHeadersFromQuery=n;function i(o,a,l){if(!globalThis.crossOriginIsolated)return;let c=a&&l?"3":l?"2":"1";o instanceof URLSearchParams?o.set(t,c):o[t]=c}s.addSearchParam=i})(mp||={});function ct(r){return cr(r,!0)}var ur=class{constructor(e){this._ignorePathCasing=e}compare(e,t,n=!1){return e===t?0:ar(this.getComparisonKey(e,n),this.getComparisonKey(t,n))}isEqual(e,t,n=!1){return e===t?!0:!e||!t?!1:this.getComparisonKey(e,n)===this.getComparisonKey(t,n)}getComparisonKey(e,t=!1){return e.with({path:this._ignorePathCasing(e)?e.path.toLowerCase():void 0,fragment:t?null:void 0}).toString()}ignorePathCasing(e){return this._ignorePathCasing(e)}isEqualOrParent(e,t,n=!1){if(e.scheme===t.scheme){if(e.scheme===Y.file)return lt(ct(e),ct(t),this._ignorePathCasing(e))&&e.query===t.query&&(n||e.fragment===t.fragment);if(ec(e.authority,t.authority))return lt(e.path,t.path,this._ignorePathCasing(e),"/")&&e.query===t.query&&(n||e.fragment===t.fragment)}return!1}joinPath(e,...t){return m.joinPath(e,...t)}basenameOrAuthority(e){return Eo(e)||e.authority}basename(e,t){return U.basename(e.path,t)}extname(e){return U.extname(e.path)}dirname(e){if(e.path.length===0)return e;let t;return e.scheme===Y.file?t=m.file(be(ct(e))).path:(t=U.dirname(e.path),e.authority&&t.length&&t.charCodeAt(0)!==47&&(console.error(`dirname("${e.toString})) resulted in a relative path`),t="/")),e.with({path:t})}normalizePath(e){if(!e.path.length)return e;let t;return e.scheme===Y.file?t=m.file(Me(ct(e))).path:t=U.normalize(e.path),e.with({path:t})}relativePath(e,t){if(e.scheme!==t.scheme||!ec(e.authority,t.authority))return;if(e.scheme===Y.file){let s=kl(ct(e),ct(t));return $?bo(s):s}let n=e.path||"/",i=t.path||"/";if(this._ignorePathCasing(e)){let s=0;for(let o=Math.min(n.length,i.length);s<o&&!(n.charCodeAt(s)!==i.charCodeAt(s)&&n.charAt(s).toLowerCase()!==i.charAt(s).toLowerCase());s++);n=i.substr(0,s)+n.substr(s)}return U.relative(n,i)}resolvePath(e,t){if(e.scheme===Y.file){let n=m.file(Vt(ct(e),t));return e.with({authority:n.authority,path:n.path})}return t=Kl(t),e.with({path:U.resolve(e.path,t)})}isAbsolutePath(e){return!!e.path&&e.path[0]==="/"}isEqualAuthority(e,t){return e===t||e!==void 0&&t!==void 0&&Kt(e,t)}hasTrailingPathSeparator(e,t=ie){if(e.scheme===Y.file){let n=ct(e);return n.length>yo(n).length&&n[n.length-1]===t}else{let n=e.path;return n.length>1&&n.charCodeAt(n.length-1)===47&&!/^[a-zA-Z]:(\/$|\\$)/.test(e.fsPath)}}removeTrailingPathSeparator(e,t=ie){return tc(e,t)?e.with({path:e.path.substr(0,e.path.length-1)}):e}addTrailingPathSeparator(e,t=ie){let n=!1;if(e.scheme===Y.file){let i=ct(e);n=i!==void 0&&i.length===yo(i).length&&i[i.length-1]===t}else{t="/";let i=e.path;n=i.length===1&&i.charCodeAt(i.length-1)===47}return!n&&!tc(e,t)?e.with({path:e.path+"/"}):e}},N=new ur(()=>!1),mn=new ur(r=>r.scheme===Y.file?!te:!0),nc=new ur(r=>!0),Im=N.isEqual.bind(N),Tm=N.isEqualOrParent.bind(N),Sm=N.getComparisonKey.bind(N),_m=N.basenameOrAuthority.bind(N),Eo=N.basename.bind(N),xm=N.extname.bind(N),rc=N.dirname.bind(N),se=N.joinPath.bind(N),ic=N.normalizePath.bind(N),Em=N.relativePath.bind(N),Rm=N.resolvePath.bind(N),sc=N.isAbsolutePath.bind(N),ec=N.isEqualAuthority.bind(N),tc=N.hasTrailingPathSeparator.bind(N),wm=N.removeTrailingPathSeparator.bind(N),Cm=N.addTrailingPathSeparator.bind(N);var vp;(s=>{s.META_DATA_LABEL="label",s.META_DATA_DESCRIPTION="description",s.META_DATA_SIZE="size",s.META_DATA_MIME="mime";function i(o){let a=new Map;o.path.substring(o.path.indexOf(";")+1,o.path.lastIndexOf(";")).split(";").forEach(d=>{let[u,p]=d.split(":");u&&p&&a.set(u,p)});let c=o.path.substring(0,o.path.indexOf(";"));return c&&a.set(s.META_DATA_MIME,c),a}s.parseMetaData=i})(vp||={});var oc=Symbol("MicrotaskDelay");function Si(r){return!!r&&typeof r.then=="function"}function yn(r){let e=new Ee,t=r(e.token),n=!1,i=new Promise((s,o)=>{let a=e.token.onCancellationRequested(()=>{n=!0,a.dispose(),o(new _e)});Promise.resolve(t).then(l=>{a.dispose(),e.dispose(),n?ni(l)&&l.dispose():s(l)},l=>{a.dispose(),e.dispose(),o(l)})});return new class{cancel(){e.cancel(),e.dispose()}then(s,o){return i.then(s,o)}catch(s){return this.then(void 0,s)}finally(s){return i.finally(s)}}}var Ro=class{constructor(){this.activePromise=null,this.queuedPromise=null,this.queuedPromiseFactory=null,this.cancellationTokenSource=new Ee}queue(e){if(this.cancellationTokenSource.token.isCancellationRequested)return Promise.reject(new Error("Throttler is disposed"));if(this.activePromise){if(this.queuedPromiseFactory=e,!this.queuedPromise){let t=()=>{if(this.queuedPromise=null,this.cancellationTokenSource.token.isCancellationRequested)return;let n=this.queue(this.queuedPromiseFactory);return this.queuedPromiseFactory=null,n};this.queuedPromise=new Promise(n=>{this.activePromise.then(t,t).then(n)})}return new Promise((t,n)=>{this.queuedPromise.then(t,n)})}return this.activePromise=e(this.cancellationTokenSource.token),new Promise((t,n)=>{this.activePromise.then(i=>{this.activePromise=null,t(i)},i=>{this.activePromise=null,n(i)})})}dispose(){this.cancellationTokenSource.cancel()}};var vi=class{constructor(){this.promiseMap=new Map}queue(e,t){let i=(this.promiseMap.get(e)??Promise.resolve()).catch(()=>{}).then(t).finally(()=>{this.promiseMap.get(e)===i&&this.promiseMap.delete(e)});return this.promiseMap.set(e,i),i}peek(e){return this.promiseMap.get(e)||void 0}keys(){return this.promiseMap.keys()}},bp=(r,e)=>{let t=!0,n=setTimeout(()=>{t=!1,e()},r);return{isTriggered:()=>t,dispose:()=>{clearTimeout(n),t=!1}}},yp=r=>{let e=!0;return queueMicrotask(()=>{e&&(e=!1,r())}),{isTriggered:()=>e,dispose:()=>{e=!1}}},dr=class{constructor(e){this.defaultDelay=e;this.deferred=null,this.completionPromise=null,this.doResolve=null,this.doReject=null,this.task=null}trigger(e,t=this.defaultDelay){this.task=e,this.cancelTimeout(),this.completionPromise||(this.completionPromise=new Promise((i,s)=>{this.doResolve=i,this.doReject=s}).then(()=>{if(this.completionPromise=null,this.doResolve=null,this.task){let i=this.task;return this.task=null,i()}}));let n=()=>{this.deferred=null,this.doResolve?.(null)};return this.deferred=t===oc?yp(n):bp(t,n),this.completionPromise}isTriggered(){return!!this.deferred?.isTriggered()}cancel(){this.cancelTimeout(),this.completionPromise&&(this.doReject?.(new _e),this.completionPromise=null)}cancelTimeout(){this.deferred?.dispose(),this.deferred=null}dispose(){this.cancel()}},zt=class{constructor(e){this.delayer=new dr(e),this.throttler=new Ro}trigger(e,t){return this.delayer.trigger(()=>this.throttler.queue(e),t)}isTriggered(){return this.delayer.isTriggered()}cancel(){this.delayer.cancel()}dispose(){this.delayer.dispose(),this.throttler.dispose()}},bi=class{constructor(){this._isOpen=!1,this._promise=new Promise((e,t)=>{this._completePromise=e})}isOpen(){return this._isOpen}open(){this._isOpen=!0,this._completePromise(!0)}wait(){return this._promise}};function jt(r,e){return e?new Promise((t,n)=>{let i=setTimeout(()=>{s.dispose(),t()},r),s=e.onCancellationRequested(()=>{clearTimeout(i),s.dispose(),n(new _e)})}):yn(t=>jt(r,t))}var wo=class{constructor(e){this._size=0;this._isDisposed=!1;this.maxDegreeOfParalellism=e,this.outstandingPromises=[],this.runningPromises=0,this._onDrained=new I}whenIdle(){return this.size>0?V.toPromise(this.onDrained):Promise.resolve()}get onDrained(){return this._onDrained.event}get size(){return this._size}queue(e){if(this._isDisposed)throw new Error("Object has been disposed");return this._size++,new Promise((t,n)=>{this.outstandingPromises.push({factory:e,c:t,e:n}),this.consume()})}consume(){for(;this.outstandingPromises.length&&this.runningPromises<this.maxDegreeOfParalellism;){let e=this.outstandingPromises.shift();this.runningPromises++;let t=e.factory();t.then(e.c,e.e),t.then(()=>this.consumed(),()=>this.consumed())}}consumed(){this._isDisposed||(this.runningPromises--,--this._size===0&&this._onDrained.fire(),this.outstandingPromises.length>0&&this.consume())}clear(){if(this._isDisposed)throw new Error("Object has been disposed");this.outstandingPromises.length=0,this._size=this.runningPromises}dispose(){this._isDisposed=!0,this.outstandingPromises.length=0,this._size=0,this._onDrained.dispose()}},Co=class extends wo{constructor(){super(1)}};var vn=class{constructor(){this.queues=new Map;this.drainers=new Set;this.drainListeners=void 0;this.drainListenerCount=0}async whenDrained(){if(this.isDrained())return;let e=new Ze;return this.drainers.add(e),e.p}isDrained(){for(let[,e]of this.queues)if(e.size>0)return!1;return!0}queueSize(e,t=N){let n=t.getComparisonKey(e);return this.queues.get(n)?.size??0}queueFor(e,t,n=N){let i=n.getComparisonKey(e),s=this.queues.get(i);if(!s){s=new Co;let o=this.drainListenerCount++,a=V.once(s.onDrained)(()=>{s?.dispose(),this.queues.delete(i),this.onDidQueueDrain(),this.drainListeners?.deleteAndDispose(o),this.drainListeners?.size===0&&(this.drainListeners.dispose(),this.drainListeners=void 0)});this.drainListeners||(this.drainListeners=new Ye),this.drainListeners.set(o,a),this.queues.set(i,s)}return s.queue(t)}onDidQueueDrain(){this.isDrained()&&this.releaseDrainers()}releaseDrainers(){for(let e of this.drainers)e.complete();this.drainers.clear()}dispose(){for(let[,e]of this.queues)e.dispose();this.queues.clear(),this.releaseDrainers(),this.drainListeners?.dispose()}};var yi=class{constructor(e,t){this.timeoutToken=void 0,this.runner=e,this.timeout=t,this.timeoutHandler=this.onTimeout.bind(this)}dispose(){this.cancel(),this.runner=null}cancel(){this.isScheduled()&&(clearTimeout(this.timeoutToken),this.timeoutToken=void 0)}schedule(e=this.timeout){this.cancel(),this.timeoutToken=setTimeout(this.timeoutHandler,e)}get delay(){return this.timeout}set delay(e){this.timeout=e}isScheduled(){return this.timeoutToken!==void 0}flush(){this.isScheduled()&&(this.cancel(),this.doRun())}onTimeout(){this.timeoutToken=void 0,this.runner&&this.doRun()}doRun(){this.runner?.()}};var Ii=class extends yi{constructor(t,n){super(t,n);this.units=[]}work(t){this.units.push(t),this.isScheduled()||this.schedule()}doRun(){let t=this.units;this.units=[],this.runner?.(t)}dispose(){this.units=[],super.dispose()}},bn=class extends A{constructor(t,n){super();this.options=t;this.handler=n;this.pendingWork=[];this.throttler=this._register(new St);this.disposed=!1;this.lastExecutionTime=0}get pending(){return this.pendingWork.length}work(t){if(this.disposed)return!1;if(typeof this.options.maxBufferedWork=="number"){if(this.throttler.value){if(this.pending+t.length>this.options.maxBufferedWork)return!1}else if(this.pending+t.length-this.options.maxWorkChunkSize>this.options.maxBufferedWork)return!1}for(let i of t)this.pendingWork.push(i);let n=Date.now()-this.lastExecutionTime;return!this.throttler.value&&(!this.options.waitThrottleDelayBetweenWorkUnits||n>=this.options.throttleDelay)?this.doWork():!this.throttler.value&&this.options.waitThrottleDelayBetweenWorkUnits&&this.scheduleThrottler(Math.max(this.options.throttleDelay-n,0)),!0}doWork(){this.lastExecutionTime=Date.now(),this.handler(this.pendingWork.splice(0,this.options.maxWorkChunkSize)),this.pendingWork.length>0&&this.scheduleThrottler()}scheduleThrottler(t=this.options.throttleDelay){this.throttler.value=new yi(()=>{this.throttler.clear(),this.doWork()},t),this.throttler.value.schedule()}dispose(){super.dispose(),this.pendingWork.length=0,this.disposed=!0}},Ip,mi;(function(){let r=globalThis;typeof r.requestIdleCallback!="function"||typeof r.cancelIdleCallback!="function"?mi=(e,t,n)=>{bl(()=>{if(i)return;let s=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,s-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:mi=(e,t,n)=>{let i=e.requestIdleCallback(t,typeof n=="number"?{timeout:n}:void 0),s=!1;return{dispose(){s||(s=!0,e.cancelIdleCallback(i))}}},Ip=(e,t)=>mi(globalThis,e,t)})();var Po=class{constructor(e,t){this._didRun=!1;this._executor=()=>{try{this._value=t()}catch(n){this._error=n}finally{this._didRun=!0}},this._handle=mi(e,()=>this._executor())}dispose(){this._handle.dispose()}get value(){if(this._didRun||(this._handle.dispose(),this._executor()),this._error)throw this._error;return this._value}get isInitialized(){return this._didRun}},Ti=class extends Po{constructor(e){super(globalThis,e)}};async function cc(r,e,t){let n;for(let i=0;i<t;i++)try{return await r()}catch(s){n=s,await jt(e)}throw n}var Ze=class r{static fromPromise(e){let t=new r;return t.settleWith(e),t}get isRejected(){return this.outcome?.outcome===1}get isResolved(){return this.outcome?.outcome===0}get isSettled(){return!!this.outcome}get value(){return this.outcome?.outcome===0?this.outcome?.value:void 0}constructor(){this.p=new Promise((e,t)=>{this.completeCallback=e,this.errorCallback=t})}complete(e){return this.isSettled?Promise.resolve():new Promise(t=>{this.completeCallback(e),this.outcome={outcome:0,value:e},t()})}error(e){return this.isSettled?Promise.resolve():new Promise(t=>{this.errorCallback(e),this.outcome={outcome:1,value:e},t()})}settleWith(e){return e.then(t=>this.complete(t),t=>this.error(t))}cancel(){return this.error(new _e)}},Ht;(t=>{async function r(n){let i,s=await Promise.all(n.map(o=>o.then(a=>a,a=>{i||(i=a)})));if(typeof i<"u")throw i;return s}t.settled=r;function e(n){return new Promise(async(i,s)=>{try{await n(i,s)}catch(o){s(o)}})}t.withAsyncBody=e})(Ht||={});var ac=class r{static fromArray(e){return new r(t=>{t.emitMany(e)})}static fromPromise(e){return new r(async t=>{t.emitMany(await e)})}static fromPromisesResolveOrder(e){return new r(async t=>{await Promise.all(e.map(async n=>t.emitOne(await n)))})}static merge(e){return new r(async t=>{await Promise.all(e.map(async n=>{for await(let i of n)t.emitOne(i)}))})}static{this.EMPTY=r.fromArray([])}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new I,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await V.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,t){return new r(async n=>{for await(let i of e)n.emitOne(t(i))})}map(e){return r.map(this,e)}static filter(e,t){return new r(async n=>{for await(let i of e)t(i)&&n.emitOne(i)})}filter(e){return r.filter(this,e)}static coalesce(e){return r.filter(e,t=>!!t)}coalesce(){return r.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return r.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};var Do=class{constructor(){this._unsatisfiedConsumers=[];this._unconsumedValues=[]}get hasFinalValue(){return!!this._finalValue}produce(e){if(this._ensureNoFinalValue(),this._unsatisfiedConsumers.length>0){let t=this._unsatisfiedConsumers.shift();this._resolveOrRejectDeferred(t,e)}else this._unconsumedValues.push(e)}produceFinal(e){this._ensureNoFinalValue(),this._finalValue=e;for(let t of this._unsatisfiedConsumers)this._resolveOrRejectDeferred(t,e);this._unsatisfiedConsumers.length=0}_ensureNoFinalValue(){if(this._finalValue)throw new H("ProducerConsumer: cannot produce after final value has been set")}_resolveOrRejectDeferred(e,t){t.ok?e.complete(t.value):e.error(t.error)}consume(){if(this._unconsumedValues.length>0||this._finalValue){let e=this._unconsumedValues.length>0?this._unconsumedValues.shift():this._finalValue;return e.ok?Promise.resolve(e.value):Promise.reject(e.error)}else{let e=new Ze;return this._unsatisfiedConsumers.push(e),e.p}}},lc=class r{constructor(e,t){this._onReturn=t;this._producerConsumer=new Do;this._iterator={next:()=>this._producerConsumer.consume(),return:()=>(this._onReturn?.(),Promise.resolve({done:!0,value:void 0})),throw:async e=>(this._finishError(e),{done:!0,value:void 0})};queueMicrotask(async()=>{let n=e({emitOne:i=>this._producerConsumer.produce({ok:!0,value:{done:!1,value:i}}),emitMany:i=>{for(let s of i)this._producerConsumer.produce({ok:!0,value:{done:!1,value:s}})},reject:i=>this._finishError(i)});if(!this._producerConsumer.hasFinalValue)try{await n,this._finishOk()}catch(i){this._finishError(i)}})}static fromArray(e){return new r(t=>{t.emitMany(e)})}static fromPromise(e){return new r(async t=>{t.emitMany(await e)})}static fromPromisesResolveOrder(e){return new r(async t=>{await Promise.all(e.map(async n=>t.emitOne(await n)))})}static merge(e){return new r(async t=>{await Promise.all(e.map(async n=>{for await(let i of n)t.emitOne(i)}))})}static{this.EMPTY=r.fromArray([])}static map(e,t){return new r(async n=>{for await(let i of e)n.emitOne(t(i))})}static tee(e){let t,n,i=new Ze,s=async()=>{if(!(!t||!n))try{for await(let l of e)t.emitOne(l),n.emitOne(l)}catch(l){t.reject(l),n.reject(l)}finally{i.complete()}},o=new r(async l=>(t=l,s(),i.p)),a=new r(async l=>(n=l,s(),i.p));return[o,a]}map(e){return r.map(this,e)}static coalesce(e){return r.filter(e,t=>!!t)}coalesce(){return r.coalesce(this)}static filter(e,t){return new r(async n=>{for await(let i of e)t(i)&&n.emitOne(i)})}filter(e){return r.filter(this,e)}_finishOk(){this._producerConsumer.hasFinalValue||this._producerConsumer.produceFinal({ok:!0,value:{done:!0,value:void 0}})}_finishError(e){this._producerConsumer.hasFinalValue||this._producerConsumer.produceFinal({ok:!1,error:e})}[Symbol.asyncIterator](){return this._iterator}};function pr(r){let e=r;return e?[e.on,e.pause,e.resume,e.destroy].every(t=>typeof t=="function"):!1}function _i(r){let e=r;return e?pr(e.stream)&&Array.isArray(e.buffer)&&typeof e.ended=="boolean":!1}function Gt(r,e){return new Ao(r,e)}var Ao=class{constructor(e,t){this.reducer=e;this.options=t;this.state={flowing:!1,ended:!1,destroyed:!1};this.buffer={data:[],error:[]};this.listeners={data:[],error:[],end:[]};this.pendingWritePromises=[]}pause(){this.state.destroyed||(this.state.flowing=!1)}resume(){this.state.destroyed||this.state.flowing||(this.state.flowing=!0,this.flowData(),this.flowErrors(),this.flowEnd())}write(e){if(!this.state.destroyed){if(this.state.flowing)this.emitData(e);else if(this.buffer.data.push(e),typeof this.options?.highWaterMark=="number"&&this.buffer.data.length>this.options.highWaterMark)return new Promise(t=>this.pendingWritePromises.push(t))}}error(e){this.state.destroyed||(this.state.flowing?this.emitError(e):this.buffer.error.push(e))}end(e){this.state.destroyed||(typeof e<"u"&&this.write(e),this.state.flowing?(this.emitEnd(),this.destroy()):this.state.ended=!0)}emitData(e){this.listeners.data.slice(0).forEach(t=>t(e))}emitError(e){this.listeners.error.length===0?Z(e):this.listeners.error.slice(0).forEach(t=>t(e))}emitEnd(){this.listeners.end.slice(0).forEach(e=>e())}on(e,t){if(!this.state.destroyed)switch(e){case"data":this.listeners.data.push(t),this.resume();break;case"end":this.listeners.end.push(t),this.state.flowing&&this.flowEnd()&&this.destroy();break;case"error":this.listeners.error.push(t),this.state.flowing&&this.flowErrors();break}}removeListener(e,t){if(this.state.destroyed)return;let n;switch(e){case"data":n=this.listeners.data;break;case"end":n=this.listeners.end;break;case"error":n=this.listeners.error;break}if(n){let i=n.indexOf(t);i>=0&&n.splice(i,1)}}flowData(){if(this.buffer.data.length===0)return;if(typeof this.reducer=="function"){let t=this.reducer(this.buffer.data);this.emitData(t)}else for(let t of this.buffer.data)this.emitData(t);this.buffer.data.length=0;let e=[...this.pendingWritePromises];this.pendingWritePromises.length=0,e.forEach(t=>t())}flowErrors(){if(this.listeners.error.length>0){for(let e of this.buffer.error)this.emitError(e);this.buffer.error.length=0}}flowEnd(){return this.state.ended?(this.emitEnd(),this.listeners.end.length>0):!1}destroy(){this.state.destroyed||(this.state.destroyed=!0,this.state.ended=!0,this.buffer.data.length=0,this.buffer.error.length=0,this.listeners.data.length=0,this.listeners.error.length=0,this.listeners.end.length=0,this.pendingWritePromises.length=0)}};function uc(r,e){let t=[],n;for(;(n=r.read())!==null;)t.push(n);return e(t)}function dc(r,e,t){let n=[],i;for(;(i=r.read())!==null&&n.length<t;)n.push(i);return i===null&&n.length>0?e(n):{read:()=>{if(n.length>0)return n.shift();if(typeof i<"u"){let s=i;return i=void 0,s}return r.read()}}}function xi(r,e){return new Promise((t,n)=>{let i=[];Ei(r,{onData:s=>{e&&i.push(s)},onError:s=>{e?n(s):t(void 0)},onEnd:()=>{t(e?e(i):void 0)}})})}function Ei(r,e,t){r.on("error",n=>{t?.isCancellationRequested||e.onError(n)}),r.on("end",()=>{t?.isCancellationRequested||e.onEnd()}),r.on("data",n=>{t?.isCancellationRequested||e.onData(n)})}function pc(r,e){return new Promise((t,n)=>{let i=new D,s=[],o=c=>{if(s.push(c),s.length>e)return i.dispose(),r.pause(),t({stream:r,buffer:s,ended:!1})},a=c=>(i.dispose(),n(c)),l=()=>(i.dispose(),t({stream:r,buffer:s,ended:!0}));i.add(O(()=>r.removeListener("error",a))),r.on("error",a),i.add(O(()=>r.removeListener("end",l))),r.on("end",l),i.add(O(()=>r.removeListener("data",o))),r.on("data",o)})}function fc(r){let e=!1;return{read:()=>e?null:(e=!0,r)}}function ko(r,e,t){let n=Gt(t);return Ei(r,{onData:i=>n.write(e.data(i)),onError:i=>n.error(e.error?e.error(i):i),onEnd:()=>n.end()}),n}var fr=typeof Buffer<"u",Sp=new Ce(()=>new Uint8Array(256)),Lo,Oo,x=class r{static alloc(e){return fr?new r(Buffer.allocUnsafe(e)):new r(new Uint8Array(e))}static wrap(e){return fr&&!Buffer.isBuffer(e)&&(e=Buffer.from(e.buffer,e.byteOffset,e.byteLength)),new r(e)}static fromString(e,t){return!(t?.dontUseNodeBuffer||!1)&&fr?new r(Buffer.from(e)):(Lo||(Lo=new TextEncoder),new r(Lo.encode(e)))}static fromByteArray(e){let t=r.alloc(e.length);for(let n=0,i=e.length;n<i;n++)t.buffer[n]=e[n];return t}static concat(e,t){if(typeof t>"u"){t=0;for(let s=0,o=e.length;s<o;s++)t+=e[s].byteLength}let n=r.alloc(t),i=0;for(let s=0,o=e.length;s<o;s++){let a=e[s];n.set(a,i),i+=a.byteLength}return n}static isNativeBuffer(e){return fr&&Buffer.isBuffer(e)}constructor(e){this.buffer=e,this.byteLength=this.buffer.byteLength}clone(){let e=r.alloc(this.byteLength);return e.set(this),e}toString(){return fr?this.buffer.toString():(Oo||(Oo=new TextDecoder(void 0,{ignoreBOM:!0})),Oo.decode(this.buffer))}slice(e,t){return new r(this.buffer.subarray(e,t))}set(e,t){if(e instanceof r)this.buffer.set(e.buffer,t);else if(e instanceof Uint8Array)this.buffer.set(e,t);else if(e instanceof ArrayBuffer)this.buffer.set(new Uint8Array(e),t);else if(ArrayBuffer.isView(e))this.buffer.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t);else throw new Error("Unknown argument 'array'")}readUInt32BE(e){return xp(this.buffer,e)}writeUInt32BE(e,t){Ep(this.buffer,e,t)}readUInt32LE(e){return Rp(this.buffer,e)}writeUInt32LE(e,t){wp(this.buffer,e,t)}readUInt8(e){return Cp(this.buffer,e)}writeUInt8(e,t){Pp(this.buffer,e,t)}indexOf(e,t=0){return _p(this.buffer,e instanceof r?e.buffer:e,t)}equals(e){return this===e?!0:this.byteLength!==e.byteLength?!1:this.buffer.every((t,n)=>t===e.buffer[n])}};function _p(r,e,t=0){let n=e.byteLength,i=r.byteLength;if(n===0)return 0;if(n===1)return r.indexOf(e[0],t);if(n>i-t)return-1;let s=Sp.value;s.fill(e.length);for(let c=0;c<e.length;c++)s[e[c]]=e.length-c-1;let o=t+e.length-1,a=o,l=-1;for(;o<i;)if(r[o]===e[a]){if(a===0){l=o;break}o--,a--}else o+=Math.max(e.length-a,s[r[o]]),a=e.length-1;return l}function xp(r,e){return r[e]*2**24+r[e+1]*2**16+r[e+2]*2**8+r[e+3]}function Ep(r,e,t){r[t+3]=e,e=e>>>8,r[t+2]=e,e=e>>>8,r[t+1]=e,e=e>>>8,r[t]=e}function Rp(r,e){return r[e+0]<<0>>>0|r[e+1]<<8>>>0|r[e+2]<<16>>>0|r[e+3]<<24>>>0}function wp(r,e,t){r[t+0]=e&255,e=e>>>8,r[t+1]=e&255,e=e>>>8,r[t+2]=e&255,e=e>>>8,r[t+3]=e&255}function Cp(r,e){return r[e]}function Pp(r,e,t){r[t]=e}function mc(r){return uc(r,e=>x.concat(e))}function vc(r){return fc(r)}function hr(r){return xi(r,e=>x.concat(e))}async function bc(r){return r.ended?x.concat(r.buffer):x.concat([...r.buffer,await hr(r.stream)])}function yc(r){return Gt(e=>x.concat(e),r)}function Ic(r){let e=0,t=0,n=0,i=new Uint8Array(Math.floor(r.length/4*3)),s=a=>{switch(t){case 3:i[n++]=e|a,t=0;break;case 2:i[n++]=e|a>>>2,e=a<<6,t=3;break;case 1:i[n++]=e|a>>>4,e=a<<4,t=2;break;default:e=a<<2,t=1}};for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);if(l>=65&&l<=90)s(l-65);else if(l>=97&&l<=122)s(l-97+26);else if(l>=48&&l<=57)s(l-48+52);else if(l===43||l===45)s(62);else if(l===47||l===95)s(63);else{if(l===61)break;throw new SyntaxError(`Unexpected base64 character ${r[a]}`)}}let o=n;for(;t>0;)s(0);return x.wrap(i).slice(0,o)}var hc="0123456789abcdef";function gr({buffer:r}){let e="";for(let t=0;t<r.length;t++){let n=r[t];e+=hc[n>>>4],e+=hc[n&15]}return e}function Fo(r){if(r.length%2!==0)throw new SyntaxError("Hex string must have an even length");let e=new Uint8Array(r.length>>1);for(let t=0;t<r.length;)e[t>>1]=gc(r,t++)<<4|gc(r,t++);return x.wrap(e)}function gc(r,e){let t=r.charCodeAt(e);if(t>=48&&t<=57)return t-48;if(t>=97&&t<=102)return t-87;if(t>=65&&t<=70)return t-55;throw new SyntaxError(`Invalid hex character at position ${e}`)}function B(r,e,t){let n=null,i=null;if(typeof t.value=="function"?(n="value",i=t.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof t.get=="function"&&(n="get",i=t.get),!i)throw new Error("not supported");let s=`$memoize$${e}`;t[n]=function(...o){return this.hasOwnProperty(s)||Object.defineProperty(this,s,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,o)}),this[s]}}function mr(r,e=0){if(!r||e>200)return r;if(typeof r=="object"){switch(r.$mid){case 1:return m.revive(r);case 2:return new RegExp(r.source,r.flags);case 17:return new Date(r.source)}if(r instanceof x||r instanceof Uint8Array)return r;if(Array.isArray(r))for(let t=0;t<r.length;++t)r[t]=mr(r[t],e+1);else for(let t in r)Object.hasOwnProperty.call(r,t)&&(r[t]=mr(r[t],e+1))}return r}function Sn(r){switch(r){case 100:return"req";case 101:return"cancel";case 102:return"subscribe";case 103:return"unsubscribe"}}function Ri(r){switch(r){case 200:return"init";case 201:return"reply:";case 202:case 203:return"replyErr:";case 204:return"event:"}}function In(r){let e=0;for(let t=0;;t+=7){let n=r.read(1);if(e|=(n.buffer[0]&127)<<t,!(n.buffer[0]&128))return e}}var Dp=Pt(0);function Tn(r,e){if(e===0){r.write(Dp);return}let t=0;for(let i=e;i!==0;i=i>>>7)t++;let n=x.alloc(t);for(let i=0;e!==0;i++)n.buffer[i]=e&127,e=e>>>7,e>0&&(n.buffer[i]|=128);r.write(n)}var vr=class{constructor(e){this.buffer=e;this.pos=0}read(e){let t=this.buffer.slice(this.pos,this.pos+e);return this.pos+=t.byteLength,t}},wi=class{constructor(){this.buffers=[]}get buffer(){return x.concat(this.buffers)}write(e){this.buffers.push(e)}};function Pt(r){let e=x.alloc(1);return e.writeUInt8(r,0),e}var Qt={Undefined:Pt(0),String:Pt(1),Buffer:Pt(2),VSBuffer:Pt(3),Array:Pt(4),Object:Pt(5),Uint:Pt(6)};function br(r,e){if(typeof e>"u")r.write(Qt.Undefined);else if(typeof e=="string"){let t=x.fromString(e);r.write(Qt.String),Tn(r,t.byteLength),r.write(t)}else if(x.isNativeBuffer(e)){let t=x.wrap(e);r.write(Qt.Buffer),Tn(r,t.byteLength),r.write(t)}else if(e instanceof x)r.write(Qt.VSBuffer),Tn(r,e.byteLength),r.write(e);else if(Array.isArray(e)){r.write(Qt.Array),Tn(r,e.length);for(let t of e)br(r,t)}else if(typeof e=="number"&&(e|0)===e)r.write(Qt.Uint),Tn(r,e);else{let t=x.fromString(JSON.stringify(e));r.write(Qt.Object),Tn(r,t.byteLength),r.write(t)}}function xn(r){switch(r.read(1).readUInt8(0)){case 0:return;case 1:return r.read(In(r)).toString();case 2:return r.read(In(r)).buffer;case 3:return r.read(In(r));case 4:{let t=In(r),n=[];for(let i=0;i<t;i++)n.push(xn(r));return n}case 5:return JSON.parse(r.read(In(r)).toString());case 6:return In(r)}}var yr=class{constructor(e,t,n=null,i=1e3){this.protocol=e;this.ctx=t;this.logger=n;this.timeoutDelay=i;this.channels=new Map;this.activeRequests=new Map;this.pendingRequests=new Map;this.protocolListener=this.protocol.onMessage(s=>this.onRawMessage(s)),this.sendResponse({type:200})}registerChannel(e,t){this.channels.set(e,t),setTimeout(()=>this.flushPendingRequests(e),0)}sendResponse(e){switch(e.type){case 200:{let t=this.send([e.type]);this.logger?.logOutgoing(t,0,1,Ri(e.type));return}case 201:case 202:case 204:case 203:{let t=this.send([e.type,e.id],e.data);this.logger?.logOutgoing(t,e.id,1,Ri(e.type),e.data);return}}}send(e,t=void 0){let n=new wi;return br(n,e),br(n,t),this.sendBuffer(n.buffer)}sendBuffer(e){try{return this.protocol.send(e),e.byteLength}catch{return 0}}onRawMessage(e){let t=new vr(e),n=xn(t),i=xn(t),s=n[0];switch(s){case 100:return this.logger?.logIncoming(e.byteLength,n[1],1,`${Sn(s)}: ${n[2]}.${n[3]}`,i),this.onPromise({type:s,id:n[1],channelName:n[2],name:n[3],arg:i});case 102:return this.logger?.logIncoming(e.byteLength,n[1],1,`${Sn(s)}: ${n[2]}.${n[3]}`,i),this.onEventListen({type:s,id:n[1],channelName:n[2],name:n[3],arg:i});case 101:return this.logger?.logIncoming(e.byteLength,n[1],1,`${Sn(s)}`),this.disposeActiveRequest({type:s,id:n[1]});case 103:return this.logger?.logIncoming(e.byteLength,n[1],1,`${Sn(s)}`),this.disposeActiveRequest({type:s,id:n[1]})}}onPromise(e){let t=this.channels.get(e.channelName);if(!t){this.collectPendingRequest(e);return}let n=new Ee,i;try{i=t.call(this.ctx,e.name,e.arg,n.token)}catch(a){i=Promise.reject(a)}let s=e.id;i.then(a=>{this.sendResponse({id:s,data:a,type:201})},a=>{a instanceof Error?this.sendResponse({id:s,data:{message:a.message,name:a.name,stack:a.stack?a.stack.split(`
`):void 0},type:202}):this.sendResponse({id:s,data:a,type:203})}).finally(()=>{o.dispose(),this.activeRequests.delete(e.id)});let o=O(()=>n.cancel());this.activeRequests.set(e.id,o)}onEventListen(e){let t=this.channels.get(e.channelName);if(!t){this.collectPendingRequest(e);return}let n=e.id,s=t.listen(this.ctx,e.name,e.arg)(o=>this.sendResponse({id:n,data:o,type:204}));this.activeRequests.set(e.id,s)}disposeActiveRequest(e){let t=this.activeRequests.get(e.id);t&&(t.dispose(),this.activeRequests.delete(e.id))}collectPendingRequest(e){let t=this.pendingRequests.get(e.channelName);t||(t=[],this.pendingRequests.set(e.channelName,t));let n=setTimeout(()=>{console.error(`Unknown channel: ${e.channelName}`),e.type===100&&this.sendResponse({id:e.id,data:{name:"Unknown channel",message:`Channel name '${e.channelName}' timed out after ${this.timeoutDelay}ms`,stack:void 0},type:202})},this.timeoutDelay);t.push({request:e,timeoutTimer:n})}flushPendingRequests(e){let t=this.pendingRequests.get(e);if(t){for(let n of t)switch(clearTimeout(n.timeoutTimer),n.request.type){case 100:this.onPromise(n.request);break;case 102:this.onEventListen(n.request);break}this.pendingRequests.delete(e)}}dispose(){this.protocolListener&&(this.protocolListener.dispose(),this.protocolListener=null),xe(this.activeRequests.values()),this.activeRequests.clear()}};var _n=class{constructor(e,t=null){this.protocol=e;this.isDisposed=!1;this.state=0;this.activeRequests=new Set;this.handlers=new Map;this.lastRequestId=0;this._onDidInitialize=new I;this.onDidInitialize=this._onDidInitialize.event;this.protocolListener=this.protocol.onMessage(n=>this.onBuffer(n)),this.logger=t}getChannel(e){let t=this;return{call(n,i,s){return t.isDisposed?Promise.reject(new _e):t.requestPromise(e,n,i,s)},listen(n,i){return t.isDisposed?V.None:t.requestEvent(e,n,i)}}}requestPromise(e,t,n,i=Ke.None){let s=this.lastRequestId++,a={id:s,type:100,channelName:e,name:t,arg:n};if(i.isCancellationRequested)return Promise.reject(new _e);let l,c;return new Promise((u,p)=>{if(i.isCancellationRequested)return p(new _e);let h=()=>{let W=j=>{switch(j.type){case 201:this.handlers.delete(s),u(j.data);break;case 202:{this.handlers.delete(s);let Pe=new Error(j.data.message);Pe.stack=Array.isArray(j.data.stack)?j.data.stack.join(`
`):j.data.stack,Pe.name=j.data.name,p(Pe);break}case 203:this.handlers.delete(s),p(j.data);break}};this.handlers.set(s,W),this.sendRequest(a)},g=null;this.state===1?h():(g=yn(W=>this.whenInitialized()),g.then(()=>{g=null,h()}));let b=()=>{g?(g.cancel(),g=null):this.sendRequest({id:s,type:101}),p(new _e)};l=i.onCancellationRequested(b),c={dispose:an(()=>{b(),l.dispose()})},this.activeRequests.add(c)}).finally(()=>{l?.dispose(),this.activeRequests.delete(c)})}requestEvent(e,t,n){let i=this.lastRequestId++,o={id:i,type:102,channelName:e,name:t,arg:n},a=null,l=new I({onWillAddFirstListener:()=>{let d=()=>{this.activeRequests.add(l),this.sendRequest(o)};this.state===1?d():(a=yn(u=>this.whenInitialized()),a.then(()=>{a=null,d()}))},onDidRemoveLastListener:()=>{a?(a.cancel(),a=null):(this.activeRequests.delete(l),this.sendRequest({id:i,type:103})),this.handlers.delete(i)}}),c=d=>l.fire(d.data);return this.handlers.set(i,c),l.event}sendRequest(e){switch(e.type){case 100:case 102:{let t=this.send([e.type,e.id,e.channelName,e.name],e.arg);this.logger?.logOutgoing(t,e.id,0,`${Sn(e.type)}: ${e.channelName}.${e.name}`,e.arg);return}case 101:case 103:{let t=this.send([e.type,e.id]);this.logger?.logOutgoing(t,e.id,0,Sn(e.type));return}}}send(e,t=void 0){let n=new wi;return br(n,e),br(n,t),this.sendBuffer(n.buffer)}sendBuffer(e){try{return this.protocol.send(e),e.byteLength}catch{return 0}}onBuffer(e){let t=new vr(e),n=xn(t),i=xn(t),s=n[0];switch(s){case 200:return this.logger?.logIncoming(e.byteLength,0,0,Ri(s)),this.onResponse({type:n[0]});case 201:case 202:case 204:case 203:return this.logger?.logIncoming(e.byteLength,n[1],0,Ri(s),i),this.onResponse({type:n[0],id:n[1],data:i})}}onResponse(e){if(e.type===200){this.state=1,this._onDidInitialize.fire();return}this.handlers.get(e.id)?.(e)}get onDidInitializePromise(){return V.toPromise(this.onDidInitialize)}whenInitialized(){return this.state===1?Promise.resolve():this.onDidInitializePromise}dispose(){this.isDisposed=!0,this.protocolListener&&(this.protocolListener.dispose(),this.protocolListener=null),xe(this.activeRequests.values()),this.activeRequests.clear(),this._onDidInitialize.dispose()}};P([B],_n.prototype,"onDidInitializePromise",1);var Ci=class{constructor(e,t,n){this.channels=new Map;this._connections=new Set;this._onDidAddConnection=new I;this.onDidAddConnection=this._onDidAddConnection.event;this._onDidRemoveConnection=new I;this.onDidRemoveConnection=this._onDidRemoveConnection.event;this.disposables=new D;this.disposables.add(e(({protocol:i,onDidClientDisconnect:s})=>{let o=V.once(i.onMessage);this.disposables.add(o(a=>{let l=new vr(a),c=xn(l),d=new yr(i,c,t,n),u=new _n(i,t);this.channels.forEach((h,g)=>d.registerChannel(g,h));let p={channelServer:d,channelClient:u,ctx:c};this._connections.add(p),this._onDidAddConnection.fire(p),this.disposables.add(s(()=>{d.dispose(),u.dispose(),this._connections.delete(p),this._onDidRemoveConnection.fire(p)}))}))}))}get connections(){let e=[];return this._connections.forEach(t=>e.push(t)),e}getChannel(e,t){let n=this;return{call(i,s,o){let a;if(Ys(t)){let c=Ha(n.connections.filter(t));a=c?Promise.resolve(c):V.toPromise(V.filter(n.onDidAddConnection,t))}else a=t.routeCall(n,i,s);let l=a.then(c=>c.channelClient.getChannel(e));return Tc(l).call(i,s,o)},listen(i,s){if(Ys(t))return n.getMulticastEvent(e,t,i,s);let o=t.routeEvent(n,i,s).then(a=>a.channelClient.getChannel(e));return Tc(o).listen(i,s)}}}getMulticastEvent(e,t,n,i){let s=this,o,a=new I({onWillAddFirstListener:()=>{o=new D;let l=new li,c=new Map,d=p=>{let g=p.channelClient.getChannel(e).listen(n,i),b=l.add(g);c.set(p,b)},u=p=>{let h=c.get(p);h&&(h.dispose(),c.delete(p))};s.connections.filter(t).forEach(d),V.filter(s.onDidAddConnection,t)(d,void 0,o),s.onDidRemoveConnection(u,void 0,o),l.event(a.fire,a,o),o.add(l)},onDidRemoveLastListener:()=>{o?.dispose(),o=void 0}});return s.disposables.add(a),a.event}registerChannel(e,t){this.channels.set(e,t);for(let n of this._connections)n.channelServer.registerChannel(e,t)}dispose(){this.disposables.dispose();for(let e of this._connections)e.channelClient.dispose(),e.channelServer.dispose();this._connections.clear(),this.channels.clear(),this._onDidAddConnection.dispose(),this._onDidRemoveConnection.dispose()}};function Tc(r){return{call(e,t,n){return r.then(i=>i.call(e,t,n))},listen(e,t){let n=new sr;return r.then(i=>n.input=i.listen(e,t)),n.event}}}function Sc(r){let e=!1;return{call(t,n,i){return e?r.call(t,n,i):jt(0).then(()=>e=!0).then(()=>r.call(t,n,i))},listen(t,n){if(e)return r.listen(t,n);let i=new sr;return jt(0).then(()=>e=!0).then(()=>i.input=r.listen(t,n)),i.event}}}var En;(i=>{function r(s,o,a){let l=s,c=a?.disableMarshalling,d=new Map;for(let u in l)t(u)&&d.set(u,V.buffer(l[u],u,!0,void 0,o));return new class{listen(u,p,h){let g=d.get(p);if(g)return g;let b=l[p];if(typeof b=="function"){if(n(p))return b.call(l,h);if(t(p))return d.set(p,V.buffer(l[p],p,!0,void 0,o)),d.get(p)}throw new Je(`Event not found: ${p}`)}call(u,p,h){let g=l[p];if(typeof g=="function"){if(!c&&Array.isArray(h))for(let W=0;W<h.length;W++)h[W]=mr(h[W]);let b=g.apply(l,h);return b instanceof Promise||(b=Promise.resolve(b)),b}throw new Je(`Method not found: ${p}`)}}}i.fromService=r;function e(s,o){let a=o?.disableMarshalling;return new Proxy({},{get(l,c){if(typeof c=="string")return o?.properties?.has(c)?o.properties.get(c):n(c)?function(d){return s.listen(c,d)}:t(c)?s.listen(c):async function(...d){let u;o&&!ei(o.context)?u=[o.context,...d]:u=d;let p=await s.call(c,u);return a?p:mr(p)};throw new Je(`Property not found: ${String(c)}`)}})}i.toService=e;function t(s){return s[0]==="o"&&s[1]==="n"&&mo(s.charCodeAt(2))}function n(s){return/^onDynamic/.test(s)&&mo(s.charCodeAt(9))}})(En||={});import{fork as tf}from"child_process";function _c(r){let e=r;return e&&typeof e.type=="string"&&typeof e.severity=="string"}function Ap(r){let e=[],t;try{let n=JSON.parse(r.arguments),i=n[n.length-1];i&&i.__$stack&&(n.pop(),t=i.__$stack),e.push(...n)}catch{e.push("Unable to log remote console arguments",r.arguments)}return{args:e,stack:t}}function kp(r){if(!r)return r;let e=r.indexOf(`
`);return e===-1?r:r.substring(0,e)}function xc(r,e){let{args:t,stack:n}=Ap(r),i=typeof t[0]=="string"&&t.length===1,s=kp(n);s&&(s=`(${s.trim()})`);let o=[];if(typeof t[0]=="string"?s&&i?o=[`%c[${e}] %c${t[0]} %c${s}`,Rn("blue"),Rn(""),Rn("grey")]:o=[`%c[${e}] %c${t[0]}`,Rn("blue"),Rn(""),...t.slice(1)]:o=[`%c[${e}]%`,Rn("blue"),...t],s&&!i&&o.push(s),typeof console[r.severity]!="function")throw new Error("Unknown console method");console[r.severity].apply(console,o)}function Rn(r){return`color: ${r}`}function Uo(r){if(!r||typeof r!="object"||r instanceof RegExp)return r;let e=Array.isArray(r)?[]:{};return Object.entries(r).forEach(([t,n])=>{e[t]=n&&typeof n=="object"?Uo(n):n}),e}import*as ef from"child_process";import{promises as nv}from"fs";function Ec(r){r&&(delete r.DEBUG,te&&delete r.LD_PRELOAD)}import*as w from"fs";import{tmpdir as Np}from"os";import{promisify as Tr}from"util";var Lp=new Tt(1e4);function Ir(r){return Rc(r,"NFC",Lp)}var Op=new Tt(1e4);function Fp(r){return Rc(r,"NFD",Op)}var Up=/[^\u0000-\u0080]/;function Rc(r,e,t){if(!r)return r;let n=t.get(r);if(n)return n;let i;return Up.test(r)?i=r.normalize(e):i=r,t.set(r,i),i}var M1=(function(){let r=new Tt(1e4),e=/[\u0300-\u036f]/g;return function(t){let n=r.get(t);if(n)return n;let i=Fp(t).replace(e,""),s=(i.length===t.length?i:t).toLowerCase();return r.set(t,s),s}})();async function Pc(r,e=0,t){if(Io(r))throw new Error("rimraf - will refuse to recursively delete root");return e===0?No(r):Mp(r,t)}async function Mp(r,e=Hl(Np())){try{try{await w.promises.rename(r,e)}catch(t){return t.code==="ENOENT"?void 0:No(r)}No(e).catch(()=>{})}catch(t){if(t.code!=="ENOENT")throw t}}async function No(r){return w.promises.rm(r,{recursive:!0,force:!0,maxRetries:3})}async function Pi(r,e){try{return await wc(r,e)}catch(t){if(t.code==="ENOENT"&&$&&Io(r))try{return await wc(`${r}.`,e)}catch{}throw t}}async function wc(r,e){return Bp(await(e?Wp(r):w.promises.readdir(r)))}async function Wp(r){try{return await w.promises.readdir(r,{withFileTypes:!0})}catch(n){n.code!=="ENOENT"&&console.warn("[node.js fs] readdir with filetypes failed with error: ",n)}let e=[],t=await Pi(r);for(let n of t){let i=!1,s=!1,o=!1;try{let a=await w.promises.lstat(J(r,n));i=a.isFile(),s=a.isDirectory(),o=a.isSymbolicLink()}catch(a){a.code!=="ENOENT"&&console.warn("[node.js fs] unexpected error from lstat after readdir: ",a)}e.push({name:n,isFile:()=>i,isDirectory:()=>s,isSymbolicLink:()=>o})}return e}function Bp(r){return r.map(e=>typeof e=="string"?$e?Ir(e):e:(e.name=$e?Ir(e.name):e.name,e))}async function Vp(r){let e=await Pi(r),t=[];for(let n of e)await et.existsDirectory(J(r,n))&&t.push(n);return t}var et;(n=>{async function r(i){let s;try{if(s=await w.promises.lstat(i),!s.isSymbolicLink())return{stat:s}}catch{}try{return{stat:await w.promises.stat(i),symbolicLink:s?.isSymbolicLink()?{dangling:!1}:void 0}}catch(o){if(o.code==="ENOENT"&&s)return{stat:s,symbolicLink:{dangling:!0}};if($&&o.code==="EACCES")try{return{stat:await w.promises.stat(await w.promises.readlink(i)),symbolicLink:{dangling:!1}}}catch(a){if(a.code==="ENOENT"&&s)return{stat:s,symbolicLink:{dangling:!0}};throw a}throw o}}n.stat=r;async function e(i){try{let{stat:s,symbolicLink:o}=await n.stat(i);return s.isFile()&&o?.dangling!==!0}catch{}return!1}n.existsFile=e;async function t(i){try{let{stat:s,symbolicLink:o}=await n.stat(i);return s.isDirectory()&&o?.dangling!==!0}catch{}return!1}n.existsDirectory=t})(et||={});var qp=new vn;function $p(r,e,t){return qp.queueFor(m.file(r),()=>{let n=jp(t);return new Promise((i,s)=>zp(r,e,n,o=>o?s(o):i()))},mn)}var Dc=!0;function Kp(r){Dc=r}function zp(r,e,t,n){if(!Dc)return w.writeFile(r,e,{mode:t.mode,flag:t.flag},n);w.open(r,t.flag,t.mode,(i,s)=>{if(i)return n(i);w.writeFile(s,e,o=>{if(o)return w.close(s,()=>n(o));w.fdatasync(s,a=>(a&&(console.warn("[node.js fs] fdatasync is now disabled for this session because it failed: ",a),Kp(!1)),w.close(s,l=>n(l))))})})}function jp(r){return r?{mode:typeof r.mode=="number"?r.mode:438,flag:typeof r.flag=="string"?r.flag:"w"}:{mode:438,flag:"w"}}async function Hp(r,e,t=6e4){if(r!==e)try{$&&typeof t=="number"?await Ac(r,e,Date.now(),t):await w.promises.rename(r,e)}catch(n){if(r.toLowerCase()!==e.toLowerCase()&&n.code==="EXDEV"||r.endsWith("."))await kc(r,e,{preserveSymlinks:!1}),await Pc(r,1);else throw n}}async function Ac(r,e,t,n,i=0){try{return await w.promises.rename(r,e)}catch(s){if(s.code!=="EACCES"&&s.code!=="EPERM"&&s.code!=="EBUSY")throw s;if(Date.now()-t>=n)throw console.error(`[node.js fs] rename failed after ${i} retries with error: ${s}`),s;if(i===0){let o=!1;try{let{stat:a}=await et.stat(e);a.isFile()||(o=!0)}catch{}if(o)throw s}return await jt(Math.min(100,i*10)),Ac(r,e,t,n,i+1)}}async function kc(r,e,t){return Lc(r,e,{root:{source:r,target:e},options:t,handledSourcePaths:new Set})}var Cc=511;async function Lc(r,e,t){if(t.handledSourcePaths.has(r))return;t.handledSourcePaths.add(r);let{stat:n,symbolicLink:i}=await et.stat(r);if(i){if(t.options.preserveSymlinks)try{return await Jp(r,e,t)}catch{}if(i.dangling)return}return n.isDirectory()?Gp(r,e,n.mode&Cc,t):Qp(r,e,n.mode&Cc)}async function Gp(r,e,t,n){await w.promises.mkdir(e,{recursive:!0,mode:t});let i=await Pi(r);for(let s of i)await Lc(J(r,s),J(e,s),n)}async function Qp(r,e,t){await w.promises.copyFile(r,e),await w.promises.chmod(e,t)}async function Jp(r,e,t){let n=await w.promises.readlink(r);lt(n,t.root.source,!te)&&(n=J(t.root.target,n.substr(t.root.source.length+1))),await w.promises.symlink(n,e)}async function Yp(r){try{return await Tr(w.realpath)(r)}catch{let e=Xp(r);return await w.promises.access(e,w.constants.R_OK),e}}function Xp(r){return or(Me(r),ie)}var ee=new class{get read(){return(r,e,t,n,i)=>new Promise((s,o)=>{w.read(r,e,t,n,i,(a,l,c)=>a?o(a):s({bytesRead:l,buffer:c}))})}get write(){return(r,e,t,n,i)=>new Promise((s,o)=>{w.write(r,e,t,n,i,(a,l,c)=>a?o(a):s({bytesWritten:l,buffer:c}))})}get fdatasync(){return Tr(w.fdatasync)}get open(){return Tr(w.open)}get close(){return Tr(w.close)}get ftruncate(){return Tr(w.ftruncate)}async exists(r){try{return await w.promises.access(r),!0}catch{return!1}}get readdir(){return Pi}get readDirsInDir(){return Vp}get writeFile(){return $p}get rm(){return Pc}get rename(){return Hp}get copy(){return kc}get realpath(){return Yp}};function Oc(r){let e=[],t=!1,n=function(i){if(t){e.push(i);return}(!r.send(i,o=>{if(o&&console.error(o),t=!1,e.length>0){let a=e.slice(0);e=[],a.forEach(l=>n(l))}})||$)&&(t=!0)};return{send:n}}var Di=class extends yr{constructor(e){super({send:t=>{try{process.send?.(t.buffer.toString("base64"))}catch{}},onMessage:V.fromNodeEventEmitter(process,"message",t=>x.wrap(Buffer.from(t,"base64")))},e),process.once("disconnect",()=>this.dispose())}},Ai=class{constructor(e,t){this.modulePath=e;this.options=t;this.activeRequests=new Set;this.channels=new Map;this._onDidProcessExit=new I;this.onDidProcessExit=this._onDidProcessExit.event;let n=t.timeout||6e4;this.disposeDelayer=new dr(n),this.child=null,this._client=null}getChannel(e){let t=this;return{call(n,i,s){return t.requestPromise(e,n,i,s)},listen(n,i){return t.requestEvent(e,n,i)}}}requestPromise(e,t,n,i=Ke.None){if(!this.disposeDelayer)return Promise.reject(new Error("disposed"));if(i.isCancellationRequested)return Promise.reject(Qr());this.disposeDelayer.cancel();let s=this.getCachedChannel(e),o=yn(c=>s.call(t,n,c)),a=i.onCancellationRequested(()=>o.cancel()),l=O(()=>o.cancel());return this.activeRequests.add(l),o.finally(()=>{a.dispose(),this.activeRequests.delete(l),this.activeRequests.size===0&&this.disposeDelayer&&this.disposeDelayer.trigger(()=>this.disposeClient())}),o}requestEvent(e,t,n){if(!this.disposeDelayer)return V.None;this.disposeDelayer.cancel();let i,s=new I({onWillAddFirstListener:()=>{i=this.getCachedChannel(e).listen(t,n)(s.fire,s),this.activeRequests.add(i)},onDidRemoveLastListener:()=>{this.activeRequests.delete(i),i.dispose(),this.activeRequests.size===0&&this.disposeDelayer&&this.disposeDelayer.trigger(()=>this.disposeClient())}});return s.event}get client(){if(!this._client){let e=this.options.args||[],t=Object.create(null);t.env={...Uo(process.env),VSCODE_PARENT_PID:String(process.pid)},this.options.env&&(t.env={...t.env,...this.options.env}),this.options.freshExecArgv&&(t.execArgv=[]),typeof this.options.debug=="number"&&(t.execArgv=["--nolazy","--inspect="+this.options.debug]),typeof this.options.debugBrk=="number"&&(t.execArgv=["--nolazy","--inspect-brk="+this.options.debugBrk]),t.execArgv===void 0&&(t.execArgv=process.execArgv.filter(u=>!/^--inspect(-brk)?=/.test(u)).filter(u=>!u.startsWith("--vscode-"))),Ec(t.env),this.child=tf(this.modulePath,e,t);let n=new I,s=V.fromNodeEventEmitter(this.child,"message",u=>u)(u=>{if(_c(u)){xc(u,`IPC Library: ${this.options.serverName}`);return}n.fire(x.wrap(Buffer.from(u,"base64")))}),o=this.options.useQueue?Oc(this.child):this.child,a=u=>this.child?.connected&&o.send(u.buffer.toString("base64")),l=n.event,c={send:a,onMessage:l};this._client=new _n(c);let d=()=>this.disposeClient();process.once("exit",d),this.child.on("error",u=>console.warn('IPC "'+this.options.serverName+'" errored with '+u)),this.child.on("exit",(u,p)=>{process.removeListener("exit",d),s.dispose(),this.activeRequests.forEach(h=>xe(h)),this.activeRequests.clear(),u!==0&&p!=="SIGTERM"&&console.warn('IPC "'+this.options.serverName+'" crashed with exit code '+u+" and signal "+p),this.disposeDelayer?.cancel(),this.disposeClient(),this._onDidProcessExit.fire({code:u,signal:p})})}return this._client}getCachedChannel(e){let t=this.channels.get(e);return t||(t=this.client.getChannel(e),this.channels.set(e,t)),t}disposeClient(){this._client&&(this.child&&(this.child.kill(),this.child=null),this._client=null,this.channels.clear())}dispose(){this._onDidProcessExit.dispose(),this.disposeDelayer?.cancel(),this.disposeDelayer=void 0,this.disposeClient(),this.activeRequests.clear()}};function ki(r){return!!r.parentPort}var Mo=class{constructor(e){this.port=e;this.onMessage=V.fromNodeEventEmitter(this.port,"message",t=>t.data?x.wrap(t.data):x.alloc(0)),e.start()}send(e){this.port.postMessage(e.buffer)}disconnect(){this.port.close()}},Li=class r extends Ci{static getOnDidClientConnect(e){al(ki(process),"Electron Utility Process");let t=new I;return process.parentPort.on("message",n=>{if(e?.handledClientConnection(n))return;let i=n.ports.at(0);i&&t.fire(i)}),V.map(t.event,n=>({protocol:new Mo(n),onDidClientDisconnect:V.fromNodeEventEmitter(n,"close")}))}constructor(e){super(r.getOnDidClientConnect(e))}};import*as dd from"os";var je;(i=>{i.serviceIds=new Map,i.DI_TARGET="$di$target",i.DI_DEPENDENCIES="$di$dependencies";function n(s){return s[i.DI_DEPENDENCIES]||[]}i.getServiceDependencies=n})(je||={});var Oi=Fe("instantiationService");function nf(r,e,t){e[je.DI_TARGET]===e?e[je.DI_DEPENDENCIES].push({id:r,index:t}):(e[je.DI_DEPENDENCIES]=[{id:r,index:t}],e[je.DI_TARGET]=e)}function Fe(r){if(je.serviceIds.has(r))return je.serviceIds.get(r);let e=function(t,n,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");nf(e,t,i)};return e.toString=()=>r,je.serviceIds.set(r,e),e}var oe;(n=>{function r(i,s){return m.from({scheme:i,path:`/${s}`})}n.uri=r;function e(i){return(typeof i=="string"?m.parse(i):i).path.substring(1)}n.id=e;function t(i){return(typeof i=="string"?m.parse(i):i).scheme||void 0}n.provider=t})(oe||={});var qv=Fe("agentService"),$v=Fe("agentHostService");var Re=class{constructor(e,t,n){this.owner=e;this.debugNameSource=t;this.referenceFn=n}getDebugName(e){return Mc(e,this)}},Fc=new Map,Wo=new WeakMap;function Mc(r,e){let t=Wo.get(r);if(t)return t;let n=rf(r,e);if(n){let i=Fc.get(n)??0;i++,Fc.set(n,i);let s=i===1?n:`${n}#${i}`;return Wo.set(r,s),s}}function rf(r,e){let t=Wo.get(r);if(t)return t;let n=e.owner?of(e.owner)+".":"",i,s=e.debugNameSource;if(s!==void 0)if(typeof s=="function"){if(i=s(),i!==void 0)return n+i}else return n+s;let o=e.referenceFn;if(o!==void 0&&(i=Sr(o),i!==void 0))return n+i;if(e.owner!==void 0){let a=sf(e.owner,r);if(a!==void 0)return n+a}}function sf(r,e){for(let t in r)if(r[t]===e)return t}var Uc=new Map,Nc=new WeakMap;function of(r){let e=Nc.get(r);if(e)return e;let t=Bo(r)??"Object",n=Uc.get(t)??0;n++,Uc.set(t,n);let i=n===1?t:`${t}#${n}`;return Nc.set(r,i),i}function Bo(r){let e=r.constructor;if(e)return e.name==="Object"?void 0:e.name}function Sr(r){let e=r.toString(),n=/\/\*\*\s*@description\s*([^*]*)\*\//.exec(e);return(n?n[1]:void 0)?.trim()}function Be(r,e){return r===e}function af(){return(r,e)=>r===e}function lf(r,e,t){return Zn(r,e,t??Be)}function cf(r){return(e,t)=>Zn(e,t,r??Be)}function Fi(r,e){if(r===e)return!0;if(Array.isArray(r)&&Array.isArray(e)){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!Fi(r[t],e[t]))return!1;return!0}if(r&&typeof r=="object"&&e&&typeof e=="object"&&Object.getPrototypeOf(r)===Object.prototype&&Object.getPrototypeOf(e)===Object.prototype){let t=r,n=e,i=Object.keys(t),s=Object.keys(n),o=new Set(s);if(i.length!==s.length)return!1;for(let a of i)if(!o.has(a)||!Fi(t[a],n[a]))return!1;return!0}return!1}function uf(){return(r,e)=>Fi(r,e)}function df(r,e){return JSON.stringify(r)===JSON.stringify(e)}function pf(){return(r,e)=>JSON.stringify(r)===JSON.stringify(e)}function ff(){return(r,e)=>r.equals(e)}function hf(r,e,t){return r==null||e===void 0||e===null?e===r:t(r,e)}function gf(r){return(e,t)=>e==null||t===void 0||t===null?t===e:r(e,t)}var mf;(u=>(u.strict=Be,u.strictC=af,u.array=lf,u.arrayC=cf,u.structural=Fi,u.structuralC=uf,u.jsonStringify=df,u.jsonStringifyC=pf,u.thisC=ff,u.ifDefined=hf,u.ifDefinedC=gf))(mf||={});function Vo(r){let e=new Error("BugIndicatingErrorRecovery: "+r);Z(e),console.error("recovered from an error that indicates a bug",e)}var Jt;function _r(r){Jt?Jt instanceof Ui?Jt.loggers.push(r):Jt=new Ui([Jt,r]):Jt=r}function Q(){return Jt}var qo;function Wc(r){qo=r}function Bc(r){qo&&qo(r)}var Ui=class{constructor(e){this.loggers=e}handleObservableCreated(e,t){for(let n of this.loggers)n.handleObservableCreated(e,t)}handleOnListenerCountChanged(e,t){for(let n of this.loggers)n.handleOnListenerCountChanged(e,t)}handleObservableUpdated(e,t){for(let n of this.loggers)n.handleObservableUpdated(e,t)}handleAutorunCreated(e,t){for(let n of this.loggers)n.handleAutorunCreated(e,t)}handleAutorunDisposed(e){for(let t of this.loggers)t.handleAutorunDisposed(e)}handleAutorunDependencyChanged(e,t,n){for(let i of this.loggers)i.handleAutorunDependencyChanged(e,t,n)}handleAutorunStarted(e){for(let t of this.loggers)t.handleAutorunStarted(e)}handleAutorunFinished(e){for(let t of this.loggers)t.handleAutorunFinished(e)}handleDerivedDependencyChanged(e,t,n){for(let i of this.loggers)i.handleDerivedDependencyChanged(e,t,n)}handleDerivedCleared(e){for(let t of this.loggers)t.handleDerivedCleared(e)}handleBeginTransaction(e){for(let t of this.loggers)t.handleBeginTransaction(e)}handleEndTransaction(e){for(let t of this.loggers)t.handleEndTransaction(e)}};function wn(r,e){let t=new Yt(r,e);try{r(t)}finally{t.finish()}}function $o(r,e,t){r?e(r):wn(e,t)}var Yt=class{constructor(e,t){this._fn=e;this._getDebugName=t;this._updatingObservers=[];Q()?.handleBeginTransaction(this)}getDebugName(){return this._getDebugName?this._getDebugName():Sr(this._fn)}updateObserver(e,t){if(!this._updatingObservers){Vo("Transaction already finished!"),wn(n=>{n.updateObserver(e,t)});return}this._updatingObservers.push({observer:e,observable:t}),e.beginUpdate(t)}finish(){let e=this._updatingObservers;if(!e){Vo("transaction.finish() has already been called!");return}for(let t=0;t<e.length;t++){let{observer:n,observable:i}=e[t];n.endUpdate(i)}this._updatingObservers=null,Q()?.handleEndTransaction(this)}debugGetUpdatingObservers(){return this._updatingObservers}};var ae;(n=>{let r=!1;function e(){r=!0}n.enable=e;function t(){if(!r)return;let i=Error,s=i.stackTraceLimit;i.stackTraceLimit=3;let o=new Error().stack;return i.stackTraceLimit=s,Ko.fromStack(o,2)}n.ofCaller=t})(ae||={});var Ko=class r{constructor(e,t,n,i){this.fileName=e;this.line=t;this.column=n;this.id=i}static fromStack(e,t){let n=e.split(`
`),i=vf(n[t+1]);if(i)return new r(i.fileName,i.line,i.column,i.id)}};function vf(r){let e=r.match(/\((.*):(\d+):(\d+)\)/);if(e)return{fileName:e[1],line:parseInt(e[2]),column:parseInt(e[3]),id:r};let t=r.match(/at ([^\(\)]*):(\d+):(\d+)/);if(t)return{fileName:t[1],line:parseInt(t[2]),column:parseInt(t[3]),id:r}}var zo;function Vc(r){zo=r}var qc;function $c(r){qc=r}var Kc;function zc(r){Kc=r}var jo;function jc(r){jo=r}var Ni=class{get TChange(){return null}reportChanges(){this.get()}read(e){return e?e.readObservable(this):this.get()}map(e,t,n=ae.ofCaller()){let i=t===void 0?void 0:e,s=t===void 0?e:t;return zo({owner:i,debugName:()=>{let o=Sr(s);if(o!==void 0)return o;let l=/^\s*\(?\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\)?\s*=>\s*\1(?:\??)\.([a-zA-Z_$][a-zA-Z_$0-9]*)\s*$/.exec(s.toString());if(l)return`${this.debugName}.${l[2]}`;if(!i)return`${this.debugName} (mapped)`},debugReferenceFn:s},o=>s(this.read(o),o),n)}flatten(){return zo({owner:void 0,debugName:()=>`${this.debugName} (flattened)`},e=>this.read(e).read(e))}recomputeInitiallyAndOnChange(e,t){return e.add(qc(this,t)),this}keepObserved(e){return e.add(Kc(this)),this}get debugValue(){return this.get()}get debug(){return new Ho(this)}},Ho=class{constructor(e){this.observable=e}getDependencyGraph(){return jo(this.observable,{type:"dependencies"})}getObserverGraph(){return jo(this.observable,{type:"observers"})}},He=class extends Ni{constructor(t){super();this._observers=new Set;Q()?.handleObservableCreated(this,t)}addObserver(t){let n=this._observers.size;this._observers.add(t),n===0&&this.onFirstObserverAdded(),n!==this._observers.size&&Q()?.handleOnListenerCountChanged(this,this._observers.size)}removeObserver(t){let n=this._observers.delete(t);n&&this._observers.size===0&&this.onLastObserverRemoved(),n&&Q()?.handleOnListenerCountChanged(this,this._observers.size)}onFirstObserverAdded(){}onLastObserverRemoved(){}log(){let t=!!Q();return Bc(this),t||Q()?.handleObservableCreated(this,ae.ofCaller()),this}debugGetObservers(){return this._observers}};function xr(r,e,t=ae.ofCaller()){let n;return typeof r=="string"?n=new Re(void 0,r,void 0):n=new Re(r,void 0,void 0),new ut(n,e,Be,t)}var ut=class extends He{constructor(t,n,i,s){super(s);this._debugNameData=t;this._equalityComparator=i;this._value=n,Q()?.handleObservableUpdated(this,{hadValue:!1,newValue:n,change:void 0,didChange:!0,oldValue:void 0})}get debugName(){return this._debugNameData.getDebugName(this)??"ObservableValue"}get(){return this._value}set(t,n,i){if(i===void 0&&this._equalityComparator(this._value,t))return;let s;n||(n=s=new Yt(()=>{},()=>`Setting ${this.debugName}`));try{let o=this._value;this._setValue(t),Q()?.handleObservableUpdated(this,{oldValue:o,newValue:t,change:i,didChange:!0,hadValue:!0});for(let a of this._observers)n.updateObserver(a,this),a.handleChange(this,i)}finally{s&&s.finish()}}toString(){return`${this.debugName}: ${this._value}`}_setValue(t){this._value=t}debugGetState(){return{value:this._value}}debugSetValue(t){this._value=t}};function bf(r){switch(r){case 1:return"dependenciesMightHaveChanged";case 2:return"stale";case 3:return"upToDate";default:return"<unknown>"}}var dt=class{constructor(e,t,n,i){this._debugNameData=e;this._runFn=t;this._changeTracker=n;this._state=2;this._updateCount=0;this._disposed=!1;this._dependencies=new Set;this._dependenciesToBeRemoved=new Set;this._isRunning=!1;this._iteration=0;this._store=void 0;this._delayedStore=void 0;this._changeSummary=this._changeTracker?.createChangeSummary(void 0),Q()?.handleAutorunCreated(this,i),this._run(),_t(this)}get debugName(){return this._debugNameData.getDebugName(this)??"(anonymous)"}dispose(){if(!this._disposed){this._disposed=!0;for(let e of this._dependencies)e.removeObserver(this);this._dependencies.clear(),this._store!==void 0&&this._store.dispose(),this._delayedStore!==void 0&&this._delayedStore.dispose(),Q()?.handleAutorunDisposed(this),xt(this)}}_run(){let e=this._dependenciesToBeRemoved;this._dependenciesToBeRemoved=this._dependencies,this._dependencies=e,this._state=3;try{if(!this._disposed){Q()?.handleAutorunStarted(this);let t=this._changeSummary,n=this._delayedStore;n!==void 0&&(this._delayedStore=void 0);try{this._isRunning=!0,this._changeTracker&&(this._changeTracker.beforeUpdate?.(this,t),this._changeSummary=this._changeTracker.createChangeSummary(t)),this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._runFn(this,t)}catch(i){It(i)}finally{this._isRunning=!1,n!==void 0&&n.dispose()}}}finally{this._disposed||Q()?.handleAutorunFinished(this);for(let t of this._dependenciesToBeRemoved)t.removeObserver(this);this._dependenciesToBeRemoved.clear()}}toString(){return`Autorun<${this.debugName}>`}beginUpdate(e){this._state===3&&(this._checkIterations(),this._state=1),this._updateCount++}endUpdate(e){try{if(this._updateCount===1){this._iteration=1;do{if(this._checkIterations())return;if(this._state===1){this._state=3;for(let t of this._dependencies)if(t.reportChanges(),this._state===2)break}this._iteration++,this._state!==3&&this._run()}while(this._state!==3)}}finally{this._updateCount--}er(()=>this._updateCount>=0)}handlePossibleChange(e){this._state===3&&this._isDependency(e)&&(this._checkIterations(),this._state=1)}handleChange(e,t){if(this._isDependency(e)){Q()?.handleAutorunDependencyChanged(this,e,t);try{(!this._changeTracker||this._changeTracker.handleChange({changedObservable:e,change:t,didChange:i=>i===e},this._changeSummary))&&(this._checkIterations(),this._state=2)}catch(n){It(n)}}}_isDependency(e){return this._dependencies.has(e)&&!this._dependenciesToBeRemoved.has(e)}_ensureNoRunning(){if(!this._isRunning)throw new H("The reader object cannot be used outside its compute function!")}readObservable(e){if(this._ensureNoRunning(),this._disposed)return e.get();e.addObserver(this);let t=e.get();return this._dependencies.add(e),this._dependenciesToBeRemoved.delete(e),t}get store(){if(this._ensureNoRunning(),this._disposed)throw new H("Cannot access store after dispose");return this._store===void 0&&(this._store=new D),this._store}get delayedStore(){if(this._ensureNoRunning(),this._disposed)throw new H("Cannot access store after dispose");return this._delayedStore===void 0&&(this._delayedStore=new D),this._delayedStore}debugGetState(){return{isRunning:this._isRunning,updateCount:this._updateCount,dependencies:this._dependencies,state:this._state,stateStr:bf(this._state)}}debugRerun(){this._isRunning?this._state=2:this._run()}_checkIterations(){return this._iteration>100?(It(new H(`Autorun '${this.debugName}' is stuck in an infinite update loop.`)),!0):!1}};function Er(r,e=ae.ofCaller()){return new dt(new Re(void 0,void 0,r),r,void 0,e)}function yf(r){switch(r){case 0:return"initial";case 1:return"dependenciesMightHaveChanged";case 2:return"stale";case 3:return"upToDate";default:return"<unknown>"}}var he=class extends He{constructor(t,n,i,s=void 0,o,a){super(a);this._debugNameData=t;this._computeFn=n;this._changeTracker=i;this._handleLastObserverRemoved=s;this._equalityComparator=o;this._state=0;this._value=void 0;this._updateCount=0;this._dependencies=new Set;this._dependenciesToBeRemoved=new Set;this._changeSummary=void 0;this._isUpdating=!1;this._isComputing=!1;this._didReportChange=!1;this._isInBeforeUpdate=!1;this._isReaderValid=!1;this._store=void 0;this._delayedStore=void 0;this._removedObserverToCallEndUpdateOn=null;this._changeSummary=this._changeTracker?.createChangeSummary(void 0)}get debugName(){return this._debugNameData.getDebugName(this)??"(anonymous)"}onLastObserverRemoved(){this._state=0,this._value=void 0,Q()?.handleDerivedCleared(this);for(let t of this._dependencies)t.removeObserver(this);this._dependencies.clear(),this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._delayedStore!==void 0&&(this._delayedStore.dispose(),this._delayedStore=void 0),this._handleLastObserverRemoved?.()}get(){if(this._isComputing,this._observers.size===0){let n;try{this._isReaderValid=!0;let i;this._changeTracker&&(i=this._changeTracker.createChangeSummary(void 0),this._changeTracker.beforeUpdate?.(this,i)),n=this._computeFn(this,i)}finally{this._isReaderValid=!1}return this.onLastObserverRemoved(),n}else{do{if(this._state===1){for(let n of this._dependencies)if(n.reportChanges(),this._state===2)break}this._state===1&&(this._state=3),this._state!==3&&this._recompute()}while(this._state!==3);return this._value}}_recompute(){let t=!1;this._isComputing=!0,this._didReportChange=!1;let n=this._dependenciesToBeRemoved;this._dependenciesToBeRemoved=this._dependencies,this._dependencies=n;try{let i=this._changeSummary;this._isReaderValid=!0,this._changeTracker&&(this._isInBeforeUpdate=!0,this._changeTracker.beforeUpdate?.(this,i),this._isInBeforeUpdate=!1,this._changeSummary=this._changeTracker?.createChangeSummary(i));let s=this._state!==0,o=this._value;this._state=3;let a=this._delayedStore;a!==void 0&&(this._delayedStore=void 0);try{this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._value=this._computeFn(this,i)}finally{this._isReaderValid=!1;for(let l of this._dependenciesToBeRemoved)l.removeObserver(this);this._dependenciesToBeRemoved.clear(),a!==void 0&&a.dispose()}t=this._didReportChange||s&&!this._equalityComparator(o,this._value),Q()?.handleObservableUpdated(this,{oldValue:o,newValue:this._value,change:void 0,didChange:t,hadValue:s})}catch(i){It(i)}if(this._isComputing=!1,!this._didReportChange&&t)for(let i of this._observers)i.handleChange(this,void 0);else this._didReportChange=!1}toString(){return`LazyDerived<${this.debugName}>`}beginUpdate(t){if(this._isUpdating)throw new H("Cyclic deriveds are not supported yet!");this._updateCount++,this._isUpdating=!0;try{let n=this._updateCount===1;if(this._state===3&&(this._state=1,!n))for(let i of this._observers)i.handlePossibleChange(this);if(n)for(let i of this._observers)i.beginUpdate(this)}finally{this._isUpdating=!1}}endUpdate(t){if(this._updateCount--,this._updateCount===0){let n=[...this._observers];for(let i of n)i.endUpdate(this);if(this._removedObserverToCallEndUpdateOn){let i=[...this._removedObserverToCallEndUpdateOn];this._removedObserverToCallEndUpdateOn=null;for(let s of i)s.endUpdate(this)}}er(()=>this._updateCount>=0)}handlePossibleChange(t){if(this._state===3&&this._dependencies.has(t)&&!this._dependenciesToBeRemoved.has(t)){this._state=1;for(let n of this._observers)n.handlePossibleChange(this)}}handleChange(t,n){if(this._dependencies.has(t)&&!this._dependenciesToBeRemoved.has(t)||this._isInBeforeUpdate){Q()?.handleDerivedDependencyChanged(this,t,n);let i=!1;try{i=this._changeTracker?this._changeTracker.handleChange({changedObservable:t,change:n,didChange:o=>o===t},this._changeSummary):!0}catch(o){It(o)}let s=this._state===3;if(i&&(this._state===1||s)&&(this._state=2,s))for(let o of this._observers)o.handlePossibleChange(this)}}_ensureReaderValid(){if(!this._isReaderValid)throw new H("The reader object cannot be used outside its compute function!")}readObservable(t){this._ensureReaderValid(),t.addObserver(this);let n=t.get();return this._dependencies.add(t),this._dependenciesToBeRemoved.delete(t),n}reportChange(t){this._ensureReaderValid(),this._didReportChange=!0;for(let n of this._observers)n.handleChange(this,t)}get store(){return this._ensureReaderValid(),this._store===void 0&&(this._store=new D),this._store}get delayedStore(){return this._ensureReaderValid(),this._delayedStore===void 0&&(this._delayedStore=new D),this._delayedStore}addObserver(t){let n=!this._observers.has(t)&&this._updateCount>0;super.addObserver(t),n&&(this._removedObserverToCallEndUpdateOn?.delete(t)||t.beginUpdate(this))}removeObserver(t){this._observers.has(t)&&this._updateCount>0&&(this._removedObserverToCallEndUpdateOn||(this._removedObserverToCallEndUpdateOn=new Set),this._removedObserverToCallEndUpdateOn.add(t)),super.removeObserver(t)}debugGetState(){return{state:this._state,stateStr:yf(this._state),updateCount:this._updateCount,isComputing:this._isComputing,dependencies:this._dependencies,value:this._value}}debugSetValue(t){this._value=t}debugRecompute(){this.beginUpdate(this);try{this._isComputing?this._state=2:this._recompute()}finally{this.endUpdate(this)}}setValue(t,n,i){this._value=t;let s=this._observers;n.updateObserver(this,this);for(let o of s)o.handleChange(this,i)}};function Go(r,e,t=ae.ofCaller()){return new he(new Re(r.owner,r.debugName,r.debugReferenceFn),e,void 0,r.onLastObserverRemoved,r.equalsFn??Be,t)}Vc(Go);function Cn(...r){let e,t,n,i;return r.length===2?[t,n]=r:[e,t,n,i]=r,new Ve(new Re(e,void 0,n),t,n,()=>Ve.globalTransaction,Be,i??ae.ofCaller())}var Ve=class extends He{constructor(t,n,i,s,o,a){super(a);this._debugNameData=t;this.event=n;this._getValue=i;this._getTransaction=s;this._equalityComparator=o;this._hasValue=!1;this.handleEvent=t=>{let n=this._getValue(t),i=this._value,s=!this._hasValue||!this._equalityComparator(i,n),o=!1;s&&(this._value=n,this._hasValue&&(o=!0,$o(this._getTransaction(),a=>{Q()?.handleObservableUpdated(this,{oldValue:i,newValue:n,change:void 0,didChange:s,hadValue:this._hasValue});for(let l of this._observers)a.updateObserver(l,this),l.handleChange(this,void 0)},()=>{let a=this.getDebugName();return"Event fired"+(a?`: ${a}`:"")})),this._hasValue=!0),o||Q()?.handleObservableUpdated(this,{oldValue:i,newValue:n,change:void 0,didChange:s,hadValue:this._hasValue})}}getDebugName(){return this._debugNameData.getDebugName(this)}get debugName(){let t=this.getDebugName();return"From Event"+(t?`: ${t}`:"")}onFirstObserverAdded(){this._subscription=this.event(this.handleEvent)}onLastObserverRemoved(){this._subscription.dispose(),this._subscription=void 0,this._hasValue=!1,this._value=void 0}get(){return this._subscription?(this._hasValue||this.handleEvent(void 0),this._value):this._getValue(void 0)}debugSetValue(t){this._value=t}debugGetState(){return{value:this._value,hasValue:this._hasValue}}};(t=>{t.Observer=Ve;function e(n,i){let s=!1;Ve.globalTransaction===void 0&&(Ve.globalTransaction=n,s=!0);try{i()}finally{s&&(Ve.globalTransaction=void 0)}}t.batchEventsGlobally=e})(Cn||={});function Gc(r){let e=new Mi(!1,void 0);return r.addObserver(e),O(()=>{r.removeObserver(e)})}zc(Gc);function Qc(r,e){let t=new Mi(!0,e);r.addObserver(t);try{t.beginUpdate(r)}finally{t.endUpdate(r)}return O(()=>{r.removeObserver(t)})}$c(Qc);var Mi=class{constructor(e,t){this._forceRecompute=e;this._handleValue=t;this._counter=0}beginUpdate(e){this._counter++}endUpdate(e){this._counter===1&&this._forceRecompute&&(this._handleValue?this._handleValue(e.get()):e.reportChanges()),this._counter--}handlePossibleChange(e){}handleChange(e,t){}};var Wi;function Yc(r){Wi||(Wi=new Rr,_r(Wi)),Wi.addFilteredObj(r)}var Rr=class{constructor(){this.indentation=0;this.changedObservablesSets=new WeakMap}addFilteredObj(e){this._filteredObjects||(this._filteredObjects=new Set),this._filteredObjects.add(e)}_isIncluded(e){return this._filteredObjects?.has(e)??!0}textToConsoleArgs(e){return Ef([Pn(Cf("|  ",this.indentation)),e])}formatInfo(e){return e.hadValue?e.didChange?[Pn(" "),qe(Ue(e.oldValue,70),{color:"red",strikeThrough:!0}),Pn(" "),qe(Ue(e.newValue,60),{color:"green"})]:[Pn(" (unchanged)")]:[Pn(" "),qe(Ue(e.newValue,60),{color:"green"}),Pn(" (initial)")]}handleObservableCreated(e){if(e instanceof he){let t=e;if(this.changedObservablesSets.set(t,new Set),!1){let i=[];t.__debugUpdating=i;let s=t.beginUpdate;t.beginUpdate=a=>(i.push(a),s.apply(t,[a]));let o=t.endUpdate;t.endUpdate=a=>{let l=i.indexOf(a);return l===-1&&console.error("endUpdate called without beginUpdate",t.debugName,a.debugName),i.splice(l,1),o.apply(t,[a])}}}}handleOnListenerCountChanged(e,t){}handleObservableUpdated(e,t){if(this._isIncluded(e)){if(e instanceof he){this._handleDerivedRecomputed(e,t);return}console.log(...this.textToConsoleArgs([Dn("observable value changed"),qe(e.debugName,{color:"BlueViolet"}),...this.formatInfo(t)]))}}formatChanges(e){if(e.size!==0)return qe(" (changed deps: "+[...e].map(t=>t.debugName).join(", ")+")",{color:"gray"})}handleDerivedDependencyChanged(e,t,n){this._isIncluded(e)&&this.changedObservablesSets.get(e)?.add(t)}_handleDerivedRecomputed(e,t){if(!this._isIncluded(e))return;let n=this.changedObservablesSets.get(e);n&&(console.log(...this.textToConsoleArgs([Dn("derived recomputed"),qe(e.debugName,{color:"BlueViolet"}),...this.formatInfo(t),this.formatChanges(n),{data:[{fn:e._debugNameData.referenceFn??e._computeFn}]}])),n.clear())}handleDerivedCleared(e){this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Dn("derived cleared"),qe(e.debugName,{color:"BlueViolet"})]))}handleFromEventObservableTriggered(e,t){this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Dn("observable from event triggered"),qe(e.debugName,{color:"BlueViolet"}),...this.formatInfo(t),{data:[{fn:e._getValue}]}]))}handleAutorunCreated(e){this._isIncluded(e)&&this.changedObservablesSets.set(e,new Set)}handleAutorunDisposed(e){}handleAutorunDependencyChanged(e,t,n){this._isIncluded(e)&&this.changedObservablesSets.get(e).add(t)}handleAutorunStarted(e){let t=this.changedObservablesSets.get(e);t&&(this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Dn("autorun"),qe(e.debugName,{color:"BlueViolet"}),this.formatChanges(t),{data:[{fn:e._debugNameData.referenceFn??e._runFn}]}])),t.clear(),this.indentation++)}handleAutorunFinished(e){this.indentation--}handleBeginTransaction(e){let t=e.getDebugName();t===void 0&&(t=""),this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Dn("transaction"),qe(t,{color:"BlueViolet"}),{data:[{fn:e._fn}]}])),this.indentation++}handleEndTransaction(){this.indentation--}};function Ef(r){let e=new Array,t=[],n="";function i(o){if("length"in o)for(let a of o)a&&i(a);else"text"in o?(n+=`%c${o.text}`,e.push(o.style),o.data&&t.push(...o.data)):"data"in o&&t.push(...o.data)}i(r);let s=[n,...e];return s.push(...t),s}function Pn(r){return qe(r,{color:"black"})}function Dn(r){return qe(Pf(`${r}: `,10),{color:"black",bold:!0})}function qe(r,e={color:"black"}){function t(i){return Object.entries(i).reduce((s,[o,a])=>`${s}${o}:${a};`,"")}let n={color:e.color};return e.strikeThrough&&(n["text-decoration"]="line-through"),e.bold&&(n["font-weight"]="bold"),{text:r,style:t(n)}}function Ue(r,e){switch(typeof r){case"number":return""+r;case"string":return r.length+2<=e?`"${r}"`:`"${r.substr(0,e-7)}"+...`;case"boolean":return r?"true":"false";case"undefined":return"undefined";case"object":return r===null?"null":Array.isArray(r)?Rf(r,e):wf(r,e);case"symbol":return r.toString();case"function":return`[[Function${r.name?" "+r.name:""}]]`;default:return""+r}}function Rf(r,e){let t="[ ",n=!0;for(let i of r){if(n||(t+=", "),t.length-5>e){t+="...";break}n=!1,t+=`${Ue(i,e-t.length)}`}return t+=" ]",t}function wf(r,e){if(typeof r.toString=="function"&&r.toString!==Object.prototype.toString){let s=r.toString();return s.length<=e?s:s.substring(0,e-3)+"..."}let t=Bo(r),n=t?t+"(":"{ ",i=!0;for(let[s,o]of Object.entries(r)){if(i||(n+=", "),n.length-5>e){n+="...";break}i=!1,n+=`${s}: ${Ue(o,e-n.length)}`}return n+=t?")":" }",n}function Cf(r,e){let t="";for(let n=1;n<=e;n++)t+=r;return t}function Pf(r,e){for(;r.length<e;)r+=" ";return r}var Bi=class r{constructor(e,t){this._channelFactory=e;this._getHandler=t;this._channel=this._channelFactory({handleNotification:s=>{let o=s,a=this._getHandler().notifications[o[0]];if(!a)throw new Error(`Unknown notification "${o[0]}"!`);a(...o[1])},handleRequest:s=>{let o=s;try{return{type:"result",value:this._getHandler().requests[o[0]](...o[1])}}catch(a){return{type:"error",value:a}}}});let n=new Proxy({},{get:(s,o)=>async(...a)=>{let l=await this._channel.sendRequest([o,a]);if(l.type==="error")throw l.value;return l.value}}),i=new Proxy({},{get:(s,o)=>(...a)=>{this._channel.sendNotification([o,a])}});this.api={notifications:i,requests:n}}static createHost(e,t){return new r(e,t)}static createClient(e,t){return new r(e,t)}};function Xc(r,e){let t=globalThis,n=[],i,{channel:s,handler:o}=Df({sendNotification:l=>{i?i.sendNotification(l):n.push(l)}}),a;return(t.$$debugValueEditor_debugChannels??(t.$$debugValueEditor_debugChannels={}))[r]=l=>{a=e(),i=l;for(let c of n)l.sendNotification(c);return n=[],o},Bi.createClient(s,()=>{if(!a)throw new Error("Not supported");return a})}function Df(r){let e;return{channel:n=>(e=n,{sendNotification:i=>{r.sendNotification(i)},sendRequest:i=>{throw new Error("not supported")}}),handler:{handleRequest:n=>n.type==="notification"?e?.handleNotification(n.data):e?.handleRequest(n.data)}}}var Vi=class{constructor(){this._timeout=void 0}throttle(e,t){this._timeout===void 0&&(this._timeout=setTimeout(()=>{this._timeout=void 0,e()},t))}dispose(){this._timeout!==void 0&&clearTimeout(this._timeout)}};function Qo(r,e){for(let t in e)r[t]&&typeof r[t]=="object"&&e[t]&&typeof e[t]=="object"?Qo(r[t],e[t]):r[t]=e[t]}function Jo(r,e){for(let t in e)e[t]===null?delete r[t]:r[t]&&typeof r[t]=="object"&&e[t]&&typeof e[t]=="object"?Jo(r[t],e[t]):r[t]=e[t]}var qi=class r{constructor(){this._declarationId=0;this._instanceId=0;this._declarations=new Map;this._instanceInfos=new WeakMap;this._aliveInstances=new Map;this._activeTransactions=new Set;this._channel=Xc("observableDevTools",()=>({notifications:{setDeclarationIdFilter:e=>{},logObservableValue:e=>{console.log("logObservableValue",e)},flushUpdates:()=>{this._flushUpdates()},resetUpdates:()=>{this._pendingChanges=null,this._channel.api.notifications.handleChange(this._fullState,!0)}},requests:{getDeclarations:()=>{let e={};for(let t of this._declarations.values())e[t.id]=t;return{decls:e}},getSummarizedInstances:()=>null,getObservableValueInfo:e=>({observers:[...this._aliveInstances.get(e).debugGetObservers()].map(n=>this._formatObserver(n)).filter(ln)}),getDerivedInfo:e=>{let t=this._aliveInstances.get(e);return{dependencies:[...t.debugGetState().dependencies].map(n=>this._formatObservable(n)).filter(ln),observers:[...t.debugGetObservers()].map(n=>this._formatObserver(n)).filter(ln)}},getAutorunInfo:e=>({dependencies:[...this._aliveInstances.get(e).debugGetState().dependencies].map(n=>this._formatObservable(n)).filter(ln)}),getTransactionState:()=>this.getTransactionState(),setValue:(e,t)=>{let n=this._aliveInstances.get(e);if(n instanceof he)n.debugSetValue(t);else if(n instanceof ut)n.debugSetValue(t);else if(n instanceof Ve)n.debugSetValue(t);else throw new H("Observable is not supported");let i=[...n.debugGetObservers()];for(let s of i)s.beginUpdate(n);for(let s of i)s.handleChange(n,void 0);for(let s of i)s.endUpdate(n)},getValue:e=>{let t=this._aliveInstances.get(e);if(t instanceof he)return Ue(t.debugGetState().value,200);if(t instanceof ut)return Ue(t.debugGetState().value,200)},logValue:e=>{let t=this._aliveInstances.get(e);if(t&&"get"in t)console.log("Logged Value:",t.get());else throw new H("Observable is not supported")},rerun:e=>{let t=this._aliveInstances.get(e);if(t instanceof he)t.debugRecompute();else if(t instanceof dt)t.debugRerun();else throw new H("Observable is not supported")}}}));this._pendingChanges=null;this._changeThrottler=new Vi;this._fullState={};this._flushUpdates=()=>{this._pendingChanges!==null&&(this._channel.api.notifications.handleChange(this._pendingChanges,!1),this._pendingChanges=null)};ae.enable()}static{this._instance=void 0}static getInstance(){return r._instance===void 0&&(r._instance=new r),r._instance}getTransactionState(){let e=[],t=[...this._activeTransactions];if(t.length===0)return;let n=t.flatMap(s=>s.debugGetUpdatingObservers()??[]).map(s=>s.observer),i=new Set;for(;n.length>0;){let s=n.shift();if(i.has(s))continue;i.add(s);let o=this._getInfo(s,a=>{i.has(a)||n.push(a)});o&&e.push(o)}return{names:t.map(s=>s.getDebugName()??"tx"),affected:e}}_getObservableInfo(e){let t=this._instanceInfos.get(e);if(!t){Z(new H("No info found"));return}return t}_getAutorunInfo(e){let t=this._instanceInfos.get(e);if(!t){Z(new H("No info found"));return}return t}_getInfo(e,t){if(e instanceof he){let n=[...e.debugGetObservers()];for(let l of n)t(l);let i=this._getObservableInfo(e);if(!i)return;let s=e.debugGetState(),o={name:e.debugName,instanceId:i.instanceId,updateCount:s.updateCount},a=[...i.changedObservables].map(l=>this._instanceInfos.get(l)?.instanceId).filter(ln);if(s.isComputing)return{...o,type:"observable/derived",state:"updating",changedDependencies:a,initialComputation:!1};switch(s.state){case 0:return{...o,type:"observable/derived",state:"noValue"};case 3:return{...o,type:"observable/derived",state:"upToDate"};case 2:return{...o,type:"observable/derived",state:"stale",changedDependencies:a};case 1:return{...o,type:"observable/derived",state:"possiblyStale"}}}else if(e instanceof dt){let n=this._getAutorunInfo(e);if(!n)return;let i={name:e.debugName,instanceId:n.instanceId,updateCount:n.updateCount},s=[...n.changedObservables].map(o=>this._instanceInfos.get(o).instanceId);if(e.debugGetState().isRunning)return{...i,type:"autorun",state:"updating",changedDependencies:s};switch(e.debugGetState().state){case 3:return{...i,type:"autorun",state:"upToDate"};case 2:return{...i,type:"autorun",state:"stale",changedDependencies:s};case 1:return{...i,type:"autorun",state:"possiblyStale"}}}}_formatObservable(e){let t=this._getObservableInfo(e);if(t)return{name:e.debugName,instanceId:t.instanceId}}_formatObserver(e){if(e instanceof he)return{name:e.toString(),instanceId:this._getObservableInfo(e)?.instanceId};let t=this._getAutorunInfo(e);if(t)return{name:e.toString(),instanceId:t.instanceId}}_handleChange(e){Jo(this._fullState,e),this._pendingChanges===null?this._pendingChanges=e:Qo(this._pendingChanges,e),this._changeThrottler.throttle(this._flushUpdates,10)}_getDeclarationId(e,t){if(!t)return-1;let n=this._declarations.get(t.id);return n===void 0&&(n={id:this._declarationId++,type:e,url:t.fileName,line:t.line,column:t.column},this._declarations.set(t.id,n),this._handleChange({decls:{[n.id]:n}})),n.id}handleObservableCreated(e,t){let i={declarationId:this._getDeclarationId("observable/value",t),instanceId:this._instanceId++,listenerCount:0,lastValue:void 0,updateCount:0,changedObservables:new Set};this._instanceInfos.set(e,i)}handleOnListenerCountChanged(e,t){let n=this._getObservableInfo(e);if(n){if(n.listenerCount===0&&t>0){let i=e instanceof he?"observable/derived":"observable/value";this._aliveInstances.set(n.instanceId,e),this._handleChange({instances:{[n.instanceId]:{instanceId:n.instanceId,declarationId:n.declarationId,formattedValue:n.lastValue,type:i,name:e.debugName}}})}else n.listenerCount>0&&t===0&&(this._handleChange({instances:{[n.instanceId]:null}}),this._aliveInstances.delete(n.instanceId));n.listenerCount=t}}handleObservableUpdated(e,t){if(e instanceof he){this._handleDerivedRecomputed(e,t);return}let n=this._getObservableInfo(e);n&&t.didChange&&(n.lastValue=Ue(t.newValue,30),n.listenerCount>0&&this._handleChange({instances:{[n.instanceId]:{formattedValue:n.lastValue}}}))}handleAutorunCreated(e,t){let i={declarationId:this._getDeclarationId("autorun",t),instanceId:this._instanceId++,updateCount:0,changedObservables:new Set};this._instanceInfos.set(e,i),this._aliveInstances.set(i.instanceId,e),i&&this._handleChange({instances:{[i.instanceId]:{instanceId:i.instanceId,declarationId:i.declarationId,runCount:0,type:"autorun",name:e.debugName}}})}handleAutorunDisposed(e){let t=this._getAutorunInfo(e);t&&(this._handleChange({instances:{[t.instanceId]:null}}),this._instanceInfos.delete(e),this._aliveInstances.delete(t.instanceId))}handleAutorunDependencyChanged(e,t,n){let i=this._getAutorunInfo(e);i&&i.changedObservables.add(t)}handleAutorunStarted(e){}handleAutorunFinished(e){let t=this._getAutorunInfo(e);t&&(t.changedObservables.clear(),t.updateCount++,this._handleChange({instances:{[t.instanceId]:{runCount:t.updateCount}}}))}handleDerivedDependencyChanged(e,t,n){let i=this._getObservableInfo(e);i&&i.changedObservables.add(t)}_handleDerivedRecomputed(e,t){let n=this._getObservableInfo(e);if(!n)return;let i=Ue(t.newValue,30);n.updateCount++,n.changedObservables.clear(),n.lastValue=i,n.listenerCount>0&&this._handleChange({instances:{[n.instanceId]:{formattedValue:i,recomputationCount:n.updateCount}}})}handleDerivedCleared(e){let t=this._getObservableInfo(e);t&&(t.lastValue=void 0,t.changedObservables.clear(),t.listenerCount>0&&this._handleChange({instances:{[t.instanceId]:{formattedValue:void 0}}}))}handleBeginTransaction(e){this._activeTransactions.add(e)}handleEndTransaction(e){this._activeTransactions.delete(e)}};function Zc(r,e){let t=e?.debugNamePostProcessor??(s=>s),n=Xt.from(r,t);if(!n)return"";let i=new Set;return e.type==="observers"?tu(n,0,i,e).trim():eu(n,0,i,e).trim()}function eu(r,e,t,n){let i="		".repeat(e),s=[];if(t.has(r.sourceObj))return s.push(`${i}* ${r.type} ${r.name} (already listed)`),s.join(`
`);if(t.add(r.sourceObj),s.push(`${i}* ${r.type} ${r.name}:`),s.push(`${i}  value: ${Ue(r.value,50)}`),s.push(`${i}  state: ${r.state}`),r.dependencies.length>0){s.push(`${i}  dependencies:`);for(let a of r.dependencies){let l=Xt.from(a,n.debugNamePostProcessor??(c=>c))??Xt.unknown(a);s.push(eu(l,e+1,t,n))}}return s.join(`
`)}function tu(r,e,t,n){let i="		".repeat(e),s=[];if(t.has(r.sourceObj))return s.push(`${i}* ${r.type} ${r.name} (already listed)`),s.join(`
`);if(t.add(r.sourceObj),s.push(`${i}* ${r.type} ${r.name}:`),s.push(`${i}  value: ${Ue(r.value,50)}`),s.push(`${i}  state: ${r.state}`),r.observers.length>0){s.push(`${i}  observers:`);for(let a of r.observers){let l=Xt.from(a,n.debugNamePostProcessor??(c=>c))??Xt.unknown(a);s.push(tu(l,e+1,t,n))}}return s.join(`
`)}var Xt=class r{constructor(e,t,n,i,s,o,a){this.sourceObj=e;this.name=t;this.type=n;this.value=i;this.state=s;this.dependencies=o;this.observers=a}static from(e,t){if(e instanceof dt){let n=e.debugGetState();return new r(e,t(e.debugName),"autorun",void 0,n.stateStr,Array.from(n.dependencies),[])}else if(e instanceof he){let n=e.debugGetState();return new r(e,t(e.debugName),"derived",n.value,n.stateStr,Array.from(n.dependencies),Array.from(e.debugGetObservers()))}else if(e instanceof ut){let n=e.debugGetState();return new r(e,t(e.debugName),"observableValue",n.value,"upToDate",[],Array.from(e.debugGetObservers()))}else if(e instanceof Ve){let n=e.debugGetState();return new r(e,t(e.debugName),"fromEvent",n.value,n.hasValue?"upToDate":"initial",[],Array.from(e.debugGetObservers()))}}static unknown(e){return new r(e,"(unknown)","unknown",void 0,"unknown",[],[])}};jc(Zc);Wc(Yc);var Af=!1;Af&&_r(new Rr);pe&&pe.VSCODE_DEV_DEBUG_OBSERVABLES&&_r(qi.getInstance());var Ge=(function(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID.bind(crypto);let r=new Uint8Array(16),e=[];for(let t=0;t<256;t++)e.push(t.toString(16).padStart(2,"0"));return function(){crypto.getRandomValues(r),r[6]=r[6]&15|64,r[8]=r[8]&63|128;let n=0,i="";return i+=e[r[n++]],i+=e[r[n++]],i+=e[r[n++]],i+=e[r[n++]],i+="-",i+=e[r[n++]],i+=e[r[n++]],i+="-",i+=e[r[n++]],i+=e[r[n++]],i+="-",i+=e[r[n++]],i+=e[r[n++]],i+="-",i+=e[r[n++]],i+=e[r[n++]],i+=e[r[n++]],i+=e[r[n++]],i+=e[r[n++]],i+=e[r[n++]],i}})();var Yo=class{constructor(){this._value="";this._pos=0}reset(e){return this._value=e,this._pos=0,this}next(){return this._pos+=1,this}hasNext(){return this._pos<this._value.length-1}cmp(e){let t=e.charCodeAt(0),n=this._value.charCodeAt(this._pos);return t-n}value(){return this._value[this._pos]}},Xo=class{constructor(e=!0){this._caseSensitive=e}reset(e){return this._value=e,this._from=0,this._to=0,this.next()}hasNext(){return this._to<this._value.length}next(){this._from=this._to;let e=!0;for(;this._to<this._value.length;this._to++)if(this._value.charCodeAt(this._to)===46)if(e)this._from++;else break;else e=!1;return this}cmp(e){return this._caseSensitive?hi(e,this._value,0,e.length,this._from,this._to):$t(e,this._value,0,e.length,this._from,this._to)}value(){return this._value.substring(this._from,this._to)}},$i=class{constructor(e=!0,t=!0){this._splitOnBackslash=e;this._caseSensitive=t}reset(e){this._from=0,this._to=0,this._value=e,this._valueLen=e.length;for(let t=e.length-1;t>=0;t--,this._valueLen--){let n=this._value.charCodeAt(t);if(!(n===47||this._splitOnBackslash&&n===92))break}return this.next()}hasNext(){return this._to<this._valueLen}next(){this._from=this._to;let e=!0;for(;this._to<this._valueLen;this._to++){let t=this._value.charCodeAt(this._to);if(t===47||this._splitOnBackslash&&t===92)if(e)this._from++;else break;else e=!1}return this}cmp(e){return this._caseSensitive?hi(e,this._value,0,e.length,this._from,this._to):$t(e,this._value,0,e.length,this._from,this._to)}value(){return this._value.substring(this._from,this._to)}};var Zo=class{constructor(e,t){this._ignorePathCasing=e;this._ignoreQueryAndFragment=t;this._states=[];this._stateIdx=0}reset(e){return this._value=e,this._states=[],this._value.scheme&&this._states.push(1),this._value.authority&&this._states.push(2),this._value.path&&(this._pathIterator=new $i(!1,!this._ignorePathCasing(e)),this._pathIterator.reset(e.path),this._pathIterator.value()&&this._states.push(3)),this._ignoreQueryAndFragment(e)||(this._value.query&&this._states.push(4),this._value.fragment&&this._states.push(5)),this._stateIdx=0,this}next(){return this._states[this._stateIdx]===3&&this._pathIterator.hasNext()?this._pathIterator.next():this._stateIdx+=1,this}hasNext(){return this._states[this._stateIdx]===3&&this._pathIterator.hasNext()||this._stateIdx<this._states.length-1}cmp(e){if(this._states[this._stateIdx]===1)return go(e,this._value.scheme);if(this._states[this._stateIdx]===2)return go(e,this._value.authority);if(this._states[this._stateIdx]===3)return this._pathIterator.cmp(e);if(this._states[this._stateIdx]===4)return ar(e,this._value.query);if(this._states[this._stateIdx]===5)return ar(e,this._value.fragment);throw new Error}value(){if(this._states[this._stateIdx]===1)return this._value.scheme;if(this._states[this._stateIdx]===2)return this._value.authority;if(this._states[this._stateIdx]===3)return this._pathIterator.value();if(this._states[this._stateIdx]===4)return this._value.query;if(this._states[this._stateIdx]===5)return this._value.fragment;throw new Error}},pt=class r{static{this.Val=Symbol("undefined_placeholder")}static wrap(e){return e===void 0?r.Val:e}static unwrap(e){return e===r.Val?void 0:e}},An=class{constructor(){this.height=1;this.value=void 0;this.key=void 0;this.left=void 0;this.mid=void 0;this.right=void 0}isEmpty(){return!this.left&&!this.mid&&!this.right&&this.value===void 0}rotateLeft(){let e=this.right;return this.right=e.left,e.left=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.left;return this.left=e.right,e.right=this,this.updateHeight(),e.updateHeight(),e}updateHeight(){this.height=1+Math.max(this.heightLeft,this.heightRight)}balanceFactor(){return this.heightRight-this.heightLeft}get heightLeft(){return this.left?.height??0}get heightRight(){return this.right?.height??0}};var Dt=class r{static forUris(e=()=>!1,t=()=>!1){return new r(new Zo(e,t))}static forPaths(e=!1){return new r(new $i(void 0,!e))}static forStrings(){return new r(new Yo)}static forConfigKeys(){return new r(new Xo)}constructor(e){this._iter=e}clear(){this._root=void 0}fill(e,t){if(t){let n=t.slice(0);Hs(n);for(let i of n)this.set(i,e)}else{let n=e.slice(0);Hs(n);for(let i of n)this.set(i[0],i[1])}}set(e,t){let n=this._iter.reset(e),i;this._root||(this._root=new An,this._root.segment=n.value());let s=[];for(i=this._root;;){let a=n.cmp(i.segment);if(a>0)i.left||(i.left=new An,i.left.segment=n.value()),s.push([-1,i]),i=i.left;else if(a<0)i.right||(i.right=new An,i.right.segment=n.value()),s.push([1,i]),i=i.right;else if(n.hasNext())n.next(),i.mid||(i.mid=new An,i.mid.segment=n.value()),s.push([0,i]),i=i.mid;else break}let o=pt.unwrap(i.value);i.value=pt.wrap(t),i.key=e;for(let a=s.length-1;a>=0;a--){let l=s[a][1];l.updateHeight();let c=l.balanceFactor();if(c<-1||c>1){let d=s[a][0],u=s[a+1][0];if(d===1&&u===1)s[a][1]=l.rotateLeft();else if(d===-1&&u===-1)s[a][1]=l.rotateRight();else if(d===1&&u===-1)l.right=s[a+1][1]=s[a+1][1].rotateRight(),s[a][1]=l.rotateLeft();else if(d===-1&&u===1)l.left=s[a+1][1]=s[a+1][1].rotateLeft(),s[a][1]=l.rotateRight();else throw new Error;if(a>0)switch(s[a-1][0]){case-1:s[a-1][1].left=s[a][1];break;case 1:s[a-1][1].right=s[a][1];break;case 0:s[a-1][1].mid=s[a][1];break}else this._root=s[0][1]}}return o}get(e){return pt.unwrap(this._getNode(e)?.value)}_getNode(e){let t=this._iter.reset(e),n=this._root;for(;n;){let i=t.cmp(n.segment);if(i>0)n=n.left;else if(i<0)n=n.right;else if(t.hasNext())t.next(),n=n.mid;else break}return n}has(e){let t=this._getNode(e);return!(t?.value===void 0&&t?.mid===void 0)}delete(e){return this._delete(e,!1)}deleteSuperstr(e){return this._delete(e,!0)}_delete(e,t){let n=this._iter.reset(e),i=[],s=this._root;for(;s;){let o=n.cmp(s.segment);if(o>0)i.push([-1,s]),s=s.left;else if(o<0)i.push([1,s]),s=s.right;else if(n.hasNext())n.next(),i.push([0,s]),s=s.mid;else break}if(s){if(t?(s.left=void 0,s.mid=void 0,s.right=void 0,s.height=1):(s.key=void 0,s.value=void 0),!s.mid&&!s.value)if(s.left&&s.right){let o=[[1,s]],a=this._min(s.right,o);if(a.key){s.key=a.key,s.value=a.value,s.segment=a.segment;let l=a.right;if(o.length>1){let[d,u]=o[o.length-1];switch(d){case-1:u.left=l;break;case 0:Zr(!1);case 1:Zr(!1)}}else s.right=l;let c=this._balanceByStack(o);if(i.length>0){let[d,u]=i[i.length-1];switch(d){case-1:u.left=c;break;case 0:u.mid=c;break;case 1:u.right=c;break}}else this._root=c}}else{let o=s.left??s.right;if(i.length>0){let[a,l]=i[i.length-1];switch(a){case-1:l.left=o;break;case 0:l.mid=o;break;case 1:l.right=o;break}}else this._root=o}this._root=this._balanceByStack(i)??this._root}}_min(e,t){for(;e.left;)t.push([-1,e]),e=e.left;return e}_balanceByStack(e){for(let t=e.length-1;t>=0;t--){let n=e[t][1];n.updateHeight();let i=n.balanceFactor();if(i>1?(n.right.balanceFactor()>=0||(n.right=n.right.rotateRight()),e[t][1]=n.rotateLeft()):i<-1&&(n.left.balanceFactor()<=0||(n.left=n.left.rotateLeft()),e[t][1]=n.rotateRight()),t>0)switch(e[t-1][0]){case-1:e[t-1][1].left=e[t][1];break;case 1:e[t-1][1].right=e[t][1];break;case 0:e[t-1][1].mid=e[t][1];break}else return e[0][1]}}findSubstr(e){let t=this._iter.reset(e),n=this._root,i;for(;n;){let s=t.cmp(n.segment);if(s>0)n=n.left;else if(s<0)n=n.right;else if(t.hasNext())t.next(),i=pt.unwrap(n.value)||i,n=n.mid;else break}return n&&pt.unwrap(n.value)||i}findSuperstr(e){return this._findSuperstrOrElement(e,!1)}_findSuperstrOrElement(e,t){let n=this._iter.reset(e),i=this._root;for(;i;){let s=n.cmp(i.segment);if(s>0)i=i.left;else if(s<0)i=i.right;else if(n.hasNext())n.next(),i=i.mid;else return i.mid?this._entries(i.mid):t?pt.unwrap(i.value):void 0}}hasElementOrSubtree(e){return this._findSuperstrOrElement(e,!0)!==void 0}forEach(e){for(let[t,n]of this)e(n,t)}*[Symbol.iterator](){yield*this._entries(this._root)}_entries(e){let t=[];return this._dfsEntries(e,t),t[Symbol.iterator]()}_dfsEntries(e,t){e&&(e.left&&this._dfsEntries(e.left,t),e.value!==void 0&&t.push([e.key,pt.unwrap(e.value)]),e.mid&&this._dfsEntries(e.mid,t),e.right&&this._dfsEntries(e.right,t))}_isBalanced(){let e=t=>{if(!t)return!0;let n=t.balanceFactor();return n<-1||n>1?!1:e(t.left)&&e(t.right)};return e(this._root)}};var Fn=Fe("fileService");function Zt(r){return r.create===!0}function Ne(r){return!!(r.capabilities&2)}function nu(r){return!!(r.capabilities&524288)}function ea(r){return!!(r.capabilities&8)}function ru(r){return!!(r.capabilities&131072)}function iu(r){return!!(r.capabilities&262144)}function ht(r){return!!(r.capabilities&4)}function ji(r){return!!(r.capabilities&16)}function Hi(r){return Ne(r)?!!(r.capabilities&16384):!1}function ta(r){return Ne(r)?!!(r.capabilities&32768):!1}function su(r){return!!(r.capabilities&65536)}var kn=class r extends Error{constructor(t,n){super(t);this.code=n}static create(t,n){let i=new r(t.toString(),n);return kf(i,n),i}};function Qe(r,e){return kn.create(r,e)}function gt(r){return r||Qe(f(2130,null),"Unknown")}function kf(r,e){return r.name=e?`${e} (FileSystemError)`:"FileSystemError",r}function en(r){if(!r)return"Unknown";if(r instanceof kn)return r.code;let e=/^(.+) \(FileSystemError\)$/.exec(r.name);if(!e)return"Unknown";switch(e[1]){case"EntryExists":return"EntryExists";case"EntryIsADirectory":return"EntryIsADirectory";case"EntryNotADirectory":return"EntryNotADirectory";case"EntryNotFound":return"EntryNotFound";case"EntryTooLarge":return"EntryTooLarge";case"EntryWriteLocked":return"EntryWriteLocked";case"NoPermissions":return"NoPermissions";case"Unavailable":return"Unavailable"}return"Unknown"}function na(r){if(r instanceof le)return r.fileOperationResult;switch(en(r)){case"EntryNotFound":return 1;case"EntryIsADirectory":return 0;case"EntryNotADirectory":return 9;case"EntryWriteLocked":return 5;case"NoPermissions":return 6;case"EntryExists":return 4;case"EntryTooLarge":return 7;default:return 10}}var ft=class{constructor(e,t,n){this.resource=e;this.operation=t;this.target=n}isOperation(e){return this.operation===e}};var Ki=class r{constructor(e,t){this.ignorePathCasing=t;this.correlationId=void 0;this.added=new Ce(()=>{let e=Dt.forUris(()=>this.ignorePathCasing);return e.fill(this.rawAdded.map(t=>[t,!0])),e});this.updated=new Ce(()=>{let e=Dt.forUris(()=>this.ignorePathCasing);return e.fill(this.rawUpdated.map(t=>[t,!0])),e});this.deleted=new Ce(()=>{let e=Dt.forUris(()=>this.ignorePathCasing);return e.fill(this.rawDeleted.map(t=>[t,!0])),e});this.rawAdded=[];this.rawUpdated=[];this.rawDeleted=[];for(let n of e){switch(n.type){case 1:this.rawAdded.push(n.resource);break;case 0:this.rawUpdated.push(n.resource);break;case 2:this.rawDeleted.push(n.resource);break}this.correlationId!==r.MIXED_CORRELATION&&(typeof n.cId=="number"?this.correlationId===void 0?this.correlationId=n.cId:this.correlationId!==n.cId&&(this.correlationId=r.MIXED_CORRELATION):this.correlationId!==void 0&&(this.correlationId=r.MIXED_CORRELATION))}}static{this.MIXED_CORRELATION=null}contains(e,...t){return this.doContains(e,{includeChildren:!1},...t)}affects(e,...t){return this.doContains(e,{includeChildren:!0},...t)}doContains(e,t,...n){if(!e)return!1;let i=n.length>0;return!!((!i||n.includes(1))&&(this.added.value.get(e)||t.includeChildren&&this.added.value.findSuperstr(e))||(!i||n.includes(0))&&(this.updated.value.get(e)||t.includeChildren&&this.updated.value.findSuperstr(e))||(!i||n.includes(2))&&(this.deleted.value.findSubstr(e)||t.includeChildren&&this.deleted.value.findSuperstr(e)))}gotAdded(){return this.rawAdded.length>0}gotDeleted(){return this.rawDeleted.length>0}gotUpdated(){return this.rawUpdated.length>0}correlates(e){return this.correlationId===e}hasCorrelation(){return typeof this.correlationId=="number"}};function ou(r,e,t){return!r||!e||r===e||e.length>r.length?!1:(e.charAt(e.length-1)!==ie&&(e+=ie),t?lr(r,e):r.indexOf(e)===0)}var le=class extends Error{constructor(t,n,i){super(t);this.fileOperationResult=n;this.options=i}},Ln=class extends le{constructor(t,n,i,s){super(t,n,s);this.fileOperationResult=n;this.size=i}},On=class extends le{constructor(t,n,i){super(t,2,i);this.stat=n}};var Gi="";function ra(r){if(!(typeof r.size!="number"||typeof r.mtime!="number"))return r.mtime.toString(29)+r.size.toString(31)}var zi=class r{static{this.KB=1024}static{this.MB=r.KB*r.KB}static{this.GB=r.MB*r.KB}static{this.TB=r.GB*r.KB}static formatSize(e){return tr(e)||(e=0),e<r.KB?f(2125,null,e.toFixed(0)):e<r.MB?f(2127,null,(e/r.KB).toFixed(2)):e<r.GB?f(2128,null,(e/r.MB).toFixed(2)):e<r.TB?f(2126,null,(e/r.GB).toFixed(2)):f(2129,null,(e/r.TB).toFixed(2))}};function au(r){return r.type.startsWith("root/")}function Qi(r){return r.type.startsWith("session/")}var mt={SessionNotFound:-32001,ProviderNotFound:-32002,SessionAlreadyExists:-32003,TurnInProgress:-32004,UnsupportedProtocolVersion:-32005,ContentNotFound:-32006,AuthRequired:-32007,NotFound:-32008,PermissionDenied:-32009,AlreadyExists:-32010};var lu=-32700,Nn=-32603,Mn=-32001,cu=-32002;var uu=-32005;function du(r){return"method"in r&&"id"in r}function pu(r){return"method"in r&&!("id"in r)}var X=class extends Error{constructor(t,n,i){super(n);this.code=t;this.data=i}};var Yi="agenthost:/root";function mu(){return{agents:[],activeSessions:0}}function la(r){return{summary:r,lifecycle:"creating",turns:[],activeTurn:void 0}}var Wn="**",vu="/",Xi="[/\\\\]",Zi="[^/\\\\]",Uf=/\//g;function bu(r,e){switch(r){case 0:return"";case 1:return`${Zi}*?`;default:return`(?:${Xi}|${Zi}+${Xi}${e?`|${Xi}${Zi}+`:""})*?`}}function yu(r,e){if(!r)return[];let t=[],n=!1,i=!1,s="";for(let o of r){switch(o){case e:if(!n&&!i){t.push(s),s="";continue}break;case"{":n=!0;break;case"}":n=!1;break;case"[":i=!0;break;case"]":i=!1;break}s+=o}return s&&t.push(s),t}function xu(r){if(!r)return"";let e="",t=yu(r,vu);if(t.every(n=>n===Wn))e=".*";else{let n=!1;t.forEach((i,s)=>{if(i===Wn){if(n)return;e+=bu(2,s===t.length-1)}else{let o=!1,a="",l=!1,c="";for(let d of i){if(d!=="}"&&o){a+=d;continue}if(l&&(d!=="]"||!c)){let u;d==="-"?u=d:(d==="^"||d==="!")&&!c?u="^":d===vu?u="":u=ho(d),c+=u;continue}switch(d){case"{":o=!0;continue;case"[":l=!0;continue;case"}":{let p=`(?:${yu(a,",").map(h=>xu(h)).join("|")})`;e+=p,o=!1,a="";break}case"]":{e+="["+c+"]",l=!1,c="";break}case"?":e+=Zi;continue;case"*":e+=bu(1);continue;default:e+=ho(d)}}s<t.length-1&&(t[s+1]!==Wn||s+2<t.length)&&(e+=Xi)}n=i===Wn})}return e}var Nf=/^\*\*\/\*\.[\w\.-]+$/,Mf=/^\*\*\/([\w\.-]+)\/?$/,Wf=/^{\*\*\/\*?[\w\.-]+\/?(,\*\*\/\*?[\w\.-]+\/?)*}$/,Bf=/^{\*\*\/\*?[\w\.-]+(\/(\*\*)?)?(,\*\*\/\*?[\w\.-]+(\/(\*\*)?)?)*}$/,Vf=/^\*\*((\/[\w\.-]+)+)\/?$/,qf=/^([\w\.-]+(\/[\w\.-]+)*)\/?$/,Iu=new Tt(1e4),Tu=function(){return!1},tt=function(){return null};function ua(r,e){if(!r)return tt;let t;typeof r!="string"?t=r.pattern:t=r,t=t.trim();let n=e.ignoreCase??!1,i={...e,equals:n?Kt:(l,c)=>l===c,endsWith:n?Bl:(l,c)=>l.endsWith(c),isEqualOrParent:(l,c)=>lt(l,c,e.ignoreCase??!te)},s=`${n?t.toLowerCase():t}_${!!e.trimForExclusions}_${n}`,o=Iu.get(s);if(o)return Su(o,r,i);let a;return Nf.test(t)?o=$f(t.substring(4),t,i):(a=Mf.exec(ca(t,i)))?o=Kf(a[1],t,i):(e.trimForExclusions?Bf:Wf).test(t)?o=zf(t,i):(a=Vf.exec(ca(t,i)))?o=_u(a[1].substring(1),t,!0,i):(a=qf.exec(ca(t,i)))?o=_u(a[1],t,!1,i):o=jf(t,i),Iu.set(s,o),Su(o,r,i)}function Su(r,e,t){if(typeof e=="string")return r;let n=function(i,s){return t.isEqualOrParent(i,e.base)?r(Wl(i.substring(e.base.length),ie),s):null};return n.allBasenames=r.allBasenames,n.allPaths=r.allPaths,n.basenames=r.basenames,n.patterns=r.patterns,n}function ca(r,e){return e.trimForExclusions&&r.endsWith("/**")?r.substring(0,r.length-2):r}function $f(r,e,t){return function(n,i){return typeof n=="string"&&t.endsWith(n,r)?e:null}}function Kf(r,e,t){let n=`/${r}`,i=`\\${r}`,s=function(a,l){return typeof a!="string"?null:l?t.equals(l,r)?e:null:t.equals(a,r)||t.endsWith(a,n)||t.endsWith(a,i)?e:null},o=[r];return s.basenames=o,s.patterns=[e],s.allBasenames=o,s}function zf(r,e){let t=Ru(r.slice(1,-1).split(",").map(a=>ua(a,e)).filter(a=>a!==tt),r),n=t.length;if(!n)return tt;if(n===1)return t[0];let i=function(a,l){for(let c=0,d=t.length;c<d;c++)if(t[c](a,l))return r;return null},s=t.find(a=>!!a.allBasenames);s&&(i.allBasenames=s.allBasenames);let o=t.reduce((a,l)=>l.allPaths?a.concat(l.allPaths):a,[]);return o.length&&(i.allPaths=o),i}function _u(r,e,t,n){let i=ie===U.sep,s=i?r:r.replace(Uf,ie),o=ie+s,a=U.sep+r,l;return t?l=function(c,d){return typeof c=="string"&&(n.equals(c,s)||n.endsWith(c,o)||!i&&(n.equals(c,r)||n.endsWith(c,a)))?e:null}:l=function(c,d){return typeof c=="string"&&(n.equals(c,s)||!i&&n.equals(c,r))?e:null},l.allPaths=[(t?"*/":"./")+r],l}function jf(r,e){try{let t=new RegExp(`^${xu(r)}$`,e.ignoreCase?"i":void 0);return function(n){return t.lastIndex=0,typeof n=="string"&&t.test(n)?r:null}}catch{return tt}}function Eu(r,e,t){return!r||typeof e!="string"?!1:da(r,t)(e)}function da(r,e={}){if(!r)return Tu;if(typeof r=="string"||Hf(r)){let t=ua(r,e);if(t===tt)return Tu;let n=function(i,s){return!!t(i,s)};return t.allBasenames&&(n.allBasenames=t.allBasenames),t.allPaths&&(n.allPaths=t.allPaths),n}return Gf(r,e)}function Hf(r){let e=r;return e?typeof e.base=="string"&&typeof e.pattern=="string":!1}function Gf(r,e){let t=Ru(Object.getOwnPropertyNames(r).map(a=>Qf(a,r[a],e)).filter(a=>a!==tt)),n=t.length;if(!n)return tt;if(!t.some(a=>!!a.requiresSiblings)){if(n===1)return t[0];let a=function(d,u){let p;for(let h=0,g=t.length;h<g;h++){let b=t[h](d,u);if(typeof b=="string")return b;Si(b)&&(p||(p=[]),p.push(b))}return p?(async()=>{for(let h of p){let g=await h;if(typeof g=="string")return g}return null})():null},l=t.find(d=>!!d.allBasenames);l&&(a.allBasenames=l.allBasenames);let c=t.reduce((d,u)=>u.allPaths?d.concat(u.allPaths):d,[]);return c.length&&(a.allPaths=c),a}let i=function(a,l,c){let d,u;for(let p=0,h=t.length;p<h;p++){let g=t[p];g.requiresSiblings&&c&&(l||(l=We(a)),d||(d=l.substring(0,l.length-Ll(a).length)));let b=g(a,l,d,c);if(typeof b=="string")return b;Si(b)&&(u||(u=[]),u.push(b))}return u?(async()=>{for(let p of u){let h=await p;if(typeof h=="string")return h}return null})():null},s=t.find(a=>!!a.allBasenames);s&&(i.allBasenames=s.allBasenames);let o=t.reduce((a,l)=>l.allPaths?a.concat(l.allPaths):a,[]);return o.length&&(i.allPaths=o),i}function Qf(r,e,t){if(e===!1)return tt;let n=ua(r,t);if(n===tt)return tt;if(typeof e=="boolean")return n;if(e){let i=e.when;if(typeof i=="string"){let s=(o,a,l,c)=>{if(!c||!n(o,a))return null;let d=i.replace("$(basename)",()=>l),u=c(d);return Si(u)?u.then(p=>p?r:null):u?r:null};return s.requiresSiblings=!0,s}}return n}function Ru(r,e){let t=r.filter(a=>!!a.basenames);if(t.length<2)return r;let n=t.reduce((a,l)=>{let c=l.basenames;return c?a.concat(c):a},[]),i;if(e){i=[];for(let a=0,l=n.length;a<l;a++)i.push(e)}else i=t.reduce((a,l)=>{let c=l.patterns;return c?a.concat(c):a},[]);let s=function(a,l){if(typeof a!="string")return null;if(!l){let d;for(d=a.length;d>0;d--){let u=a.charCodeAt(d-1);if(u===47||u===92)break}l=a.substring(d)}let c=n.indexOf(l);return c!==-1?i[c]:null};s.basenames=n,s.patterns=i,s.allBasenames=n;let o=r.filter(a=>!a.basenames);return o.push(s),o}function pa(r,e){return Zn(r,e,(t,n)=>typeof t=="string"&&typeof n=="string"?t===n:typeof t!="string"&&typeof n!="string"?t.base===n.base&&t.pattern===n.pattern:!1)}var es=class{constructor(){this._currentMarkdownPartId=new Map;this._currentReasoningPartId=new Map}reset(e){this._currentMarkdownPartId.delete(e),this._currentReasoningPartId.delete(e)}mapProgressEventToActions(e,t,n){switch(e.type){case"delta":{let i=e,s=this._currentMarkdownPartId.get(t);if(!s){let o=Ge();return this._currentMarkdownPartId.set(t,o),{type:"session/responsePart",session:t,turnId:n,part:{kind:"markdown",id:o,content:i.content}}}return{type:"session/delta",session:t,turnId:n,partId:s,content:i.content}}case"tool_start":{this._currentMarkdownPartId.delete(t);let i=e,s={type:"session/toolCallStart",session:t,turnId:n,toolCallId:i.toolCallId,toolName:i.toolName,displayName:i.displayName,_meta:{toolKind:i.toolKind,language:i.language}},o={type:"session/toolCallReady",session:t,turnId:n,toolCallId:i.toolCallId,invocationMessage:i.invocationMessage,toolInput:i.toolInput,confirmed:"not-needed"};return[s,o]}case"tool_ready":{let i=e;return{type:"session/toolCallReady",session:t,turnId:n,toolCallId:i.toolCallId,invocationMessage:i.invocationMessage,toolInput:i.toolInput,confirmationTitle:i.confirmationTitle}}case"tool_complete":{let i=e;return{type:"session/toolCallComplete",session:t,turnId:n,toolCallId:i.toolCallId,result:i.result}}case"idle":return{type:"session/turnComplete",session:t,turnId:n};case"error":{let i=e;return{type:"session/error",session:t,turnId:n,error:{errorType:i.errorType,message:i.message,stack:i.stack}}}case"usage":{let i=e;return{type:"session/usage",session:t,turnId:n,usage:{inputTokens:i.inputTokens,outputTokens:i.outputTokens,model:i.model,cacheReadTokens:i.cacheReadTokens}}}case"title_changed":return{type:"session/titleChanged",session:t,title:e.title};case"reasoning":{let i=e,s=this._currentReasoningPartId.get(t);if(!s){let o=Ge();return this._currentReasoningPartId.set(t,o),{type:"session/responsePart",session:t,turnId:n,part:{kind:"reasoning",id:o,content:i.content}}}return{type:"session/reasoning",session:t,turnId:n,partId:s,content:i.content}}case"message":return;default:return}}};var ts=class r extends A{constructor(t,n,i){super();this._stateManager=t;this._options=n;this._logService=i;this._toolCallAgents=new Map;this._eventMappers=new Map;this._register(Er(s=>{let o=this._options.agents.read(s);this._publishAgentInfos(o)}))}async _publishAgentInfos(t){let n=await Promise.all(t.map(async i=>{let s=i.getDescriptor(),o;try{o=(await i.listModels()).map(l=>({id:l.id,provider:l.provider,name:l.name,maxContextWindow:l.maxContextWindow,supportsVision:l.supportsVision,policyState:l.policyState}))}catch{o=[]}return{provider:s.provider,displayName:s.displayName,description:s.description,models:o}}));this._stateManager.dispatchServerAction({type:"root/agentsChanged",agents:n})}static{this._DEFAULT_EDIT_AUTO_APPROVE_PATTERNS={"**/*":!0,"**/.vscode/*.json":!1,"**/.git/**":!1,"**/{package.json,server.xml,build.rs,web.config,.gitattributes,.env}":!1,"**/*.{code-workspace,csproj,fsproj,vbproj,vcxproj,proj,targets,props}":!1,"**/*.lock":!1,"**/*-lock.{yaml,json}":!1}}_shouldAutoApproveEdit(t){let n=r._DEFAULT_EDIT_AUTO_APPROVE_PATTERNS,i=!0;for(let[s,o]of Object.entries(n))o!==i&&Eu(s,t)&&(i=o);return i}registerProgressListener(t){let n=new D,i=this._eventMappers.get(t.id);i||(i=new es,this._eventMappers.set(t.id,i));let s=i;return n.add(t.onDidSessionProgress(o=>{o.type==="tool_start"&&this._toolCallAgents.set(`${o.session.toString()}:${o.toolCallId}`,t.id);let a=o.session.toString(),l=this._stateManager.getActiveTurnId(a);if(l){if(o.type==="tool_ready"&&o.permissionKind==="write"&&o.permissionPath&&this._shouldAutoApproveEdit(o.permissionPath)){this._logService.trace(`[AgentSideEffects] Auto-approving write to ${o.permissionPath}`),t.respondToPermissionRequest(o.toolCallId,!0);return}let c=s.mapProgressEventToActions(o,a,l);if(c)if(Array.isArray(c))for(let d of c)this._stateManager.dispatchServerAction(d);else this._stateManager.dispatchServerAction(c)}o.type==="idle"&&this._tryConsumeNextQueuedMessage(a)})),n}handleAction(t){switch(t.type){case"session/turnStarted":{for(let s of this._eventMappers.values())s.reset(t.session);let n=this._options.getAgent(t.session);if(!n){this._stateManager.dispatchServerAction({type:"session/error",session:t.session,turnId:t.turnId,error:{errorType:"noAgent",message:"No agent found for session"}});return}let i=t.userMessage.attachments?.map(s=>({type:s.type,path:s.path,displayName:s.displayName}));n.sendMessage(m.parse(t.session),t.userMessage.text,i).catch(s=>{this._logService.error("[AgentSideEffects] sendMessage failed",s),this._stateManager.dispatchServerAction({type:"session/error",session:t.session,turnId:t.turnId,error:{errorType:"sendFailed",message:String(s)}})});break}case"session/toolCallConfirmed":{let n=`${t.session}:${t.toolCallId}`,i=this._toolCallAgents.get(n);i?(this._toolCallAgents.delete(n),this._options.agents.get().find(o=>o.id===i)?.respondToPermissionRequest(t.toolCallId,t.approved)):this._logService.warn(`[AgentSideEffects] No agent for tool call confirmation: ${t.toolCallId}`);break}case"session/turnCancelled":{this._options.getAgent(t.session)?.abortSession(m.parse(t.session)).catch(i=>{this._logService.error("[AgentSideEffects] abortSession failed",i)});break}case"session/modelChanged":{this._options.getAgent(t.session)?.changeModel?.(m.parse(t.session),t.model).catch(i=>{this._logService.error("[AgentSideEffects] changeModel failed",i)});break}case"session/pendingMessageSet":case"session/pendingMessageRemoved":case"session/queuedMessagesReordered":{this._syncPendingMessages(t.session);break}}}_syncPendingMessages(t){let n=this._stateManager.getSessionState(t);if(!n)return;this._options.getAgent(t)?.setPendingMessages?.(m.parse(t),n.steeringMessage,[]),n.steeringMessage&&this._stateManager.dispatchServerAction({type:"session/pendingMessageRemoved",session:t,kind:"steering",id:n.steeringMessage.id}),this._tryConsumeNextQueuedMessage(t)}_tryConsumeNextQueuedMessage(t){if(this._stateManager.getActiveTurnId(t))return;let n=this._stateManager.getSessionState(t);if(!n?.queuedMessages?.length)return;let i=n.queuedMessages[0],s=Ge();for(let l of this._eventMappers.values())l.reset(t);this._stateManager.dispatchServerAction({type:"session/turnStarted",session:t,turnId:s,userMessage:i.userMessage,queuedMessageId:i.id});let o=this._options.getAgent(t);if(!o){this._stateManager.dispatchServerAction({type:"session/error",session:t,turnId:s,error:{errorType:"noAgent",message:"No agent found for session"}});return}let a=i.userMessage.attachments?.map(l=>({type:l.type,path:l.path,displayName:l.displayName}));o.sendMessage(m.parse(t),i.userMessage.text,a).catch(l=>{this._logService.error("[AgentSideEffects] sendMessage failed (queued)",l),this._stateManager.dispatchServerAction({type:"session/error",session:t,turnId:s,error:{errorType:"sendFailed",message:String(l)}})})}dispose(){this._toolCallAgents.clear(),super.dispose()}};var wu="session-db";function wr(r,e,t,n){return m.from({scheme:wu,authority:gr(x.fromString(r)).toString(),path:`/${encodeURIComponent(e)}/${gr(x.fromString(t))}/${n}`}).toString()}function Cu(r){let e=m.parse(r);if(e.scheme!==wu)return;let[,t,n,i]=e.path.split("/");if(!(!t||!n||i!=="before"&&i!=="after"))try{return{sessionUri:Fo(e.authority).toString(),toolCallId:decodeURIComponent(t),filePath:Fo(n).toString(),part:i}}catch{return}}var ns=class{constructor(e,t,n,i){this._sessionUri=e;this._db=t;this._fileService=n;this._logService=i;this._pendingEdits=new Map;this._completedEdits=new Map}async trackEditStart(e){let t=this._readFile(e),n={beforeContent:x.fromString(""),snapshotDone:t.then(i=>{n.beforeContent=i})};this._pendingEdits.set(e,n),await n.snapshotDone}async completeEdit(e){let t=this._pendingEdits.get(e);if(!t)return;this._pendingEdits.delete(e),await t.snapshotDone;let n=await this._readFile(e);this._completedEdits.set(e,{beforeContent:t.beforeContent,afterContent:n})}takeCompletedEdit(e,t,n){let i=this._completedEdits.get(n);if(!i)return;this._completedEdits.delete(n);let s=i.beforeContent.buffer,o=i.afterContent.buffer;return this._db.storeFileEdit({turnId:e,toolCallId:t,filePath:n,beforeContent:s,afterContent:o,addedLines:void 0,removedLines:void 0}).catch(a=>this._logService.warn(`[FileEditTracker] Failed to persist file edit to database: ${n}`,a)),{type:"fileEdit",beforeURI:wr(this._sessionUri,t,n,"before"),afterURI:wr(this._sessionUri,t,n,"after")}}async _readFile(e){try{return(await this._fileService.readFile(m.file(e))).value}catch(t){return this._logService.trace(`[FileEditTracker] Could not read file for snapshot: ${e}`,t),x.fromString("")}}};function fa(r,e){return e&&(r.stack||r.stacktrace)?f(116,null,Du(r),Pu(r.stack)||Pu(r.stacktrace)):Du(r)}function Pu(r){return Array.isArray(r)?r.join(`
`):r}function Du(r){return r.code==="ERR_UNC_HOST_NOT_ALLOWED"?`${r.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.`:typeof r.code=="string"&&typeof r.errno=="number"&&typeof r.syscall=="string"?f(115,null,r.message):r.message||f(113,null)}function ha(r=null,e=!1){if(!r)return f(113,null);if(Array.isArray(r)){let t=Yr(r),n=ha(t[0],e);return t.length>1?f(114,null,n,t.length):n}if(Ut(r))return r;if(r.detail){let t=r.detail;if(t.error)return fa(t.error,e);if(t.exception)return fa(t.exception,e)}return r.stack?fa(r,e):r.message?r.message:f(113,null)}function Bn(r){return ma(r,0)}function ma(r,e){switch(typeof r){case"object":return r===null?vt(349,e):Array.isArray(r)?Yf(r,e):Xf(r,e);case"string":return ku(r,e);case"boolean":return Jf(r,e);case"number":return vt(r,e);case"undefined":return vt(937,e);default:return vt(617,e)}}function vt(r,e){return(e<<5)-e+r|0}function Jf(r,e){return vt(r?433:863,e)}function ku(r,e){e=vt(149417,e);for(let t=0,n=r.length;t<n;t++)e=vt(r.charCodeAt(t),e);return e}function Yf(r,e){return e=vt(104579,e),r.reduce((t,n)=>ma(n,t),e)}function Xf(r,e){return e=vt(181387,e),Object.keys(r).sort().reduce((t,n)=>(t=ku(n,t),ma(r[n],t)),e)}function ga(r,e,t=32){let n=t-e,i=~((1<<n)-1);return(r<<e|(i&r)>>>n)>>>0}function Cr(r,e=32){return r instanceof ArrayBuffer?gr(x.wrap(new Uint8Array(r))):(r>>>0).toString(16).padStart(e/4,"0")}var Au=class r{constructor(){this._h0=1732584193;this._h1=4023233417;this._h2=2562383102;this._h3=271733878;this._h4=3285377520;this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}static{this._bigBlock32=new DataView(new ArrayBuffer(320))}update(e){let t=e.length;if(t===0)return;let n=this._buff,i=this._buffLen,s=this._leftoverHighSurrogate,o,a;for(s!==0?(o=s,a=-1,s=0):(o=e.charCodeAt(0),a=0);;){let l=o;if(Vl(o))if(a+1<t){let c=e.charCodeAt(a+1);vo(c)?(a++,l=ql(o,c)):l=65533}else{s=o;break}else vo(o)&&(l=65533);if(i=this._push(n,i,l),a++,a<t)o=e.charCodeAt(a);else break}this._buffLen=i,this._leftoverHighSurrogate=s}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),Cr(this._h0)+Cr(this._h1)+Cr(this._h2)+Cr(this._h3)+Cr(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,this._buff.subarray(this._buffLen).fill(0),this._buffLen>56&&(this._step(),this._buff.fill(0));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let e=r._bigBlock32,t=this._buffDV;for(let u=0;u<64;u+=4)e.setUint32(u,t.getUint32(u,!1),!1);for(let u=64;u<320;u+=4)e.setUint32(u,ga(e.getUint32(u-12,!1)^e.getUint32(u-32,!1)^e.getUint32(u-56,!1)^e.getUint32(u-64,!1),1),!1);let n=this._h0,i=this._h1,s=this._h2,o=this._h3,a=this._h4,l,c,d;for(let u=0;u<80;u++)u<20?(l=i&s|~i&o,c=1518500249):u<40?(l=i^s^o,c=1859775393):u<60?(l=i&s|i&o|s&o,c=2400959708):(l=i^s^o,c=3395469782),d=ga(n,5)+l+a+c+e.getUint32(u*4,!1)&4294967295,a=o,o=s,s=ga(i,30),i=n,n=d;this._h0=this._h0+n&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+s&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+a&4294967295}};function va(...r){switch(r.length){case 1:return f(1931,null,r[0]);case 2:return f(1932,null,r[0],r[1]);case 3:return f(1933,null,r[0],r[1],r[2]);default:return}}var Zf=f(1930,null),eh=f(1929,null),At=class r{constructor(){this._input="";this._start=0;this._current=0;this._tokens=[];this._errors=[];this.stringRe=/[a-zA-Z0-9_<>\-\./\\:\*\?\+\[\]\^,#@;"%\$\p{L}-]+/uy}static getLexeme(e){switch(e.type){case 0:return"(";case 1:return")";case 2:return"!";case 3:return e.isTripleEq?"===":"==";case 4:return e.isTripleEq?"!==":"!=";case 5:return"<";case 6:return"<=";case 7:return">=";case 8:return">=";case 9:return"=~";case 10:return e.lexeme;case 11:return"true";case 12:return"false";case 13:return"in";case 14:return"not";case 15:return"&&";case 16:return"||";case 17:return e.lexeme;case 18:return e.lexeme;case 19:return e.lexeme;case 20:return"EOF";default:throw Jr(`unhandled token type: ${JSON.stringify(e)}; have you forgotten to add a case?`)}}static{this._regexFlags=new Set(["i","g","s","m","y","u"].map(e=>e.charCodeAt(0)))}static{this._keywords=new Map([["not",14],["in",13],["false",12],["true",11]])}get errors(){return this._errors}reset(e){return this._input=e,this._start=0,this._current=0,this._tokens=[],this._errors=[],this}scan(){for(;!this._isAtEnd();)switch(this._start=this._current,this._advance()){case 40:this._addToken(0);break;case 41:this._addToken(1);break;case 33:if(this._match(61)){let t=this._match(61);this._tokens.push({type:4,offset:this._start,isTripleEq:t})}else this._addToken(2);break;case 39:this._quotedString();break;case 47:this._regex();break;case 61:if(this._match(61)){let t=this._match(61);this._tokens.push({type:3,offset:this._start,isTripleEq:t})}else this._match(126)?this._addToken(9):this._error(va("==","=~"));break;case 60:this._addToken(this._match(61)?6:5);break;case 62:this._addToken(this._match(61)?8:7);break;case 38:this._match(38)?this._addToken(15):this._error(va("&&"));break;case 124:this._match(124)?this._addToken(16):this._error(va("||"));break;case 32:case 13:case 9:case 10:case 160:break;default:this._string()}return this._start=this._current,this._addToken(20),Array.from(this._tokens)}_match(e){return this._isAtEnd()||this._input.charCodeAt(this._current)!==e?!1:(this._current++,!0)}_advance(){return this._input.charCodeAt(this._current++)}_peek(){return this._isAtEnd()?0:this._input.charCodeAt(this._current)}_addToken(e){this._tokens.push({type:e,offset:this._start})}_error(e){let t=this._start,n=this._input.substring(this._start,this._current),i={type:19,offset:this._start,lexeme:n};this._errors.push({offset:t,lexeme:n,additionalInfo:e}),this._tokens.push(i)}_string(){this.stringRe.lastIndex=this._start;let e=this.stringRe.exec(this._input);if(e){this._current=this._start+e[0].length;let t=this._input.substring(this._start,this._current),n=r._keywords.get(t);n?this._addToken(n):this._tokens.push({type:17,lexeme:t,offset:this._start})}}_quotedString(){for(;this._peek()!==39&&!this._isAtEnd();)this._advance();if(this._isAtEnd()){this._error(Zf);return}this._advance(),this._tokens.push({type:18,lexeme:this._input.substring(this._start+1,this._current-1),offset:this._start+1})}_regex(){let e=this._current,t=!1,n=!1;for(;;){if(e>=this._input.length){this._current=e,this._error(eh);return}let s=this._input.charCodeAt(e);if(t)t=!1;else if(s===47&&!n){e++;break}else s===91?n=!0:s===92?t=!0:s===93&&(n=!1);e++}for(;e<this._input.length&&r._regexFlags.has(this._input.charCodeAt(e));)e++;this._current=e;let i=this._input.substring(this._start,this._current);this._tokens.push({type:10,lexeme:i,offset:this._start})}_isAtEnd(){return this._current>=this._input.length}};var ce=new Map;ce.set("false",!1);ce.set("true",!0);ce.set("isMac",$e);ce.set("isLinux",te);ce.set("isWindows",$);ce.set("isWeb",un);ce.set("isMacNative",$e&&!un);ce.set("isEdge",Tl);ce.set("isFirefox",yl);ce.set("isChrome",ro);ce.set("isSafari",Il);var th=Object.prototype.hasOwnProperty;var nh={regexParsingWithErrorRecovery:!0},rh=f(1910,null),ih=f(1911,null),sh=f(1913,null),Lu=f(1909,null),oh=f(1916,null),ah=f(1917,null),lh=f(1914,null),ch=f(1915,null),ba=class r{constructor(e=nh){this._config=e;this._scanner=new At;this._tokens=[];this._current=0;this._parsingErrors=[];this._flagsGYRe=/g|y/g}static{this._parseError=new Error}get lexingErrors(){return this._scanner.errors}get parsingErrors(){return this._parsingErrors}parse(e){if(e===""){this._parsingErrors.push({message:rh,offset:0,lexeme:"",additionalInfo:ih});return}this._tokens=this._scanner.reset(e).scan(),this._current=0,this._parsingErrors=[];try{let t=this._expr();if(!this._isAtEnd()){let n=this._peek(),i=n.type===17?ah:void 0;throw this._parsingErrors.push({message:oh,offset:n.offset,lexeme:At.getLexeme(n),additionalInfo:i}),r._parseError}return t}catch(t){if(t!==r._parseError)throw t;return}}_expr(){return this._or()}_or(){let e=[this._and()];for(;this._matchOne(16);){let t=this._and();e.push(t)}return e.length===1?e[0]:ge.or(...e)}_and(){let e=[this._term()];for(;this._matchOne(15);){let t=this._term();e.push(t)}return e.length===1?e[0]:ge.and(...e)}_term(){if(this._matchOne(2)){let e=this._peek();switch(e.type){case 11:return this._advance(),ye.INSTANCE;case 12:return this._advance(),we.INSTANCE;case 0:{this._advance();let t=this._expr();return this._consume(1,Lu),t?.negate()}case 17:return this._advance(),nn.create(e.lexeme);default:throw this._errExpectedButGot("KEY | true | false | '(' expression ')'",e)}}return this._primary()}_primary(){let e=this._peek();switch(e.type){case 11:return this._advance(),ge.true();case 12:return this._advance(),ge.false();case 0:{this._advance();let t=this._expr();return this._consume(1,Lu),t}case 17:{let t=e.lexeme;if(this._advance(),this._matchOne(9)){let i=this._peek();if(!this._config.regexParsingWithErrorRecovery){if(this._advance(),i.type!==10)throw this._errExpectedButGot("REGEX",i);let s=i.lexeme,o=s.lastIndexOf("/"),a=o===s.length-1?void 0:this._removeFlagsGY(s.substring(o+1)),l;try{l=new RegExp(s.substring(1,o),a)}catch{throw this._errExpectedButGot("REGEX",i)}return Fr.create(t,l)}switch(i.type){case 10:case 19:{let s=[i.lexeme];this._advance();let o=this._peek(),a=0;for(let p=0;p<i.lexeme.length;p++)i.lexeme.charCodeAt(p)===40?a++:i.lexeme.charCodeAt(p)===41&&a--;for(;!this._isAtEnd()&&o.type!==15&&o.type!==16;){switch(o.type){case 0:a++;break;case 1:a--;break;case 10:case 18:for(let p=0;p<o.lexeme.length;p++)o.lexeme.charCodeAt(p)===40?a++:i.lexeme.charCodeAt(p)===41&&a--}if(a<0)break;s.push(At.getLexeme(o)),this._advance(),o=this._peek()}let l=s.join(""),c=l.lastIndexOf("/"),d=c===l.length-1?void 0:this._removeFlagsGY(l.substring(c+1)),u;try{u=new RegExp(l.substring(1,c),d)}catch{throw this._errExpectedButGot("REGEX",i)}return ge.regex(t,u)}case 18:{let s=i.lexeme;this._advance();let o=null;if(!Ml(s)){let a=s.indexOf("/"),l=s.lastIndexOf("/");if(a!==l&&a>=0){let c=s.slice(a+1,l),d=s[l+1]==="i"?"i":"";try{o=new RegExp(c,d)}catch{throw this._errExpectedButGot("REGEX",i)}}}if(o===null)throw this._errExpectedButGot("REGEX",i);return Fr.create(t,o)}default:throw this._errExpectedButGot("REGEX",this._peek())}}if(this._matchOne(14)){this._consume(13,sh);let i=this._value();return ge.notIn(t,i)}switch(this._peek().type){case 3:{this._advance();let i=this._value();if(this._previous().type===18)return ge.equals(t,i);switch(i){case"true":return ge.has(t);case"false":return ge.not(t);default:return ge.equals(t,i)}}case 4:{this._advance();let i=this._value();if(this._previous().type===18)return ge.notEquals(t,i);switch(i){case"true":return ge.not(t);case"false":return ge.has(t);default:return ge.notEquals(t,i)}}case 5:return this._advance(),Lr.create(t,this._value());case 6:return this._advance(),Or.create(t,this._value());case 7:return this._advance(),Vn.create(t,this._value());case 8:return this._advance(),kr.create(t,this._value());case 13:return this._advance(),ge.in(t,this._value());default:return ge.has(t)}}case 20:throw this._parsingErrors.push({message:lh,offset:e.offset,lexeme:"",additionalInfo:ch}),r._parseError;default:throw this._errExpectedButGot(`true | false | KEY 
	| KEY '=~' REGEX 
	| KEY ('==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not' 'in') value`,this._peek())}}_value(){let e=this._peek();switch(e.type){case 17:case 18:return this._advance(),e.lexeme;case 11:return this._advance(),"true";case 12:return this._advance(),"false";case 13:return this._advance(),"in";default:return""}}_removeFlagsGY(e){return e.replaceAll(this._flagsGYRe,"")}_previous(){return this._tokens[this._current-1]}_matchOne(e){return this._check(e)?(this._advance(),!0):!1}_advance(){return this._isAtEnd()||this._current++,this._previous()}_consume(e,t){if(this._check(e))return this._advance();throw this._errExpectedButGot(t,this._peek())}_errExpectedButGot(e,t,n){let i=f(1912,null,e,At.getLexeme(t)),s=t.offset,o=At.getLexeme(t);return this._parsingErrors.push({message:i,offset:s,lexeme:o,additionalInfo:n}),r._parseError}_check(e){return this._peek().type===e}_peek(){return this._tokens[this._current]}_isAtEnd(){return this._peek().type===20}},ge=class{static false(){return ye.INSTANCE}static true(){return we.INSTANCE}static has(e){return tn.create(e)}static equals(e,t){return Dr.create(e,t)}static notEquals(e,t){return Ar.create(e,t)}static regex(e,t){return Fr.create(e,t)}static in(e,t){return rs.create(e,t)}static notIn(e,t){return is.create(e,t)}static not(e){return nn.create(e)}static and(...e){return ss.create(e,null,!0)}static or(...e){return Ur.create(e,null,!0)}static greater(e,t){return Vn.create(e,t)}static greaterEquals(e,t){return kr.create(e,t)}static smaller(e,t){return Lr.create(e,t)}static smallerEquals(e,t){return Or.create(e,t)}static{this._parser=new ba({regexParsingWithErrorRecovery:!1})}static deserialize(e){return e==null?void 0:this._parser.parse(e)}};function Pr(r,e){return r.cmp(e)}var ye=class r{constructor(){this.type=0}static{this.INSTANCE=new r}cmp(e){return this.type-e.type}equals(e){return e.type===this.type}substituteConstants(){return this}evaluate(e){return!1}serialize(){return"false"}keys(){return[]}map(e){return this}negate(){return we.INSTANCE}},we=class r{constructor(){this.type=1}static{this.INSTANCE=new r}cmp(e){return this.type-e.type}equals(e){return e.type===this.type}substituteConstants(){return this}evaluate(e){return!0}serialize(){return"true"}keys(){return[]}map(e){return this}negate(){return ye.INSTANCE}},tn=class r{constructor(e,t){this.key=e;this.negated=t;this.type=2}static create(e,t=null){let n=ce.get(e);return typeof n=="boolean"?n?we.INSTANCE:ye.INSTANCE:new r(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:Uu(this.key,e.key)}equals(e){return e.type===this.type?this.key===e.key:!1}substituteConstants(){let e=ce.get(this.key);return typeof e=="boolean"?e?we.INSTANCE:ye.INSTANCE:this}evaluate(e){return!!e.getValue(this.key)}serialize(){return this.key}keys(){return[this.key]}map(e){return e.mapDefined(this.key)}negate(){return this.negated||(this.negated=nn.create(this.key,this)),this.negated}},Dr=class r{constructor(e,t,n){this.key=e;this.value=t;this.negated=n;this.type=4}static create(e,t,n=null){if(typeof t=="boolean")return t?tn.create(e,n):nn.create(e,n);let i=ce.get(e);return typeof i=="boolean"?t===(i?"true":"false")?we.INSTANCE:ye.INSTANCE:new r(e,t,n)}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type?this.key===e.key&&this.value===e.value:!1}substituteConstants(){let e=ce.get(this.key);if(typeof e=="boolean"){let t=e?"true":"false";return this.value===t?we.INSTANCE:ye.INSTANCE}return this}evaluate(e){return e.getValue(this.key)==this.value}serialize(){return`${this.key} == '${this.value}'`}keys(){return[this.key]}map(e){return e.mapEquals(this.key,this.value)}negate(){return this.negated||(this.negated=Ar.create(this.key,this.value,this)),this.negated}},rs=class r{constructor(e,t){this.key=e;this.valueKey=t;this.type=10;this.negated=null}static create(e,t){return new r(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.valueKey,e.key,e.valueKey)}equals(e){return e.type===this.type?this.key===e.key&&this.valueKey===e.valueKey:!1}substituteConstants(){return this}evaluate(e){let t=e.getValue(this.valueKey),n=e.getValue(this.key);if(Array.isArray(t)){if(t.includes(n))return!0;if($&&typeof n=="string"&&n.startsWith("file:///")){let i=n.toLowerCase();return t.some(s=>typeof s=="string"&&s.toLowerCase()===i)}return!1}if(typeof n=="string"&&typeof t=="object"&&t!==null){if(th.call(t,n))return!0;if($&&n.startsWith("file:///")){let i=n.toLowerCase();return Object.keys(t).some(s=>s.toLowerCase()===i)}return!1}return!1}serialize(){return`${this.key} in '${this.valueKey}'`}keys(){return[this.key,this.valueKey]}map(e){return e.mapIn(this.key,this.valueKey)}negate(){return this.negated||(this.negated=is.create(this.key,this.valueKey)),this.negated}},is=class r{constructor(e,t){this.key=e;this.valueKey=t;this.type=11;this._negated=rs.create(e,t)}static create(e,t){return new r(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:this._negated.cmp(e._negated)}equals(e){return e.type===this.type?this._negated.equals(e._negated):!1}substituteConstants(){return this}evaluate(e){return!this._negated.evaluate(e)}serialize(){return`${this.key} not in '${this.valueKey}'`}keys(){return this._negated.keys()}map(e){return e.mapNotIn(this.key,this.valueKey)}negate(){return this._negated}},Ar=class r{constructor(e,t,n){this.key=e;this.value=t;this.negated=n;this.type=5}static create(e,t,n=null){if(typeof t=="boolean")return t?nn.create(e,n):tn.create(e,n);let i=ce.get(e);return typeof i=="boolean"?t===(i?"true":"false")?ye.INSTANCE:we.INSTANCE:new r(e,t,n)}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type?this.key===e.key&&this.value===e.value:!1}substituteConstants(){let e=ce.get(this.key);if(typeof e=="boolean"){let t=e?"true":"false";return this.value===t?ye.INSTANCE:we.INSTANCE}return this}evaluate(e){return e.getValue(this.key)!=this.value}serialize(){return`${this.key} != '${this.value}'`}keys(){return[this.key]}map(e){return e.mapNotEquals(this.key,this.value)}negate(){return this.negated||(this.negated=Dr.create(this.key,this.value,this)),this.negated}},nn=class r{constructor(e,t){this.key=e;this.negated=t;this.type=3}static create(e,t=null){let n=ce.get(e);return typeof n=="boolean"?n?ye.INSTANCE:we.INSTANCE:new r(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:Uu(this.key,e.key)}equals(e){return e.type===this.type?this.key===e.key:!1}substituteConstants(){let e=ce.get(this.key);return typeof e=="boolean"?e?ye.INSTANCE:we.INSTANCE:this}evaluate(e){return!e.getValue(this.key)}serialize(){return`!${this.key}`}keys(){return[this.key]}map(e){return e.mapNot(this.key)}negate(){return this.negated||(this.negated=tn.create(this.key,this)),this.negated}};function as(r,e){if(typeof r=="string"){let t=parseFloat(r);isNaN(t)||(r=t)}return typeof r=="string"||typeof r=="number"?e(r):ye.INSTANCE}var Vn=class r{constructor(e,t,n){this.key=e;this.value=t;this.negated=n;this.type=12}static create(e,t,n=null){return as(t,i=>new r(e,i,n))}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type?this.key===e.key&&this.value===e.value:!1}substituteConstants(){return this}evaluate(e){return typeof this.value=="string"?!1:parseFloat(e.getValue(this.key))>this.value}serialize(){return`${this.key} > ${this.value}`}keys(){return[this.key]}map(e){return e.mapGreater(this.key,this.value)}negate(){return this.negated||(this.negated=Or.create(this.key,this.value,this)),this.negated}},kr=class r{constructor(e,t,n){this.key=e;this.value=t;this.negated=n;this.type=13}static create(e,t,n=null){return as(t,i=>new r(e,i,n))}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type?this.key===e.key&&this.value===e.value:!1}substituteConstants(){return this}evaluate(e){return typeof this.value=="string"?!1:parseFloat(e.getValue(this.key))>=this.value}serialize(){return`${this.key} >= ${this.value}`}keys(){return[this.key]}map(e){return e.mapGreaterEquals(this.key,this.value)}negate(){return this.negated||(this.negated=Lr.create(this.key,this.value,this)),this.negated}},Lr=class r{constructor(e,t,n){this.key=e;this.value=t;this.negated=n;this.type=14}static create(e,t,n=null){return as(t,i=>new r(e,i,n))}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type?this.key===e.key&&this.value===e.value:!1}substituteConstants(){return this}evaluate(e){return typeof this.value=="string"?!1:parseFloat(e.getValue(this.key))<this.value}serialize(){return`${this.key} < ${this.value}`}keys(){return[this.key]}map(e){return e.mapSmaller(this.key,this.value)}negate(){return this.negated||(this.negated=kr.create(this.key,this.value,this)),this.negated}},Or=class r{constructor(e,t,n){this.key=e;this.value=t;this.negated=n;this.type=15}static create(e,t,n=null){return as(t,i=>new r(e,i,n))}cmp(e){return e.type!==this.type?this.type-e.type:rn(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type?this.key===e.key&&this.value===e.value:!1}substituteConstants(){return this}evaluate(e){return typeof this.value=="string"?!1:parseFloat(e.getValue(this.key))<=this.value}serialize(){return`${this.key} <= ${this.value}`}keys(){return[this.key]}map(e){return e.mapSmallerEquals(this.key,this.value)}negate(){return this.negated||(this.negated=Vn.create(this.key,this.value,this)),this.negated}},Fr=class r{constructor(e,t){this.key=e;this.regexp=t;this.type=7;this.negated=null}static create(e,t){return new r(e,t)}cmp(e){if(e.type!==this.type)return this.type-e.type;if(this.key<e.key)return-1;if(this.key>e.key)return 1;let t=this.regexp?this.regexp.source:"",n=e.regexp?e.regexp.source:"";return t<n?-1:t>n?1:0}equals(e){if(e.type===this.type){let t=this.regexp?this.regexp.source:"",n=e.regexp?e.regexp.source:"";return this.key===e.key&&t===n}return!1}substituteConstants(){return this}evaluate(e){let t=e.getValue(this.key);return this.regexp?this.regexp.test(t):!1}serialize(){let e=this.regexp?`/${this.regexp.source}/${this.regexp.flags}`:"/invalid/";return`${this.key} =~ ${e}`}keys(){return[this.key]}map(e){return e.mapRegex(this.key,this.regexp)}negate(){return this.negated||(this.negated=ya.create(this)),this.negated}},ya=class r{constructor(e){this._actual=e;this.type=8}static create(e){return new r(e)}cmp(e){return e.type!==this.type?this.type-e.type:this._actual.cmp(e._actual)}equals(e){return e.type===this.type?this._actual.equals(e._actual):!1}substituteConstants(){return this}evaluate(e){return!this._actual.evaluate(e)}serialize(){return`!(${this._actual.serialize()})`}keys(){return this._actual.keys()}map(e){return new r(this._actual.map(e))}negate(){return this._actual}};function Fu(r){let e=null;for(let t=0,n=r.length;t<n;t++){let i=r[t].substituteConstants();if(r[t]!==i&&e===null){e=[];for(let s=0;s<t;s++)e[s]=r[s]}e!==null&&(e[t]=i)}return e===null?r:e}var ss=class r{constructor(e,t){this.expr=e;this.negated=t;this.type=6}static create(e,t,n){return r._normalizeArr(e,t,n)}cmp(e){if(e.type!==this.type)return this.type-e.type;if(this.expr.length<e.expr.length)return-1;if(this.expr.length>e.expr.length)return 1;for(let t=0,n=this.expr.length;t<n;t++){let i=Pr(this.expr[t],e.expr[t]);if(i!==0)return i}return 0}equals(e){if(e.type===this.type){if(this.expr.length!==e.expr.length)return!1;for(let t=0,n=this.expr.length;t<n;t++)if(!this.expr[t].equals(e.expr[t]))return!1;return!0}return!1}substituteConstants(){let e=Fu(this.expr);return e===this.expr?this:r.create(e,this.negated,!1)}evaluate(e){for(let t=0,n=this.expr.length;t<n;t++)if(!this.expr[t].evaluate(e))return!1;return!0}static _normalizeArr(e,t,n){let i=[],s=!1;for(let o of e)if(o){if(o.type===1){s=!0;continue}if(o.type===0)return ye.INSTANCE;if(o.type===6){i.push(...o.expr);continue}i.push(o)}if(i.length===0&&s)return we.INSTANCE;if(i.length!==0){if(i.length===1)return i[0];i.sort(Pr);for(let o=1;o<i.length;o++)i[o-1].equals(i[o])&&(i.splice(o,1),o--);if(i.length===1)return i[0];for(;i.length>1;){let o=i[i.length-1];if(o.type!==9)break;i.pop();let a=i.pop(),l=i.length===0,c=Ur.create(o.expr.map(d=>r.create([d,a],null,n)),null,l);c&&(i.push(c),i.sort(Pr))}if(i.length===1)return i[0];if(n){for(let o=0;o<i.length;o++)for(let a=o+1;a<i.length;a++)if(i[o].negate().equals(i[a]))return ye.INSTANCE;if(i.length===1)return i[0]}return new r(i,t)}}serialize(){return this.expr.map(e=>e.serialize()).join(" && ")}keys(){let e=[];for(let t of this.expr)e.push(...t.keys());return e}map(e){return new r(this.expr.map(t=>t.map(e)),null)}negate(){if(!this.negated){let e=[];for(let t of this.expr)e.push(t.negate());this.negated=Ur.create(e,this,!0)}return this.negated}},Ur=class r{constructor(e,t){this.expr=e;this.negated=t;this.type=9}static create(e,t,n){return r._normalizeArr(e,t,n)}cmp(e){if(e.type!==this.type)return this.type-e.type;if(this.expr.length<e.expr.length)return-1;if(this.expr.length>e.expr.length)return 1;for(let t=0,n=this.expr.length;t<n;t++){let i=Pr(this.expr[t],e.expr[t]);if(i!==0)return i}return 0}equals(e){if(e.type===this.type){if(this.expr.length!==e.expr.length)return!1;for(let t=0,n=this.expr.length;t<n;t++)if(!this.expr[t].equals(e.expr[t]))return!1;return!0}return!1}substituteConstants(){let e=Fu(this.expr);return e===this.expr?this:r.create(e,this.negated,!1)}evaluate(e){for(let t=0,n=this.expr.length;t<n;t++)if(this.expr[t].evaluate(e))return!0;return!1}static _normalizeArr(e,t,n){let i=[],s=!1;if(e){for(let o=0,a=e.length;o<a;o++){let l=e[o];if(l){if(l.type===0){s=!0;continue}if(l.type===1)return we.INSTANCE;if(l.type===9){i=i.concat(l.expr);continue}i.push(l)}}if(i.length===0&&s)return ye.INSTANCE;i.sort(Pr)}if(i.length!==0){if(i.length===1)return i[0];for(let o=1;o<i.length;o++)i[o-1].equals(i[o])&&(i.splice(o,1),o--);if(i.length===1)return i[0];if(n){for(let o=0;o<i.length;o++)for(let a=o+1;a<i.length;a++)if(i[o].negate().equals(i[a]))return we.INSTANCE;if(i.length===1)return i[0]}return new r(i,t)}}serialize(){return this.expr.map(e=>e.serialize()).join(" || ")}keys(){let e=[];for(let t of this.expr)e.push(...t.keys());return e}map(e){return new r(this.expr.map(t=>t.map(e)),null)}negate(){if(!this.negated){let e=[];for(let t of this.expr)e.push(t.negate());for(;e.length>1;){let t=e.shift(),n=e.shift(),i=[];for(let s of Ou(t))for(let o of Ou(n))i.push(ss.create([s,o],null,!1));e.unshift(r.create(i,null,!1))}this.negated=r.create(e,this,!0)}return this.negated}},os=class r extends tn{static{this._info=[]}static all(){return r._info.values()}constructor(e,t,n){super(e,null),this._defaultValue=t,typeof n=="object"?r._info.push({...n,key:e}):n!==!0&&r._info.push({key:e,description:n,type:t!=null?typeof t:void 0})}bindTo(e){return e.createKey(this.key,this._defaultValue)}getValue(e){return e.getContextKeyValue(this.key)}toNegated(){return this.negate()}isEqualTo(e){return Dr.create(this.key,e)}notEqualsTo(e){return Ar.create(this.key,e)}greater(e){return Vn.create(this.key,e)}},oS=Fe("contextKeyService");function Uu(r,e){return r<e?-1:r>e?1:0}function rn(r,e,t,n){return r<t?-1:r>t?1:e<n?-1:e>n?1:0}function Ou(r){return r.type===9?r.expr:[r]}var Le=Fe("logService"),SS=Fe("loggerService");function Ia(r){return tr(r)}var Nu=3;function uh(r,e){return r!==0&&r<=e}function qn(r,e=!1){let t="";for(let n=0;n<r.length;n++){let i=r[n];if(i instanceof Error&&(i=ha(i,e)),typeof i=="object")try{i=JSON.stringify(i)}catch{}t+=(n>0?" ":"")+i}return t}var ls=class extends A{constructor(){super(...arguments);this.level=Nu;this._onDidChangeLogLevel=this._register(new I)}get onDidChangeLogLevel(){return this._onDidChangeLogLevel.event}setLevel(t){this.level!==t&&(this.level=t,this._onDidChangeLogLevel.fire(this.level))}getLevel(){return this.level}checkLogLevel(t){return uh(this.level,t)}canLog(t){return this._store.isDisposed?!1:this.checkLogLevel(t)}},Nr=class extends ls{constructor(t){super();this.logAlways=t}checkLogLevel(t){return this.logAlways||super.checkLogLevel(t)}trace(t,...n){this.canLog(1)&&this.log(1,qn([t,...n],!0))}debug(t,...n){this.canLog(2)&&this.log(2,qn([t,...n]))}info(t,...n){this.canLog(3)&&this.log(3,qn([t,...n]))}warn(t,...n){this.canLog(4)&&this.log(4,qn([t,...n]))}error(t,...n){if(this.canLog(5))if(t instanceof Error){let i=Array.prototype.slice.call(arguments);i[0]=t.stack,this.log(5,qn(i))}else this.log(5,qn([t,...n]))}flush(){}};var cs=class extends ls{constructor(t){super();this.loggers=t;t.length&&this.setLevel(t[0].getLevel())}setLevel(t){for(let n of this.loggers)n.setLevel(t);super.setLevel(t)}trace(t,...n){for(let i of this.loggers)i.trace(t,...n)}debug(t,...n){for(let i of this.loggers)i.debug(t,...n)}info(t,...n){for(let i of this.loggers)i.info(t,...n)}warn(t,...n){for(let i of this.loggers)i.warn(t,...n)}error(t,...n){for(let i of this.loggers)i.error(t,...n)}flush(){for(let t of this.loggers)t.flush()}dispose(){for(let t of this.loggers)t.dispose();super.dispose()}},Mr=class extends A{constructor(t,n,i){super();this.logLevel=t;this.logsHome=n;this._loggers=new rt;this._onDidChangeLoggers=this._register(new I);this.onDidChangeLoggers=this._onDidChangeLoggers.event;this._onDidChangeLogLevel=this._register(new I);this.onDidChangeLogLevel=this._onDidChangeLogLevel.event;this._onDidChangeVisibility=this._register(new I);this.onDidChangeVisibility=this._onDidChangeVisibility.event;if(i)for(let s of i)this._loggers.set(s.resource,{logger:void 0,info:s})}getLoggerEntry(t){return Ut(t)?[...this._loggers.values()].find(n=>n.info.id===t):this._loggers.get(t)}getLogger(t){return this.getLoggerEntry(t)?.logger}createLogger(t,n){let i=this.toResource(t),s=Ut(t)?t:n?.id??Bn(i.toString()).toString(16),o=this._loggers.get(i)?.logger,a=n?.logLevel==="always"?1:n?.logLevel;o||(o=this.doCreateLogger(i,a??this.getLogLevel(i)??this.logLevel,{...n,id:s}));let l={logger:o,info:{resource:i,id:s,logLevel:a,name:n?.name,hidden:n?.hidden,group:n?.group,extensionId:n?.extensionId,when:n?.when}};return this.registerLogger(l.info),this._loggers.set(i,l),o}toResource(t){return Ut(t)?se(this.logsHome,`${t.replace(/[\\/:\*\?"<>\|]/g,"")}.log`):t}setLogLevel(t,n){if(m.isUri(t)){let i=t,s=n,o=this._loggers.get(i);o&&s!==o.info.logLevel&&(o.info.logLevel=s===this.logLevel?void 0:s,o.logger?.setLevel(s),this._loggers.set(o.info.resource,o),this._onDidChangeLogLevel.fire([i,s]))}else{this.logLevel=t;for(let[i,s]of this._loggers.entries())this._loggers.get(i)?.info.logLevel===void 0&&s.logger?.setLevel(this.logLevel);this._onDidChangeLogLevel.fire(this.logLevel)}}setVisibility(t,n){let i=this.getLoggerEntry(t);i&&n!==!i.info.hidden&&(i.info.hidden=!n,this._loggers.set(i.info.resource,i),this._onDidChangeVisibility.fire([i.info.resource,n]))}getLogLevel(t){let n;return t&&(n=this._loggers.get(t)?.info.logLevel),n??this.logLevel}registerLogger(t){let n=this._loggers.get(t.resource);n?n.info.hidden!==t.hidden&&this.setVisibility(t.resource,!t.hidden):(this._loggers.set(t.resource,{info:t,logger:void 0}),this._onDidChangeLoggers.fire({added:[t],removed:[]}))}deregisterLogger(t){let n=this.toResource(t),i=this._loggers.get(n);i&&(i.logger&&i.logger.dispose(),this._loggers.delete(n),this._onDidChangeLoggers.fire({added:[],removed:[i.info]}))}*getRegisteredLoggers(){for(let t of this._loggers.values())yield t.info}getRegisteredLogger(t){return this._loggers.get(t)?.info}dispose(){this._loggers.forEach(t=>t.logger?.dispose()),this._loggers.clear(),super.dispose()}};function Mu(r){if(r.verbose)return 1;if(typeof r.logLevel=="string"){let e=ph(r.logLevel.toLowerCase());if(e!==void 0)return e}return Nu}function dh(r){switch(r){case 1:return"trace";case 2:return"debug";case 3:return"info";case 4:return"warn";case 5:return"error";case 0:return"off"}}function ph(r){switch(r){case"trace":return 1;case"debug":return 2;case"info":return 3;case"warn":return 4;case"error":return 5;case"critical":return 5;case"off":return 0}}var _S=new os("logLevel",dh(3));var fh={"root/agentsChanged":!1,"root/activeSessionsChanged":!1,"session/ready":!1,"session/creationFailed":!1,"session/turnStarted":!0,"session/delta":!1,"session/responsePart":!1,"session/toolCallStart":!1,"session/toolCallDelta":!1,"session/toolCallReady":!1,"session/toolCallConfirmed":!0,"session/toolCallComplete":!0,"session/toolCallResultConfirmed":!0,"session/turnComplete":!1,"session/turnCancelled":!0,"session/error":!1,"session/titleChanged":!1,"session/usage":!1,"session/reasoning":!1,"session/modelChanged":!0,"session/serverToolsChanged":!1,"session/activeClientChanged":!0,"session/activeClientToolsChanged":!0,"session/pendingMessageSet":!0,"session/pendingMessageRemoved":!0,"session/queuedMessagesReordered":!0,"session/customizationsChanged":!1,"session/customizationToggled":!0};function Sa(r,e){let t=`Unhandled action type: ${JSON.stringify(r)}`;(e??console.warn)(t)}function Br(r){return{toolCallId:r.toolCallId,toolName:r.toolName,displayName:r.displayName,toolClientId:r.toolClientId,_meta:r._meta}}function Ta(r,e,t,n,i){if(!r.activeTurn||r.activeTurn.id!==e)return r;let s=r.activeTurn,o=s.responseParts.map(l=>{if(l.kind!=="toolCall")return l;let c=l.toolCall;return c.status==="completed"||c.status==="cancelled"?l:{kind:"toolCall",toolCall:{status:"cancelled",...Br(c),invocationMessage:c.status==="streaming"?c.invocationMessage??"":c.invocationMessage,toolInput:c.status==="streaming"?void 0:c.toolInput,reason:"skipped"}}}),a={id:s.id,userMessage:s.userMessage,responseParts:o,usage:s.usage,state:t,error:i};return{...r,turns:[...r.turns,a],activeTurn:void 0,summary:{...r.summary,status:n,modifiedAt:Date.now()}}}function Wr(r,e,t,n){let i=r.activeTurn;if(!i||i.id!==e)return r;let s=!1,o=i.responseParts.map(a=>{if(a.kind==="toolCall"&&a.toolCall.toolCallId===t){let l=n(a.toolCall);return l===a.toolCall?a:(s=!0,{...a,toolCall:l})}return a});return s?{...r,activeTurn:{...i,responseParts:o}}:r}function Wu(r,e,t,n){let i=r.activeTurn;if(!i||i.id!==e)return r;let s=!1,o=i.responseParts.map(a=>!s&&(a.kind==="toolCall"?a.toolCall.toolCallId:"id"in a?a.id:void 0)===t?(s=!0,n(a)):a);return s?{...r,activeTurn:{...i,responseParts:o}}:r}function _a(r,e,t){switch(e.type){case"root/agentsChanged":return{...r,agents:e.agents};case"root/activeSessionsChanged":return{...r,activeSessions:e.activeSessions};default:return Sa(e,t),r}}function xa(r,e,t){switch(e.type){case"session/ready":return{...r,lifecycle:"ready",summary:{...r.summary,status:"idle"}};case"session/creationFailed":return{...r,lifecycle:"creationFailed",creationError:e.error};case"session/turnStarted":{let n={...r,summary:{...r.summary,status:"in-progress",modifiedAt:Date.now()},activeTurn:{id:e.turnId,userMessage:e.userMessage,responseParts:[],usage:void 0}};if(e.queuedMessageId&&(n.steeringMessage?.id===e.queuedMessageId&&(n={...n,steeringMessage:void 0}),n.queuedMessages)){let i=n.queuedMessages.filter(s=>s.id!==e.queuedMessageId);n={...n,queuedMessages:i.length>0?i:void 0}}return n}case"session/delta":return Wu(r,e.turnId,e.partId,n=>n.kind==="markdown"?{...n,content:n.content+e.content}:n);case"session/responsePart":return!r.activeTurn||r.activeTurn.id!==e.turnId?r:{...r,activeTurn:{...r.activeTurn,responseParts:[...r.activeTurn.responseParts,e.part]}};case"session/turnComplete":return Ta(r,e.turnId,"complete","idle");case"session/turnCancelled":return Ta(r,e.turnId,"cancelled","idle");case"session/error":return Ta(r,e.turnId,"error","error",e.error);case"session/toolCallStart":return!r.activeTurn||r.activeTurn.id!==e.turnId?r:{...r,activeTurn:{...r.activeTurn,responseParts:[...r.activeTurn.responseParts,{kind:"toolCall",toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,displayName:e.displayName,toolClientId:e.toolClientId,_meta:e._meta,status:"streaming"}}]}};case"session/toolCallDelta":return Wr(r,e.turnId,e.toolCallId,n=>n.status!=="streaming"?n:{...n,partialInput:(n.partialInput??"")+e.content,invocationMessage:e.invocationMessage??n.invocationMessage});case"session/toolCallReady":return Wr(r,e.turnId,e.toolCallId,n=>{if(n.status!=="streaming"&&n.status!=="running")return n;let i=Br(n);return e.confirmed?{status:"running",...i,invocationMessage:e.invocationMessage,toolInput:e.toolInput,confirmed:e.confirmed}:{status:"pending-confirmation",...i,invocationMessage:e.invocationMessage,toolInput:e.toolInput,confirmationTitle:e.confirmationTitle}});case"session/toolCallConfirmed":return Wr(r,e.turnId,e.toolCallId,n=>{if(n.status!=="pending-confirmation")return n;let i=Br(n);return e.approved?{status:"running",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:e.confirmed}:{status:"cancelled",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,reason:e.reason,reasonMessage:e.reasonMessage,userSuggestion:e.userSuggestion}});case"session/toolCallComplete":return Wr(r,e.turnId,e.toolCallId,n=>{if(n.status!=="running"&&n.status!=="pending-confirmation")return n;let i=Br(n),s=n.status==="running"?n.confirmed:"not-needed";return e.requiresResultConfirmation?{status:"pending-result-confirmation",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:s,...e.result}:{status:"completed",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:s,...e.result}});case"session/toolCallResultConfirmed":return Wr(r,e.turnId,e.toolCallId,n=>{if(n.status!=="pending-result-confirmation")return n;let i=Br(n);return e.approved?{status:"completed",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:n.confirmed,success:n.success,pastTenseMessage:n.pastTenseMessage,content:n.content,structuredContent:n.structuredContent,error:n.error}:{status:"cancelled",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,reason:"result-denied"}});case"session/titleChanged":return{...r,summary:{...r.summary,title:e.title,modifiedAt:Date.now()}};case"session/usage":return!r.activeTurn||r.activeTurn.id!==e.turnId?r:{...r,activeTurn:{...r.activeTurn,usage:e.usage}};case"session/reasoning":return Wu(r,e.turnId,e.partId,n=>n.kind==="reasoning"?{...n,content:n.content+e.content}:n);case"session/modelChanged":return{...r,summary:{...r.summary,model:e.model,modifiedAt:Date.now()}};case"session/serverToolsChanged":return{...r,serverTools:e.tools};case"session/activeClientChanged":return{...r,activeClient:e.activeClient??void 0};case"session/activeClientToolsChanged":return r.activeClient?{...r,activeClient:{...r.activeClient,tools:e.tools}}:r;case"session/customizationsChanged":return{...r,customizations:e.customizations};case"session/customizationToggled":{let n=r.customizations;if(!n)return r;let i=n.findIndex(o=>o.customization.uri===e.uri);if(i<0)return r;let s=[...n];return s[i]={...n[i],enabled:e.enabled},{...r,customizations:s}}case"session/pendingMessageSet":{let n={id:e.id,userMessage:e.userMessage};if(e.kind==="steering")return{...r,steeringMessage:n};let i=r.queuedMessages??[],s=i.findIndex(o=>o.id===e.id);if(s>=0){let o=[...i];return o[s]=n,{...r,queuedMessages:o}}return{...r,queuedMessages:[...i,n]}}case"session/pendingMessageRemoved":{if(e.kind==="steering")return!r.steeringMessage||r.steeringMessage.id!==e.id?r:{...r,steeringMessage:void 0};let n=r.queuedMessages;if(!n)return r;let i=n.filter(s=>s.id!==e.id);return i.length===n.length?r:{...r,queuedMessages:i.length>0?i:void 0}}case"session/queuedMessagesReordered":{let n=r.queuedMessages;if(!n)return r;let i=new Map(n.map(a=>[a.id,a])),s=new Set,o=e.order.filter(a=>i.has(a)&&!s.has(a)?(s.add(a),!0):!1).map(a=>i.get(a));for(let a of n)s.has(a.id)||o.push(a);return{...r,queuedMessages:o}}default:return Sa(e,t),r}}var $n=class extends A{constructor(t){super();this._logService=t;this._serverSeq=0;this._sessionStates=new Map;this._activeTurnToSession=new Map;this._onDidEmitEnvelope=this._register(new I);this.onDidEmitEnvelope=this._onDidEmitEnvelope.event;this._onDidEmitNotification=this._register(new I);this.onDidEmitNotification=this._onDidEmitNotification.event;this._log=t=>this._logService.warn(`[SessionStateManager] ${t}`);this._rootState=mu()}get hasActiveSessions(){return this._activeTurnToSession.size>0}get rootState(){return this._rootState}getSessionState(t){return this._sessionStates.get(t)}get serverSeq(){return this._serverSeq}getSnapshot(t){if(t===Yi)return{resource:t,state:this._rootState,fromSeq:this._serverSeq};let n=this._sessionStates.get(t);if(n)return{resource:t,state:n,fromSeq:this._serverSeq}}createSession(t){let n=t.resource;if(this._sessionStates.has(n))return this._logService.warn(`[SessionStateManager] Session already exists: ${n}`),this._sessionStates.get(n);let i=la(t);return this._sessionStates.set(n,i),this._logService.trace(`[SessionStateManager] Created session: ${n}`),this._onDidEmitNotification.fire({type:"notify/sessionAdded",summary:t}),i}restoreSession(t,n){let i=t.resource;if(this._sessionStates.has(i))return this._logService.warn(`[SessionStateManager] Session already exists (restore): ${i}`),this._sessionStates.get(i);let s={...la(t),lifecycle:"ready",turns:n};return this._sessionStates.set(i,s),this._logService.trace(`[SessionStateManager] Restored session: ${i} (${n.length} turns)`),s}removeSession(t){let n=this._sessionStates.get(t);n&&(n.activeTurn&&this._activeTurnToSession.delete(n.activeTurn.id),this._sessionStates.delete(t),this._logService.trace(`[SessionStateManager] Removed session: ${t}`))}deleteSession(t){this.removeSession(t),this._onDidEmitNotification.fire({type:"notify/sessionRemoved",session:t})}getActiveTurnId(t){return this._sessionStates.get(t)?.activeTurn?.id}dispatchServerAction(t){this._applyAndEmit(t,void 0)}dispatchClientAction(t,n){return this._applyAndEmit(t,n)}_applyAndEmit(t,n){let i;if(au(t)&&(this._rootState=_a(this._rootState,t,this._log),i=this._rootState),Qi(t)){let o=t,a=o.session,l=this._sessionStates.get(a);if(l){let c=xa(l,o,this._log);this._sessionStates.set(a,c),o.type==="session/turnStarted"?(this._activeTurnToSession.set(o.turnId,a),this.dispatchServerAction({type:"root/activeSessionsChanged",activeSessions:this._activeTurnToSession.size})):(o.type==="session/turnComplete"||o.type==="session/turnCancelled"||o.type==="session/error")&&(this._activeTurnToSession.delete(o.turnId),this.dispatchServerAction({type:"root/activeSessionsChanged",activeSessions:this._activeTurnToSession.size})),i=c}else this._logService.warn(`[SessionStateManager] Action for unknown session: ${a}, type=${t.type}`)}let s={action:t,serverSeq:++this._serverSeq,origin:n};return this._logService.trace(`[SessionStateManager] Emitting envelope: seq=${s.serverSeq}, type=${t.type}${n?`, origin=${n.clientId}:${n.clientSeq}`:""}`),this._onDidEmitEnvelope.fire(s),i}};$n=P([Se(0,Le)],$n);var us=class extends A{constructor(t,n,i){super();this._logService=t;this._fileService=n;this._sessionDataService=i;this._onDidAction=this._register(new I);this.onDidAction=this._onDidAction.event;this._onDidNotification=this._register(new I);this.onDidNotification=this._onDidNotification.event;this._providers=new Map;this._sessionToProvider=new Map;this._providerSubscriptions=this._register(new D);this._agents=xr("agents",[]);this._logService.info("AgentService initialized"),this._stateManager=this._register(new $n(t)),this._register(this._stateManager.onDidEmitEnvelope(s=>this._onDidAction.fire(s))),this._register(this._stateManager.onDidEmitNotification(s=>this._onDidNotification.fire(s))),this._sideEffects=this._register(new ts(this._stateManager,{getAgent:s=>this._findProviderForSession(s),sessionDataService:this._sessionDataService,agents:this._agents},this._logService))}get stateManager(){return this._stateManager}registerProvider(t){if(this._providers.has(t.id))throw new Error(`Agent provider already registered: ${t.id}`);this._logService.info(`Registering agent provider: ${t.id}`),this._providers.set(t.id,t),this._providerSubscriptions.add(this._sideEffects.registerProgressListener(t)),this._defaultProvider||(this._defaultProvider=t.id),this._updateAgents()}async listAgents(){return[...this._providers.values()].map(t=>t.getDescriptor())}async getResourceMetadata(){return{resources:[...this._providers.values()].flatMap(n=>n.getProtectedResources())}}getResourceMetadataSync(){return{resources:[...this._providers.values()].flatMap(n=>n.getProtectedResources())}}async authenticate(t){this._logService.trace(`[AgentService] authenticate called: resource=${t.resource}`);for(let n of this._providers.values())if(n.getProtectedResources().some(s=>s.resource===t.resource)&&await n.authenticate(t.resource,t.token))return{authenticated:!0};return{authenticated:!1}}async listSessions(){this._logService.trace("[AgentService] listSessions called");let n=(await Promise.all([...this._providers.values()].map(i=>i.listSessions()))).flat();return this._logService.trace(`[AgentService] listSessions returned ${n.length} sessions`),n}async refreshModels(){this._logService.trace("[AgentService] refreshModels called"),this._updateAgents()}async createSession(t){let n=t?.provider??this._defaultProvider,i=n?this._providers.get(n):void 0;if(!i)throw new Error(`No agent provider registered for: ${n??"(none)"}`);this._logService.trace(`[AgentService] createSession: provider=${i.id} model=${t?.model??"(default)"}`);let s=await i.createSession(t);this._sessionToProvider.set(s.toString(),i.id),this._logService.trace(`[AgentService] createSession returned: ${s.toString()}`);let o={resource:s.toString(),provider:i.id,title:"New Session",status:"idle",createdAt:Date.now(),modifiedAt:Date.now(),workingDirectory:t?.workingDirectory?.toString()};return this._stateManager.createSession(o),this._stateManager.dispatchServerAction({type:"session/ready",session:s.toString()}),s}async disposeSession(t){this._logService.trace(`[AgentService] disposeSession: ${t.toString()}`);let n=this._findProviderForSession(t);n&&(await n.disposeSession(t),this._sessionToProvider.delete(t.toString())),this._stateManager.deleteSession(t.toString())}async subscribe(t){this._logService.trace(`[AgentService] subscribe: ${t.toString()}`);let n=this._stateManager.getSnapshot(t.toString());if(n||(await this.restoreSession(t),n=this._stateManager.getSnapshot(t.toString())),!n)throw new Error(`Cannot subscribe to unknown resource: ${t.toString()}`);return n}unsubscribe(t){this._logService.trace(`[AgentService] unsubscribe: ${t.toString()}`)}dispatchAction(t,n,i){this._logService.trace(`[AgentService] dispatchAction: type=${t.type}, clientId=${n}, clientSeq=${i}`,t);let s={clientId:n,clientSeq:i},o=this._stateManager.dispatchClientAction(t,s);this._logService.trace("[AgentService] resulting state:",o),this._sideEffects.handleAction(t)}async browseDirectory(t){let n;try{n=await this._fileService.resolve(t)}catch{throw new X(mt.NotFound,`Directory not found: ${t.toString()}`)}if(!n.isDirectory)throw new X(mt.NotFound,`Not a directory: ${t.toString()}`);return{entries:(n.children??[]).map(s=>({name:s.name,type:s.isDirectory?"directory":"file"}))}}async restoreSession(t){let n=t.toString();if(this._stateManager.getSessionState(n))return;let i=this._findProviderForSession(t);if(!i)throw new X(Mn,`No agent for session: ${n}`);let s;try{s=await i.listSessions()}catch(d){if(d instanceof X)throw d;let u=d instanceof Error?d.message:String(d);throw new X(Nn,`Failed to list sessions for ${n}: ${u}`)}let o=s.find(d=>d.session.toString()===n);if(!o)throw new X(Mn,`Session not found on backend: ${n}`);let a;try{a=await i.getSessionMessages(t)}catch(d){if(d instanceof X)throw d;let u=d instanceof Error?d.message:String(d);throw new X(Nn,`Failed to restore session ${n}: ${u}`)}let l=this._buildTurnsFromMessages(a),c={resource:n,provider:i.id,title:o.summary??"Session",status:"idle",createdAt:o.startTime,modifiedAt:o.modifiedTime,workingDirectory:o.workingDirectory?.toString()};this._stateManager.restoreSession(c,l),this._logService.info(`[AgentService] Restored session ${n} with ${l.length} turns`)}async fetchContent(t){let n=Cu(t.toString());if(n)return this._fetchSessionDbContent(n);try{return{data:(await this._fileService.readFile(t)).value.toString(),encoding:"utf-8",contentType:"text/plain"}}catch{throw new X(mt.NotFound,`Content not found: ${t.toString()}`)}}async writeFile(t){let n=typeof t.uri=="string"?m.parse(t.uri):m.revive(t.uri),i;t.encoding==="base64"?i=Ic(t.data):i=x.fromString(t.data);try{return t.createOnly?await this._fileService.createFile(n,i,{overwrite:!1}):await this._fileService.writeFile(n,i),{}}catch(s){let o=en(s);throw o==="EntryExists"?new X(mt.AlreadyExists,`File already exists: ${n.toString()}`):o==="NoPermissions"?new X(mt.PermissionDenied,`Permission denied: ${n.toString()}`):new X(mt.NotFound,`Failed to write file: ${n.toString()}`)}}async shutdown(){this._logService.info("AgentService: shutting down all providers...");let t=[];for(let n of this._providers.values())t.push(n.shutdown());await Promise.all(t),this._sessionToProvider.clear()}_buildTurnsFromMessages(t){let n=[],i,s=(a,l)=>{n.push({id:a.id,userMessage:a.userMessage,responseParts:a.responseParts,usage:void 0,state:l})},o=(a,l)=>({id:a,userMessage:{text:l},responseParts:[],pendingTools:new Map});for(let a of t)if(a.type==="message"&&a.role==="user")i&&s(i,"cancelled"),i=o(a.messageId,a.content);else if(a.type==="message"&&a.role==="assistant")i||(i=o(a.messageId,"")),a.content&&i.responseParts.push({kind:"markdown",id:Ge(),content:a.content}),(!a.toolRequests||a.toolRequests.length===0)&&(s(i,"complete"),i=void 0);else if(a.type==="tool_start")i?.pendingTools.set(a.toolCallId,a);else if(a.type==="tool_complete"&&i){let l=i.pendingTools.get(a.toolCallId);i.pendingTools.delete(a.toolCallId);let c={status:"completed",toolCallId:a.toolCallId,toolName:l?.toolName??"unknown",displayName:l?.displayName??"Unknown Tool",invocationMessage:l?.invocationMessage??"",toolInput:l?.toolInput,success:a.result.success,pastTenseMessage:a.result.pastTenseMessage,content:a.result.content,error:a.result.error,confirmed:"not-needed",_meta:l?{toolKind:l.toolKind,language:l.language}:void 0};i.responseParts.push({kind:"toolCall",toolCall:c})}return i&&s(i,"cancelled"),n}async _fetchSessionDbContent(t){let n=m.parse(t.sessionUri),i=this._sessionDataService.openDatabase(n);try{let s=await i.object.readFileEditContent(t.toolCallId,t.filePath);if(!s)throw new X(mt.NotFound,`File edit not found: toolCallId=${t.toolCallId}, filePath=${t.filePath}`);let o=t.part==="before"?s.beforeContent:s.afterContent;return{data:new TextDecoder().decode(o),encoding:"utf-8",contentType:"text/plain"}}finally{i.dispose()}}_findProviderForSession(t){let n=typeof t=="string"?t:t.toString(),i=this._sessionToProvider.get(n);if(i)return this._providers.get(i);let s=oe.provider(t);if(s)return this._providers.get(s);if(this._defaultProvider)return this._providers.get(this._defaultProvider)}_updateAgents(){this._agents.set([...this._providers.values()],void 0)}dispose(){for(let t of this._providers.values())t.dispose();this._providers.clear(),super.dispose()}};import{CopilotClient as vh}from"@github/copilot-sdk";import{rgPath as bh}from"@vscode/ripgrep";var ds=Fe("sessionDataService");var hh=new Set(["edit","write","patch"]);function zn(r){return hh.has(r)}function ps(r){if(typeof r=="string")try{r=JSON.parse(r)}catch{return}return r?.path}var fs=new Set(["bash","powershell"]),gh=new Set(["report_intent"]);function Vr(r){return gh.has(r)}function Kn(r,e){return r.length>e?r.substring(0,e-3)+"...":r}function qr(r){switch(r){case"bash":return f(1875,null);case"powershell":return f(1882,null);case"read_bash":case"read_powershell":return f(1883,null);case"write_bash":case"write_powershell":return f(1887,null);case"bash_shutdown":return f(1876,null);case"list_bash":case"list_powershell":return f(1880,null);case"view":return f(1884,null);case"edit":return f(1877,null);case"write":return f(1886,null);case"grep":return f(1879,null);case"glob":return f(1878,null);case"patch":return f(1881,null);case"web_search":return f(1885,null);case"ask_user":return f(1874,null);default:return r}}function hs(r,e,t){if(fs.has(r)){let n=t;if(n?.command){let i=n.command.split(`
`)[0];return f(1869,null,Kn(i,80))}return f(1868,null,e)}switch(r){case"view":{let n=t;return n?.path?f(1871,null,n.path):f(1870,null)}case"edit":{let n=t;return n?.path?f(1862,null,n.path):f(1861,null)}case"write":{let n=t;return n?.path?f(1873,null,n.path):f(1872,null)}case"grep":{let n=t;return n?.pattern?f(1867,null,Kn(n.pattern,80)):f(1866,null)}case"glob":{let n=t;return n?.pattern?f(1865,null,Kn(n.pattern,80)):f(1864,null)}default:return f(1863,null,e)}}function gs(r,e,t,n){if(!n)return f(1849,null,e);if(fs.has(r)){let i=t;if(i?.command){let s=i.command.split(`
`)[0];return f(1856,null,Kn(s,80))}return f(1855,null,e)}switch(r){case"view":{let i=t;return i?.path?f(1858,null,i.path):f(1857,null)}case"edit":{let i=t;return i?.path?f(1848,null,i.path):f(1847,null)}case"write":{let i=t;return i?.path?f(1860,null,i.path):f(1859,null)}case"grep":{let i=t;return i?.pattern?f(1854,null,Kn(i.pattern,80)):f(1853,null)}case"glob":{let i=t;return i?.pattern?f(1852,null,Kn(i.pattern,80)):f(1851,null)}default:return f(1850,null,e)}}function ms(r,e,t){if(!(!e&&!t)){if(fs.has(r))return e?.command??t;switch(r){case"grep":return e?.pattern??t;default:if(e)try{return JSON.stringify(e,null,2)}catch{return t}return t}}}function vs(r){if(fs.has(r))return"terminal"}function bs(r){return r==="powershell"?"powershell":"shellscript"}function ys(r){try{return JSON.stringify(r)}catch{return}}async function Bu(r,e,t){let n=[],i=new Map,s=[];for(let l of t)if(l.type==="tool.execution_start"){let c=l.data;if(Vr(c.toolName))continue;let d=c.arguments!==void 0?ys(c.arguments):void 0,u;if(d)try{u=JSON.parse(d)}catch{}i.set(c.toolCallId,{toolName:c.toolName,parameters:u}),zn(c.toolName)&&s.push(c.toolCallId)}let o;if(e&&s.length>0)try{let l=await e.getFileEdits(s);if(l.length>0){o=new Map;for(let c of l){let d=o.get(c.toolCallId);d||(d=[],o.set(c.toolCallId,d)),d.push(c)}}}catch{}let a=r.toString();for(let l of t)if(l.type==="assistant.message"||l.type==="user.message"){let c=l.data;n.push({session:r,type:"message",role:l.type==="user.message"?"user":"assistant",messageId:c?.messageId??c?.interactionId??"",content:c?.content??"",toolRequests:c?.toolRequests?.map(d=>({toolCallId:d.toolCallId,name:d.name,arguments:d.arguments!==void 0?ys(d.arguments):void 0,type:d.type})),reasoningOpaque:c?.reasoningOpaque,reasoningText:c?.reasoningText,encryptedContent:c?.encryptedContent,parentToolCallId:c?.parentToolCallId})}else if(l.type==="tool.execution_start"){let c=l.data;if(Vr(c.toolName))continue;let d=i.get(c.toolCallId),u=qr(c.toolName),p=vs(c.toolName),h=c.arguments!==void 0?ys(c.arguments):void 0;n.push({session:r,type:"tool_start",toolCallId:c.toolCallId,toolName:c.toolName,displayName:u,invocationMessage:hs(c.toolName,u,d?.parameters),toolInput:ms(c.toolName,d?.parameters,h),toolKind:p,language:p==="terminal"?bs(c.toolName):void 0,toolArguments:h,mcpServerName:c.mcpServerName,mcpToolName:c.mcpToolName,parentToolCallId:c.parentToolCallId})}else if(l.type==="tool.execution_complete"){let c=l.data,d=i.get(c.toolCallId);if(!d)continue;i.delete(c.toolCallId);let u=qr(d.toolName),p=c.error?.message??c.result?.content,h=[];p!==void 0&&h.push({type:"text",text:p});let g=o?.get(c.toolCallId);if(g)for(let b of g)h.push({type:"fileEdit",beforeURI:wr(a,b.toolCallId,b.filePath,"before"),afterURI:wr(a,b.toolCallId,b.filePath,"after"),diff:b.addedLines!==void 0||b.removedLines!==void 0?{added:b.addedLines,removed:b.removedLines}:void 0});n.push({session:r,type:"tool_complete",toolCallId:c.toolCallId,result:{success:c.success,pastTenseMessage:gs(d.toolName,u,d.parameters,c.success),content:h.length>0?h:void 0,error:c.error},isUserRequested:c.isUserRequested,toolTelemetry:c.toolTelemetry!==void 0?ys(c.toolTelemetry):void 0,parentToolCallId:c.parentToolCallId})}return n}function sn(r){try{return JSON.stringify(r)}catch{return}}function mh(r){let e=typeof r.path=="string"?r.path:typeof r.fileName=="string"?r.fileName:void 0,t=typeof r.fullCommandText=="string"?r.fullCommandText:void 0,n=typeof r.intention=="string"?r.intention:void 0,i=typeof r.serverName=="string"?r.serverName:void 0,s=typeof r.toolName=="string"?r.toolName:void 0;switch(r.kind){case"shell":return{confirmationTitle:f(1843,null),invocationMessage:n??f(1842,null),toolInput:t};case"write":return{confirmationTitle:f(1846,null),invocationMessage:e?f(1844,null,e):f(1845,null),toolInput:sn(e?{path:e}:r)??void 0};case"mcp":{let o=s??f(1839,null);return{confirmationTitle:i?`${i}: ${o}`:o,invocationMessage:i?`${i}: ${o}`:o,toolInput:sn({serverName:i,toolName:s})??void 0}}case"read":return{confirmationTitle:f(1841,null),invocationMessage:n??f(1840,null),toolInput:sn(e?{path:e,intention:n}:r)??void 0};default:return{confirmationTitle:f(1838,null),invocationMessage:f(1837,null),toolInput:sn(r)??void 0}}}var jn=class extends A{constructor(t,n,i,s,o,a,l,c){super();this._onDidSessionProgress=s;this._wrapperFactory=o;this._fileService=a;this._logService=l;this._activeToolCalls=new Map;this._pendingPermissions=new Map;this._turnId="";this.sessionId=n,this.sessionUri=t,this._workingDirectory=i,this._databaseRef=c.openDatabase(t),this._register(O(()=>this._databaseRef.dispose())),this._editTracker=new ns(t.toString(),this._databaseRef.object,this._fileService,this._logService),this._register(O(()=>this._denyPendingPermissions()))}async initializeSession(){this._wrapper=this._register(await this._wrapperFactory({onPermissionRequest:t=>this.handlePermissionRequest(t),hooks:{onPreToolUse:async t=>{if(zn(t.toolName)){let n=ps(t.toolArgs);n&&await this._editTracker.trackEditStart(n)}},onPostToolUse:async t=>{if(zn(t.toolName)){let n=ps(t.toolArgs);n&&await this._editTracker.completeEdit(n)}}}})),this._subscribeToEvents(),this._subscribeForLogging()}async send(t,n){this._logService.info(`[Copilot:${this.sessionId}] sendMessage called: "${t.substring(0,100)}${t.length>100?"...":""}" (${n?.length??0} attachments)`);let i=n?.map(s=>s.type==="selection"?{type:"selection",filePath:s.path,displayName:s.displayName??s.path,text:s.text,selection:s.selection}:{type:s.type,path:s.path,displayName:s.displayName});i?.length&&this._logService.trace(`[Copilot:${this.sessionId}] Attachments: ${JSON.stringify(i.map(s=>({type:s.type,path:s.type==="selection"?s.filePath:s.path})))}`),await this._wrapper.session.send({prompt:t,attachments:i}),this._logService.info(`[Copilot:${this.sessionId}] session.send() returned`)}sendSteering(t){this._logService.info(`[Copilot:${this.sessionId}] Sending steering message: "${t.userMessage.text.substring(0,100)}"`),this._wrapper.session.send({prompt:t.userMessage.text,mode:"immediate"}).catch(n=>{this._logService.error(`[Copilot:${this.sessionId}] Steering message failed`,n)})}async getMessages(){let t=await this._wrapper.session.getMessages(),n;try{n=this._databaseRef.object}catch{}return Bu(this.sessionUri,n,t)}async abort(){this._logService.info(`[Copilot:${this.sessionId}] Aborting session...`),this._denyPendingPermissions(),await this._wrapper.session.abort()}async setModel(t){this._logService.info(`[Copilot:${this.sessionId}] Changing model to: ${t}`),await this._wrapper.session.setModel(t)}async handlePermissionRequest(t){if(this._logService.info(`[Copilot:${this.sessionId}] Permission request: kind=${t.kind}`),t.kind==="read"){let c=typeof t.path=="string"?t.path:void 0;if(c&&this._workingDirectory&&mn.isEqualOrParent(ic(m.file(c)),this._workingDirectory))return this._logService.trace(`[Copilot:${this.sessionId}] Auto-approving read inside working directory: ${c}`),{kind:"approved"}}let n=t.toolCallId;if(!n)return this._logService.warn(`[Copilot:${this.sessionId}] Permission request without toolCallId, auto-denying: kind=${t.kind}`),{kind:"denied-interactively-by-user"};this._logService.info(`[Copilot:${this.sessionId}] Requesting confirmation for tool call: ${n}`);let i=new Ze;this._pendingPermissions.set(n,i);let{confirmationTitle:s,invocationMessage:o,toolInput:a}=mh(t);this._onDidSessionProgress.fire({session:this.sessionUri,type:"tool_ready",toolCallId:n,invocationMessage:o,toolInput:a,confirmationTitle:s,permissionKind:t.kind,permissionPath:typeof t.path=="string"?t.path:typeof t.fileName=="string"?t.fileName:void 0});let l=await i.p;return this._logService.info(`[Copilot:${this.sessionId}] Permission response: toolCallId=${n}, approved=${l}`),{kind:l?"approved":"denied-interactively-by-user"}}respondToPermissionRequest(t,n){let i=this._pendingPermissions.get(t);return i?(this._pendingPermissions.delete(t),i.complete(n),!0):!1}_subscribeToEvents(){let t=this._wrapper,n=this.sessionId,i=this.sessionUri;this._register(t.onMessageDelta(s=>{this._logService.trace(`[Copilot:${n}] delta: ${s.data.deltaContent}`),this._onDidSessionProgress.fire({session:i,type:"delta",messageId:s.data.messageId,content:s.data.deltaContent,parentToolCallId:s.data.parentToolCallId})})),this._register(t.onMessage(s=>{this._logService.info(`[Copilot:${n}] Full message received: ${s.data.content.length} chars`),this._onDidSessionProgress.fire({session:i,type:"message",role:"assistant",messageId:s.data.messageId,content:s.data.content,toolRequests:s.data.toolRequests?.map(o=>({toolCallId:o.toolCallId,name:o.name,arguments:o.arguments!==void 0?sn(o.arguments):void 0,type:o.type})),reasoningOpaque:s.data.reasoningOpaque,reasoningText:s.data.reasoningText,encryptedContent:s.data.encryptedContent,parentToolCallId:s.data.parentToolCallId})})),this._register(t.onToolStart(s=>{if(Vr(s.data.toolName)){this._logService.trace(`[Copilot:${n}] Tool started (hidden): ${s.data.toolName}`);return}this._logService.info(`[Copilot:${n}] Tool started: ${s.data.toolName}`);let o=s.data.arguments!==void 0?sn(s.data.arguments):void 0,a;if(o)try{a=JSON.parse(o)}catch{}let l=qr(s.data.toolName);this._activeToolCalls.set(s.data.toolCallId,{toolName:s.data.toolName,displayName:l,parameters:a});let c=vs(s.data.toolName);this._onDidSessionProgress.fire({session:i,type:"tool_start",toolCallId:s.data.toolCallId,toolName:s.data.toolName,displayName:l,invocationMessage:hs(s.data.toolName,l,a),toolInput:ms(s.data.toolName,a,o),toolKind:c,language:c==="terminal"?bs(s.data.toolName):void 0,toolArguments:o,mcpServerName:s.data.mcpServerName,mcpToolName:s.data.mcpToolName,parentToolCallId:s.data.parentToolCallId})})),this._register(t.onTurnStart(s=>{this._turnId=s.data.turnId})),this._register(t.onToolComplete(s=>{let o=this._activeToolCalls.get(s.data.toolCallId);if(!o)return;this._logService.info(`[Copilot:${n}] Tool completed: ${s.data.toolCallId}`),this._activeToolCalls.delete(s.data.toolCallId);let a=o.displayName,l=s.data.error?.message??s.data.result?.content,c=[];l!==void 0&&c.push({type:"text",text:l});let d=zn(o.toolName)?ps(o.parameters):void 0;if(d){let u=this._editTracker.takeCompletedEdit(this._turnId,s.data.toolCallId,d);u&&c.push(u)}this._onDidSessionProgress.fire({session:i,type:"tool_complete",toolCallId:s.data.toolCallId,result:{success:s.data.success,pastTenseMessage:gs(o.toolName,a,o.parameters,s.data.success),content:c.length>0?c:void 0,error:s.data.error},isUserRequested:s.data.isUserRequested,toolTelemetry:s.data.toolTelemetry!==void 0?sn(s.data.toolTelemetry):void 0,parentToolCallId:s.data.parentToolCallId})})),this._register(t.onIdle(()=>{this._logService.info(`[Copilot:${n}] Session idle`),this._onDidSessionProgress.fire({session:i,type:"idle"})})),this._register(t.onSessionError(s=>{this._logService.error(`[Copilot:${n}] Session error: ${s.data.errorType} - ${s.data.message}`),this._onDidSessionProgress.fire({session:i,type:"error",errorType:s.data.errorType,message:s.data.message,stack:s.data.stack})})),this._register(t.onUsage(s=>{this._logService.trace(`[Copilot:${n}] Usage: model=${s.data.model}, in=${s.data.inputTokens??"?"}, out=${s.data.outputTokens??"?"}, cacheRead=${s.data.cacheReadTokens??"?"}`),this._onDidSessionProgress.fire({session:i,type:"usage",inputTokens:s.data.inputTokens,outputTokens:s.data.outputTokens,model:s.data.model,cacheReadTokens:s.data.cacheReadTokens})})),this._register(t.onReasoningDelta(s=>{this._logService.trace(`[Copilot:${n}] Reasoning delta: ${s.data.deltaContent.length} chars`),this._onDidSessionProgress.fire({session:i,type:"reasoning",content:s.data.deltaContent})}))}_subscribeForLogging(){let t=this._wrapper,n=this.sessionId;this._register(t.onSessionStart(i=>{this._logService.trace(`[Copilot:${n}] Session started: model=${i.data.selectedModel??"default"}, producer=${i.data.producer}`)})),this._register(t.onSessionResume(i=>{this._logService.trace(`[Copilot:${n}] Session resumed: eventCount=${i.data.eventCount}`)})),this._register(t.onSessionInfo(i=>{this._logService.trace(`[Copilot:${n}] Session info [${i.data.infoType}]: ${i.data.message}`)})),this._register(t.onSessionModelChange(i=>{this._logService.trace(`[Copilot:${n}] Model changed: ${i.data.previousModel??"(none)"} -> ${i.data.newModel}`)})),this._register(t.onSessionHandoff(i=>{this._logService.trace(`[Copilot:${n}] Session handoff: sourceType=${i.data.sourceType}, remoteSessionId=${i.data.remoteSessionId??"(none)"}`)})),this._register(t.onSessionTruncation(i=>{this._logService.trace(`[Copilot:${n}] Session truncation: removed ${i.data.tokensRemovedDuringTruncation} tokens, ${i.data.messagesRemovedDuringTruncation} messages`)})),this._register(t.onSessionSnapshotRewind(i=>{this._logService.trace(`[Copilot:${n}] Snapshot rewind: upTo=${i.data.upToEventId}, eventsRemoved=${i.data.eventsRemoved}`)})),this._register(t.onSessionShutdown(i=>{this._logService.trace(`[Copilot:${n}] Session shutdown: type=${i.data.shutdownType}, premiumRequests=${i.data.totalPremiumRequests}, apiDuration=${i.data.totalApiDurationMs}ms`)})),this._register(t.onSessionUsageInfo(i=>{this._logService.trace(`[Copilot:${n}] Usage info: ${i.data.currentTokens}/${i.data.tokenLimit} tokens, ${i.data.messagesLength} messages`)})),this._register(t.onSessionCompactionStart(()=>{this._logService.trace(`[Copilot:${n}] Compaction started`)})),this._register(t.onSessionCompactionComplete(i=>{this._logService.trace(`[Copilot:${n}] Compaction complete: success=${i.data.success}, tokensRemoved=${i.data.tokensRemoved??"?"}`)})),this._register(t.onUserMessage(i=>{this._logService.trace(`[Copilot:${n}] User message: ${i.data.content.length} chars, ${i.data.attachments?.length??0} attachments`)})),this._register(t.onPendingMessagesModified(()=>{this._logService.trace(`[Copilot:${n}] Pending messages modified`)})),this._register(t.onTurnStart(i=>{this._logService.trace(`[Copilot:${n}] Turn started: ${i.data.turnId}`)})),this._register(t.onIntent(i=>{this._logService.trace(`[Copilot:${n}] Intent: ${i.data.intent}`)})),this._register(t.onReasoning(i=>{this._logService.trace(`[Copilot:${n}] Reasoning: ${i.data.content.length} chars`)})),this._register(t.onTurnEnd(i=>{this._logService.trace(`[Copilot:${n}] Turn ended: ${i.data.turnId}`)})),this._register(t.onAbort(i=>{this._logService.trace(`[Copilot:${n}] Aborted: ${i.data.reason}`)})),this._register(t.onToolUserRequested(i=>{this._logService.trace(`[Copilot:${n}] Tool user-requested: ${i.data.toolName} (${i.data.toolCallId})`)})),this._register(t.onToolPartialResult(i=>{this._logService.trace(`[Copilot:${n}] Tool partial result: ${i.data.toolCallId} (${i.data.partialOutput.length} chars)`)})),this._register(t.onToolProgress(i=>{this._logService.trace(`[Copilot:${n}] Tool progress: ${i.data.toolCallId} - ${i.data.progressMessage}`)})),this._register(t.onSkillInvoked(i=>{this._logService.trace(`[Copilot:${n}] Skill invoked: ${i.data.name} (${i.data.path})`)})),this._register(t.onSubagentStarted(i=>{this._logService.trace(`[Copilot:${n}] Subagent started: ${i.data.agentName} (${i.data.agentDisplayName})`)})),this._register(t.onSubagentCompleted(i=>{this._logService.trace(`[Copilot:${n}] Subagent completed: ${i.data.agentName}`)})),this._register(t.onSubagentFailed(i=>{this._logService.error(`[Copilot:${n}] Subagent failed: ${i.data.agentName} - ${i.data.error}`)})),this._register(t.onSubagentSelected(i=>{this._logService.trace(`[Copilot:${n}] Subagent selected: ${i.data.agentName}`)})),this._register(t.onHookStart(i=>{this._logService.trace(`[Copilot:${n}] Hook started: ${i.data.hookType} (${i.data.hookInvocationId})`)})),this._register(t.onHookEnd(i=>{this._logService.trace(`[Copilot:${n}] Hook ended: ${i.data.hookType} (${i.data.hookInvocationId}), success=${i.data.success}`)})),this._register(t.onSystemMessage(i=>{this._logService.trace(`[Copilot:${n}] System message [${i.data.role}]: ${i.data.content.length} chars`)}))}_denyPendingPermissions(){for(let[,t]of this._pendingPermissions)t.complete(!1);this._pendingPermissions.clear()}};jn=P([Se(5,Fn),Se(6,Le),Se(7,ds)],jn);var $r=class extends A{constructor(t){super();this.session=t;this._register(O(()=>{t.destroy().catch(()=>{})}))}get sessionId(){return this.session.sessionId}get onMessageDelta(){return this._onMessageDelta??=this._sdkEvent("assistant.message_delta")}get onMessage(){return this._onMessage??=this._sdkEvent("assistant.message")}get onToolStart(){return this._onToolStart??=this._sdkEvent("tool.execution_start")}get onToolComplete(){return this._onToolComplete??=this._sdkEvent("tool.execution_complete")}get onIdle(){return this._onIdle??=this._sdkEvent("session.idle")}get onSessionStart(){return this._onSessionStart??=this._sdkEvent("session.start")}get onSessionResume(){return this._onSessionResume??=this._sdkEvent("session.resume")}get onSessionError(){return this._onSessionError??=this._sdkEvent("session.error")}get onSessionInfo(){return this._onSessionInfo??=this._sdkEvent("session.info")}get onSessionModelChange(){return this._onSessionModelChange??=this._sdkEvent("session.model_change")}get onSessionHandoff(){return this._onSessionHandoff??=this._sdkEvent("session.handoff")}get onSessionTruncation(){return this._onSessionTruncation??=this._sdkEvent("session.truncation")}get onSessionSnapshotRewind(){return this._onSessionSnapshotRewind??=this._sdkEvent("session.snapshot_rewind")}get onSessionShutdown(){return this._onSessionShutdown??=this._sdkEvent("session.shutdown")}get onSessionUsageInfo(){return this._onSessionUsageInfo??=this._sdkEvent("session.usage_info")}get onSessionCompactionStart(){return this._onSessionCompactionStart??=this._sdkEvent("session.compaction_start")}get onSessionCompactionComplete(){return this._onSessionCompactionComplete??=this._sdkEvent("session.compaction_complete")}get onUserMessage(){return this._onUserMessage??=this._sdkEvent("user.message")}get onPendingMessagesModified(){return this._onPendingMessagesModified??=this._sdkEvent("pending_messages.modified")}get onTurnStart(){return this._onTurnStart??=this._sdkEvent("assistant.turn_start")}get onIntent(){return this._onIntent??=this._sdkEvent("assistant.intent")}get onReasoning(){return this._onReasoning??=this._sdkEvent("assistant.reasoning")}get onReasoningDelta(){return this._onReasoningDelta??=this._sdkEvent("assistant.reasoning_delta")}get onTurnEnd(){return this._onTurnEnd??=this._sdkEvent("assistant.turn_end")}get onUsage(){return this._onUsage??=this._sdkEvent("assistant.usage")}get onAbort(){return this._onAbort??=this._sdkEvent("abort")}get onToolUserRequested(){return this._onToolUserRequested??=this._sdkEvent("tool.user_requested")}get onToolPartialResult(){return this._onToolPartialResult??=this._sdkEvent("tool.execution_partial_result")}get onToolProgress(){return this._onToolProgress??=this._sdkEvent("tool.execution_progress")}get onSkillInvoked(){return this._onSkillInvoked??=this._sdkEvent("skill.invoked")}get onSubagentStarted(){return this._onSubagentStarted??=this._sdkEvent("subagent.started")}get onSubagentCompleted(){return this._onSubagentCompleted??=this._sdkEvent("subagent.completed")}get onSubagentFailed(){return this._onSubagentFailed??=this._sdkEvent("subagent.failed")}get onSubagentSelected(){return this._onSubagentSelected??=this._sdkEvent("subagent.selected")}get onHookStart(){return this._onHookStart??=this._sdkEvent("hook.start")}get onHookEnd(){return this._onHookEnd??=this._sdkEvent("hook.end")}get onSystemMessage(){return this._onSystemMessage??=this._sdkEvent("system.message")}_sdkEvent(t){let n=this._register(new I),i=this.session.on(t,s=>n.fire(s));return this._register(O(i)),n.event}};var Hn=class extends A{constructor(t,n){super();this._logService=t;this._instantiationService=n;this.id="copilot";this._onDidSessionProgress=this._register(new I);this.onDidSessionProgress=this._onDidSessionProgress.event;this._sessions=this._register(new Ye)}getDescriptor(){return{provider:"copilot",displayName:"Agent Host - Copilot",description:"Copilot SDK agent running in a dedicated process",requiresAuth:!0}}getProtectedResources(){return[{resource:"https://api.github.com",resource_name:"GitHub Copilot",authorization_servers:["https://github.com/login/oauth"],scopes_supported:["read:user","user:email"]}]}async authenticate(t,n){if(t!=="https://api.github.com")return!1;let i=this._githubToken!==n;if(this._githubToken=n,this._logService.info(`[Copilot] Auth token ${i?"updated":"unchanged"}`),i&&this._client&&this._sessions.size===0){this._logService.info("[Copilot] Restarting CopilotClient with new token");let s=this._client;this._client=void 0,this._clientStarting=void 0,await s.stop()}return!0}async _ensureClient(){return this._client?this._client:this._clientStarting?this._clientStarting:(this._clientStarting=(async()=>{this._logService.info(`[Copilot] Starting CopilotClient... ${this._githubToken?"(with token)":"(no token)"}`);let t=Object.assign({},process.env,{ELECTRON_RUN_AS_NODE:"1"});delete t.NODE_OPTIONS,delete t.VSCODE_INSPECTOR_OPTIONS,delete t.VSCODE_ESM_ENTRYPOINT,delete t.VSCODE_HANDLES_UNCAUGHT_ERRORS;for(let c of Object.keys(t))c!=="ELECTRON_RUN_AS_NODE"&&(c.startsWith("VSCODE_")||c.startsWith("ELECTRON_"))&&delete t[c];t.COPILOT_CLI_RUN_AS_NODE="1",t.USE_BUILTIN_RIPGREP="0";let n=m.joinPath(Ct.asFileUri(""),"..","node_modules","@github","copilot","index.js").fsPath,i=bh.replace(/\bnode_modules\.asar\b/,"node_modules.asar.unpacked"),s=be(i),o=Object.keys(t).find(c=>c.toUpperCase()==="PATH")??"PATH",a=t[o];t[o]=a?`${a}${fo}${s}`:s,this._logService.info(`[Copilot] Resolved CLI path: ${n}`);let l=new vh({githubToken:this._githubToken,useLoggedInUser:!this._githubToken,useStdio:!0,autoStart:!0,env:t,cliPath:n});return await l.start(),this._logService.info("[Copilot] CopilotClient started successfully"),this._client=l,this._clientStarting=void 0,l})(),this._clientStarting)}async listSessions(){this._logService.info("[Copilot] Listing sessions...");let i=(await(await this._ensureClient()).listSessions()).map(s=>({session:oe.uri(this.id,s.sessionId),startTime:s.startTime.getTime(),modifiedTime:s.modifiedTime.getTime(),summary:s.summary,workingDirectory:typeof s.context?.cwd=="string"?m.file(s.context.cwd):void 0}));return this._logService.info(`[Copilot] Found ${i.length} sessions`),i}async listModels(){this._logService.info("[Copilot] Listing models...");let i=(await(await this._ensureClient()).listModels()).map(s=>({provider:this.id,id:s.id,name:s.name,maxContextWindow:s.capabilities.limits.max_context_window_tokens,supportsVision:s.capabilities.supports.vision,supportsReasoningEffort:s.capabilities.supports.reasoningEffort,supportedReasoningEfforts:s.supportedReasoningEfforts,defaultReasoningEffort:s.defaultReasoningEffort,policyState:s.policy?.state,billingMultiplier:s.billing?.multiplier}));return this._logService.info(`[Copilot] Found ${i.length} models`),i}async createSession(t){this._logService.info(`[Copilot] Creating session... ${t?.model?`model=${t.model}`:""}`);let n=await this._ensureClient(),i=async a=>{let l=await n.createSession({model:t?.model,sessionId:t?.session?oe.id(t.session):void 0,streaming:!0,workingDirectory:t?.workingDirectory?.fsPath,onPermissionRequest:a.onPermissionRequest,hooks:a.hooks});return new $r(l)},s=this._createAgentSession(i,t?.workingDirectory,t?.session?oe.id(t.session):void 0);await s.initializeSession();let o=s.sessionUri;return this._logService.info(`[Copilot] Session created: ${o.toString()}`),o}async sendMessage(t,n,i){let s=oe.id(t);await(this._sessions.get(s)??await this._resumeSession(s)).send(n,i)}setPendingMessages(t,n,i){let s=oe.id(t),o=this._sessions.get(s);if(!o){this._logService.warn(`[Copilot:${s}] setPendingMessages: session not found`);return}n&&o.sendSteering(n)}async getSessionMessages(t){let n=oe.id(t),i=this._sessions.get(n)??await this._resumeSession(n).catch(()=>{});return i?i.getMessages():[]}async disposeSession(t){let n=oe.id(t);this._sessions.deleteAndDispose(n)}async abortSession(t){let n=oe.id(t),i=this._sessions.get(n);i&&await i.abort()}async changeModel(t,n){let i=oe.id(t),s=this._sessions.get(i);s&&await s.setModel(n)}async shutdown(){this._logService.info("[Copilot] Shutting down..."),this._sessions.clearAndDisposeAll(),await this._client?.stop(),this._client=void 0}respondToPermissionRequest(t,n){for(let[,i]of this._sessions)if(i.respondToPermissionRequest(t,n))return}hasSession(t){return this._sessions.has(oe.id(t))}_createAgentSession(t,n,i){let s=i??Ge(),o=oe.uri(this.id,s),a=this._instantiationService.createInstance(jn,o,s,n,this._onDidSessionProgress,t);return this._sessions.set(s,a),a}async _resumeSession(t){this._logService.info(`[Copilot:${t}] Session not in memory, resuming...`);let n=await this._ensureClient(),i=async o=>{let a=await n.resumeSession(t,{onPermissionRequest:o.onPermissionRequest,workingDirectory:void 0,hooks:o.hooks});return new $r(a)},s=this._createAgentSession(i,void 0,t);return await s.initializeSession(),s}dispose(){this._client?.stop().catch(()=>{}),super.dispose()}};Hn=P([Se(0,Le),Se(1,Oi)],Hn);var yh=1e3;function Is(r,e){return{jsonrpc:"2.0",id:r,result:e}}function Ra(r,e,t,n){return{jsonrpc:"2.0",id:r,error:{code:e,message:t,...n!==void 0?{data:n}:{}}}}function Ts(r,e){if(e instanceof X)return Ra(r,e.code,e.message,e.data);let t=e instanceof Error?e.stack??e.message:String(e);return Ra(r,Nn,t)}var Gn=class extends A{constructor(t,n,i,s,o){super();this._agentService=t;this._stateManager=n;this._server=i;this._config=s;this._logService=o;this._clients=new Map;this._replayBuffer=[];this._onDidChangeConnectionCount=this._register(new I);this.onDidChangeConnectionCount=this._onDidChangeConnectionCount.event;this._requestHandlers={subscribe:async(t,n)=>{try{let i=await this._agentService.subscribe(m.parse(n.resource));return t.subscriptions.add(n.resource),{snapshot:i}}catch(i){throw i instanceof X?i:new X(Mn,`Resource not found: ${n.resource}`)}},createSession:async(t,n)=>{let i;try{i=await this._agentService.createSession({provider:n.provider,model:n.model,workingDirectory:n.workingDirectory?m.parse(n.workingDirectory):void 0,session:m.parse(n.session)})}catch(s){throw s instanceof X?s:new X(cu,s instanceof Error?s.message:String(s))}return i.toString()!==m.parse(n.session).toString()&&this._logService.warn(`[ProtocolServer] createSession: provider returned URI ${i.toString()} but client requested ${n.session}`),null},disposeSession:async(t,n)=>(await this._agentService.disposeSession(m.parse(n.session)),null),writeFile:async(t,n)=>this._agentService.writeFile(n),listSessions:async()=>({items:(await this._agentService.listSessions()).map(i=>({resource:i.session.toString(),provider:oe.provider(i.session)??"copilot",title:i.summary??"Session",status:"idle",createdAt:i.startTime,modifiedAt:i.modifiedTime,workingDirectory:i.workingDirectory?.toString()}))}),fetchTurns:async(t,n)=>{let i=this._stateManager.getSessionState(n.session);if(!i)throw new X(Mn,`Session not found: ${n.session}`);let s=i.turns,o=Math.min(n.limit??50,100),a=s.length;if(n.before){let c=s.findIndex(d=>d.id===n.before);c!==-1&&(a=c)}let l=Math.max(0,a-o);return{turns:s.slice(l,a),hasMore:l>0}},browseDirectory:async(t,n)=>this._agentService.browseDirectory(m.parse(n.uri)),fetchContent:async(t,n)=>this._agentService.fetchContent(m.parse(n.uri))};this._register(this._server.onConnection(a=>{this._handleNewConnection(a)})),this._register(this._stateManager.onDidEmitEnvelope(a=>{this._replayBuffer.push(a),this._replayBuffer.length>yh&&this._replayBuffer.shift(),this._broadcastAction(a)})),this._register(this._stateManager.onDidEmitNotification(a=>{this._broadcastNotification(a)}))}_handleNewConnection(t){let n=new D,i;n.add(t.onMessage(s=>{if(du(s)){if(this._logService.trace(`[ProtocolServer] request: method=${s.method} id=${s.id}`),!i&&s.method==="initialize"){try{let o=this._handleInitialize(s.params,t,n);i=o.client,t.send(Is(s.id,o.response))}catch(o){t.send(Ts(s.id,o))}return}if(!i&&s.method==="reconnect"){try{let o=this._handleReconnect(s.params,t,n);i=o.client,t.send(Is(s.id,o.response))}catch(o){t.send(Ts(s.id,o))}return}if(!i)return;this._handleRequest(i,s.method,s.params,s.id)}else if(pu(s))switch(this._logService.trace(`[ProtocolServer] notification: method=${s.method}`),s.method){case"unsubscribe":i&&i.subscriptions.delete(s.params.resource);break;case"dispatchAction":if(i){this._logService.trace(`[ProtocolServer] dispatchAction: ${JSON.stringify(s.params.action.type)}`);let o=s.params.action;this._agentService.dispatchAction(o,i.clientId,s.params.clientSeq)}break}})),n.add(t.onClose(()=>{i&&this._clients.get(i.clientId)===i&&(this._logService.info(`[ProtocolServer] Client disconnected: ${i.clientId}`),this._clients.delete(i.clientId),this._onDidChangeConnectionCount.fire(this._clients.size)),n.dispose()})),n.add(t)}_handleInitialize(t,n,i){if(this._logService.info(`[ProtocolServer] Initialize: clientId=${t.clientId}, version=${t.protocolVersion}`),t.protocolVersion<1)throw new X(uu,`Client protocol version ${t.protocolVersion} is below minimum ${1}`);let s={clientId:t.clientId,protocolVersion:t.protocolVersion,transport:n,subscriptions:new Set,disposables:i};this._clients.set(t.clientId,s),this._onDidChangeConnectionCount.fire(this._clients.size);let o=[];if(t.initialSubscriptions)for(let a of t.initialSubscriptions){let l=this._stateManager.getSnapshot(a);l&&(o.push(l),s.subscriptions.add(a.toString()))}return{client:s,response:{protocolVersion:1,serverSeq:this._stateManager.serverSeq,snapshots:o,defaultDirectory:this._config.defaultDirectory}}}_handleReconnect(t,n,i){this._logService.info(`[ProtocolServer] Reconnect: clientId=${t.clientId}, lastSeenSeq=${t.lastSeenServerSeq}`);let s={clientId:t.clientId,protocolVersion:1,transport:n,subscriptions:new Set,disposables:i};this._clients.set(t.clientId,s),this._onDidChangeConnectionCount.fire(this._clients.size);let o=this._replayBuffer.length>0?this._replayBuffer[0].serverSeq:this._stateManager.serverSeq;if(t.lastSeenServerSeq>=o){let l=[];for(let c of t.subscriptions)s.subscriptions.add(c.toString());for(let c of this._replayBuffer)c.serverSeq>t.lastSeenServerSeq&&this._isRelevantToClient(s,c)&&l.push(c);return{client:s,response:{type:"replay",actions:l}}}else{let l=[];for(let c of t.subscriptions){let d=this._stateManager.getSnapshot(c);d&&(l.push(d),s.subscriptions.add(c))}return{client:s,response:{type:"snapshot",snapshots:l}}}}_handleRequest(t,n,i,s){let o=this._requestHandlers.hasOwnProperty(n)?this._requestHandlers[n]:void 0;if(o){o(t,i).then(l=>{this._logService.trace(`[ProtocolServer] Request '${n}' id=${s} succeeded`),t.transport.send(Is(s,l??null))}).catch(l=>{this._logService.error(`[ProtocolServer] Request '${n}' failed`,l),t.transport.send(Ts(s,l))});return}let a=this._handleExtensionRequest(n,i);if(a){a.then(l=>{t.transport.send(Is(s,l??null))}).catch(l=>{this._logService.error(`[ProtocolServer] Extension request '${n}' failed`,l),t.transport.send(Ts(s,l))});return}t.transport.send(Ra(s,Nn,`Unknown method: ${n}`))}_handleExtensionRequest(t,n){switch(t){case"getResourceMetadata":return this._agentService.getResourceMetadata();case"authenticate":{let i=n;return!i||typeof i.resource!="string"||typeof i.token!="string"?Promise.reject(new X(-32602,"Invalid authenticate params")):this._agentService.authenticate(i)}case"refreshModels":return this._agentService.refreshModels();case"listAgents":return this._agentService.listAgents();case"shutdown":return this._agentService.shutdown();default:return}}_broadcastAction(t){this._logService.trace(`[ProtocolServer] Broadcasting action: ${t.action.type}`);let n={jsonrpc:"2.0",method:"action",params:t};for(let i of this._clients.values())this._isRelevantToClient(i,t)&&i.transport.send(n)}_broadcastNotification(t){let n={jsonrpc:"2.0",method:"notification",params:{notification:t}};for(let i of this._clients.values())i.transport.send(n)}_isRelevantToClient(t,n){let i=n.action;return i.type.startsWith("root/")?t.subscriptions.has(Yi):Qi(i)?t.subscriptions.has(i.session):!1}dispose(){for(let t of this._clients.values())t.disposables.dispose();this._clients.clear(),this._replayBuffer.length=0,super.dispose()}};Gn=P([Se(4,Le)],Gn);var wa=class extends A{constructor(t,n){super();this._ws=t;this._WebSocket=n;this._onMessage=this._register(new I);this.onMessage=this._onMessage.event;this._onClose=this._register(new I);this.onClose=this._onClose.event;this._ws.on("message",i=>{try{let s=typeof i=="string"?i:i.toString("utf-8"),o=JSON.parse(s);this._onMessage.fire(o)}catch{this.send({jsonrpc:"2.0",id:null,error:{code:lu,message:"Parse error"}})}}),this._ws.on("close",()=>{this._onClose.fire()}),this._ws.on("error",()=>{this._onClose.fire()})}send(t){this._ws.readyState===this._WebSocket.OPEN&&this._ws.send(JSON.stringify(t))}dispose(){this._ws.close(),super.dispose()}},Ss=class r extends A{constructor(t,n,i,s,o){super();this._logService=n;this._onConnection=this._register(new I);this.onConnection=this._onConnection.event;this._WebSocket=i.WebSocket;let a=typeof t=="number"?{port:t}:t,l=a.host??"127.0.0.1",c=a.connectionTokenValidate?(d,u)=>{let h=o.parse(d.req.url??"",!0).query[xo];if(!a.connectionTokenValidate(h)){this._logService.warn("[WebSocketProtocol] Connection rejected: invalid connection token"),u(!1,403,"Forbidden");return}u(!0)}:void 0;a.socketPath?(this._httpServer=s.createServer(),this._wss=new i.WebSocketServer({server:this._httpServer,verifyClient:c}),this._httpServer.listen(a.socketPath,()=>{this._logService.info(`[WebSocketProtocol] Server listening on socket ${a.socketPath}`)})):(this._wss=new i.WebSocketServer({port:a.port,host:l,verifyClient:c}),this._logService.info(`[WebSocketProtocol] Server listening on ${l}:${a.port}`)),this._wss.on("connection",d=>{this._logService.trace("[WebSocketProtocol] New client connection");let u=new wa(d,this._WebSocket);this._onConnection.fire(u)}),this._wss.on("error",d=>{this._logService.error("[WebSocketProtocol] Server error",d)})}get address(){let t=this._wss.address();return!t||typeof t=="string"?t??void 0:`${t.address}:${t.port}`}static async create(t,n){let[i,s,o]=await Promise.all([import("ws"),import("http"),import("url")]);return new r(t,n,i,s,o)}dispose(){this._wss.close(),this._httpServer?.close(),super.dispose()}};import{homedir as wh,tmpdir as Ch}from"os";var Ih=60,Th=Ih*60,Ca=Th*24,Q4=Ca*7,J4=Ca*30,Y4=Ca*365;function $u(r){return r.getFullYear()+"-"+String(r.getMonth()+1).padStart(2,"0")+"-"+String(r.getDate()).padStart(2,"0")+"T"+String(r.getHours()).padStart(2,"0")+":"+String(r.getMinutes()).padStart(2,"0")+":"+String(r.getSeconds()).padStart(2,"0")+"."+(r.getMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"}var Ku=/^([^.]+\..+)[:=](.+)$/,M=class{constructor(e,t,n){this._args=e;this.paths=t;this.productService=n}get appRoot(){return be(Ct.asFileUri("").fsPath)}get userHome(){return m.file(this.paths.homeDir)}get userDataPath(){return this.paths.userDataDir}get appSettingsHome(){return m.file(J(this.userDataPath,"User"))}get tmpDir(){return m.file(this.paths.tmpDir)}get cacheHome(){return m.file(this.userDataPath)}get stateResource(){return se(this.appSettingsHome,"globalStorage","storage.json")}get userRoamingDataHome(){return this.appSettingsHome.with({scheme:Y.vscodeUserData})}get userDataSyncHome(){return se(this.appSettingsHome,"sync")}get logsHome(){if(!this.args.logsPath){let e=$u(new Date).replace(/-|:|\.\d+Z$/g,"");this.args.logsPath=J(this.userDataPath,"logs",e)}return m.file(this.args.logsPath)}get sync(){return this.args.sync}get workspaceStorageHome(){return se(this.appSettingsHome,"workspaceStorage")}get localHistoryHome(){return se(this.appSettingsHome,"History")}get keyboardLayoutResource(){return se(this.userRoamingDataHome,"keyboardLayout.json")}get argvResource(){let e=pe.VSCODE_PORTABLE;return e?m.file(J(e,"argv.json")):se(this.userHome,this.productService.dataFolderName,"argv.json")}get isExtensionDevelopment(){return!!this.args.extensionDevelopmentPath}get untitledWorkspacesHome(){return m.file(J(this.userDataPath,"Workspaces"))}get builtinExtensionsPath(){let e=this.args["builtin-extensions-dir"];return e?Vt(e):Me(J(Ct.asFileUri("").fsPath,"..","extensions"))}get extensionsDownloadLocation(){let e=this.args["extensions-download-dir"];return e?m.file(Vt(e)):m.file(J(this.userDataPath,"CachedExtensionVSIXs"))}get extensionsPath(){let e=this.args["extensions-dir"];if(e)return Vt(e);let t=pe.VSCODE_EXTENSIONS;if(t)return t;let n=pe.VSCODE_PORTABLE;return n?J(n,"extensions"):se(this.userHome,this.productService.dataFolderName,"extensions").fsPath}get agentPluginsPath(){let e=this.args["agent-plugins-dir"];if(e)return Vt(e);let t=pe.VSCODE_AGENT_PLUGINS;if(t)return t;let n=pe.VSCODE_PORTABLE;return n?J(n,"agent-plugins"):se(this.userHome,this.productService.dataFolderName,"agent-plugins").fsPath}get extensionDevelopmentLocationURI(){let e=this.args.extensionDevelopmentPath;if(Array.isArray(e))return e.map(t=>/^[^:/?#]+?:\/\//.test(t)?m.parse(t):m.file(Me(t)))}get extensionDevelopmentKind(){return this.args.extensionDevelopmentKind?.map(e=>e==="ui"||e==="workspace"||e==="web"?e:"workspace")}get extensionTestsLocationURI(){let e=this.args.extensionTestsPath;if(e)return/^[^:/?#]+?:\/\//.test(e)?m.parse(e):m.file(Me(e))}get disableExtensions(){if(this.args["disable-extensions"])return!0;let e=this.args["disable-extension"];if(e){if(typeof e=="string")return[e];if(Array.isArray(e)&&e.length>0)return e}return!1}get debugExtensionHost(){return Sh(this.args,this.isBuilt)}get debugRenderer(){return!!this.args.debugRenderer}get isBuilt(){return!pe.VSCODE_DEV}get verbose(){return!!this.args.verbose}get logLevel(){return this.args.log?.find(e=>!Ku.test(e))}get extensionLogLevel(){let e=[];for(let t of this.args.log||[]){let n=Ku.exec(t);n?.[1]&&n[2]&&e.push([n[1],n[2]])}return e.length?e:void 0}get serviceMachineIdResource(){return se(m.file(this.userDataPath),"machineid")}get crashReporterId(){return this.args["crash-reporter-id"]}get crashReporterDirectory(){return this.args["crash-reporter-directory"]}get disableTelemetry(){return!!this.args["disable-telemetry"]}get disableExperiments(){return!!this.args["disable-experiments"]}get disableWorkspaceTrust(){return!!this.args["disable-workspace-trust"]}get useInMemorySecretStorage(){return!!this.args["use-inmemory-secretstorage"]}get policyFile(){if(this.args["__enable-file-policy"]){let e=pe.VSCODE_PORTABLE;return e?m.file(J(e,"policy.json")):se(this.userHome,this.productService.dataFolderName,"policy.json")}}get agentSessionsWorkspace(){return se(this.appSettingsHome,"agent-sessions.code-workspace")}get editSessionId(){return this.args.editSessionId}get exportPolicyData(){return this.args["export-policy-data"]}get exportDefaultKeybindings(){return this.args["export-default-keybindings"]}get continueOn(){return this.args.continueOn}set continueOn(e){this.args.continueOn=e}get args(){return this._args}};P([B],M.prototype,"appRoot",1),P([B],M.prototype,"userHome",1),P([B],M.prototype,"userDataPath",1),P([B],M.prototype,"appSettingsHome",1),P([B],M.prototype,"tmpDir",1),P([B],M.prototype,"cacheHome",1),P([B],M.prototype,"stateResource",1),P([B],M.prototype,"userRoamingDataHome",1),P([B],M.prototype,"userDataSyncHome",1),P([B],M.prototype,"sync",1),P([B],M.prototype,"workspaceStorageHome",1),P([B],M.prototype,"localHistoryHome",1),P([B],M.prototype,"keyboardLayoutResource",1),P([B],M.prototype,"argvResource",1),P([B],M.prototype,"isExtensionDevelopment",1),P([B],M.prototype,"untitledWorkspacesHome",1),P([B],M.prototype,"builtinExtensionsPath",1),P([B],M.prototype,"extensionsDownloadLocation",1),P([B],M.prototype,"extensionsPath",1),P([B],M.prototype,"agentPluginsPath",1),P([B],M.prototype,"extensionDevelopmentLocationURI",1),P([B],M.prototype,"extensionDevelopmentKind",1),P([B],M.prototype,"extensionTestsLocationURI",1),P([B],M.prototype,"debugExtensionHost",1),P([B],M.prototype,"logLevel",1),P([B],M.prototype,"extensionLogLevel",1),P([B],M.prototype,"serviceMachineIdResource",1),P([B],M.prototype,"disableTelemetry",1),P([B],M.prototype,"disableExperiments",1),P([B],M.prototype,"disableWorkspaceTrust",1),P([B],M.prototype,"useInMemorySecretStorage",1),P([B],M.prototype,"policyFile",1),P([B],M.prototype,"agentSessionsWorkspace",1);function Sh(r,e){return zu(r["inspect-extensions"],r["inspect-brk-extensions"],5870,e,r.debugId,r.extensionEnvironment)}function zu(r,e,t,n,i,s){let a=Number(e||r)||(n?null:t),l=a?!!e:!1,c;if(s)try{c=JSON.parse(s)}catch{}return{port:a,break:l,debugId:i,env:c}}import{homedir as ju}from"os";import{resolve as _h,isAbsolute as xh,join as Qn}from"path";var Eh=process.env.VSCODE_CWD||process.cwd();function Hu(r,e){let t=Rh(r,e),n=[t];return xh(t)||n.unshift(Eh),_h(...n)}function Rh(r,e){process.env.VSCODE_DEV&&(process.isEmbeddedApp?e="sessions-oss-dev":e="code-oss-dev");let t=process.env.VSCODE_PORTABLE;if(t)return Qn(t,"user-data");let n=process.env.VSCODE_APPDATA;if(n)return Qn(n,e);let i=r["user-data-dir"];if(i)return i;switch(process.platform){case"win32":if(n=process.env.APPDATA,!n){let s=process.env.USERPROFILE;if(typeof s!="string")throw new Error("Windows: Unexpected undefined %USERPROFILE% environment variable");n=Qn(s,"AppData","Roaming")}break;case"darwin":n=Qn(ju(),"Library","Application Support");break;case"linux":n=process.env.XDG_CONFIG_HOME||Qn(ju(),".config");break;default:throw new Error("Platform not supported")}return Qn(n,e)}var _s=class extends M{constructor(e,t){super(e,{homeDir:wh(),tmpDir:Ch(),userDataDir:Hu(e,t.nameShort)},t)}};import Ph from"minimist";var bx={o:f(1980,null),e:f(1964,null),t:f(1995,null),m:f(1975,null)};var Gu={chat:{type:"subcommand",description:"Pass in a prompt to run in a chat session in the current working directory.",options:{_:{type:"string[]",description:f(1984,null)},mode:{type:"string",cat:"o",alias:"m",args:"mode",description:f(1952,null)},"add-file":{type:"string[]",cat:"o",alias:"a",args:"path",description:f(1948,null)},maximize:{type:"boolean",cat:"o",description:f(1951,null)},"reuse-window":{type:"boolean",cat:"o",alias:"r",description:f(1987,null)},"new-window":{type:"boolean",cat:"o",alias:"n",description:f(1978,null)},profile:{type:"string",cat:"o",args:"profileName",description:f(1983,null)},help:{type:"boolean",alias:"h",description:f(1966,null)}}},"serve-web":{type:"subcommand",description:"Run a server that displays the editor UI in browsers.",options:{"cli-data-dir":{type:"string",args:"dir",description:f(1953,null)},"disable-telemetry":{type:"boolean"},"telemetry-level":{type:"string"}}},"agent-host":{type:"subcommand",description:"Run a server that hosts agents.",options:{"cli-data-dir":{type:"string",args:"dir",description:f(1953,null)},"disable-telemetry":{type:"boolean"},"telemetry-level":{type:"string"}}},tunnel:{type:"subcommand",description:"Make the current machine accessible from vscode.dev or other machines through a secure tunnel.",options:{"cli-data-dir":{type:"string",args:"dir",description:f(1953,null)},"disable-telemetry":{type:"boolean"},"telemetry-level":{type:"string"},user:{type:"subcommand",options:{login:{type:"subcommand",options:{provider:{type:"string"},"access-token":{type:"string"}}}}}}},diff:{type:"boolean",cat:"o",alias:"d",args:["file","file"],description:f(1956,null)},merge:{type:"boolean",cat:"o",alias:"m",args:["path1","path2","base","result"],description:f(1976,null)},add:{type:"boolean",cat:"o",alias:"a",args:"folder",description:f(1947,null)},remove:{type:"boolean",cat:"o",args:"folder",description:f(1985,null)},goto:{type:"boolean",cat:"o",alias:"g",args:"file:line[:character]",description:f(1965,null)},"new-window":{type:"boolean",cat:"o",alias:"n",description:f(1977,null)},"reuse-window":{type:"boolean",cat:"o",alias:"r",description:f(1986,null)},sessions:{type:"boolean",cat:"o",description:f(1988,null)},wait:{type:"boolean",cat:"o",alias:"w",description:f(2005,null)},waitMarkerFilePath:{type:"string"},locale:{type:"string",cat:"o",args:"locale",description:f(1972,null)},"user-data-dir":{type:"string",cat:"o",args:"dir",description:f(2002,null)},profile:{type:"string",cat:"o",args:"profileName",description:f(1983,null)},help:{type:"boolean",cat:"o",alias:"h",description:f(1966,null)},"extensions-dir":{type:"string",deprecates:["extensionHomePath"],cat:"e",args:"dir",description:f(1963,null)},"extensions-download-dir":{type:"string"},"builtin-extensions-dir":{type:"string"},"list-extensions":{type:"boolean",cat:"e",description:f(1971,null)},"agent-plugins-dir":{type:"string"},"show-versions":{type:"boolean",cat:"e",description:f(1989,null)},category:{type:"string",allowEmptyValue:!0,cat:"e",description:f(1950,null),args:"category"},"install-extension":{type:"string[]",cat:"e",args:"ext-id | path",description:f(1970,null)},"pre-release":{type:"boolean",cat:"e",description:f(1969,null)},"uninstall-extension":{type:"string[]",cat:"e",args:"ext-id",description:f(1997,null)},"update-extensions":{type:"boolean",cat:"e",description:f(2000,null)},"enable-proposed-api":{type:"string[]",allowEmptyValue:!0,cat:"e",args:"ext-id",description:f(1962,null)},"add-mcp":{type:"string[]",cat:"m",args:"json",description:f(1949,null)},version:{type:"boolean",cat:"t",alias:"v",description:f(2004,null)},verbose:{type:"boolean",cat:"t",global:!0,description:f(2003,null)},log:{type:"string[]",cat:"t",args:"level",global:!0,description:f(1974,null)},status:{type:"boolean",alias:"s",cat:"t",description:f(1990,null)},"prof-startup":{type:"boolean",cat:"t",description:f(1982,null)},"prof-append-timers":{type:"string"},"prof-duration-markers":{type:"string[]"},"prof-duration-markers-file":{type:"string"},"no-cached-data":{type:"boolean"},"prof-startup-prefix":{type:"string"},"prof-v8-extensions":{type:"boolean"},"disable-extensions":{type:"boolean",deprecates:["disableExtensions"],cat:"t",description:f(1959,null)},"disable-extension":{type:"string[]",cat:"t",args:"ext-id",description:f(1958,null)},sync:{type:"string",cat:"t",description:f(1996,null),args:["on | off"]},"inspect-extensions":{type:"string",allowEmptyValue:!0,deprecates:["debugPluginHost"],args:"port",cat:"t",description:f(1968,null)},"inspect-brk-extensions":{type:"string",allowEmptyValue:!0,deprecates:["debugBrkPluginHost"],args:"port",cat:"t",description:f(1967,null)},"disable-lcd-text":{type:"boolean",cat:"t",description:f(1961,null)},"disable-gpu":{type:"boolean",cat:"t",description:f(1960,null)},"disable-chromium-sandbox":{type:"boolean",cat:"t",description:f(1957,null)},sandbox:{type:"boolean"},"locate-shell-integration-path":{type:"string",cat:"t",args:["shell"],description:f(1973,null)},telemetry:{type:"boolean",cat:"t",description:f(1993,null)},remote:{type:"string",allowEmptyValue:!0},"folder-uri":{type:"string[]",cat:"o",args:"uri"},"file-uri":{type:"string[]",cat:"o",args:"uri"},"locate-extension":{type:"string[]"},extensionDevelopmentPath:{type:"string[]"},extensionDevelopmentKind:{type:"string[]"},extensionTestsPath:{type:"string"},extensionEnvironment:{type:"string"},debugId:{type:"string"},debugRenderer:{type:"boolean"},"inspect-ptyhost":{type:"string",allowEmptyValue:!0},"inspect-brk-ptyhost":{type:"string",allowEmptyValue:!0},"inspect-agenthost":{type:"string",allowEmptyValue:!0},"inspect-brk-agenthost":{type:"string",allowEmptyValue:!0},"inspect-search":{type:"string",deprecates:["debugSearch"],allowEmptyValue:!0},"inspect-brk-search":{type:"string",deprecates:["debugBrkSearch"],allowEmptyValue:!0},"inspect-sharedprocess":{type:"string",allowEmptyValue:!0},"inspect-brk-sharedprocess":{type:"string",allowEmptyValue:!0},"export-default-configuration":{type:"string"},"export-policy-data":{type:"string",allowEmptyValue:!0},"export-default-keybindings":{type:"string",allowEmptyValue:!0},"install-source":{type:"string"},"enable-smoke-test-driver":{type:"boolean"},"skip-sessions-welcome":{type:"boolean"},logExtensionHostCommunication:{type:"boolean"},"skip-release-notes":{type:"boolean"},"skip-welcome":{type:"boolean"},"disable-telemetry":{type:"boolean"},"disable-updates":{type:"boolean"},transient:{type:"boolean",cat:"t",description:f(1994,null)},"use-inmemory-secretstorage":{type:"boolean",deprecates:["disable-keytar"]},"password-store":{type:"string"},"disable-workspace-trust":{type:"boolean"},"disable-crash-reporter":{type:"boolean"},"crash-reporter-directory":{type:"string"},"crash-reporter-id":{type:"string"},"skip-add-to-recently-opened":{type:"boolean"},"open-url":{type:"boolean"},"file-write":{type:"boolean"},"file-chmod":{type:"boolean"},"install-builtin-extension":{type:"string[]"},force:{type:"boolean"},"do-not-sync":{type:"boolean"},"do-not-include-pack-dependencies":{type:"boolean"},trace:{type:"boolean"},"trace-memory-infra":{type:"boolean"},"trace-category-filter":{type:"string"},"trace-options":{type:"string"},"preserve-env":{type:"boolean"},"force-user-env":{type:"boolean"},"force-disable-user-env":{type:"boolean"},"open-devtools":{type:"boolean"},"disable-gpu-sandbox":{type:"boolean"},logsPath:{type:"string"},"__enable-file-policy":{type:"boolean"},editSessionId:{type:"string"},continueOn:{type:"string"},"enable-coi":{type:"boolean"},"unresponsive-sample-interval":{type:"string"},"unresponsive-sample-period":{type:"string"},"enable-rdp-display-tracking":{type:"boolean"},"disable-layout-restore":{type:"boolean"},"disable-experiments":{type:"boolean"},"no-proxy-server":{type:"boolean"},"no-sandbox":{type:"boolean",alias:"sandbox"},"proxy-server":{type:"string"},"proxy-bypass-list":{type:"string"},"proxy-pac-url":{type:"string"},"js-flags":{type:"string"},inspect:{type:"string",allowEmptyValue:!0},"inspect-brk":{type:"string",allowEmptyValue:!0},nolazy:{type:"boolean"},"force-device-scale-factor":{type:"string"},"force-renderer-accessibility":{type:"boolean"},"ignore-certificate-errors":{type:"boolean"},"allow-insecure-localhost":{type:"boolean"},"log-net-log":{type:"string"},vmodule:{type:"string"},_urls:{type:"string[]"},"disable-dev-shm-usage":{type:"boolean"},"profile-temp":{type:"boolean"},"ozone-platform":{type:"string"},"enable-tracing":{type:"string"},"trace-startup-format":{type:"string"},"trace-startup-file":{type:"string"},"trace-startup-duration":{type:"string"},"xdg-portal-required-version":{type:"string"},_:{type:"string[]"}},Dh={onUnknownOption:()=>{},onMultipleValues:()=>{},onEmptyValue:()=>{},onDeprecatedOption:()=>{}};function Pa(r,e,t=Dh){let n=r.find((p,h)=>p.length>0&&p[0]!=="-"&&e.hasOwnProperty(p)&&e[p].type==="subcommand"),i={},s=["_"],o=[],a={},l;for(let p in e){let h=e[p];h.type==="subcommand"?p===n&&(l=h):(h.alias&&(i[p]=h.alias),h.type==="string"||h.type==="string[]"?(s.push(p),h.deprecates&&s.push(...h.deprecates)):h.type==="boolean"&&(o.push(p),h.deprecates&&o.push(...h.deprecates)),h.global&&(a[p]=h))}if(l&&n){let p=a;for(let W in l.options)p[W]=l.options[W];let h=r.filter(W=>W!==n),g=t.getSubcommandReporter?t.getSubcommandReporter(n):void 0,b=Pa(h,p,g);return{[n]:b,_:[]}}let c=Ph(r,{string:s,boolean:o,alias:i}),d={},u=c;d._=c._.map(p=>String(p)).filter(p=>p.length>0),delete u._;for(let p in e){let h=e[p];if(h.type==="subcommand")continue;h.alias&&delete u[h.alias];let g=u[p];if(h.deprecates)for(let b of h.deprecates)u.hasOwnProperty(b)&&(g||(g=u[b],g&&t.onDeprecatedOption(b,h.deprecationMessage||f(1955,null,p))),delete u[b]);if(typeof g<"u"){if(h.type==="string[]"){if(Array.isArray(g)||(g=[g]),!h.allowEmptyValue){let b=g.filter(W=>W.length>0);b.length!==g.length&&(t.onEmptyValue(p),g=b.length>0?b:void 0)}}else h.type==="string"&&(Array.isArray(g)?(g=g.pop(),t.onMultipleValues(p,g)):!g&&!h.allowEmptyValue&&(t.onEmptyValue(p),g=void 0));d[p]=g,h.deprecationMessage&&t.onDeprecatedOption(p,h.deprecationMessage)}delete u[p]}for(let p in u)t.onUnknownOption(p);return d}var xs=class extends A{constructor(e,t=[]){super(),this.logger=new cs([e,...t]),this._register(e.onDidChangeLogLevel(n=>this.setLevel(n)))}get onDidChangeLogLevel(){return this.logger.onDidChangeLogLevel}setLevel(e){this.logger.setLevel(e)}getLevel(){return this.logger.getLevel()}trace(e,...t){this.logger.trace(e,...t)}debug(e,...t){this.logger.debug(e,...t)}info(e,...t){this.logger.info(e,...t)}warn(e,...t){this.logger.warn(e,...t)}error(e,...t){this.logger.error(e,...t)}flush(){this.logger.flush()}};async function kh(r,e,t,n,i){try{let s=await import("@vscode/spdlog");s.setFlushOn(0);let o=await s.createAsyncRotatingLogger(r,e,t,n);return i?o.clearFormatters():o.setPattern("%Y-%m-%d %H:%M:%S.%e [%l] %v"),o}catch(s){console.error(s)}return null}function Qu(r,e,t){switch(e){case 1:r.trace(t);break;case 2:r.debug(t);break;case 3:r.info(t);break;case 4:r.warn(t);break;case 5:r.error(t);break;case 0:break;default:throw new Error(`Invalid log level ${e}`)}}function Ju(r,e){switch(e){case 1:r.setLevel(0);break;case 2:r.setLevel(1);break;case 3:r.setLevel(2);break;case 4:r.setLevel(3);break;case 5:r.setLevel(4);break;case 0:r.setLevel(6);break;default:throw new Error(`Invalid log level ${e}`)}}var Es=class extends Nr{constructor(t,n,i,s,o){super();this.buffer=[];this.setLevel(o),this._loggerCreationPromise=this._createSpdLogLogger(t,n,i,s),this._register(this.onDidChangeLogLevel(a=>{this._logger&&Ju(this._logger,a)}))}async _createSpdLogLogger(t,n,i,s){let o=i?6:1,a=30/o*zi.MB,l=await kh(t,n,a,o,s);if(l){this._logger=l,Ju(this._logger,this.getLevel());for(let{level:c,message:d}of this.buffer)Qu(this._logger,c,d);this.buffer=[]}}log(t,n){this._logger?Qu(this._logger,t,n):this.getLevel()<=t&&this.buffer.push({level:t,message:n})}flush(){this._logger?this.flushLogger():this._loggerCreationPromise.then(()=>this.flushLogger())}dispose(){this._logger?this.disposeLogger():this._loggerCreationPromise.then(()=>this.disposeLogger()),super.dispose()}flushLogger(){this._logger&&this._logger.flush()}disposeLogger(){this._logger&&(this._logger.drop(),this._logger=void 0)}};var Rs=class extends Mr{doCreateLogger(e,t,n){return new Es(Ge(),e.fsPath,!n?.donotRotate,!!n?.donotUseFormatters,t)}};var ws=class{constructor(e,t){this.loggerService=e;this.getUriTransformer=t}listen(e,t){let n=this.getUriTransformer(e);switch(t){case"onDidChangeLoggers":return V.map(this.loggerService.onDidChangeLoggers,i=>({added:[...i.added].map(s=>this.transformLogger(s,n)),removed:[...i.removed].map(s=>this.transformLogger(s,n))}));case"onDidChangeVisibility":return V.map(this.loggerService.onDidChangeVisibility,i=>[n.transformOutgoingURI(i[0]),i[1]]);case"onDidChangeLogLevel":return V.map(this.loggerService.onDidChangeLogLevel,i=>Ia(i)?i:[n.transformOutgoingURI(i[0]),i[1]])}throw new Error(`Event not found: ${t}`)}async call(e,t,n){let i=this.getUriTransformer(e);switch(t){case"setLogLevel":return Ia(n[0])?this.loggerService.setLogLevel(n[0]):this.loggerService.setLogLevel(m.revive(i.transformIncoming(n[0][0])),n[0][1]);case"getRegisteredLoggers":return Promise.resolve([...this.loggerService.getRegisteredLoggers()].map(s=>this.transformLogger(s,i)))}throw new Error(`Call not found: ${t}`)}transformLogger(e,t){return{...e,resource:t.transformOutgoingURI(e.resource)}}};var Yu=new class{transformIncoming(r){return r}transformOutgoing(r){return r}transformOutgoingURI(r){return r}transformOutgoingScheme(r){return r}};var Oe,Da=globalThis.vscode;if(typeof Da<"u"&&typeof Da.context<"u"){let r=Da.context.configuration();if(r)Oe=r.product;else throw new Error("Sandbox: unable to resolve product configuration from preload script.")}else if(globalThis._VSCODE_PRODUCT_JSON&&globalThis._VSCODE_PACKAGE_JSON){if(Oe=globalThis._VSCODE_PRODUCT_JSON,pe.VSCODE_DEV&&Object.assign(Oe,{nameShort:`${Oe.nameShort} Dev`,nameLong:`${Oe.nameLong} Dev`,dataFolderName:`${Oe.dataFolderName}-dev`,serverDataFolderName:Oe.serverDataFolderName?`${Oe.serverDataFolderName}-dev`:void 0}),!Oe.version){let r=globalThis._VSCODE_PACKAGE_JSON;Object.assign(Oe,{version:r.version})}}else Oe={quality:"stable",extensionsGallery:{serviceUrl:"https://open-vsx.org/vscode/gallery",itemUrl:"https://open-vsx.org/vscode/item"},linkProtectionTrustedDomains:["https://open-vsx.org"],documentationUrl:"https://code.visualstudio.com/docs",requestFeatureUrl:"https://github.com/Microsoft/vscode/issues",introductoryVideosUrl:"https://go.microsoft.com/fwlink/?linkid=832146",tipsAndTricksUrl:"https://go.microsoft.com/fwlink/?linkid=852118",keyboardShortcutsUrlLinux:"https://go.microsoft.com/fwlink/?linkid=832144",commit:"e7fb5e96c0730b9deb70b33781f98e2f35975036",date:"2026-04-01T09:27:11Z",nameShort:"Code - OSS",nameLong:"Code - OSS",applicationName:"code-oss",dataFolderName:".vscode-oss",win32MutexName:"vscodeoss",licenseName:"MIT",licenseUrl:"https://github.com/microsoft/vscode/blob/main/LICENSE.txt",serverLicenseUrl:"https://github.com/microsoft/vscode/blob/main/LICENSE.txt",serverGreeting:[],serverLicense:[],serverLicensePrompt:"",serverApplicationName:"code-server-oss",serverDataFolderName:".vscode-server-oss",tunnelApplicationName:"code-tunnel-oss",win32DirName:"Microsoft Code OSS",win32NameVersion:"Microsoft Code OSS",win32RegValueName:"CodeOSS",win32x64AppId:"{{D77B7E06-80BA-4137-BCF4-654B95CCEBC5}",win32arm64AppId:"{{D1ACE434-89C5-48D1-88D3-E2991DF85475}",win32x64UserAppId:"{{CC6B787D-37A0-49E8-AE24-8559A032BE0C}",win32arm64UserAppId:"{{3AEBF0C8-F733-4AD4-BADE-FDB816D53D7B}",win32AppUserModelId:"Microsoft.CodeOSS",win32ShellNameShort:"C&ode - OSS",win32TunnelServiceMutex:"vscodeoss-tunnelservice",win32TunnelMutex:"vscodeoss-tunnel",darwinBundleIdentifier:"com.visualstudio.code.oss",darwinProfileUUID:"47827DD9-4734-49A0-AF80-7E19B11495CC",darwinProfilePayloadUUID:"CF808BE7-53F3-46C6-A7E2-7EDB98A5E959",linuxIconName:"code-oss",licenseFileName:"LICENSE.txt",reportIssueUrl:"https://github.com/microsoft/vscode/issues/new",nodejsRepository:"https://nodejs.org",urlProtocol:"code-oss",webviewContentExternalBaseUrlTemplate:"https://{{uuid}}.vscode-cdn.net/insider/ef65ac1ba57f57f2a3961bfe94aa20481caca4c6/out/vs/workbench/contrib/webview/browser/pre/",builtInExtensions:[{name:"ms-vscode.js-debug-companion",version:"1.1.3",sha256:"7380a890787452f14b2db7835dfa94de538caf358ebc263f9d46dd68ac52de93",repo:"https://github.com/microsoft/vscode-js-debug-companion",metadata:{id:"99cb0b7f-7354-4278-b8da-6cc79972169d",publisherId:{publisherId:"5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",publisherName:"ms-vscode",displayName:"Microsoft",flags:"verified"},publisherDisplayName:"Microsoft"}},{name:"ms-vscode.js-debug",version:"1.112.0",sha256:"c24322931434940938f8cf76ebc3dac1e95a5539b9625b165b6672d7f7eafea8",repo:"https://github.com/microsoft/vscode-js-debug",metadata:{id:"25629058-ddac-4e17-abba-74678e126c5d",publisherId:{publisherId:"5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",publisherName:"ms-vscode",displayName:"Microsoft",flags:"verified"},publisherDisplayName:"Microsoft"}},{name:"ms-vscode.vscode-js-profile-table",version:"1.0.10",sha256:"7361748ddf9fd09d8a2ed1f2a2d7376a2cf9aae708692820b799708385c38e08",repo:"https://github.com/microsoft/vscode-js-profile-visualizer",metadata:{id:"7e52b41b-71ad-457b-ab7e-0620f1fc4feb",publisherId:{publisherId:"5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",publisherName:"ms-vscode",displayName:"Microsoft",flags:"verified"},publisherDisplayName:"Microsoft"}}],defaultChatAgent:{extensionId:"GitHub.copilot",chatExtensionId:"GitHub.copilot-chat",chatExtensionOutputId:"GitHub.copilot-chat.GitHub Copilot Chat.log",chatExtensionOutputExtensionStateCommand:"github.copilot.debug.extensionState",documentationUrl:"https://aka.ms/github-copilot-overview",termsStatementUrl:"https://aka.ms/github-copilot-terms-statement",privacyStatementUrl:"https://aka.ms/github-copilot-privacy-statement",skusDocumentationUrl:"https://aka.ms/github-copilot-plans",publicCodeMatchesUrl:"https://aka.ms/github-copilot-match-public-code",manageSettingsUrl:"https://aka.ms/github-copilot-settings",managePlanUrl:"https://aka.ms/github-copilot-manage-plan",manageOverageUrl:"https://aka.ms/github-copilot-manage-overage",upgradePlanUrl:"https://aka.ms/github-copilot-upgrade-plan",signUpUrl:"https://aka.ms/github-sign-up",provider:{default:{id:"github",name:"GitHub"},enterprise:{id:"github-enterprise",name:"GHE.com"},google:{id:"google",name:"Google"},apple:{id:"apple",name:"Apple"}},providerExtensionId:"vscode.github-authentication",providerUriSetting:"github-enterprise.uri",providerScopes:[["read:user","user:email","repo","workflow"],["user:email"],["read:user"]],entitlementUrl:"https://api.github.com/copilot_internal/user",entitlementSignupLimitedUrl:"https://api.github.com/copilot_internal/subscribe_limited_user",chatQuotaExceededContext:"github.copilot.chat.quotaExceeded",completionsQuotaExceededContext:"github.copilot.completions.quotaExceeded",walkthroughCommand:"github.copilot.open.walkthrough",completionsMenuCommand:"github.copilot.toggleStatusMenu",completionsRefreshTokenCommand:"github.copilot.signIn",chatRefreshTokenCommand:"github.copilot.refreshToken",generateCommitMessageCommand:"github.copilot.git.generateCommitMessage",resolveMergeConflictsCommand:"github.copilot.git.resolveMergeConflicts",completionsAdvancedSetting:"github.copilot.advanced",completionsEnablementSetting:"github.copilot.enable",nextEditSuggestionsSetting:"github.copilot.nextEditSuggestions.enabled",tokenEntitlementUrl:"https://api.github.com/copilot_internal/v2/token",mcpRegistryDataUrl:"https://api.github.com/copilot/mcp_registry"},trustedExtensionAuthAccess:{github:["GitHub.copilot-chat"],"github-enterprise":["GitHub.copilot-chat"]},version:"1.114.0"},Object.keys(Oe).length===0&&Object.assign(Oe,{version:"1.104.0-dev",nameShort:"Code - OSS Dev",nameLong:"Code - OSS Dev",applicationName:"code-oss",dataFolderName:".vscode-oss",urlProtocol:"code-oss",reportIssueUrl:"https://github.com/microsoft/vscode/issues/new",licenseName:"MIT",licenseUrl:"https://github.com/microsoft/vscode/blob/main/LICENSE.txt",serverLicenseUrl:"https://github.com/microsoft/vscode/blob/main/LICENSE.txt",defaultChatAgent:{extensionId:"GitHub.copilot",chatExtensionId:"GitHub.copilot-chat",provider:{default:{id:"github",name:"GitHub"},enterprise:{id:"github-enterprise",name:"GitHub Enterprise"}},providerScopes:[]}});var Xu=Oe;function Aa(r){let e=[];typeof r=="number"&&e.push("code/timeOrigin",r);function t(s,o){e.push(s,o?.startTime??Date.now())}function n(){let s=[];for(let o=0;o<e.length;o+=2)s.push({name:e[o],startTime:e[o+1]});return s}function i(s){for(let o=e.length-2;o>=0;o-=2)typeof e[o]=="string"&&e[o].startsWith(s)&&e.splice(o,2)}return{mark:t,getMarks:n,clearMarks:i}}function Lh(){if(typeof performance=="object"&&typeof performance.mark=="function"&&!performance.nodeTiming)return typeof performance.timeOrigin!="number"&&!performance.timing?Aa():{mark(r,e){performance.mark(r,e)},clearMarks(r){let e=new Set;for(let t of performance.getEntriesByType("mark"))t.name.startsWith(r)&&e.add(t.name);for(let t of e)performance.clearMarks(t)},getMarks(){let r=performance.timeOrigin;typeof r!="number"&&(r=(performance.timing.navigationStart||performance.timing.redirectStart||performance.timing.fetchStart)??0);let e=[{name:"code/timeOrigin",startTime:Math.round(r)}];for(let t of performance.getEntriesByType("mark"))e.push({name:t.name,startTime:Math.round(r+t.startTime)});return e}};if(typeof process=="object"){let r=performance?.timeOrigin;return Aa(r)}else return console.trace("perf-util loaded in UNKNOWN environment"),Aa()}function Oh(r){return r.MonacoPerformanceMarks||(r.MonacoPerformanceMarks=Lh()),r.MonacoPerformanceMarks}var ka=Oh(globalThis),Zu=ka.mark,i5=ka.clearMarks,s5=ka.getMarks;async function Cs(r,e,t,n,i,s){let o;try{await Fh(r,e,t,n,i,s)}catch(a){o=a}finally{o&&i.errorTransformer&&(o=i.errorTransformer(o)),typeof o<"u"&&t.error(o),t.end()}}async function Fh(r,e,t,n,i,s){La(s);let o=await r.open(e,{create:!1});try{La(s);let a=0,l=0,c=i&&typeof i.length=="number"?i.length:void 0,d=x.alloc(Math.min(i.bufferSize,typeof c=="number"?c:i.bufferSize)),u=i&&typeof i.position=="number"?i.position:0,p=0;do l=await r.read(o,u,d.buffer,p,d.byteLength-p),u+=l,p+=l,a+=l,typeof c=="number"&&(c-=l),p===d.byteLength&&(await t.write(n(d)),d=x.alloc(Math.min(i.bufferSize,typeof c=="number"?c:i.bufferSize)),p=0);while(l>0&&(typeof c!="number"||c>0)&&La(s)&&Uh(a,i));if(p>0){let h=p;typeof c=="number"&&(h=Math.min(p,c)),t.write(n(d.slice(0,h)))}}catch(a){throw gt(a)}finally{await r.close(o)}}function La(r){if(r.isCancellationRequested)throw Qr();return!0}function Uh(r,e){if(typeof e?.limits?.size=="number"&&r>e.limits.size)throw Qe(f(2158,null),"EntryTooLarge");return!0}var kt=class extends A{constructor(t){super();this.logService=t;this.BUFFER_SIZE=256*1024;this._onDidChangeFileSystemProviderRegistrations=this._register(new I);this.onDidChangeFileSystemProviderRegistrations=this._onDidChangeFileSystemProviderRegistrations.event;this._onWillActivateFileSystemProvider=this._register(new I);this.onWillActivateFileSystemProvider=this._onWillActivateFileSystemProvider.event;this._onDidChangeFileSystemProviderCapabilities=this._register(new I);this.onDidChangeFileSystemProviderCapabilities=this._onDidChangeFileSystemProviderCapabilities.event;this.provider=new Map;this._onDidRunOperation=this._register(new I);this.onDidRunOperation=this._onDidRunOperation.event;this.internalOnDidFilesChange=this._register(new I);this._onDidUncorrelatedFilesChange=this._register(new I);this.onDidFilesChange=this._onDidUncorrelatedFilesChange.event;this._onDidWatchError=this._register(new I);this.onDidWatchError=this._onDidWatchError.event;this.activeWatchers=new Map;this.writeQueue=this._register(new vn)}registerProvider(t,n){if(this.provider.has(t))throw new Error(`A filesystem provider for the scheme '${t}' is already registered.`);Zu(`code/registerFilesystem/${t}`);let i=new D;return this.provider.set(t,n),this._onDidChangeFileSystemProviderRegistrations.fire({added:!0,scheme:t,provider:n}),i.add(n.onDidChangeFile(s=>{let o=new Ki(s,!this.isPathCaseSensitive(n));this.internalOnDidFilesChange.fire(o),o.hasCorrelation()||this._onDidUncorrelatedFilesChange.fire(o)})),typeof n.onDidWatchError=="function"&&i.add(n.onDidWatchError(s=>this._onDidWatchError.fire(new Error(s)))),i.add(n.onDidChangeCapabilities(()=>this._onDidChangeFileSystemProviderCapabilities.fire({provider:n,scheme:t}))),O(()=>{this._onDidChangeFileSystemProviderRegistrations.fire({added:!1,scheme:t,provider:n}),this.provider.delete(t),xe(i)})}getProvider(t){return this.provider.get(t)}async activateProvider(t){let n=[];this._onWillActivateFileSystemProvider.fire({scheme:t,join(i){n.push(i)}}),!this.provider.has(t)&&await Ht.settled(n)}async canHandleResource(t){return await this.activateProvider(t.scheme),this.hasProvider(t)}hasProvider(t){return this.provider.has(t.scheme)}hasCapability(t,n){let i=this.provider.get(t.scheme);return!!(i&&i.capabilities&n)}listCapabilities(){return nr.map(this.provider,([t,n])=>({scheme:t,capabilities:n.capabilities}))}async withProvider(t){if(!sc(t))throw new le(f(2147,null,this.resourceForError(t)),8);await this.activateProvider(t.scheme);let n=this.provider.get(t.scheme);if(!n){let i=new Je;throw i.message=f(2149,null,t.toString()),i}return n}async withReadProvider(t){let n=await this.withProvider(t);if(ht(n)||Ne(n)||ji(n))return n;throw new Error(`Filesystem provider for scheme '${t.scheme}' neither has FileReadWrite, FileReadStream nor FileOpenReadWriteClose capability which is needed for the read operation.`)}async withWriteProvider(t){let n=await this.withProvider(t);if(ht(n)||Ne(n))return n;throw new Error(`Filesystem provider for scheme '${t.scheme}' neither has FileReadWrite nor FileOpenReadWriteClose capability which is needed for the write operation.`)}async resolve(t,n){try{return await this.doResolveFile(t,n)}catch(i){throw en(i)==="EntryNotFound"?new le(f(2144,null,this.resourceForError(t)),1):gt(i)}}async doResolveFile(t,n){let i=await this.withProvider(t),s=this.isPathCaseSensitive(i),o=n?.resolveTo,a=n?.resolveSingleChildDescendants,l=n?.resolveMetadata,c=await i.stat(t),d;return this.toFileStat(i,t,c,void 0,!!l,(u,p)=>(d||(d=Dt.forUris(()=>!s),d.set(t,!0),o&&d.fill(!0,o)),d.get(u.resource)||d.findSuperstr(u.resource.with({query:null,fragment:null}))?!0:u.isDirectory&&a?p===1:!1))}async toFileStat(t,n,i,s,o,a){let{providerExtUri:l}=this.getExtUri(t),c={resource:n,name:l.basename(n),isFile:(i.type&1)!==0,isDirectory:(i.type&2)!==0,isSymbolicLink:(i.type&64)!==0,mtime:i.mtime,ctime:i.ctime,size:i.size,readonly:!!((i.permissions??0)&1)||!!(t.capabilities&2048),locked:!!((i.permissions??0)&2),executable:!!((i.permissions??0)&4),etag:ra({mtime:i.mtime,size:i.size}),children:void 0};if(c.isDirectory&&a(c,s)){try{let d=await t.readdir(n),u=await Ht.settled(d.map(async([p,h])=>{try{let g=l.joinPath(n,p),b=o?await t.stat(g):{type:h};return await this.toFileStat(t,g,b,d.length,o,a)}catch(g){return this.logService.trace(g),null}}));c.children=Yr(u)}catch(d){this.logService.trace(d),c.children=[]}return c}return c}async resolveAll(t){return Ht.settled(t.map(async n=>{try{return{stat:await this.doResolveFile(n.resource,n.options),success:!0}}catch(i){return this.logService.trace(i),{stat:void 0,success:!1}}}))}async stat(t){let n=await this.withProvider(t),i=await n.stat(t);return this.toFileStat(n,t,i,void 0,!0,()=>!1)}async realpath(t){let n=await this.withProvider(t);if(iu(n)){let i=await n.realpath(t);return t.with({path:i})}}async exists(t){let n=await this.withProvider(t);try{return!!await n.stat(t)}catch{return!1}}async canCreateFile(t,n){try{await this.doValidateCreateFile(t,n)}catch(i){return i}return!0}async doValidateCreateFile(t,n){if(!n?.overwrite&&await this.exists(t))throw new le(f(2140,null,this.resourceForError(t)),3,n)}async createFile(t,n=x.fromString(""),i){await this.doValidateCreateFile(t,i);let s=await this.writeFile(t,n);return this._onDidRunOperation.fire(new ft(t,0,s)),s}async writeFile(t,n,i){let s=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(t),t),{providerExtUri:o}=this.getExtUri(s),a=i;if(ta(s)&&!a?.atomic){let l=s.enforceAtomicWriteFile?.(t);l&&(a={...i,atomic:l})}try{let{stat:l,buffer:c}=await this.validateWriteFile(s,t,n,a);l||await this.mkdirp(s,o.dirname(t)),c||(c=await this.peekBufferForWriting(s,n)),!ht(s)||Ne(s)&&c instanceof x||Ne(s)&&ta(s)&&a?.atomic?await this.doWriteUnbuffered(s,t,a,c):await this.doWriteBuffered(s,t,a,c instanceof x?vc(c):c),this._onDidRunOperation.fire(new ft(t,4))}catch(l){throw new le(f(2139,null,this.resourceForError(t),gt(l).toString()),na(l),a)}return this.resolve(t,{resolveMetadata:!0})}async peekBufferForWriting(t,n){let i;if(Ne(t)&&!(n instanceof x))if(pr(n)){let s=await pc(n,3);s.ended?i=x.concat(s.buffer):i=s}else i=dc(n,s=>x.concat(s),3);else i=n;return i}async validateWriteFile(t,n,i,s){let o=!!s?.unlock;if(o&&!(t.capabilities&8192))throw new Error(f(2157,null,this.resourceForError(n)));if(s?.append&&!nu(t))throw new le(f(2136,null,this.resourceForError(n)),6);if(!!s?.atomic){if(!(t.capabilities&32768))throw new Error(f(2155,null,this.resourceForError(n)));if(!(t.capabilities&2))throw new Error(f(2156,null,this.resourceForError(n)));if(o)throw new Error(f(2154,null,this.resourceForError(n)))}let l;try{l=await t.stat(n)}catch{return Object.create(null)}if((l.type&2)!==0)throw new le(f(2142,null,this.resourceForError(n)),0,s);this.throwIfFileIsReadonly(n,l);let c;if(typeof s?.mtime=="number"&&typeof s.etag=="string"&&s.etag!==Gi&&typeof l.mtime=="number"&&typeof l.size=="number"&&s.mtime<l.mtime&&s.etag!==ra({mtime:s.mtime,size:l.size})){if(c=await this.peekBufferForWriting(t,i),c instanceof x&&c.byteLength===l.size)try{let{value:d}=await this.readFile(n,{limits:{size:l.size}});if(c.equals(d))return{stat:l,buffer:c}}catch{}throw new le(f(2143,null),3,s)}return{stat:l,buffer:c}}async readFile(t,n,i){let s=await this.withReadProvider(t);return n?.atomic?this.doReadFileAtomic(s,t,n,i):this.doReadFile(s,t,n,i)}async doReadFileAtomic(t,n,i,s){return new Promise((o,a)=>{this.writeQueue.queueFor(n,async()=>{try{let l=await this.doReadFile(t,n,i,s);o(l)}catch(l){a(l)}},this.getExtUri(t).providerExtUri)})}async doReadFile(t,n,i,s){let o=await this.doReadFileStream(t,n,{...i,preferUnbuffered:!0},s);return{...o,value:await hr(o.value)}}async readFileStream(t,n,i){let s=await this.withReadProvider(t);return this.doReadFileStream(s,t,n,i)}async doReadFileStream(t,n,i,s){let o=new Ee(s),a=i;Hi(t)&&t.enforceAtomicReadFile?.(n)&&(a={...i,atomic:!0});let l=this.validateReadFile(n,a).then(d=>d,d=>{throw o.dispose(!0),d}),c;try{return typeof a?.etag=="string"&&a.etag!==Gi&&await l,a?.atomic&&Hi(t)||!(ht(t)||ji(t))||Ne(t)&&a?.preferUnbuffered?c=this.readFileUnbuffered(t,n,a):ji(t)?c=this.readFileStreamed(t,n,o.token,a):c=this.readFileBuffered(t,n,o.token,a),c.on("end",()=>o.dispose()),c.on("error",()=>o.dispose()),{...await l,value:c}}catch(d){throw c&&await xi(c),this.restoreReadError(d,n,a)}}restoreReadError(t,n,i){let s=f(2137,null,this.resourceForError(n),gt(t).toString());return t instanceof On?new On(s,t.stat,i):t instanceof Ln?new Ln(s,t.fileOperationResult,t.size,t.options):new le(s,na(t),i)}readFileStreamed(t,n,i,s=Object.create(null)){let o=t.readFileStream(n,s,i);return ko(o,{data:a=>a instanceof x?a:x.wrap(a),error:a=>this.restoreReadError(a,n,s)},a=>x.concat(a))}readFileBuffered(t,n,i,s=Object.create(null)){let o=yc();return Cs(t,n,o,a=>a,{...s,bufferSize:this.BUFFER_SIZE,errorTransformer:a=>this.restoreReadError(a,n,s)},i),o}readFileUnbuffered(t,n,i){let s=Gt(o=>x.concat(o));return(async()=>{try{let o;i?.atomic&&Hi(t)?o=await t.readFile(n,{atomic:!0}):o=await t.readFile(n),typeof i?.position=="number"&&(o=o.slice(i.position)),typeof i?.length=="number"&&(o=o.slice(0,i.length)),this.validateReadFileLimits(n,o.byteLength,i),s.end(x.wrap(o))}catch(o){s.error(o),s.end()}})(),s}async validateReadFile(t,n){let i=await this.resolve(t,{resolveMetadata:!0});if(i.isDirectory)throw new le(f(2141,null,this.resourceForError(t)),0,n);if(typeof n?.etag=="string"&&n.etag!==Gi&&n.etag===i.etag)throw new On(f(2145,null),i,n);return this.validateReadFileLimits(t,i.size,n),i}validateReadFileLimits(t,n,i){if(typeof i?.limits?.size=="number"&&n>i.limits.size)throw new Ln(f(2146,null,this.resourceForError(t)),7,n,i)}async canMove(t,n,i){return this.doCanMoveCopy(t,n,"move",i)}async canCopy(t,n,i){return this.doCanMoveCopy(t,n,"copy",i)}async doCanMoveCopy(t,n,i,s){if(t.toString()!==n.toString())try{let o=i==="move"?this.throwIfFileSystemIsReadonly(await this.withWriteProvider(t),t):await this.withReadProvider(t),a=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n);await this.doValidateMoveCopy(o,t,a,n,i,s)}catch(o){return o}return!0}async move(t,n,i){let s=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(t),t),o=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n),a=await this.doMoveCopy(s,t,o,n,"move",!!i),l=await this.resolve(n,{resolveMetadata:!0});return this._onDidRunOperation.fire(new ft(t,a==="move"?2:3,l)),l}async copy(t,n,i){let s=await this.withReadProvider(t),o=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n),a=await this.doMoveCopy(s,t,o,n,"copy",!!i),l=await this.resolve(n,{resolveMetadata:!0});return this._onDidRunOperation.fire(new ft(t,a==="copy"?3:2,l)),l}async doMoveCopy(t,n,i,s,o,a){if(n.toString()===s.toString())return o;let{exists:l,isSameResourceWithDifferentPathCase:c}=await this.doValidateMoveCopy(t,n,i,s,o,a);if(l&&!c&&a&&await this.del(s,{recursive:!0}),await this.mkdirp(i,this.getExtUri(i).providerExtUri.dirname(s)),o==="copy"){if(t===i&&ea(t))await t.copy(n,s,{overwrite:a});else{let d=await this.resolve(n);d.isDirectory?await this.doCopyFolder(t,d,i,s):await this.doCopyFile(t,n,i,s)}return o}else return t===i?(await t.rename(n,s,{overwrite:a}),o):(await this.doMoveCopy(t,n,i,s,"copy",a),await this.del(n,{recursive:!0}),"copy")}async doCopyFile(t,n,i,s){if(ht(t)&&ht(i))return this.doPipeBuffered(t,n,i,s);if(ht(t)&&Ne(i))return this.doPipeBufferedToUnbuffered(t,n,i,s);if(Ne(t)&&ht(i))return this.doPipeUnbufferedToBuffered(t,n,i,s);if(Ne(t)&&Ne(i))return this.doPipeUnbuffered(t,n,i,s)}async doCopyFolder(t,n,i,s){await i.mkdir(s),Array.isArray(n.children)&&await Ht.settled(n.children.map(async o=>{let a=this.getExtUri(i).providerExtUri.joinPath(s,o.name);return o.isDirectory?this.doCopyFolder(t,await this.resolve(o.resource),i,a):this.doCopyFile(t,o.resource,i,a)}))}async doValidateMoveCopy(t,n,i,s,o,a){let l=!1;if(t===i){let{providerExtUri:d,isPathCaseSensitive:u}=this.getExtUri(t);if(u||(l=d.isEqual(n,s)),l&&o==="copy")throw new Error(f(2150,null,this.resourceForError(n),this.resourceForError(s)));if(!l&&d.isEqualOrParent(s,n))throw new Error(f(2151,null,this.resourceForError(n),this.resourceForError(s)))}let c=await this.exists(s);if(c&&!l){if(!a)throw new le(f(2152,null,this.resourceForError(n),this.resourceForError(s)),4);if(t===i){let{providerExtUri:d}=this.getExtUri(t);if(d.isEqualOrParent(n,s))throw new Error(f(2153,null,this.resourceForError(n),this.resourceForError(s)))}}return{exists:c,isSameResourceWithDifferentPathCase:l}}getExtUri(t){let n=this.isPathCaseSensitive(t);return{providerExtUri:n?N:nc,isPathCaseSensitive:n}}isPathCaseSensitive(t){return!!(t.capabilities&1024)}async createFolder(t){let n=this.throwIfFileSystemIsReadonly(await this.withProvider(t),t);await this.mkdirp(n,t);let i=await this.resolve(t,{resolveMetadata:!0});return this._onDidRunOperation.fire(new ft(t,0,i)),i}async mkdirp(t,n){let i=[],{providerExtUri:s}=this.getExtUri(t);for(;!s.isEqual(n,s.dirname(n));)try{if(((await t.stat(n)).type&2)===0)throw new Error(f(2148,null,this.resourceForError(n)));break}catch(o){if(en(o)!=="EntryNotFound")throw o;i.push(s.basename(n)),n=s.dirname(n)}for(let o=i.length-1;o>=0;o--){n=s.joinPath(n,i[o]);try{await t.mkdir(n)}catch(a){if(en(a)!=="EntryExists")throw a}}}async canDelete(t,n){try{await this.doValidateDelete(t,n)}catch(i){return i}return!0}async doValidateDelete(t,n){let i=this.throwIfFileSystemIsReadonly(await this.withProvider(t),t),s=!!n?.useTrash;if(s&&!(i.capabilities&4096))throw new Error(f(2135,null,this.resourceForError(t)));let o=n?.atomic;if(o&&!(i.capabilities&65536))throw new Error(f(2131,null,this.resourceForError(t)));if(s&&o)throw new Error(f(2134,null,this.resourceForError(t)));let a;try{a=await i.stat(t)}catch{}if(a)this.throwIfFileIsReadonly(t,a);else throw new le(f(2133,null,this.resourceForError(t)),1);if(!!!n?.recursive){let c=await this.resolve(t);if(c.isDirectory&&Array.isArray(c.children)&&c.children.length>0)throw new Error(f(2132,null,this.resourceForError(t)))}return i}async del(t,n){let i=await this.doValidateDelete(t,n),s=n;if(su(i)&&!s?.atomic){let c=i.enforceAtomicDelete?.(t);c&&(s={...n,atomic:c})}let o=!!s?.useTrash,a=!!s?.recursive,l=s?.atomic??!1;await i.delete(t,{recursive:a,useTrash:o,atomic:l}),this._onDidRunOperation.fire(new ft(t,1))}async cloneFile(t,n){let i=await this.withProvider(t),s=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n);if(!(i===s&&this.getExtUri(i).providerExtUri.isEqual(t,n)))return i===s&&ru(i)?i.cloneFile(t,n):(await this.mkdirp(s,this.getExtUri(s).providerExtUri.dirname(n)),i===s&&ea(i)?this.writeQueue.queueFor(t,()=>i.copy(t,n,{overwrite:!0}),this.getExtUri(i).providerExtUri):this.writeQueue.queueFor(t,()=>this.doCopyFile(i,t,s,n),this.getExtUri(i).providerExtUri))}static{this.WATCHER_CORRELATION_IDS=0}createWatcher(t,n){return this.watch(t,{...n,correlationId:kt.WATCHER_CORRELATION_IDS++})}watch(t,n={recursive:!1,excludes:[]}){let i=new D,s=!1,o=()=>{s=!0};i.add(O(()=>o())),(async()=>{try{let l=await this.doWatch(t,n);s?xe(l):o=()=>xe(l)}catch(l){this.logService.error(l)}})();let a=n.correlationId;if(typeof a=="number"){let l=i.add(new I);return i.add(this.internalOnDidFilesChange.event(d=>{d.correlates(a)&&l.fire(d)})),{onDidChange:l.event,dispose:()=>i.dispose()}}return i}async doWatch(t,n){let i=await this.withProvider(t),s=Bn([this.getExtUri(i).providerExtUri.getComparisonKey(t),n]),o=this.activeWatchers.get(s);return o||(o={count:0,disposable:i.watch(t,n)},this.activeWatchers.set(s,o)),o.count+=1,O(()=>{o&&(o.count--,o.count===0&&(xe(o.disposable),this.activeWatchers.delete(s)))})}dispose(){super.dispose();for(let[,t]of this.activeWatchers)xe(t.disposable);this.activeWatchers.clear()}async doWriteBuffered(t,n,i,s){return this.writeQueue.queueFor(n,async()=>{let o=await t.open(n,{create:!0,unlock:i?.unlock??!1,append:i?.append??!1});try{pr(s)||_i(s)?await this.doWriteStreamBufferedQueued(t,o,s):await this.doWriteReadableBufferedQueued(t,o,s)}catch(a){throw gt(a)}finally{await t.close(o)}},this.getExtUri(t).providerExtUri)}async doWriteStreamBufferedQueued(t,n,i){let s=0,o;if(_i(i)){if(i.buffer.length>0){let a=x.concat(i.buffer);await this.doWriteBuffer(t,n,a,a.byteLength,s,0),s+=a.byteLength}if(i.ended)return;o=i.stream}else o=i;return new Promise((a,l)=>{Ei(o,{onData:async c=>{o.pause();try{await this.doWriteBuffer(t,n,c,c.byteLength,s,0)}catch(d){return l(d)}s+=c.byteLength,setTimeout(()=>o.resume())},onError:c=>l(c),onEnd:()=>a()})})}async doWriteReadableBufferedQueued(t,n,i){let s=0,o;for(;(o=i.read())!==null;)await this.doWriteBuffer(t,n,o,o.byteLength,s,0),s+=o.byteLength}async doWriteBuffer(t,n,i,s,o,a){let l=0;for(;l<s;){let c=await t.write(n,o+l,i.buffer,a+l,s-l);l+=c}}async doWriteUnbuffered(t,n,i,s){return this.writeQueue.queueFor(n,()=>this.doWriteUnbufferedQueued(t,n,i,s),this.getExtUri(t).providerExtUri)}async doWriteUnbufferedQueued(t,n,i,s){let o;s instanceof x?o=s:pr(s)?o=await hr(s):_i(s)?o=await bc(s):o=mc(s),await t.writeFile(n,o.buffer,{create:!0,overwrite:!0,unlock:i?.unlock??!1,atomic:i?.atomic??!1,append:i?.append??!1})}async doPipeBuffered(t,n,i,s){return this.writeQueue.queueFor(s,()=>this.doPipeBufferedQueued(t,n,i,s),this.getExtUri(i).providerExtUri)}async doPipeBufferedQueued(t,n,i,s){let o,a;try{o=await t.open(n,{create:!1}),a=await i.open(s,{create:!0,unlock:!1});let l=x.alloc(this.BUFFER_SIZE),c=0,d=0,u=0;do u=await t.read(o,c,l.buffer,d,l.byteLength-d),await this.doWriteBuffer(i,a,l,u,c,d),c+=u,d+=u,d===l.byteLength&&(d=0);while(u>0)}catch(l){throw gt(l)}finally{await Ht.settled([typeof o=="number"?t.close(o):Promise.resolve(),typeof a=="number"?i.close(a):Promise.resolve()])}}async doPipeUnbuffered(t,n,i,s){return this.writeQueue.queueFor(s,()=>this.doPipeUnbufferedQueued(t,n,i,s),this.getExtUri(i).providerExtUri)}async doPipeUnbufferedQueued(t,n,i,s){return i.writeFile(s,await t.readFile(n),{create:!0,overwrite:!0,unlock:!1,atomic:!1})}async doPipeUnbufferedToBuffered(t,n,i,s){return this.writeQueue.queueFor(s,()=>this.doPipeUnbufferedToBufferedQueued(t,n,i,s),this.getExtUri(i).providerExtUri)}async doPipeUnbufferedToBufferedQueued(t,n,i,s){let o=await i.open(s,{create:!0,unlock:!1});try{let a=await t.readFile(n);await this.doWriteBuffer(i,o,x.wrap(a),a.byteLength,0,0)}catch(a){throw gt(a)}finally{await i.close(o)}}async doPipeBufferedToUnbuffered(t,n,i,s){let o=await hr(this.readFileBuffered(t,n,Ke.None));await this.doWriteUnbuffered(i,s,void 0,o)}throwIfFileSystemIsReadonly(t,n){if(t.capabilities&2048)throw new le(f(2138,null,this.resourceForError(n)),6);return t}throwIfFileIsReadonly(t,n){if((n.permissions??0)&1)throw new le(f(2138,null,this.resourceForError(t)),6)}resourceForError(t){return t.scheme===Y.file?t.fsPath:t.toString(!0)}};kt=P([Se(0,Le)],kt);import{constants as Na,promises as on}from"fs";function ks(r){return typeof r.correlationId=="number"}function td(r){return r.recursive===!0}var Ps=class r extends A{constructor(t,n,i,s){super();this.onFileChanges=t;this.onLogMessage=n;this.verboseLogging=i;this.options=s;this.watcherDisposables=this._register(new St);this.requests=void 0;this.restartCounter=0}static{this.MAX_RESTARTS=5}init(){let t=new D;this.watcherDisposables.value=t,this.watcher=this.createWatcher(t),this.watcher.setVerboseLogging(this.verboseLogging),t.add(this.watcher.onDidChangeFile(n=>this.onFileChanges(n))),t.add(this.watcher.onDidLogMessage(n=>this.onLogMessage(n))),t.add(this.watcher.onDidError(n=>this.onError(n.error,n.request)))}onError(t,n){this.canRestart(t,n)?this.restartCounter<r.MAX_RESTARTS&&this.requests?(this.error(`restarting watcher after unexpected error: ${t}`),this.restart(this.requests)):this.error(`gave up attempting to restart watcher after unexpected error: ${t}`):this.error(t)}canRestart(t,n){return!(!this.options.restartOnError||n||t.indexOf("No space left on device")!==-1||t.indexOf("EMFILE")!==-1)}restart(t){this.restartCounter++,this.init(),this.watch(t)}async watch(t){this.requests=t,await this.watcher?.watch(t)}async setVerboseLogging(t){this.verboseLogging=t,await this.watcher?.setVerboseLogging(t)}error(t){this.onLogMessage({type:"error",message:`[File Watcher (${this.options.type})] ${t}`})}trace(t){this.onLogMessage({type:"trace",message:`[File Watcher (${this.options.type})] ${t}`})}dispose(){return this.watcher=void 0,super.dispose()}},Ds=class extends Ps{constructor(e,t,n){super(e,t,n,{type:"node.js",restartOnError:!1})}},As=class extends Ps{constructor(e,t,n){super(e,t,n,{type:"universal",restartOnError:!0})}};function Fa(r){return r.map(e=>({type:e.type,resource:m.revive(e.resource),cId:e.cId}))}function nd(r){let e=new Oa;for(let t of r)e.processEvent(t);return e.coalesce()}function Bh(r,e){return typeof e=="string"&&!e.startsWith(Wn)&&!di(e)?{base:r,pattern:e}:e}function Ua(r,e,t){let n=[];for(let i of e)n.push(da(Bh(r,i),{ignoreCase:t}));return n}var Oa=class{constructor(){this.coalesced=new Set;this.mapPathToChange=new Map}toKey(e){return te?e.resource.fsPath:e.resource.fsPath.toLowerCase()}processEvent(e){let t=this.mapPathToChange.get(this.toKey(e)),n=!1;if(t){let i=t.type,s=e.type;t.resource.fsPath!==e.resource.fsPath&&(e.type===2||e.type===1)?n=!0:i===1&&s===2?(this.mapPathToChange.delete(this.toKey(e)),this.coalesced.delete(t)):i===2&&s===1?t.type=0:i===1&&s===0||(t.type=s)}else n=!0;n&&(this.coalesced.add(e),this.mapPathToChange.set(this.toKey(e),e))}coalesce(){let e=[],t=[];return Array.from(this.coalesced).filter(n=>n.type!==2?(e.push(n),!1):!0).sort((n,i)=>n.resource.fsPath.length-i.resource.fsPath.length).filter(n=>t.some(i=>ou(n.resource.fsPath,i,!te))?!1:(t.push(n.resource.fsPath),!0)).concat(e)}};function rd(r,e){if(typeof e=="number")switch(r.type){case 1:return(e&4)===0;case 2:return(e&8)===0;case 0:return(e&2)===0}return!1}function id(r){if(typeof r=="number"){let e=[];return r&4&&e.push("Added"),r&8&&e.push("Deleted"),r&2&&e.push("Updated"),e.length===0?"<all>":`[${e.join(", ")}]`}return"<none>"}var Ls=class extends A{constructor(t,n){super();this.logService=t;this.options=n;this._onDidChangeFile=this._register(new I);this.onDidChangeFile=this._onDidChangeFile.event;this._onDidWatchError=this._register(new I);this.onDidWatchError=this._onDidWatchError.event;this.universalWatchRequests=[];this.universalWatchRequestDelayer=this._register(new zt(this.getRefreshWatchersDelay(this.universalWatchRequests.length)));this.nonRecursiveWatchRequests=[];this.nonRecursiveWatchRequestDelayer=this._register(new zt(this.getRefreshWatchersDelay(this.nonRecursiveWatchRequests.length)))}watch(t,n){return n.recursive||this.options?.watcher?.forceUniversal?this.watchUniversal(t,n):this.watchNonRecursive(t,n)}getRefreshWatchersDelay(t){return t>200?500:0}watchUniversal(t,n){let i=this.toWatchRequest(t,n),s=js(this.universalWatchRequests,i);return this.refreshUniversalWatchers(),O(()=>{s(),this.refreshUniversalWatchers()})}toWatchRequest(t,n){let i={path:this.toWatchPath(t),excludes:n.excludes,includes:n.includes,recursive:n.recursive,filter:n.filter,correlationId:n.correlationId};if(td(i)){let s=this.options?.watcher?.recursive?.usePolling;s===!0?i.pollingInterval=this.options?.watcher?.recursive?.pollingInterval??5e3:Array.isArray(s)&&s.includes(i.path)&&(i.pollingInterval=this.options?.watcher?.recursive?.pollingInterval??5e3)}return i}refreshUniversalWatchers(){this.universalWatchRequestDelayer.trigger(()=>this.doRefreshUniversalWatchers(),this.getRefreshWatchersDelay(this.universalWatchRequests.length)).catch(t=>Z(t))}doRefreshUniversalWatchers(){return this.universalWatcher||(this.universalWatcher=this._register(this.createUniversalWatcher(t=>this._onDidChangeFile.fire(Fa(t)),t=>this.onWatcherLogMessage(t),this.logService.getLevel()===1)),this._register(this.logService.onDidChangeLogLevel(()=>{this.universalWatcher?.setVerboseLogging(this.logService.getLevel()===1)}))),this.universalWatcher.watch(this.universalWatchRequests)}watchNonRecursive(t,n){let i={path:this.toWatchPath(t),excludes:n.excludes,includes:n.includes,recursive:!1,filter:n.filter,correlationId:n.correlationId},s=js(this.nonRecursiveWatchRequests,i);return this.refreshNonRecursiveWatchers(),O(()=>{s(),this.refreshNonRecursiveWatchers()})}refreshNonRecursiveWatchers(){this.nonRecursiveWatchRequestDelayer.trigger(()=>this.doRefreshNonRecursiveWatchers(),this.getRefreshWatchersDelay(this.nonRecursiveWatchRequests.length)).catch(t=>Z(t))}doRefreshNonRecursiveWatchers(){return this.nonRecursiveWatcher||(this.nonRecursiveWatcher=this._register(this.createNonRecursiveWatcher(t=>this._onDidChangeFile.fire(Fa(t)),t=>this.onWatcherLogMessage(t),this.logService.getLevel()===1)),this._register(this.logService.onDidChangeLogLevel(()=>{this.nonRecursiveWatcher?.setVerboseLogging(this.logService.getLevel()===1)}))),this.nonRecursiveWatcher.watch(this.nonRecursiveWatchRequests)}onWatcherLogMessage(t){t.type==="error"&&this._onDidWatchError.fire(t.message),this.logWatcherMessage(t)}logWatcherMessage(t){this.logService[t.type](t.message)}toFilePath(t){return Me(t.fsPath)}toWatchPath(t){let n=this.toFilePath(t);return jl(n)}};var Os=class extends As{constructor(e,t,n){super(e,t,n),this.init()}createWatcher(e){let t=e.add(new Ai(Ct.asFileUri("bootstrap-fork").fsPath,{serverName:"File Watcher",args:["--type=fileWatcher"],env:{VSCODE_ESM_ENTRYPOINT:"vs/platform/files/node/watcher/watcherMain",VSCODE_PIPE_LOGGING:"true",VSCODE_VERBOSE_LOGGING:"true"}}));return e.add(t.onDidProcessExit(({code:n,signal:i})=>this.onError(`terminated by itself with code ${n}, signal: ${i} (ETERM)`))),En.toService(Sc(t.getChannel("watcher")))}};import{watchFile as Vh,unwatchFile as qh}from"fs";var Fs=class extends A{constructor(){super();this._onDidChangeFile=this._register(new I);this.onDidChangeFile=this._onDidChangeFile.event;this._onDidLogMessage=this._register(new I);this.onDidLogMessage=this._onDidLogMessage.event;this._onDidWatchFail=this._register(new I);this.onDidWatchFail=this._onDidWatchFail.event;this.correlatedWatchRequests=new Map;this.nonCorrelatedWatchRequests=new Map;this.suspendedWatchRequests=this._register(new Ye);this.suspendedWatchRequestsWithPolling=new Set;this.updateWatchersDelayer=this._register(new zt(this.getUpdateWatchersDelay()));this.suspendedWatchRequestPollingInterval=5007;this.joinWatch=new Ze;this.verboseLogging=!1;this._register(this.onDidWatchFail(t=>this.suspendWatchRequest({id:this.computeId(t),correlationId:this.isCorrelated(t)?t.correlationId:void 0,path:t.path})))}isCorrelated(t){return ks(t)}computeId(t){return this.isCorrelated(t)?t.correlationId:Bn(t)}async watch(t){this.joinWatch.isSettled||this.joinWatch.complete(),this.joinWatch=new Ze;try{this.correlatedWatchRequests.clear(),this.nonCorrelatedWatchRequests.clear();for(let n of t)this.isCorrelated(n)?this.correlatedWatchRequests.set(n.correlationId,n):this.nonCorrelatedWatchRequests.set(this.computeId(n),n);for(let[n]of this.suspendedWatchRequests)!this.nonCorrelatedWatchRequests.has(n)&&!this.correlatedWatchRequests.has(n)&&(this.suspendedWatchRequests.deleteAndDispose(n),this.suspendedWatchRequestsWithPolling.delete(n));return await this.updateWatchers(!1)}finally{this.joinWatch.complete()}}updateWatchers(t){let n=[];for(let[i,s]of[...this.nonCorrelatedWatchRequests,...this.correlatedWatchRequests])this.suspendedWatchRequests.has(i)||n.push(s);return this.updateWatchersDelayer.trigger(()=>this.doWatch(n),t?this.getUpdateWatchersDelay():0).catch(i=>Z(i))}getUpdateWatchersDelay(){return 800}isSuspended(t){let n=this.computeId(t);return this.suspendedWatchRequestsWithPolling.has(n)?"polling":this.suspendedWatchRequests.has(n)}async suspendWatchRequest(t){if(this.suspendedWatchRequests.has(t.id))return;let n=new D;this.suspendedWatchRequests.set(t.id,n),await this.joinWatch.p,!n.isDisposed&&(this.monitorSuspendedWatchRequest(t,n),this.updateWatchers(!0))}resumeWatchRequest(t){this.suspendedWatchRequests.deleteAndDispose(t.id),this.suspendedWatchRequestsWithPolling.delete(t.id),this.updateWatchers(!1)}monitorSuspendedWatchRequest(t,n){this.doMonitorWithExistingWatcher(t,n)?(this.trace(`reusing an existing recursive watcher to monitor ${t.path}`),this.suspendedWatchRequestsWithPolling.delete(t.id)):(this.doMonitorWithNodeJS(t,n),this.suspendedWatchRequestsWithPolling.add(t.id))}doMonitorWithExistingWatcher(t,n){let i=this.recursiveWatcher?.subscribe(t.path,(s,o)=>{n.isDisposed||(s?this.monitorSuspendedWatchRequest(t,n):o?.type===1&&this.onMonitoredPathAdded(t))});return i?(n.add(i),!0):!1}doMonitorWithNodeJS(t,n){let i=!1,s=(o,a)=>{if(n.isDisposed)return;let l=this.isPathNotFound(o),c=this.isPathNotFound(a),d=i;i=l,!l&&(c||d)&&this.onMonitoredPathAdded(t)};this.trace(`starting fs.watchFile() on ${t.path} (correlationId: ${t.correlationId})`);try{Vh(t.path,{persistent:!1,interval:this.suspendedWatchRequestPollingInterval},s)}catch(o){this.warn(`fs.watchFile() failed with error ${o} on path ${t.path} (correlationId: ${t.correlationId})`)}n.add(O(()=>{this.trace(`stopping fs.watchFile() on ${t.path} (correlationId: ${t.correlationId})`);try{qh(t.path,s)}catch(o){this.warn(`fs.unwatchFile() failed with error ${o} on path ${t.path} (correlationId: ${t.correlationId})`)}}))}onMonitoredPathAdded(t){this.trace(`detected ${t.path} exists again, resuming watcher (correlationId: ${t.correlationId})`);let n={resource:m.file(t.path),type:1,cId:t.correlationId};this._onDidChangeFile.fire([n]),this.traceEvent(n,t),this.resumeWatchRequest(t)}isPathNotFound(t){return t.ctimeMs===0&&t.ino===0}async stop(){this.suspendedWatchRequests.clearAndDisposeAll(),this.suspendedWatchRequestsWithPolling.clear()}traceEvent(t,n){if(this.verboseLogging){let i=` >> normalized ${t.type===1?"[ADDED]":t.type===2?"[DELETED]":"[CHANGED]"} ${t.resource.fsPath}`;this.traceWithCorrelation(i,n)}}traceWithCorrelation(t,n){this.verboseLogging&&this.trace(`${t}${typeof n.correlationId=="number"?` <${n.correlationId}> `:""}`)}requestToString(t){return`${t.path} (excludes: ${t.excludes.length>0?t.excludes:"<none>"}, includes: ${t.includes&&t.includes.length>0?JSON.stringify(t.includes):"<all>"}, filter: ${id(t.filter)}, correlationId: ${typeof t.correlationId=="number"?t.correlationId:"<none>"})`}async setVerboseLogging(t){this.verboseLogging=t}};import{watch as $h,promises as Kh}from"fs";var Us=class r extends A{constructor(t,n,i,s,o,a){super();this.request=t;this.recursiveWatcher=n;this.onDidFilesChange=i;this.onDidWatchFail=s;this.onLogMessage=o;this.verboseLogging=a;this.throttledFileChangesEmitter=this._register(new bn({maxWorkChunkSize:100,throttleDelay:200,maxBufferedWork:1e4},t=>this.onDidFilesChange(t)));this.fileChangesAggregator=this._register(new Ii(t=>this.handleFileChanges(t),r.FILE_CHANGES_HANDLER_DELAY));this.cts=new Ee;this.realPath=new Ce(async()=>{let t=this.request.path;try{t=await ee.realpath(this.request.path),this.request.path!==t&&this.trace(`correcting a path to watch that seems to be a symbolic link (original: ${this.request.path}, real: ${t})`)}catch{}return t});this._isReusingRecursiveWatcher=!1;this.didFail=!1;let l=!te;this.excludes=Ua(this.request.path,this.request.excludes,l),this.includes=this.request.includes?Ua(this.request.path,this.request.includes,l):void 0,this.filter=ks(this.request)?this.request.filter:void 0,this.ready=this.watch()}static{this.FILE_DELETE_HANDLER_DELAY=100}static{this.FILE_CHANGES_HANDLER_DELAY=75}get isReusingRecursiveWatcher(){return this._isReusingRecursiveWatcher}get failed(){return this.didFail}async watch(){try{let t=await Kh.stat(this.request.path);if(this.cts.token.isCancellationRequested)return;this._register(await this.doWatch(t.isDirectory()))}catch(t){t.code!=="ENOENT"?this.error(t):this.trace(`ignoring a path for watching who's stat info failed to resolve: ${this.request.path} (error: ${t})`),this.notifyWatchFailed()}}notifyWatchFailed(){this.didFail=!0,this.onDidWatchFail?.()}async doWatch(t){let n=new D;return this.doWatchWithExistingWatcher(t,n)?(this.trace(`reusing an existing recursive watcher for ${this.request.path}`),this._isReusingRecursiveWatcher=!0):(this._isReusingRecursiveWatcher=!1,await this.doWatchWithNodeJS(t,n)),n}doWatchWithExistingWatcher(t,n){if(t)return!1;let i=m.file(this.request.path),s=this.recursiveWatcher?.subscribe(this.request.path,async(o,a)=>{n.isDisposed||(o?await dl(this.doWatch(t),n):a&&(typeof a.cId=="number"||typeof this.request.correlationId=="number")&&this.onFileChange({resource:i,type:a.type,cId:this.request.correlationId},!0))});return s?(n.add(s),!0):!1}async doWatchWithNodeJS(t,n){let i=await this.realPath.value;if(this.cts.token.isCancellationRequested)return;if($e&&lt(i,"/Volumes/",!0)){this.error(`Refusing to watch ${i} for changes using fs.watch() for possibly being a network share where watching is unreliable and unstable.`);return}let s=new Ee(this.cts.token);n.add(O(()=>s.dispose(!0)));let o=new D;n.add(o);try{let a=m.file(this.request.path),l=We(i),c=$h(i);o.add(O(()=>{c.removeAllListeners(),c.close()})),this.trace(`Started watching: '${i}'`);let d=new Set;if(t)try{for(let p of await ee.readdir(i))d.add(p)}catch(p){this.error(p)}if(s.token.isCancellationRequested)return;let u=new Map;o.add(O(()=>{for(let[,p]of u)p.dispose();u.clear()})),c.on("error",(p,h)=>{s.token.isCancellationRequested||(this.error(`Failed to watch ${i} for changes using fs.watch() (${p}, ${h})`),this.notifyWatchFailed())}),c.on("change",(p,h)=>{if(s.token.isCancellationRequested)return;this.verboseLogging&&this.traceWithCorrelation(`[raw] ["${p}"] ${h}`);let g="";if(h&&(g=h.toString(),$e&&(g=Ir(g))),!(!g||p!=="change"&&p!=="rename"))if(t)if(p==="rename"){u.get(g)?.dispose();let b=setTimeout(async()=>{if(u.delete(g),gn(g,l,!te)&&!await ee.exists(i)){this.onWatchedPathDeleted(a);return}if(s.token.isCancellationRequested)return;let W=await this.existsChildStrictCase(J(i,g));if(s.token.isCancellationRequested)return;let j;W?d.has(g)?j=0:(j=1,d.add(g)):(d.delete(g),j=2),this.onFileChange({resource:se(a,g),type:j,cId:this.request.correlationId})},r.FILE_DELETE_HANDLER_DELAY);u.set(g,O(()=>clearTimeout(b)))}else{let b;d.has(g)?b=0:(b=1,d.add(g)),this.onFileChange({resource:se(a,g),type:b,cId:this.request.correlationId})}else if(p==="rename"||!gn(g,l,!te)){let b=setTimeout(async()=>{let W=await ee.exists(i);s.token.isCancellationRequested||(W?(this.onFileChange({resource:a,type:0,cId:this.request.correlationId},!0),o.add(await this.doWatch(!1))):this.onWatchedPathDeleted(a))},r.FILE_DELETE_HANDLER_DELAY);o.clear(),o.add(O(()=>clearTimeout(b)))}else this.onFileChange({resource:a,type:0,cId:this.request.correlationId},!0)})}catch(a){if(s.token.isCancellationRequested)return;this.error(`Failed to watch ${i} for changes using fs.watch() (${a.toString()})`),this.notifyWatchFailed()}}onWatchedPathDeleted(t){this.warn("Watcher shutdown because watched path got deleted"),this.onFileChange({resource:t,type:2,cId:this.request.correlationId},!0),this.fileChangesAggregator.flush(),this.notifyWatchFailed()}onFileChange(t,n=!1){this.cts.token.isCancellationRequested||(this.verboseLogging&&this.traceWithCorrelation(`${t.type===1?"[ADDED]":t.type===2?"[DELETED]":"[CHANGED]"} ${t.resource.fsPath}`),!n&&this.excludes.some(i=>i(t.resource.fsPath))?this.verboseLogging&&this.traceWithCorrelation(` >> ignored (excluded) ${t.resource.fsPath}`):!n&&this.includes&&this.includes.length>0&&!this.includes.some(i=>i(t.resource.fsPath))?this.verboseLogging&&this.traceWithCorrelation(` >> ignored (not included) ${t.resource.fsPath}`):this.fileChangesAggregator.work(t))}handleFileChanges(t){let n=nd(t),i=[];for(let o of n){if(rd(o,this.filter)){this.verboseLogging&&this.traceWithCorrelation(` >> ignored (filtered) ${o.resource.fsPath}`);continue}i.push(o)}if(i.length===0)return;if(this.verboseLogging)for(let o of i)this.traceWithCorrelation(` >> normalized ${o.type===1?"[ADDED]":o.type===2?"[DELETED]":"[CHANGED]"} ${o.resource.fsPath}`);this.throttledFileChangesEmitter.work(i)?this.throttledFileChangesEmitter.pending>0&&this.trace(`started throttling events due to large amount of file change events at once (pending: ${this.throttledFileChangesEmitter.pending}, most recent change: ${i[0].resource.fsPath}). Use 'files.watcherExclude' setting to exclude folders with lots of changing files (e.g. compilation output).`):this.warn(`started ignoring events due to too many file change events at once (incoming: ${i.length}, most recent change: ${i[0].resource.fsPath}). Use 'files.watcherExclude' setting to exclude folders with lots of changing files (e.g. compilation output).`)}async existsChildStrictCase(t){if(te)return ee.exists(t);try{let n=We(t);return(await ee.readdir(be(t))).some(s=>s===n)}catch(n){return this.trace(n),!1}}setVerboseLogging(t){this.verboseLogging=t}error(t){this.cts.token.isCancellationRequested||this.onLogMessage?.({type:"error",message:`[File Watcher (node.js)] ${t}`})}warn(t){this.cts.token.isCancellationRequested||this.onLogMessage?.({type:"warn",message:`[File Watcher (node.js)] ${t}`})}trace(t){!this.cts.token.isCancellationRequested&&this.verboseLogging&&this.onLogMessage?.({type:"trace",message:`[File Watcher (node.js)] ${t}`})}traceWithCorrelation(t){!this.cts.token.isCancellationRequested&&this.verboseLogging&&this.trace(`${t}${typeof this.request.correlationId=="number"?` <${this.request.correlationId}> `:""}`)}dispose(){this.cts.dispose(!0),super.dispose()}};var Ns=class extends Fs{constructor(t){super();this.recursiveWatcher=t;this.onDidError=V.None;this._watchers=new Map;this.worker=this._register(new St)}get watchers(){return this._watchers.values()}async doWatch(t){t=this.removeDuplicateRequests(t);let n=[],i=new Set(Array.from(this.watchers));for(let s of t){let o=this._watchers.get(this.requestToWatcherKey(s));o&&pa(o.request.excludes,s.excludes)&&pa(o.request.includes,s.includes)?i.delete(o):n.push(s)}n.length&&this.trace(`Request to start watching: ${n.map(s=>this.requestToString(s)).join(",")}`),i.size&&this.trace(`Request to stop watching: ${Array.from(i).map(s=>this.requestToString(s.request)).join(",")}`),this.worker.clear();for(let s of i)this.stopWatching(s);this.createWatchWorker().work(n)}createWatchWorker(){return this.worker.value=new bn({maxWorkChunkSize:100,throttleDelay:100,maxBufferedWork:Number.MAX_VALUE},t=>{for(let n of t)this.startWatching(n)}),this.worker.value}requestToWatcherKey(t){return typeof t.correlationId=="number"?t.correlationId:this.pathToWatcherKey(t.path)}pathToWatcherKey(t){return te?t:t.toLowerCase()}startWatching(t){let n=new Us(t,this.recursiveWatcher,s=>this._onDidChangeFile.fire(s),()=>this._onDidWatchFail.fire(t),s=>this._onDidLogMessage.fire(s),this.verboseLogging),i={request:t,instance:n};this._watchers.set(this.requestToWatcherKey(t),i)}async stop(){await super.stop();for(let t of this.watchers)this.stopWatching(t)}stopWatching(t){this.trace("stopping file watcher",t),this._watchers.delete(this.requestToWatcherKey(t.request)),t.instance.dispose()}removeDuplicateRequests(t){let n=new Map;for(let i of t){let s=n.get(i.correlationId);s||(s=new Map,n.set(i.correlationId,s));let o=this.pathToWatcherKey(i.path);s.has(o)&&this.trace(`ignoring a request for watching who's path is already watched: ${this.requestToString(i)}`),s.set(o,i)}return Array.from(n.values()).flatMap(i=>Array.from(i.values()))}async setVerboseLogging(t){super.setVerboseLogging(t);for(let n of this.watchers)n.instance.setVerboseLogging(t)}trace(t,n){this.verboseLogging&&this._onDidLogMessage.fire({type:"trace",message:this.toMessage(t,n)})}warn(t){this._onDidLogMessage.fire({type:"warn",message:this.toMessage(t)})}toMessage(t,n){return n?`[File Watcher (node.js)] ${t} (${this.requestToString(n.request)})`:`[File Watcher (node.js)] ${t}`}};var Ms=class extends Ds{constructor(e,t,n){super(e,t,n),this.init()}createWatcher(e){return e.add(new Ns(void 0))}};var Ws=class r extends Ls{constructor(){super(...arguments);this.onDidChangeCapabilities=V.None;this.resourceLocks=new rt(t=>mn.getComparisonKey(t));this.mapHandleToPos=new Map;this.mapHandleToLock=new Map;this.writeHandles=new Map}static{this.TRACE_LOG_RESOURCE_LOCKS=!1}get capabilities(){return this._capabilities||(this._capabilities=1040414,te&&(this._capabilities|=1024)),this._capabilities}async stat(t){try{let{stat:n,symbolicLink:i}=await et.stat(this.toFilePath(t)),s;return(n.mode&128)===0&&(s=2),(n.mode&Na.S_IXUSR||n.mode&Na.S_IXGRP||n.mode&Na.S_IXOTH)&&(s=(s??0)|4),{type:this.toType(n,i),ctime:n.birthtime.getTime(),mtime:n.mtime.getTime(),size:n.size,permissions:s}}catch(n){throw this.toFileSystemProviderError(n)}}async statIgnoreError(t){try{return await this.stat(t)}catch{return}}async realpath(t){let n=this.toFilePath(t);return ee.realpath(n)}async readdir(t){try{let n=await ee.readdir(this.toFilePath(t),{withFileTypes:!0}),i=[];return await Promise.all(n.map(async s=>{try{let o;s.isSymbolicLink()?o=(await this.stat(se(t,s.name))).type:o=this.toType(s),i.push([s.name,o])}catch(o){this.logService.trace(o)}})),i}catch(n){throw this.toFileSystemProviderError(n)}}toType(t,n){let i;return n?.dangling?i=0:t.isFile()?i=1:t.isDirectory()?i=2:i=0,n&&(i|=64),i}async createResourceLock(t){let n=this.toFilePath(t);this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - request to acquire resource lock (${n})`);let i;for(;i=this.resourceLocks.get(t);)this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - waiting for resource lock to be released (${n})`),await i.wait();let s=new bi;return this.resourceLocks.set(t,s),this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - new resource lock created (${n})`),O(()=>{this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - resource lock dispose() (${n})`),this.resourceLocks.get(t)===s&&(this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - resource lock removed from resource-lock map (${n})`),this.resourceLocks.delete(t)),this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - resource lock barrier open() (${n})`),s.open()})}async readFile(t,n){let i;try{n?.atomic&&(this.traceLock(`[Disk FileSystemProvider]: atomic read operation started (${this.toFilePath(t)})`),i=await this.createResourceLock(t));let s=this.toFilePath(t);return await on.readFile(s)}catch(s){throw this.toFileSystemProviderError(s)}finally{i?.dispose()}}traceLock(t){r.TRACE_LOG_RESOURCE_LOCKS&&this.logService.trace(t)}readFileStream(t,n,i){let s=Gt(o=>x.concat(o.map(a=>x.wrap(a))).buffer);return Cs(this,t,s,o=>o.buffer,{...n,bufferSize:256*1024},i),s}async writeFile(t,n,i){return i?.atomic!==!1&&i?.atomic?.postfix&&await this.canWriteFileAtomic(t)?this.doWriteFileAtomic(t,se(rc(t),`${Eo(t)}${i.atomic.postfix}`),n,i):this.doWriteFile(t,n,i)}async canWriteFileAtomic(t){try{let n=this.toFilePath(t),{symbolicLink:i}=await et.stat(n);if(i)return!1}catch{}return!0}async doWriteFileAtomic(t,n,i,s){let o=new D;try{o.add(await this.createResourceLock(t)),o.add(await this.createResourceLock(n)),await this.doWriteFile(n,i,{...s,create:!0,overwrite:!0},!0);try{await this.rename(n,t,{overwrite:!0})}catch(a){try{await this.delete(n,{recursive:!1,useTrash:!1,atomic:!1})}catch{}throw a}}finally{o.dispose()}}async doWriteFile(t,n,i,s){let o;try{let a=this.toFilePath(t);if(!i.create||!i.overwrite){if(await ee.exists(a)){if(!i.overwrite)throw Qe(f(2163,null),"EntryExists")}else if(!i.create)throw Qe(f(2166,null),"EntryNotFound")}o=await this.open(t,{create:!0,append:i.append,unlock:i.unlock},s),await this.write(o,0,n,0,n.byteLength)}catch(a){throw await this.toFileSystemProviderWriteError(t,a)}finally{typeof o=="number"&&await this.close(o)}}static{this.canFlush=!0}static configureFlushOnWrite(t){r.canFlush=t}async open(t,n,i){let s=this.toFilePath(t),o;Zt(n)&&!i&&(o=await this.createResourceLock(t));let a;try{if(Zt(n)&&n.unlock)try{let{stat:l}=await et.stat(s);l.mode&128||await on.chmod(s,l.mode|128)}catch(l){l.code!=="ENOENT"&&this.logService.trace(l)}if($&&Zt(n)&&!n.append)try{a=await ee.open(s,"r+"),await ee.ftruncate(a,0)}catch(l){if(l.code!=="ENOENT"&&this.logService.trace(l),typeof a=="number"){try{await ee.close(a)}catch(c){this.logService.trace(c)}a=void 0}}typeof a!="number"&&(a=await ee.open(s,Zt(n)?n.append?"a":"w":"r"))}catch(l){throw o?.dispose(),Zt(n)?await this.toFileSystemProviderWriteError(t,l):this.toFileSystemProviderError(l)}if(this.mapHandleToPos.set(a,0),Zt(n)&&this.writeHandles.set(a,t),o){let l=this.mapHandleToLock.get(a);this.traceLock(`[Disk FileSystemProvider]: open() - storing lock for handle ${a} (${s})`),this.mapHandleToLock.set(a,o),l&&(this.traceLock(`[Disk FileSystemProvider]: open() - disposing a previous lock that was still stored on same handle ${a} (${s})`),l.dispose())}return a}async close(t){let n=this.mapHandleToLock.get(t);try{if(this.mapHandleToPos.delete(t),this.writeHandles.delete(t)&&r.canFlush)try{await ee.fdatasync(t)}catch(i){r.configureFlushOnWrite(!1),this.logService.error(i)}return await ee.close(t)}catch(i){throw this.toFileSystemProviderError(i)}finally{n&&(this.mapHandleToLock.get(t)===n&&(this.traceLock(`[Disk FileSystemProvider]: close() - resource lock removed from handle-lock map ${t}`),this.mapHandleToLock.delete(t)),this.traceLock(`[Disk FileSystemProvider]: close() - disposing lock for handle ${t}`),n.dispose())}}async read(t,n,i,s,o){let a=this.normalizePos(t,n),l=null;try{l=(await ee.read(t,i,s,o,a)).bytesRead}catch(c){throw this.toFileSystemProviderError(c)}finally{this.updatePos(t,a,l)}return l}normalizePos(t,n){return n===this.mapHandleToPos.get(t)?null:n}updatePos(t,n,i){let s=this.mapHandleToPos.get(t);typeof s=="number"&&(typeof n=="number"||(typeof i=="number"?this.mapHandleToPos.set(t,s+i):this.mapHandleToPos.delete(t)))}async write(t,n,i,s,o){return cc(()=>this.doWrite(t,n,i,s,o),100,3)}async doWrite(t,n,i,s,o){let a=this.normalizePos(t,n),l=null;try{l=(await ee.write(t,i,s,o,a)).bytesWritten}catch(c){throw await this.toFileSystemProviderWriteError(this.writeHandles.get(t),c)}finally{this.updatePos(t,a,l)}return l}async mkdir(t){try{await on.mkdir(this.toFilePath(t))}catch(n){throw this.toFileSystemProviderError(n)}}async delete(t,n){try{let i=this.toFilePath(t);if(n.recursive){let s;n?.atomic!==!1&&n.atomic.postfix&&(s=J(be(i),`${We(i)}${n.atomic.postfix}`)),await ee.rm(i,1,s)}else try{await on.unlink(i)}catch(s){if(s.code==="EPERM"||s.code==="EISDIR"){let o=!1;try{let{stat:a,symbolicLink:l}=await et.stat(i);o=a.isDirectory()&&!l}catch{}if(o)await on.rmdir(i);else throw s}else throw s}}catch(i){throw this.toFileSystemProviderError(i)}}async rename(t,n,i){let s=this.toFilePath(t),o=this.toFilePath(n);if(s!==o)try{await this.validateMoveCopy(t,n,"move",i.overwrite),await ee.rename(s,o)}catch(a){throw(a.code==="EINVAL"||a.code==="EBUSY"||a.code==="ENAMETOOLONG")&&(a=new Error(f(2167,null,We(s),We(be(o)),a.toString()))),this.toFileSystemProviderError(a)}}async copy(t,n,i){let s=this.toFilePath(t),o=this.toFilePath(n);if(s!==o)try{await this.validateMoveCopy(t,n,"copy",i.overwrite),await ee.copy(s,o,{preserveSymlinks:!0})}catch(a){throw(a.code==="EINVAL"||a.code==="EBUSY"||a.code==="ENAMETOOLONG")&&(a=new Error(f(2161,null,We(s),We(be(o)),a.toString()))),this.toFileSystemProviderError(a)}}async validateMoveCopy(t,n,i,s){let o=this.toFilePath(t),a=this.toFilePath(n),l=!1;if(this.capabilities&1024||(l=gn(o,a,!0)),l){if(i==="copy")throw Qe(f(2162,null),"EntryExists");if(i==="move")return}let d=await this.statIgnoreError(t);if(!d)throw Qe(f(2165,null),"EntryNotFound");let u=await this.statIgnoreError(n);if(u){if(!s)throw Qe(f(2164,null),"EntryExists");(d.type&1)!==0&&(u.type&1)!==0||await this.delete(n,{recursive:!0,useTrash:!1,atomic:!1})}}async cloneFile(t,n){return this.doCloneFile(t,n,!1)}async doCloneFile(t,n,i){let s=this.toFilePath(t),o=this.toFilePath(n),a=!!(this.capabilities&1024);if(gn(s,o,!a))return;let l=new D;try{l.add(await this.createResourceLock(t)),l.add(await this.createResourceLock(n)),i&&await on.mkdir(be(o),{recursive:!0}),await on.copyFile(s,o)}catch(c){if(c.code==="ENOENT"&&!i)return this.doCloneFile(t,n,!0);throw this.toFileSystemProviderError(c)}finally{l.dispose()}}createUniversalWatcher(t,n,i){return new Os(s=>t(s),s=>n(s),i)}createNonRecursiveWatcher(t,n,i){return new Ms(s=>t(s),s=>n(s),i)}toFileSystemProviderError(t){if(t instanceof kn)return t;let n=t,i;switch(t.code){case"ENOENT":i="EntryNotFound";break;case"EISDIR":i="EntryIsADirectory";break;case"ENOTDIR":i="EntryNotADirectory";break;case"EEXIST":i="EntryExists";break;case"EPERM":case"EACCES":i="NoPermissions";break;case"ERR_UNC_HOST_NOT_ALLOWED":n=`${t.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.`,i="Unknown";break;default:i="Unknown"}return Qe(n,i)}async toFileSystemProviderWriteError(t,n){let i=this.toFileSystemProviderError(n);if(t&&i.code==="NoPermissions")try{let{stat:s}=await et.stat(this.toFilePath(t));s.mode&128||(i=Qe(n,"EntryWriteLocked"))}catch(s){this.logService.trace(s)}return i}};var bt=class{constructor(e,t=[],n=!1){this.ctor=e,this.staticArguments=t,this.supportsDelayedInstantiation=n}};var Ma=class{constructor(e,t){this.key=e;this.data=t;this.incoming=new Map;this.outgoing=new Map}},Kr=class{constructor(e){this._hashFn=e;this._nodes=new Map}roots(){let e=[];for(let t of this._nodes.values())t.outgoing.size===0&&e.push(t);return e}insertEdge(e,t){let n=this.lookupOrInsertNode(e),i=this.lookupOrInsertNode(t);n.outgoing.set(i.key,i),i.incoming.set(n.key,n)}removeNode(e){let t=this._hashFn(e);this._nodes.delete(t);for(let n of this._nodes.values())n.outgoing.delete(t),n.incoming.delete(t)}lookupOrInsertNode(e){let t=this._hashFn(e),n=this._nodes.get(t);return n||(n=new Ma(t,e),this._nodes.set(t,n)),n}lookup(e){return this._nodes.get(this._hashFn(e))}isEmpty(){return this._nodes.size===0}toString(){let e=[];for(let[t,n]of this._nodes)e.push(`${t}
	(-> incoming)[${[...n.incoming.keys()].join(", ")}]
	(outgoing ->)[${[...n.outgoing.keys()].join(",")}]
`);return e.join(`
`)}findCycleSlow(){for(let[e,t]of this._nodes){let n=new Set([e]),i=this._findCycle(t,n);if(i)return i}}_findCycle(e,t){for(let[n,i]of e.outgoing){if(t.has(n))return[...t,n].join(" -> ");t.add(n);let s=this._findCycle(i,t);if(s)return s;t.delete(n)}}};var Jn=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}};var zh=!1,Bs=class extends Error{constructor(e){super("cyclic dependency between services"),this.message=e.findCycleSlow()??`UNABLE to detect cycle, dumping graph: 
${e.toString()}`}},Vs=class r{constructor(e=new Jn,t=!1,n,i=zh){this._services=e;this._strict=t;this._parent=n;this._enableTracing=i;this._isDisposed=!1;this._servicesToMaybeDispose=new Set;this._children=new Set;this._activeInstantiations=new Set;this._services.set(Oi,this),this._globalGraph=i?n?._globalGraph??new Kr(s=>s):void 0}dispose(){if(!this._isDisposed){this._isDisposed=!0,xe(this._children),this._children.clear();for(let e of this._servicesToMaybeDispose)ni(e)&&e.dispose();this._servicesToMaybeDispose.clear()}}_throwIfDisposed(){if(this._isDisposed)throw new Error("InstantiationService has been disposed")}createChild(e,t){this._throwIfDisposed();let n=this,i=new class extends r{dispose(){n._children.delete(i),super.dispose()}}(e,this._strict,this,this._enableTracing);return this._children.add(i),t?.add(i),i}invokeFunction(e,...t){this._throwIfDisposed();let n=zr.traceInvocation(this._enableTracing,e),i=!1;try{return e({get:o=>{if(i)throw Jr("service accessor is only valid during the invocation of its target method");let a=this._getOrCreateServiceInstance(o,n);return a||this._throwIfStrict(`[invokeFunction] unknown service '${o}'`,!1),a}},...t)}finally{i=!0,n.stop()}}createInstance(e,...t){this._throwIfDisposed();let n,i;return e instanceof bt?(n=zr.traceCreation(this._enableTracing,e.ctor),i=this._createInstance(e.ctor,e.staticArguments.concat(t),n)):(n=zr.traceCreation(this._enableTracing,e),i=this._createInstance(e,t,n)),n.stop(),i}_createInstance(e,t=[],n){let i=je.getServiceDependencies(e).sort((a,l)=>a.index-l.index),s=[];for(let a of i){let l=this._getOrCreateServiceInstance(a.id,n);l||this._throwIfStrict(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id}.`,!1),s.push(l)}let o=i.length>0?i[0].index:t.length;if(t.length!==o){console.trace(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);let a=o-t.length;a>0?t=t.concat(new Array(a)):t=t.slice(0,o)}return Reflect.construct(e,t.concat(s))}_setCreatedServiceInstance(e,t){if(this._services.get(e)instanceof bt)this._services.set(e,t);else if(this._parent)this._parent._setCreatedServiceInstance(e,t);else throw new Error("illegalState - setting UNKNOWN service instance")}_getServiceInstanceOrDescriptor(e){let t=this._services.get(e);return!t&&this._parent?this._parent._getServiceInstanceOrDescriptor(e):t}_getOrCreateServiceInstance(e,t){this._globalGraph&&this._globalGraphImplicitDependency&&this._globalGraph.insertEdge(this._globalGraphImplicitDependency,String(e));let n=this._getServiceInstanceOrDescriptor(e);return n instanceof bt?this._safeCreateAndCacheServiceInstance(e,n,t.branch(e,!0)):(t.branch(e,!1),n)}_safeCreateAndCacheServiceInstance(e,t,n){if(this._activeInstantiations.has(e))throw new Error(`illegal state - RECURSIVELY instantiating service '${e}'`);this._activeInstantiations.add(e);try{return this._createAndCacheServiceInstance(e,t,n)}finally{this._activeInstantiations.delete(e)}}_createAndCacheServiceInstance(e,t,n){let i=new Kr(l=>l.id.toString()),s=0,o=[{id:e,desc:t,_trace:n}],a=new Set;for(;o.length;){let l=o.pop();if(!a.has(String(l.id))){if(a.add(String(l.id)),i.lookupOrInsertNode(l),s++>1e3)throw new Bs(i);for(let c of je.getServiceDependencies(l.desc.ctor)){let d=this._getServiceInstanceOrDescriptor(c.id);if(d||this._throwIfStrict(`[createInstance] ${e} depends on ${c.id} which is NOT registered.`,!0),this._globalGraph?.insertEdge(String(l.id),String(c.id)),d instanceof bt){let u={id:c.id,desc:d,_trace:l._trace.branch(c.id,!0)};i.insertEdge(l,u),o.push(u)}}}}for(;;){let l=i.roots();if(l.length===0){if(!i.isEmpty())throw new Bs(i);break}for(let{data:c}of l){if(this._getServiceInstanceOrDescriptor(c.id)instanceof bt){let u=this._createServiceInstanceWithOwner(c.id,c.desc.ctor,c.desc.staticArguments,c.desc.supportsDelayedInstantiation,c._trace);this._setCreatedServiceInstance(c.id,u)}i.removeNode(c)}}return this._getServiceInstanceOrDescriptor(e)}_createServiceInstanceWithOwner(e,t,n=[],i,s){if(this._services.get(e)instanceof bt)return this._createServiceInstance(e,t,n,i,s,this._servicesToMaybeDispose);if(this._parent)return this._parent._createServiceInstanceWithOwner(e,t,n,i,s);throw new Error(`illegalState - creating UNKNOWN service instance ${t.name}`)}_createServiceInstance(e,t,n=[],i,s,o){if(i){let a=new r(void 0,this._strict,this,this._enableTracing);a._globalGraphImplicitDependency=String(e);let l=new Map,c=new Ti(()=>{let d=a._createInstance(t,n,s);for(let[u,p]of l){let h=d[u];if(typeof h=="function")for(let g of p)g.disposable=h.apply(d,g.listener)}return l.clear(),o.add(d),d});return new Proxy(Object.create(null),{get(d,u){if(!c.isInitialized&&typeof u=="string"&&(u.startsWith("onDid")||u.startsWith("onWill"))){let g=l.get(u);return g||(g=new rr,l.set(u,g)),(W,j,Pe)=>{if(c.isInitialized)return c.value[u](W,j,Pe);{let me={listener:[W,j,Pe],disposable:void 0},yt=g.push(me);return O(()=>{yt(),me.disposable?.dispose()})}}}if(u in d)return d[u];let p=c.value,h=p[u];return typeof h!="function"||(h=h.bind(p),d[u]=h),h},set(d,u,p){return c.value[u]=p,!0},getPrototypeOf(d){return t.prototype}})}else{let a=this._createInstance(t,n,s);return o.add(a),a}}_throwIfStrict(e,t){if(t&&console.warn(e),this._strict)throw new Error(e)}};var zr=class r{constructor(e,t){this.type=e;this.name=t;this._start=Date.now();this._dep=[]}static{this.all=new Set}static{this._None=new class extends r{constructor(){super(0,null)}stop(){}branch(){return this}}}static traceInvocation(e,t){return e?new r(2,t.name||new Error().stack.split(`
`).slice(3,4).join(`
`)):r._None}static traceCreation(e,t){return e?new r(1,t.name):r._None}static{this._totals=0}branch(e,t){let n=new r(3,e.toString());return this._dep.push([e,t,n]),n}stop(){let e=Date.now()-this._start;r._totals+=e;let t=!1;function n(s,o){let a=[],l=new Array(s+1).join("	");for(let[c,d,u]of o._dep)if(d&&u){t=!0,a.push(`${l}CREATES -> ${c}`);let p=n(s+1,u);p&&a.push(p)}else a.push(`${l}uses -> ${c}`);return a.join(`
`)}let i=[`${this.type===1?"CREATE":"CALL"} ${this.name}`,`${n(1,this)}`,`DONE, took ${e.toFixed(2)}ms (grand total ${r._totals.toFixed(2)}ms)`];(e>2||t)&&r.all.add(i.join(`
`))}};import*as cd from"fs";var sd=[{version:1,sql:[`CREATE TABLE IF NOT EXISTS turns (
				id TEXT PRIMARY KEY NOT NULL
			)`,`CREATE TABLE IF NOT EXISTS file_edits (
				turn_id        TEXT    NOT NULL REFERENCES turns(id) ON DELETE CASCADE,
				tool_call_id   TEXT    NOT NULL,
				file_path      TEXT    NOT NULL,
				before_content BLOB   NOT NULL,
				after_content  BLOB   NOT NULL,
				added_lines    INTEGER,
				removed_lines  INTEGER,
				PRIMARY KEY (tool_call_id, file_path)
			)`].join(`;
`)}];function Yn(r,e){return new Promise((t,n)=>{r.exec(e,i=>i?n(i):t())})}function qs(r,e,t){return new Promise((n,i)=>{r.run(e,t,function(s){if(s)return i(s);n({changes:this.changes,lastID:this.lastID})})})}function ud(r,e,t){return new Promise((n,i)=>{r.get(e,t,(s,o)=>{if(s)return i(s);n(o)})})}function od(r,e,t){return new Promise((n,i)=>{r.all(e,t,(s,o)=>{if(s)return i(s);n(o)})})}function ad(r){return new Promise((e,t)=>{r.close(n=>n?t(n):e())})}function jh(r){return new Promise((e,t)=>{import("@vscode/sqlite3").then(n=>{let i=new n.default.Database(r,s=>{if(s)return t(s);e(i)})},t)})}async function Hh(r,e){await Yn(r,"PRAGMA foreign_keys = ON");let n=(await ud(r,"PRAGMA user_version",[]))?.user_version??0,i=e.filter(s=>s.version>n).sort((s,o)=>s.version-o.version);if(i.length!==0){await Yn(r,"BEGIN TRANSACTION");try{for(let s of i)await Yn(r,s.sql),await Yn(r,`PRAGMA user_version = ${s.version}`);await Yn(r,"COMMIT")}catch(s){throw await Yn(r,"ROLLBACK"),s}}}var $s=class r{constructor(e,t=sd){this._path=e;this._migrations=t;this._fileEditSequencer=new vi}static async open(e,t=sd){let n=new r(e,t);return await n._ensureDb(),n}_ensureDb(){return this._closed?Promise.reject(new Error("SessionDatabase has been disposed")):(this._dbPromise||(this._dbPromise=(async()=>{await cd.promises.mkdir(be(this._path),{recursive:!0});let e=await jh(this._path);try{await Hh(e,this._migrations)}catch(t){throw await ad(e),this._dbPromise=void 0,t}if(this._closed)throw await ad(e),new Error("SessionDatabase has been disposed");return e})()),this._dbPromise)}async getAllTables(){let e=await this._ensureDb();return(await od(e,"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name",[])).map(n=>n.name)}async createTurn(e){let t=await this._ensureDb();await qs(t,"INSERT OR IGNORE INTO turns (id) VALUES (?)",[e])}async deleteTurn(e){let t=await this._ensureDb();await qs(t,"DELETE FROM turns WHERE id = ?",[e])}async storeFileEdit(e){return this._fileEditSequencer.queue(e.filePath,async()=>{let t=await this._ensureDb();await qs(t,"INSERT OR IGNORE INTO turns (id) VALUES (?)",[e.turnId]),await qs(t,`INSERT OR REPLACE INTO file_edits
					(turn_id, tool_call_id, file_path, before_content, after_content, added_lines, removed_lines)
				VALUES (?, ?, ?, ?, ?, ?, ?)`,[e.turnId,e.toolCallId,e.filePath,Buffer.from(e.beforeContent),Buffer.from(e.afterContent),e.addedLines??null,e.removedLines??null])})}async getFileEdits(e){if(e.length===0)return[];let t=await this._ensureDb(),n=e.map(()=>"?").join(",");return(await od(t,`SELECT turn_id, tool_call_id, file_path, added_lines, removed_lines
				FROM file_edits
				WHERE tool_call_id IN (${n})
				ORDER BY rowid`,e)).map(s=>({turnId:s.turn_id,toolCallId:s.tool_call_id,filePath:s.file_path,addedLines:s.added_lines??void 0,removedLines:s.removed_lines??void 0}))}async readFileEditContent(e,t){return this._fileEditSequencer.queue(t,async()=>{let n=await this._ensureDb(),i=await ud(n,`SELECT before_content, after_content
					FROM file_edits
					WHERE tool_call_id = ? AND file_path = ?`,[e,t]);if(i)return{beforeContent:ld(i.before_content),afterContent:ld(i.after_content)}})}async close(){await(this._closed??=this._dbPromise?.then(e=>e.close()).catch(()=>{})||!0)}dispose(){this.close()}};function ld(r){return r instanceof Buffer?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r instanceof Uint8Array?r:typeof r=="string"?new TextEncoder().encode(r):new Uint8Array(0)}var Wa=class extends ti{constructor(t,n){super();this._getDbPath=t;this._logService=n}createReferencedObject(t){let n=this._getDbPath(t);return this._logService.trace(`[SessionDataService] Opening database: ${n}`),new $s(n)}destroyReferencedObject(t,n){n.dispose()}},Xn=class{constructor(e,t,n){this._fileService=t;this._logService=n;this._basePath=m.joinPath(e,"agentSessionData"),this._databases=new Wa(i=>m.joinPath(this._basePath,i,"session.db").fsPath,this._logService)}getSessionDataDir(e){return this.getSessionDataDirById(oe.id(e))}getSessionDataDirById(e){let t=e.replace(/[^a-zA-Z0-9_.-]/g,"-");return m.joinPath(this._basePath,t)}openDatabase(e){let t=oe.id(e).replace(/[^a-zA-Z0-9_.-]/g,"-");return this._databases.acquire(t)}async deleteSessionData(e){let t=this.getSessionDataDir(e);try{await this._fileService.exists(t)&&(await this._fileService.del(t,{recursive:!0}),this._logService.trace(`[SessionDataService] Deleted session data: ${t.toString()}`))}catch(n){this._logService.warn(`[SessionDataService] Failed to delete session data: ${t.toString()}`,n)}}async cleanupOrphanedData(e){try{if(!await this._fileService.exists(this._basePath))return;let n=await this._fileService.resolve(this._basePath);if(!n.children)return;let i=[];for(let s of n.children){if(!s.isDirectory)continue;let o=s.name;e.has(o)||(this._logService.trace(`[SessionDataService] Cleaning up orphaned session data: ${o}`),i.push(this._fileService.del(s.resource,{recursive:!0}).catch(a=>{this._logService.warn(`[SessionDataService] Failed to clean up orphaned data: ${o}`,a)})))}await Promise.all(i)}catch(t){this._logService.warn("[SessionDataService] Failed to run orphan cleanup",t)}}};Xn=P([Se(1,Fn),Se(2,Le)],Xn);Gh();function Gh(){let r;ki(process)?r=new Li:r=new Di("agentHost");let e=new D,t={_serviceBrand:void 0,...Xu},n=new _s(Pa(process.argv,Gu),t),i=new Rs(Mu(n),n.logsHome);r.registerChannel("agentHostLogger",new ws(i,()=>Yu));let s=i.createLogger("agenthost",{name:f(1836,null)}),o=new xs(s);o.info("Agent Host process started successfully");let a=e.add(new kt(o));e.add(a.registerProvider(Y.file,e.add(new Ws(o))));let l=new Xn(m.file(n.userDataPath),a,o),c;try{c=new us(o,a,l);let h=new Jn;h.set(Le,o),h.set(Fn,a),h.set(ds,l);let g=new Vs(h);c.registerProvider(g.createInstance(Hn))}catch(h){throw o.error("Failed to create AgentService",h),h}let d=En.fromService(c,e);r.registerChannel("agentHost",d);let u=e.add(new I),p=En.fromService({onDidChangeConnectionCount:u.event},e);r.registerChannel("agentHostConnectionTracker",p),Qh(c,o,e,h=>u.fire(h)).catch(h=>{o.error("Failed to start WebSocket server",h)}),process.once("exit",()=>{c.dispose(),o.dispose(),e.dispose()})}async function Qh(r,e,t,n){let i=process.env.VSCODE_AGENT_HOST_PORT,s=process.env.VSCODE_AGENT_HOST_SOCKET_PATH;if(!i&&!s)return;let o=process.env.VSCODE_AGENT_HOST_CONNECTION_TOKEN,a=process.env.VSCODE_AGENT_HOST_HOST||"localhost",l=t.add(await Ss.create(s?{socketPath:s,connectionTokenValidate:o?u=>u===o:void 0}:{port:parseInt(i,10),host:a,connectionTokenValidate:o?u=>u===o:void 0},e)),c=t.add(new Gn(r,r.stateManager,l,{defaultDirectory:m.file(dd.homedir()).toString()},e));t.add(c.onDidChangeConnectionCount(n));let d=s??`${a}:${i}`;e.info(`[AgentHost] WebSocket server listening on ${d}`),console.log(`Agent host server listening on ${d}`)}
