npm-check-updates
Version:
Find newer versions of dependencies than what your package.json allows
12,154 lines • 445 kB
JavaScript
import { a as e, i as t, n, o as r, r as i, t as a } from "./rolldown-runtime-CJfroGDQ.js";
import { l as o, p as s, u as c } from "../index.js";
import { once as l } from "events";
import { URL as u } from "url";
import d from "assert";
import * as f from "http";
import * as p from "https";
import { Agent as m } from "https";
import * as h from "dns";
import * as g from "net";
import * as _ from "tls";
//#region node_modules/npm-registry-fetch/lib/errors.js
var v = /* @__PURE__ */ a(((e, n) => {
var { URL: r } = t("node:url");
function i(e) {
try {
let n = new r(e).pathname.slice(1);
if (!n.match(/^-/)) {
n = n.split("/");
var t = n.indexOf("_rewrite");
return t === -1 ? t = n.length - 1 : t++, decodeURIComponent(n[t]);
}
} catch {}
}
var a = class extends Error {
constructor(e, t, n, r) {
super(), this.name = this.constructor.name, this.headers = typeof t.headers?.raw == "function" ? t.headers.raw() : t.headers, this.statusCode = t.status, this.code = `E${t.status}`, this.method = e, this.uri = t.url, this.body = n, this.pkgid = r ? r.toString() : i(t.url), Error.captureStackTrace(this, this.constructor);
}
};
n.exports = {
HttpErrorBase: a,
HttpErrorGeneral: class extends a {
constructor(e, t, n, r) {
super(e, t, n, r);
let i = "";
if (n && typeof n == "object" && !Buffer.isBuffer(n)) {
let e = n.error || n.message || JSON.stringify(n);
e && e !== "{}" && (i = " - " + e);
}
this.message = `${t.status} ${t.statusText} - ${this.method.toUpperCase()} ${this.spec || this.uri}${i}`;
}
},
HttpErrorAuthOTP: class extends a {
constructor(e, t, n, r) {
super(e, t, n, r), this.message = "OTP required for authentication", this.code = "EOTP";
}
},
HttpErrorAuthIPAddress: class extends a {
constructor(e, t, n, r) {
super(e, t, n, r), this.message = "Login is not allowed from your IP address", this.code = "EAUTHIP";
}
},
HttpErrorAuthUnknown: class extends a {
constructor(e, t, n, r) {
super(e, t, n, r), this.message = "Unable to authenticate, need: " + t.headers.get("www-authenticate");
}
}
};
})), y = /* @__PURE__ */ a(((e) => {
var n = e && e.__importDefault || function(e) {
return e && e.__esModule ? e : { default: e };
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.Minipass = e.isWritable = e.isReadable = e.isStream = void 0;
var r = typeof process == "object" && process ? process : {
stdout: null,
stderr: null
}, i = t("node:events"), a = n(t("node:stream")), o = t("node:string_decoder");
e.isStream = (t) => !!t && typeof t == "object" && (t instanceof q || t instanceof a.default || (0, e.isReadable)(t) || (0, e.isWritable)(t)), e.isReadable = (e) => !!e && typeof e == "object" && e instanceof i.EventEmitter && typeof e.pipe == "function" && e.pipe !== a.default.Writable.prototype.pipe, e.isWritable = (e) => !!e && typeof e == "object" && e instanceof i.EventEmitter && typeof e.write == "function" && typeof e.end == "function";
var s = Symbol("EOF"), c = Symbol("maybeEmitEnd"), l = Symbol("emittedEnd"), u = Symbol("emittingEnd"), d = Symbol("emittedError"), f = Symbol("closed"), p = Symbol("read"), m = Symbol("flush"), h = Symbol("flushChunk"), g = Symbol("encoding"), _ = Symbol("decoder"), v = Symbol("flowing"), y = Symbol("paused"), b = Symbol("resume"), x = Symbol("buffer"), S = Symbol("pipes"), C = Symbol("bufferLength"), w = Symbol("bufferPush"), T = Symbol("bufferShift"), E = Symbol("objectMode"), D = Symbol("destroyed"), O = Symbol("error"), k = Symbol("emitData"), A = Symbol("emitEnd"), j = Symbol("emitEnd2"), M = Symbol("async"), N = Symbol("abort"), P = Symbol("aborted"), F = Symbol("signal"), I = Symbol("dataListeners"), L = Symbol("discarded"), R = (e) => Promise.resolve().then(e), z = (e) => e(), B = (e) => e === "end" || e === "finish" || e === "prefinish", V = (e) => e instanceof ArrayBuffer || !!e && typeof e == "object" && e.constructor && e.constructor.name === "ArrayBuffer" && e.byteLength >= 0, H = (e) => !Buffer.isBuffer(e) && ArrayBuffer.isView(e), U = class {
src;
dest;
opts;
ondrain;
constructor(e, t, n) {
this.src = e, this.dest = t, this.opts = n, this.ondrain = () => e[b](), this.dest.on("drain", this.ondrain);
}
unpipe() {
this.dest.removeListener("drain", this.ondrain);
}
/* c8 ignore start */
proxyErrors(e) {}
/* c8 ignore stop */
end() {
this.unpipe(), this.opts.end && this.dest.end();
}
}, W = class extends U {
unpipe() {
this.src.removeListener("error", this.proxyErrors), super.unpipe();
}
constructor(e, t, n) {
super(e, t, n), this.proxyErrors = (e) => this.dest.emit("error", e), e.on("error", this.proxyErrors);
}
}, G = (e) => !!e.objectMode, K = (e) => !e.objectMode && !!e.encoding && e.encoding !== "buffer", q = class extends i.EventEmitter {
[v] = !1;
[y] = !1;
[S] = [];
[x] = [];
[E];
[g];
[M];
[_];
[s] = !1;
[l] = !1;
[u] = !1;
[f] = !1;
[d] = null;
[C] = 0;
[D] = !1;
[F];
[P] = !1;
[I] = 0;
[L] = !1;
writable = !0;
readable = !0;
constructor(...e) {
let t = e[0] || {};
if (super(), t.objectMode && typeof t.encoding == "string") throw TypeError("Encoding and objectMode may not be used together");
G(t) ? (this[E] = !0, this[g] = null) : K(t) ? (this[g] = t.encoding, this[E] = !1) : (this[E] = !1, this[g] = null), this[M] = !!t.async, this[_] = this[g] ? new o.StringDecoder(this[g]) : null, t && t.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[x] }), t && t.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[S] });
let { signal: n } = t;
n && (this[F] = n, n.aborted ? this[N]() : n.addEventListener("abort", () => this[N]()));
}
get bufferLength() {
return this[C];
}
get encoding() {
return this[g];
}
set encoding(e) {
throw Error("Encoding must be set at instantiation time");
}
setEncoding(e) {
throw Error("Encoding must be set at instantiation time");
}
get objectMode() {
return this[E];
}
set objectMode(e) {
throw Error("objectMode must be set at instantiation time");
}
get async() {
return this[M];
}
set async(e) {
this[M] = this[M] || !!e;
}
[N]() {
this[P] = !0, this.emit("abort", this[F]?.reason), this.destroy(this[F]?.reason);
}
get aborted() {
return this[P];
}
set aborted(e) {}
write(e, t, n) {
if (this[P]) return !1;
if (this[s]) throw Error("write after end");
if (this[D]) return this.emit("error", Object.assign(/* @__PURE__ */ Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
typeof t == "function" && (n = t, t = "utf8"), t ||= "utf8";
let r = this[M] ? R : z;
if (!this[E] && !Buffer.isBuffer(e)) {
if (H(e)) e = Buffer.from(e.buffer, e.byteOffset, e.byteLength);
else if (V(e)) e = Buffer.from(e);
else if (typeof e != "string") throw Error("Non-contiguous data written to non-objectMode stream");
}
return this[E] ?
/* c8 ignore start */
(this[v] && this[C] !== 0 && this[m](!0), this[v] ? this.emit("data", e) : this[w](e), this[C] !== 0 && this.emit("readable"), n && r(n), this[v]) : e.length ? (typeof e == "string" && !(t === this[g] && !this[_]?.lastNeed) && (e = Buffer.from(e, t)), Buffer.isBuffer(e) && this[g] && (e = this[_].write(e)), this[v] && this[C] !== 0 && this[m](!0), this[v] ? this.emit("data", e) : this[w](e), this[C] !== 0 && this.emit("readable"), n && r(n), this[v]) : (this[C] !== 0 && this.emit("readable"), n && r(n), this[v]);
}
read(e) {
if (this[D]) return null;
if (this[L] = !1, this[C] === 0 || e === 0 || e && e > this[C]) return this[c](), null;
this[E] && (e = null), this[x].length > 1 && !this[E] && (this[x] = [this[g] ? this[x].join("") : Buffer.concat(this[x], this[C])]);
let t = this[p](e || null, this[x][0]);
return this[c](), t;
}
[p](e, t) {
if (this[E]) this[T]();
else {
let n = t;
e === n.length || e === null ? this[T]() : typeof n == "string" ? (this[x][0] = n.slice(e), t = n.slice(0, e), this[C] -= e) : (this[x][0] = n.subarray(e), t = n.subarray(0, e), this[C] -= e);
}
return this.emit("data", t), !this[x].length && !this[s] && this.emit("drain"), t;
}
end(e, t, n) {
return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = "utf8"), e !== void 0 && this.write(e, t), n && this.once("end", n), this[s] = !0, this.writable = !1, (this[v] || !this[y]) && this[c](), this;
}
[b]() {
this[D] || (!this[I] && !this[S].length && (this[L] = !0), this[y] = !1, this[v] = !0, this.emit("resume"), this[x].length ? this[m]() : this[s] ? this[c]() : this.emit("drain"));
}
resume() {
return this[b]();
}
pause() {
this[v] = !1, this[y] = !0, this[L] = !1;
}
get destroyed() {
return this[D];
}
get flowing() {
return this[v];
}
get paused() {
return this[y];
}
[w](e) {
this[E] ? this[C] += 1 : this[C] += e.length, this[x].push(e);
}
[T]() {
return this[E] ? --this[C] : this[C] -= this[x][0].length, this[x].shift();
}
[m](e = !1) {
do ;
while (this[h](this[T]()) && this[x].length);
!e && !this[x].length && !this[s] && this.emit("drain");
}
[h](e) {
return this.emit("data", e), this[v];
}
pipe(e, t) {
if (this[D]) return e;
this[L] = !1;
let n = this[l];
return t ||= {}, e === r.stdout || e === r.stderr ? t.end = !1 : t.end = t.end !== !1, t.proxyErrors = !!t.proxyErrors, n ? t.end && e.end() : (this[S].push(t.proxyErrors ? new W(this, e, t) : new U(this, e, t)), this[M] ? R(() => this[b]()) : this[b]()), e;
}
unpipe(e) {
let t = this[S].find((t) => t.dest === e);
t && (this[S].length === 1 ? (this[v] && this[I] === 0 && (this[v] = !1), this[S] = []) : this[S].splice(this[S].indexOf(t), 1), t.unpipe());
}
addListener(e, t) {
return this.on(e, t);
}
on(e, t) {
let n = super.on(e, t);
if (e === "data") this[L] = !1, this[I]++, !this[S].length && !this[v] && this[b]();
else if (e === "readable" && this[C] !== 0) super.emit("readable");
else if (B(e) && this[l]) super.emit(e), this.removeAllListeners(e);
else if (e === "error" && this[d]) {
let e = t;
this[M] ? R(() => e.call(this, this[d])) : e.call(this, this[d]);
}
return n;
}
removeListener(e, t) {
return this.off(e, t);
}
off(e, t) {
let n = super.off(e, t);
return e === "data" && (this[I] = this.listeners("data").length, this[I] === 0 && !this[L] && !this[S].length && (this[v] = !1)), n;
}
removeAllListeners(e) {
let t = super.removeAllListeners(e);
return (e === "data" || e === void 0) && (this[I] = 0, !this[L] && !this[S].length && (this[v] = !1)), t;
}
get emittedEnd() {
return this[l];
}
[c]() {
!this[u] && !this[l] && !this[D] && this[x].length === 0 && this[s] && (this[u] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[f] && this.emit("close"), this[u] = !1);
}
emit(e, ...t) {
let n = t[0];
if (e !== "error" && e !== "close" && e !== D && this[D]) return !1;
if (e === "data") return !this[E] && !n ? !1 : this[M] ? (R(() => this[k](n)), !0) : this[k](n);
if (e === "end") return this[A]();
if (e === "close") {
if (this[f] = !0, !this[l] && !this[D]) return !1;
let e = super.emit("close");
return this.removeAllListeners("close"), e;
}
if (e === "error") {
this[d] = n, super.emit(O, n);
let e = !this[F] || this.listeners("error").length ? super.emit("error", n) : !1;
return this[c](), e;
}
if (e === "resume") {
let e = super.emit("resume");
return this[c](), e;
}
if (e === "finish" || e === "prefinish") {
let t = super.emit(e);
return this.removeAllListeners(e), t;
}
let r = super.emit(e, ...t);
return this[c](), r;
}
[k](e) {
for (let t of this[S]) t.dest.write(e) === !1 && this.pause();
let t = !this[L] && super.emit("data", e);
return this[c](), t;
}
[A]() {
return !this[l] && (this[l] = !0, this.readable = !1, this[M] ? (R(() => this[j]()), !0) : this[j]());
}
[j]() {
if (this[_]) {
let e = this[_].end();
if (e) {
for (let t of this[S]) t.dest.write(e);
this[L] || super.emit("data", e);
}
}
for (let e of this[S]) e.end();
let e = super.emit("end");
return this.removeAllListeners("end"), e;
}
async collect() {
let e = Object.assign([], { dataLength: 0 });
this[E] || (e.dataLength = 0);
let t = this.promise();
return this.on("data", (t) => {
e.push(t), this[E] || (e.dataLength += t.length);
}), await t, e;
}
async concat() {
if (this[E]) throw Error("cannot concat in objectMode");
let e = await this.collect();
return this[g] ? e.join("") : Buffer.concat(e, e.dataLength);
}
async promise() {
return new Promise((e, t) => {
this.on(D, () => t(/* @__PURE__ */ Error("stream destroyed"))), this.on("error", (e) => t(e)), this.on("end", () => e());
});
}
[Symbol.asyncIterator]() {
this[L] = !1;
let e = !1, t = async () => (this.pause(), e = !0, {
value: void 0,
done: !0
});
return {
next: () => {
if (e) return t();
let n = this.read();
if (n !== null) return Promise.resolve({
done: !1,
value: n
});
if (this[s]) return t();
let r, i, a = (e) => {
this.off("data", o), this.off("end", c), this.off(D, l), t(), i(e);
}, o = (e) => {
this.off("error", a), this.off("end", c), this.off(D, l), this.pause(), r({
value: e,
done: !!this[s]
});
}, c = () => {
this.off("error", a), this.off("data", o), this.off(D, l), t(), r({
done: !0,
value: void 0
});
}, l = () => a(/* @__PURE__ */ Error("stream destroyed"));
return new Promise((e, t) => {
i = t, r = e, this.once(D, l), this.once("error", a), this.once("end", c), this.once("data", o);
});
},
throw: t,
return: t,
[Symbol.asyncIterator]() {
return this;
},
[Symbol.asyncDispose]: async () => {}
};
}
[Symbol.iterator]() {
this[L] = !1;
let e = !1, t = () => (this.pause(), this.off(O, t), this.off(D, t), this.off("end", t), e = !0, {
done: !0,
value: void 0
});
return this.once("end", t), this.once(O, t), this.once(D, t), {
next: () => {
if (e) return t();
let n = this.read();
return n === null ? t() : {
done: !1,
value: n
};
},
throw: t,
return: t,
[Symbol.iterator]() {
return this;
},
[Symbol.dispose]: () => {}
};
}
destroy(e) {
if (this[D]) return e ? this.emit("error", e) : this.emit(D), this;
this[D] = !0, this[L] = !0, this[x].length = 0, this[C] = 0;
let t = this;
return typeof t.close == "function" && !this[f] && t.close(), e ? this.emit("error", e) : this.emit(D), this;
}
static get isStream() {
return e.isStream;
}
};
e.Minipass = q;
})), b = /* @__PURE__ */ a(((e) => {
var n = e && e.__importDefault || function(e) {
return e && e.__esModule ? e : { default: e };
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.constants = void 0;
/* c8 ignore start */
var r = n(t("zlib")).default.constants || { ZLIB_VERNUM: 4736 };
/* c8 ignore stop */
e.constants = Object.freeze(Object.assign(Object.create(null), {
Z_NO_FLUSH: 0,
Z_PARTIAL_FLUSH: 1,
Z_SYNC_FLUSH: 2,
Z_FULL_FLUSH: 3,
Z_FINISH: 4,
Z_BLOCK: 5,
Z_OK: 0,
Z_STREAM_END: 1,
Z_NEED_DICT: 2,
Z_ERRNO: -1,
Z_STREAM_ERROR: -2,
Z_DATA_ERROR: -3,
Z_MEM_ERROR: -4,
Z_BUF_ERROR: -5,
Z_VERSION_ERROR: -6,
Z_NO_COMPRESSION: 0,
Z_BEST_SPEED: 1,
Z_BEST_COMPRESSION: 9,
Z_DEFAULT_COMPRESSION: -1,
Z_FILTERED: 1,
Z_HUFFMAN_ONLY: 2,
Z_RLE: 3,
Z_FIXED: 4,
Z_DEFAULT_STRATEGY: 0,
DEFLATE: 1,
INFLATE: 2,
GZIP: 3,
GUNZIP: 4,
DEFLATERAW: 5,
INFLATERAW: 6,
UNZIP: 7,
BROTLI_DECODE: 8,
BROTLI_ENCODE: 9,
Z_MIN_WINDOWBITS: 8,
Z_MAX_WINDOWBITS: 15,
Z_DEFAULT_WINDOWBITS: 15,
Z_MIN_CHUNK: 64,
Z_MAX_CHUNK: Infinity,
Z_DEFAULT_CHUNK: 16384,
Z_MIN_MEMLEVEL: 1,
Z_MAX_MEMLEVEL: 9,
Z_DEFAULT_MEMLEVEL: 8,
Z_MIN_LEVEL: -1,
Z_MAX_LEVEL: 9,
Z_DEFAULT_LEVEL: -1,
BROTLI_OPERATION_PROCESS: 0,
BROTLI_OPERATION_FLUSH: 1,
BROTLI_OPERATION_FINISH: 2,
BROTLI_OPERATION_EMIT_METADATA: 3,
BROTLI_MODE_GENERIC: 0,
BROTLI_MODE_TEXT: 1,
BROTLI_MODE_FONT: 2,
BROTLI_DEFAULT_MODE: 0,
BROTLI_MIN_QUALITY: 0,
BROTLI_MAX_QUALITY: 11,
BROTLI_DEFAULT_QUALITY: 11,
BROTLI_MIN_WINDOW_BITS: 10,
BROTLI_MAX_WINDOW_BITS: 24,
BROTLI_LARGE_MAX_WINDOW_BITS: 30,
BROTLI_DEFAULT_WINDOW: 22,
BROTLI_MIN_INPUT_BLOCK_BITS: 16,
BROTLI_MAX_INPUT_BLOCK_BITS: 24,
BROTLI_PARAM_MODE: 0,
BROTLI_PARAM_QUALITY: 1,
BROTLI_PARAM_LGWIN: 2,
BROTLI_PARAM_LGBLOCK: 3,
BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
BROTLI_PARAM_SIZE_HINT: 5,
BROTLI_PARAM_LARGE_WINDOW: 6,
BROTLI_PARAM_NPOSTFIX: 7,
BROTLI_PARAM_NDIRECT: 8,
BROTLI_DECODER_RESULT_ERROR: 0,
BROTLI_DECODER_RESULT_SUCCESS: 1,
BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
BROTLI_DECODER_NO_ERROR: 0,
BROTLI_DECODER_SUCCESS: 1,
BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
BROTLI_DECODER_ERROR_UNREACHABLE: -31
}, r));
})), x = /* @__PURE__ */ a(((e) => {
var n = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), r = e && e.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
}) : function(e, t) {
e.default = t;
}), i = e && e.__importStar || (function() {
var e = function(t) {
return e = Object.getOwnPropertyNames || function(e) {
var t = [];
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[t.length] = n);
return t;
}, e(t);
};
return function(t) {
if (t && t.__esModule) return t;
var i = {};
if (t != null) for (var a = e(t), o = 0; o < a.length; o++) a[o] !== "default" && n(i, t, a[o]);
return r(i, t), i;
};
})(), a = e && e.__importDefault || function(e) {
return e && e.__esModule ? e : { default: e };
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.ZstdDecompress = e.ZstdCompress = e.BrotliDecompress = e.BrotliCompress = e.Unzip = e.InflateRaw = e.DeflateRaw = e.Gunzip = e.Gzip = e.Inflate = e.Deflate = e.Zlib = e.ZlibError = e.constants = void 0;
var o = a(t("assert")), s = t("buffer"), c = y(), l = i(t("zlib")), u = b(), d = b();
Object.defineProperty(e, "constants", {
enumerable: !0,
get: function() {
return d.constants;
}
});
var f = s.Buffer.concat, p = Object.getOwnPropertyDescriptor(s.Buffer, "concat"), m = (e) => e, h = p?.writable === !0 || p?.set !== void 0 ? (e) => {
s.Buffer.concat = e ? m : f;
} : (e) => {}, g = Symbol("_superWrite"), _ = class extends Error {
code;
errno;
constructor(e, t) {
super("zlib: " + e.message, { cause: e }), this.code = e.code, this.errno = e.errno, this.code ||= "ZLIB_ERROR", this.message = "zlib: " + e.message, Error.captureStackTrace(this, t ?? this.constructor);
}
get name() {
return "ZlibError";
}
};
e.ZlibError = _;
var v = Symbol("flushFlag"), x = class extends c.Minipass {
#e = !1;
#t = !1;
#n;
#r;
#i;
#a;
#o;
get sawError() {
return this.#e;
}
get handle() {
return this.#a;
}
/* c8 ignore start */
get flushFlag() {
return this.#n;
}
/* c8 ignore stop */
constructor(e, t) {
if (!e || typeof e != "object") throw TypeError("invalid options for ZlibBase constructor");
/* c8 ignore stop */
if (super(e), this.#n = e.flush ?? 0, this.#r = e.finishFlush ?? 0, this.#i = e.fullFlushFlag ?? 0, typeof l[t] != "function") throw TypeError("Compression method not supported: " + t);
try {
this.#a = new l[t](e);
} catch (e) {
throw new _(e, this.constructor);
}
this.#o = (e) => {
this.#e || (this.#e = !0, this.close(), this.emit("error", e));
}, this.#a?.on("error", (e) => this.#o(new _(e))), this.once("end", () => this.close);
}
close() {
this.#a && (this.#a.close(), this.#a = void 0, this.emit("close"));
}
reset() {
if (!this.#e) return (0, o.default)(this.#a, "zlib binding closed"), this.#a.reset?.();
}
flush(e) {
this.ended || (typeof e != "number" && (e = this.#i), this.write(Object.assign(s.Buffer.alloc(0), { [v]: e })));
}
end(e, t, n) {
return typeof e == "function" && (n = e, t = void 0, e = void 0), typeof t == "function" && (n = t, t = void 0), e && (t ? this.write(e, t) : this.write(e)), this.flush(this.#r), this.#t = !0, super.end(n);
}
get ended() {
return this.#t;
}
[g](e) {
return super.write(e);
}
write(e, t, n) {
if (typeof t == "function" && (n = t, t = "utf8"), typeof e == "string" && (e = s.Buffer.from(e, t)), this.#e) return;
(0, o.default)(this.#a, "zlib binding closed");
let r = this.#a._handle, i = r.close;
r.close = () => {};
let a = this.#a.close;
this.#a.close = () => {}, h(!0);
let c;
try {
let t = typeof e[v] == "number" ? e[v] : this.#n;
c = this.#a._processChunk(e, t), h(!1);
} catch (e) {
h(!1), this.#o(new _(e, this.write));
} finally {
this.#a && (this.#a._handle = r, r.close = i, this.#a.close = a, this.#a.removeAllListeners("error"));
}
this.#a && this.#a.on("error", (e) => this.#o(new _(e, this.write)));
let l;
if (c) {
if (Array.isArray(c) && c.length > 0) {
let e = c[0];
l = this[g](s.Buffer.from(e));
for (let e = 1; e < c.length; e++) l = this[g](c[e]);
} else l = this[g](s.Buffer.from(c));
}
return n && n(), l;
}
}, S = class extends x {
#e;
#t;
constructor(e, t) {
e ||= {}, e.flush = e.flush || u.constants.Z_NO_FLUSH, e.finishFlush = e.finishFlush || u.constants.Z_FINISH, e.fullFlushFlag = u.constants.Z_FULL_FLUSH, super(e, t), this.#e = e.level, this.#t = e.strategy;
}
params(e, t) {
if (!this.sawError) {
if (!this.handle) throw Error("cannot switch params when binding is closed");
/* c8 ignore start */
if (!this.handle.params) throw Error("not supported in this implementation");
/* c8 ignore stop */
if (this.#e !== e || this.#t !== t) {
this.flush(u.constants.Z_SYNC_FLUSH), (0, o.default)(this.handle, "zlib binding closed");
let n = this.handle.flush;
this.handle.flush = (e, t) => {
typeof e == "function" && (t = e, e = this.flushFlag), this.flush(e), t?.();
};
try {
this.handle.params(e, t);
} finally {
this.handle.flush = n;
}
/* c8 ignore start */
this.handle && (this.#e = e, this.#t = t);
}
}
}
};
e.Zlib = S, e.Deflate = class extends S {
constructor(e) {
super(e, "Deflate");
}
}, e.Inflate = class extends S {
constructor(e) {
super(e, "Inflate");
}
}, e.Gzip = class extends S {
#e;
constructor(e) {
super(e, "Gzip"), this.#e = e && !!e.portable;
}
[g](e) {
return this.#e ? (this.#e = !1, e[9] = 255, super[g](e)) : super[g](e);
}
}, e.Gunzip = class extends S {
constructor(e) {
super(e, "Gunzip");
}
}, e.DeflateRaw = class extends S {
constructor(e) {
super(e, "DeflateRaw");
}
}, e.InflateRaw = class extends S {
constructor(e) {
super(e, "InflateRaw");
}
}, e.Unzip = class extends S {
constructor(e) {
super(e, "Unzip");
}
};
var C = class extends x {
constructor(e, t) {
e ||= {}, e.flush = e.flush || u.constants.BROTLI_OPERATION_PROCESS, e.finishFlush = e.finishFlush || u.constants.BROTLI_OPERATION_FINISH, e.fullFlushFlag = u.constants.BROTLI_OPERATION_FLUSH, super(e, t);
}
};
e.BrotliCompress = class extends C {
constructor(e) {
super(e, "BrotliCompress");
}
}, e.BrotliDecompress = class extends C {
constructor(e) {
super(e, "BrotliDecompress");
}
};
var w = class extends x {
constructor(e, t) {
e ||= {}, e.flush = e.flush || u.constants.ZSTD_e_continue, e.finishFlush = e.finishFlush || u.constants.ZSTD_e_end, e.fullFlushFlag = u.constants.ZSTD_e_flush, super(e, t);
}
};
e.ZstdCompress = class extends w {
constructor(e) {
super(e, "ZstdCompress");
}
}, e.ZstdDecompress = class extends w {
constructor(e) {
super(e, "ZstdDecompress");
}
};
})), S = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.MinipassSized = e.SizeError = void 0;
var t = y(), n = (e) => typeof e == "string", r = class extends Error {
expect;
found;
code = "EBADSIZE";
constructor(e, t, n) {
super(`Bad data size: expected ${t} bytes, but got ${e}`), this.expect = t, this.found = e, Error.captureStackTrace(this, n ?? this.constructor);
}
get name() {
return "SizeError";
}
};
e.SizeError = r, e.MinipassSized = class extends t.Minipass {
found = 0;
expect;
constructor(e) {
let t = e?.size;
if (typeof t != "number" || t > 2 ** 53 - 1 || isNaN(t) || t < 0 || !isFinite(t) || t !== Math.floor(t)) throw Error("invalid expected size: " + t);
if (super(e), e.objectMode) throw TypeError(`${this.constructor.name} streams only work with string and buffer data`);
this.expect = t;
}
write(e, t, i) {
let a = Buffer.isBuffer(e) ? e : typeof e == "string" ? Buffer.from(e, n(t) ? t : "utf8") : e;
return typeof t == "function" && (i = t, t = null), Buffer.isBuffer(a) ? (this.found += a.length, this.found > this.expect && this.emit("error", new r(this.found, this.expect)), super.write(e, t, i)) : (this.emit("error", /* @__PURE__ */ TypeError(`${this.constructor.name} streams only work with string and buffer data`)), !1);
}
emit(e, ...t) {
return e === "end" && this.found !== this.expect && this.emit("error", new r(this.found, this.expect, this.emit)), super.emit(e, ...t);
}
};
})), C = /* @__PURE__ */ a(((e, t) => {
var { Minipass: n } = y(), r = Symbol("type"), i = Symbol("buffer"), a = class e {
constructor(t, n) {
this[r] = "";
let a = [], o = 0;
if (t) {
let n = t, r = Number(n.length);
for (let t = 0; t < r; t++) {
let r = n[t], s = r instanceof Buffer ? r : ArrayBuffer.isView(r) ? Buffer.from(r.buffer, r.byteOffset, r.byteLength) : r instanceof ArrayBuffer ? Buffer.from(r) : r instanceof e ? r[i] : typeof r == "string" ? Buffer.from(r) : Buffer.from(String(r));
o += s.length, a.push(s);
}
}
this[i] = Buffer.concat(a, o);
let s = n && n.type !== void 0 && String(n.type).toLowerCase();
s && !/[^\u0020-\u007E]/.test(s) && (this[r] = s);
}
get size() {
return this[i].length;
}
get type() {
return this[r];
}
text() {
return Promise.resolve(this[i].toString());
}
arrayBuffer() {
let e = this[i], t = e.byteOffset, n = e.byteLength, r = e.buffer.slice(t, t + n);
return Promise.resolve(r);
}
stream() {
return new n().end(this[i]);
}
slice(t, n, r) {
let a = this.size, o = t === void 0 ? 0 : t < 0 ? Math.max(a + t, 0) : Math.min(t, a), s = n === void 0 ? a : n < 0 ? Math.max(a + n, 0) : Math.min(n, a), c = Math.max(s - o, 0), l = this[i].slice(o, o + c), u = new e([], { type: r });
return u[i] = l, u;
}
get [Symbol.toStringTag]() {
return "Blob";
}
static get BUFFER() {
return i;
}
};
Object.defineProperties(a.prototype, {
size: { enumerable: !0 },
type: { enumerable: !0 }
}), t.exports = a;
})), w = /* @__PURE__ */ a(((e, t) => {
t.exports = class extends Error {
constructor(e, t, n) {
super(e), this.code = "FETCH_ERROR", n && Object.assign(this, n), this.errno = this.code, this.type = this.code === "EBADSIZE" && this.found > this.expect ? "max-size" : t, this.message = e, Error.captureStackTrace(this, this.constructor);
}
get name() {
return "FetchError";
}
set name(e) {}
get [Symbol.toStringTag]() {
return "FetchError";
}
};
})), T = /* @__PURE__ */ i({ default: () => E }), E, D = n((() => {
E = {};
})), O = /* @__PURE__ */ a(((t, n) => {
var { Minipass: r } = y(), { MinipassSized: i } = S(), a = C(), { BUFFER: o } = a, s = w(), c;
try {
c = (D(), e(T)).decode;
} catch {}
var l = Symbol("Body internals"), u = Symbol("consumeBody"), d = class {
constructor(e, t = {}) {
let { size: n = 0, timeout: i = 0 } = t, a = e == null ? null : f(e) ? Buffer.from(e.toString()) : p(e) || Buffer.isBuffer(e) ? e : Object.prototype.toString.call(e) === "[object ArrayBuffer]" ? Buffer.from(e) : ArrayBuffer.isView(e) ? Buffer.from(e.buffer, e.byteOffset, e.byteLength) : r.isStream(e) ? e : Buffer.from(String(e));
this[l] = {
body: a,
disturbed: !1,
error: null
}, this.size = n, this.timeout = i, r.isStream(a) && a.on("error", (e) => {
let t = e.name === "AbortError" ? e : new s(`Invalid response while trying to fetch ${this.url}: ${e.message}`, "system", e);
this[l].error = t;
});
}
get body() {
return this[l].body;
}
get bodyUsed() {
return this[l].disturbed;
}
arrayBuffer() {
return this[u]().then((e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength));
}
blob() {
let e = this.headers && this.headers.get("content-type") || "";
return this[u]().then((t) => Object.assign(new a([], { type: e.toLowerCase() }), { [o]: t }));
}
async json() {
let e = await this[u]();
try {
return JSON.parse(e.toString());
} catch (e) {
throw new s(`invalid json response body at ${this.url} reason: ${e.message}`, "invalid-json");
}
}
text() {
return this[u]().then((e) => e.toString());
}
buffer() {
return this[u]();
}
textConverted() {
/* istanbul ignore if */
if (typeof c != "function") throw Error("The package `iconv-lite` must be installed to use the textConverted() function");
return this[u]().then((e) => m(e, this.headers));
}
[u]() {
if (this[l].disturbed) return Promise.reject(/* @__PURE__ */ TypeError(`body used already for: ${this.url}`));
if (this[l].disturbed = !0, this[l].error) return Promise.reject(this[l].error);
if (this.body === null) return Promise.resolve(Buffer.alloc(0));
if (Buffer.isBuffer(this.body)) return Promise.resolve(this.body);
let e = p(this.body) ? this.body.stream() : this.body;
/* istanbul ignore if: should never happen */
if (!r.isStream(e)) return Promise.resolve(Buffer.alloc(0));
let t = this.size && e instanceof i || !this.size && e instanceof r && !(e instanceof i) ? e : this.size ? new i({ size: this.size }) : new r(), n = this.timeout && t.writable ? setTimeout(() => {
t.emit("error", new s(`Response timeout while trying to fetch ${this.url} (over ${this.timeout}ms)`, "body-timeout"));
}, this.timeout) : null;
return n && n.unref && n.unref(), new Promise((n) => {
t !== e && (e.on("error", (e) => t.emit("error", e)), e.pipe(t)), n();
}).then(() => t.concat()).then((e) => (clearTimeout(n), e)).catch((e) => {
throw clearTimeout(n), e.name === "AbortError" || e.name === "FetchError" ? e : e.name === "RangeError" ? new s(`Could not create Buffer from response body for ${this.url}: ${e.message}`, "system", e) : new s(`Invalid response body while trying to fetch ${this.url}: ${e.message}`, "system", e);
});
}
static clone(e) {
if (e.bodyUsed) throw Error("cannot clone body after it is used");
let t = e.body;
if (r.isStream(t) && typeof t.getBoundary != "function") {
let n = new r(), i = new r(), a = new r();
return n.on("error", (e) => {
i.emit("error", e), a.emit("error", e);
}), t.on("error", (e) => n.emit("error", e)), n.pipe(i), n.pipe(a), t.pipe(n), e[l].body = i, a;
}
return e.body;
}
static extractContentType(e) {
return e == null ? null : typeof e == "string" ? "text/plain;charset=UTF-8" : f(e) ? "application/x-www-form-urlencoded;charset=UTF-8" : p(e) ? e.type || null : Buffer.isBuffer(e) || Object.prototype.toString.call(e) === "[object ArrayBuffer]" || ArrayBuffer.isView(e) ? null : typeof e.getBoundary == "function" ? `multipart/form-data;boundary=${e.getBoundary()}` : r.isStream(e) ? null : "text/plain;charset=UTF-8";
}
static getTotalBytes(e) {
let { body: t } = e;
return t == null ? 0 : p(t) ? t.size : Buffer.isBuffer(t) ? t.length : t && typeof t.getLengthSync == "function" && (t._lengthRetrievers &&
/* istanbul ignore next */ t._lengthRetrievers.length === 0 || t.hasKnownLength && t.hasKnownLength()) ? t.getLengthSync() : null;
}
static writeToStream(e, t) {
let { body: n } = t;
return n == null ? e.end() : Buffer.isBuffer(n) || typeof n == "string" ? e.end(n) : (p(n) ? n.stream() : n).on("error", (t) => e.emit("error", t)).pipe(e), e;
}
};
Object.defineProperties(d.prototype, {
body: { enumerable: !0 },
bodyUsed: { enumerable: !0 },
arrayBuffer: { enumerable: !0 },
blob: { enumerable: !0 },
json: { enumerable: !0 },
text: { enumerable: !0 }
});
var f = (e) => typeof e != "object" || typeof e.append != "function" || typeof e.delete != "function" || typeof e.get != "function" || typeof e.getAll != "function" || typeof e.has != "function" || typeof e.set != "function" ? !1 : e.constructor.name === "URLSearchParams" || Object.prototype.toString.call(e) === "[object URLSearchParams]" || typeof e.sort == "function", p = (e) => typeof e == "object" && typeof e.arrayBuffer == "function" && typeof e.type == "string" && typeof e.stream == "function" && typeof e.constructor == "function" && typeof e.constructor.name == "string" && /^(Blob|File)$/.test(e.constructor.name) && /^(Blob|File)$/.test(e[Symbol.toStringTag]), m = (e, t) => {
let n = t && t.get("content-type"), r = "utf-8", i;
n && (i = /charset=([^;]*)/i.exec(n));
let a = e.slice(0, 1024).toString();
if (!i && a && (i = /<meta.+?charset=(['"])(.+?)\1/i.exec(a)), !i && a && (i = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(a), i || (i = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(a), i && i.pop()), i &&= /charset=(.*)/i.exec(i.pop())), !i && a && (i = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(a)), i && (r = i.pop(), (r === "gb2312" || r === "gbk") && (r = "gb18030")), r === "UTF-8") return e.toString("UTF-8");
r = r.toString().trim().replace(/^latin[-_]?(\d+)$/i, "ISO-8859-$1").replace(/^win(?:dows)?[-_]?(\d+)$/i, "WINDOWS-$1").replace(/^utf[-_]?(\d+)$/i, "UTF-$1").replace(/^ks_c_5601-1987$/i, "CP949").replace(/^us[-_]?ascii$/i, "ASCII").toUpperCase();
try {
return c(e, r).toString();
} catch {
/* istanbul ignore next */
return e.toString("UTF-8");
}
};
n.exports = d;
})), k = /* @__PURE__ */ a(((e, t) => {
var n = /[^^_`a-zA-Z\-0-9!#$%&'*+.|~]/, r = /[^\t\x20-\x7e\x80-\xff]/, i = (e) => {
if (e = `${e}`, n.test(e) || e === "") throw TypeError(`${e} is not a legal HTTP header name`);
}, a = (e) => {
if (e = `${e}`, r.test(e)) throw TypeError(`${e} is not a legal HTTP header value`);
}, o = (e, t) => {
t = t.toLowerCase();
for (let n in e) if (n.toLowerCase() === t) return n;
}, s = Symbol("map"), c = class e {
constructor(t = void 0) {
if (this[s] = Object.create(null), t instanceof e) {
let e = t.raw(), n = Object.keys(e);
for (let t of n) for (let n of e[t]) this.append(t, n);
return;
}
if (t != null) {
if (typeof t == "object") {
let e = t[Symbol.iterator];
if (e != null) {
if (typeof e != "function") throw TypeError("Header pairs must be iterable");
let n = [];
for (let e of t) {
if (typeof e != "object" || typeof e[Symbol.iterator] != "function") throw TypeError("Each header pair must be iterable");
let t = Array.from(e);
if (t.length !== 2) throw TypeError("Each header pair must be a name/value tuple");
n.push(t);
}
for (let e of n) this.append(e[0], e[1]);
} else for (let e of Object.keys(t)) this.append(e, t[e]);
} else throw TypeError("Provided initializer must be an object");
}
}
get(e) {
e = `${e}`, i(e);
let t = o(this[s], e);
return t === void 0 ? null : this[s][t].join(", ");
}
forEach(e, t = void 0) {
let n = l(this);
for (let r = 0; r < n.length; r++) {
let [i, a] = n[r];
e.call(t, a, i, this), n = l(this);
}
}
set(e, t) {
e = `${e}`, t = `${t}`, i(e), a(t);
let n = o(this[s], e);
this[s][n === void 0 ? e : n] = [t];
}
append(e, t) {
e = `${e}`, t = `${t}`, i(e), a(t);
let n = o(this[s], e);
n === void 0 ? this[s][e] = [t] : this[s][n].push(t);
}
has(e) {
return e = `${e}`, i(e), o(this[s], e) !== void 0;
}
delete(e) {
e = `${e}`, i(e);
let t = o(this[s], e);
t !== void 0 && delete this[s][t];
}
raw() {
return this[s];
}
keys() {
return new d(this, "key");
}
values() {
return new d(this, "value");
}
[Symbol.iterator]() {
return new d(this, "key+value");
}
entries() {
return new d(this, "key+value");
}
get [Symbol.toStringTag]() {
return "Headers";
}
static exportNodeCompatibleHeaders(e) {
let t = Object.assign(Object.create(null), e[s]), n = o(e[s], "Host");
return n !== void 0 && (t[n] = t[n][0]), t;
}
static createHeadersLenient(t) {
let i = new e();
for (let e of Object.keys(t)) if (!n.test(e)) {
if (Array.isArray(t[e])) for (let n of t[e]) r.test(n) || (i[s][e] === void 0 ? i[s][e] = [n] : i[s][e].push(n));
else r.test(t[e]) || (i[s][e] = [t[e]]);
}
return i;
}
};
Object.defineProperties(c.prototype, {
get: { enumerable: !0 },
forEach: { enumerable: !0 },
set: { enumerable: !0 },
append: { enumerable: !0 },
has: { enumerable: !0 },
delete: { enumerable: !0 },
keys: { enumerable: !0 },
values: { enumerable: !0 },
entries: { enumerable: !0 }
});
var l = (e, t = "key+value") => Object.keys(e[s]).sort().map(t === "key" ? (e) => e.toLowerCase() : t === "value" ? (t) => e[s][t].join(", ") : (t) => [t.toLowerCase(), e[s][t].join(", ")]), u = Symbol("internal"), d = class e {
constructor(e, t) {
this[u] = {
target: e,
kind: t,
index: 0
};
}
get [Symbol.toStringTag]() {
return "HeadersIterator";
}
next() {
/* istanbul ignore if: should be impossible */
if (!this || Object.getPrototypeOf(this) !== e.prototype) throw TypeError("Value of `this` is not a HeadersIterator");
let { target: t, kind: n, index: r } = this[u], i = l(t, n);
return r >= i.length ? {
value: void 0,
done: !0
} : (this[u].index++, {
value: i[r],
done: !1
});
}
};
Object.setPrototypeOf(d.prototype, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))), t.exports = c;
})), A = /* @__PURE__ */ a(((e, n) => {
var { STATUS_CODES: r } = t("http"), i = k(), a = O(), { clone: o, extractContentType: s } = a, c = Symbol("Response internals"), l = class e extends a {
constructor(e = null, t = {}) {
super(e, t);
let n = t.status || 200, a = new i(t.headers);
if (e != null && !a.has("Content-Type")) {
let t = s(e);
t && a.append("Content-Type", t);
}
this[c] = {
url: t.url,
status: n,
statusText: t.statusText || r[n],
headers: a,
counter: t.counter,
trailer: Promise.resolve(t.trailer || new i())
};
}
get trailer() {
return this[c].trailer;
}
get url() {
return this[c].url || "";
}
get status() {
return this[c].status;
}
get ok() {
return this[c].status >= 200 && this[c].status < 300;
}
get redirected() {
return this[c].counter > 0;
}
get statusText() {
return this[c].statusText;
}
get headers() {
return this[c].headers;
}
clone() {
return new e(o(this), {
url: this.url,
status: this.status,
statusText: this.statusText,
headers: this.headers,
ok: this.ok,
redirected: this.redirected,
trailer: this.trailer
});
}
get [Symbol.toStringTag]() {
return "Response";
}
};
n.exports = l, Object.defineProperties(l.prototype, {
url: { enumerable: !0 },
status: { enumerable: !0 },
ok: { enumerable: !0 },
redirected: { enumerable: !0 },
statusText: { enumerable: !0 },
headers: { enumerable: !0 },
clone: { enumerable: !0 }
});
})), j = /* @__PURE__ */ i({
author: () => G,
default: () => q,
dependencies: () => z,
description: () => P,
devDependencies: () => R,
engines: () => W,
files: () => U,
keywords: () => H,
license: () => "MIT",
main: () => F,
name: () => M,
optionalDependencies: () => B,
repository: () => V,
scripts: () => I,
tap: () => L,
templateOSS: () => K,
version: () => N
}), M, N, P, F, I, L, R, z, B, V, H, U, W, G, K, q, ee = n((() => {
M = "minipass-fetch", N = "6.0.0", P = "An implementation of window.fetch in Node.js using Minipass streams", F = "lib/index.js", I = {
"test:tls-fixtures": "./test/fixtures/tls/setup.sh",
test: "tap",
snap: "tap",
lint: "npm run eslint",
postlint: "template-oss-check",
lintfix: "npm run eslint -- --fix",
posttest: "npm run lint",
"template-oss-apply": "template-oss-apply --force",
eslint: "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
}, L = {
"coverage-map": "map.js",
"check-coverage": !0,
"nyc-arg": ["--exclude", "tap-snapshots/**"]
}, R = {
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "5.0.0",
"@ungap/url-search-params": "^0.2.2",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "~1.7.3",
"form-data": "^4.0.0",
"iconv-lite": "^0.7.2",
nock: "^13.2.4",
parted: "^0.1.1",
"string-to-arraybuffer": "^1.0.2",
tap: "^16.0.0"
}, z = {
minipass: "^7.0.3",
"minipass-sized": "^2.0.0",
minizlib: "^3.0.1"
}, B = { "iconv-lite": "^0.7.2" }, V = {
type: "git",
url: "git+https://github.com/npm/minipass-fetch.git"
}, H = [
"fetch",
"minipass",
"node-fetch",
"window.fetch"
], U = ["bin/", "lib/"], W = { node: "^22.22.2 || ^24.15.0 || >=26.0.0" }, G = "GitHub Inc.", K = {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
version: "5.0.0",
publish: "true"
}, q = {
name: M,
version: N,
description: P,
license: "MIT",
main: F,
scripts: I,
tap: L,
devDependencies: R,
dependencies: z,
optionalDependencies: B,
repository: V,
keywords: H,
files: U,
engines: W,
author: G,
templateOSS: K
};
})), J = /* @__PURE__ */ a(((n, r) => {
var { URL: i } = t("url"), { Minipass: a } = y(), o = k(), { exportNodeCompatibleHeaders: s } = o, c = O(), { clone: l, extractContentType: u, getTotalBytes: d } = c, f = `minipass-fetch/${(ee(), e(j).default).version} (+https://github.com/isaacs/minipass-fetch)`, p = Symbol("Request internals"), m = (e) => typeof e == "object" && typeof e[p] == "object", h = (e) => {
let t = e && typeof e == "object" && Object.getPrototypeOf(e);
return !!(t && t.constructor.name === "AbortSignal");
}, g = class e extends c {
constructor(e, t = {}) {
let n = m(e) ? new i(e.url) : e && e.href ? new i(e.href) : new i(`${e}`);
m(e) ? t = {
...e[p],
...t
} : (!e || typeof e == "string") && (e = {});
let r = (t.method || e.method || "GET").toUpperCase(), a = r === "GET" || r === "HEAD";
if ((t.body !== null && t.body !== void 0 || m(e) && e.body !== null) && a) throw TypeError("Request with GET/HEAD method cannot have body");
let s = t.body !== null && t.body !== void 0 ? t.body : m(e) && e.body !== null ? l(e) : null;
super(s, {
timeout: t.timeout || e.timeout || 0,
size: t.size || e.size || 0
});
let c = new o(t.headers || e.headers || {});
if (s != null && !c.has("Content-Type")) {
let e = u(s);
e && c.append("Content-Type", e);
}
let d = "signal" in t ? t.signal : null;
if (d != null && !h(d)) throw TypeError("Expected signal must be an instanceof AbortSignal");
let { ca: f, cert: g, ciphers: _, clientCertEngine: v, crl: y, dhparam: b, ecdhCurve: x, family: S, honorCipherOrder: C, key: w, passphrase: T, pfx: E, rejectUnauthorized: D = process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0", secureOptions: O, secureProtocol: k, servername: A, sessionIdContext: j } = t;
this[p] = {
method: r,
redirect: t.redirect || e.redirect || "follow",
headers: c,
parsedURL: n,
signal: d,
ca: f,
cert: g,
ciphers: _,
clientCertEngine: v,
crl: y,
dhparam: b,
ecdhCurve: x,
family: S,
honorCipherOrder: C,
key: w,
passphrase: T,
pfx: E,
rejectUnauthorized: D,
secureOptions: O,
secureProtocol: k,
servername: A,
sessionIdContext: j
}, this.follow = t.follow === void 0 ? e.follow === void 0 ? 20 : e.follow : t.follow, this.compress = t.compress === void 0 ? e.compress === void 0 || e.compress : t.compress, this.counter = t.counter || e.counter || 0, this.agent = t.agent || e.agent;
}
get method() {
return this[p].method;
}
get url() {
return this[p].parsedURL.toString();
}
get headers() {
return this[p].headers;
}
get redirect() {
return this[p].redirect;
}
get signal() {
return this[p].signal;
}
clone() {
return new e(this);
}
get [Symbol.toStringTag]() {
return "Request";
}
static getNodeRequestOptions(e) {
let t = e[p].parsedURL, n = new o(e[p].headers);
if (n.has("Accept") || n.set("Accept", "*/*"), !/^https?:$/.test(t.protocol)) throw TypeError("Only HTTP(S) protocols are supported");
if (e.signal && a.isStream(e.body) && typeof e.body.destroy != "function") throw Error("Cancellation of streamed requests with AbortSignal is not supported");
let r = (e.body === null || e.body === void 0) && /^(POST|PUT)$/i.test(e.method) ? "0" : e.body !== null && e.body !== void 0 ? d(e) : null;
r && n.set("Content-Length", r + ""), n.has("User-Agent") || n.set("User-Agent", f), e.compress && !n.has("Accept-Encoding") && n.set("Accept-Encoding", "gzip,deflate");
let i = typeof e.agent == "function" ? e.agent(t) : e.agent;
!n.has("Connection") && !i && n.set("Connection", "close");
let { ca: c, cert: l, ciphers: u, clientCertEngine: m, crl: h, dhparam: g, ecdhCurve: _, family: v, honorCipherOrder: y, key: b, passphrase: x, pfx: S, rejectUnauthorized: C, secureOptions: w, secureProtocol: T, servername: E, sessionIdContext: D } = e[p];
return {
auth: t.username || t.password ? `${t.username}:${t.password}` : "",
host: t.host,
hostname: t.hostname,
path: `${t.pathname}${t.search}`,
port: t.port,
protocol: t.protocol,
method: e.method,
headers: s(n),
agent: i,
ca: c,
cert: l,
ciphers: u,
clientCertEngine: m,
crl: h,
dhparam: g,
ecdhCurve: _,
family: v,
honorCipherOrder: y,
key: b,
passphrase: x,
pfx: S,
rejectUnauthorized: C,
secureOptions: w,
secureProtocol: T,
servername: E,
sessionIdContext: D,
timeout: e.timeout
};
}
};
r.exports = g, Object.defineProperties(g.prototype, {
method: { enumerable: !0 },
url: { enumerable: !0 },
headers: { enumerable: !0 },
redirect: { enumerable: !0 },
clone: { enumerable: !0 },
signal: { enumerable: !0 }
});
})), te = /* @__PURE__ */ a(((e, t) => {
t.exports = class extends Error {
constructor(e) {
super(e), this.code = "FETCH_ABORTED", this.type = "aborted", Error.captureStackTrace(this, this.constructor);
}
get name() {
return "AbortError";
}
set name(e) {}
};
})), Y = /* @__PURE__ */ a(((e, n) => {
var { URL: r } = t("url"), i = t("http"), a = t("https"), o = x(), { Minipass: s } = y(), { writeToStream: c, getTotalBytes: l } = O(), u = A(), d = k(), { createHeadersLenient: f } = d, p = J(), { getNodeRequestOptions: m } = p, h = w(), g = te(), _ = async (e, t) => {
if (/^data:/.test(e)) {
let n = new p(e, t);
return Promise.resolve().then(() => new Promise((t, i) => {
let a, o;
try {
let { pathname: t, search: n } = new r(e), i = t.split(",");
if (i.length < 2) throw Error("invalid data: URI");
let s = i.shift(), c = /;base64$/.test(s);
a = c ? s.slice(0, -7) : s;
let l = decodeURIComponent(i.join(",") + n);
o = c ? Buffer.from(l, "base64") : Buffer.from(l);
} catch (e) {
return i(new h(`[${n.method}] ${n.url} invalid URL, ${e.message}`, "system", e));
}
let { signal: s } = n;
if (s && s.aborted) return i(new g("The user aborted a request."));
let c = { "Content-Length": o.length };
return a && (c["Content-Type"] = a), t(new u(o, { headers: c }));
}));
}
return new Promise((n, v) => {
let y = new p(e, t), b;
try {
b = m(y);
} catch (e) {
return v(e);
}
let x = (b.protocol === "https:" ? a : i).request, { signal: S } = y, C = null, w = () => {
let e = new g("The user aborted a request.");
v(e), s.isStream(y.body) && typeof y.body.destroy == "function" && y.body.destroy(e), C && C.body && C.body.emit("error", e);
};
if (S && S.aborted) return w();
let T = () => {
w(), E();
}, E = () => {
D.abort(), S && S.removeEventListener("abort", T), clearTimeout(O);
}, D = x(b);
S && S.addEventListener("abort", T);
let O = null;
y.timeout && D.once("socket", () => {
O = setTimeout(() => {
v(new h(`network timeout at: ${y.url}`, "request-timeout")), E();
}, y.timeout);
}), D.on("error", (e) => {
D.res && D.res.emit("error", e), v(new h(`request to ${y.url} failed, reason: ${e.message}`, "system", e)), E();
}), D.on("response", (e) => {
clearTimeout(O);
let t = f(e.headers);
if (_.isRedirect(e.statusCode)) {
let i = t.get("Location"), a = null;
try {
a = i === null ? null : new r(i, y.url).toString();
} catch {
if (y.redirect !== "manual") {
v(new h(`uri requested responds with an invalid redirect URL: ${i}`, "invalid-redirect")), E();
return;
}
}
if (y.redirect === "error") {
v(new h(`uri requested responds with a redirect, redirect mode is set to error: ${y.url}`, "no-redirect")), E();
return;
}
if (y.redirect === "manual") {
if (a !== null) try {
t.set("Location", a);
} catch (e) {
/* istanbul ignore next: nodejs server prevent invalid
response headers, we can't test this through normal
request */
v(e);
}
} else if (y.redirect === "follow" && a !== null) {
if (y.counter >= y.follow) {
v(new h(`maximum redirect reached at: ${y.url}`, "max-redirect")), E();
return;
}
if (e.statusCode !== 303 && y.body && l(y) === null) {
v(new h("Cannot follow redirect with body being a readable stream", "unsupported-redirect")), E();
return;
}
y.headers.set("host", new r(a).host);
let t = {
headers: new d(y.headers),
follow: y.follow,
counter: y.counter + 1,
agent: y.agent,
compress: y.compress,
method: y.method,
body: y.body,
signal: y.signal,
timeout: y.timeout
}, i = new r(y.url), o = new r(a);
i.hostname !== o.hostname && (t.headers.delete("authorization"), t.headers.delete("cookie")), (e.statusCode === 303 || (e.statusCode === 301 || e.statusCode === 302) && y.method === "POST") && (t.method = "GET", t.body = void 0, t.headers.delete("content-length")), n(_(new p(a, t))), E();
return;
}
}
e.once("end", () => S && S.removeEventListener("abort", T));
let i = new s();
i.on("error", E), e.on(
"error",
/* istanbul ignore next */
(e) => i.emit("error", e)
), e.on("data", (e) => i.write(e)), e.on("end", () => i.end());
let a = {
url: y.url,
status: e.statusCode,
statusText: e.statusMessage,
headers: t,
size: y.size,
timeout: y.timeout,
counter: y.counter,
trailer: new Promise((t) => e.on("end", () => t(f(e.trailers))))
}, c = t.get("Content-Encoding");
if (!y.compress || y.method === "HEAD" || c === null || e.statusCode === 204 || e.statusCode === 304) {
C = new u(i, a), n(C);
return;
}
let m = {
flush: o.constants.Z_SYNC_FLUSH,
finishFlush: o.constants.Z_SYNC_FLUSH
};
if (c === "gzip" || c === "x-gzip") {
let e = new o.Gunzip(m);
C = new u(i.on(
"error",
/* istanbul ignore next */
(t) => e.emit("error", t)
).pipe(e), a), n(C);
return;
}
if (c === "deflate" || c === "x-deflate") {
e.once("data", (e) => {
let t = (e[0] & 15) == 8 ? new o.Inflate() : new o.InflateRaw();
i.on(
"error",
/* istanbul ignore next */
(e) => t.emit("error", e)
).pipe(t), C = new u(t, a), n(C);
});
return;
}
if (c === "br") {
// istanbul ignore next
try {
var g = new o.BrotliDecompress();
} catch (e) {
v(e), E();
return;
}
i.on(
"error",
/* istanbul ignore next */
(e) => g.emit("error", e)
).pipe(g), C = new u(g, a), n(C);
return;
}
C = new u(i, a), n(C);
}), c(D, y);
});
};
n.exports = _, _.isRedirect = (e) => e === 301 || e === 302 || e === 303 || e === 307 || e === 308, _.Headers = d, _.Request = p, _.Response = u, _.FetchError = h, _.AbortError = g;
})), ne = /* @__PURE__ */ i({
author: () => le,
default: () => he,
dependencies: () => ue,
description: () => ae,
devDependencies: () => de,
engines: () => pe,
files: () => oe,
keywords: () => ce,
license: () => "ISC",
main: () => "lib",
name: () => re,
repository: () => se,
scripts: () => X,
tap: () => fe,
templateOSS: () => me,
version: () => ie
}), re, ie, ae, oe, X, se, ce, le, ue, de, fe, pe, me, he, ge = n((() => {
re = "npm-registry-fetch", ie = "20.0.1", ae = "Fetch-based http client for use with npm registry APIs", oe = ["bin/", "lib/"], X = {
eslint: "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
lint: "npm run eslint",
lintfix: "npm run eslint -- --fix",
test: "tap",
posttest: "npm run lint",
npmclilint: "npmcli-lint",
postsnap: "npm run lintfix --",
postlint: "template-oss-check",
snap: "tap",
"template-oss-apply": "template-oss-apply --force"
}, se = {
type: "git",
url: "git+https://github.com/npm/npm-registry-fetch.git"
}, ce = [
"npm",
"registry",
"fetch"
], le = "GitHub Inc.", ue = {
"@npmcli/redact": "^5.0.0",
jsonparse: "^1.3.1",
"make-fetch-happen": "^16.0.0",
minipass: "^7.0.2",
"minipass-fetch": "^6.0.0",
minizlib: "^3.0.1",
"npm-package-arg": "^14.0.0",
"proc-log": "^7.0.0"
}, de = {
"@npmcli/eslint-config": "^7.0.0",
"@npmcli/template-oss": "5.1.0",
cacache: "^21.0.0",
nock: "^13.2.4",
"require-inject": "^1.4.4",
ssri: "^14.0.0",
tap: "^16.0.1"
}, fe = {
"check-coverage": !0,
"test-ignore": "test[\\\\/](util|cache)[\\\\/]",
"nyc-arg": ["--exclude", "tap-snapshots/**"]
}, pe = { node: "^22.22.2 || ^24.15.0 || >=26.0.0" }, me = {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
version: "5.1.0",
publish: "true"
}, he = {
name: re,
version: ie,
description: ae,
main: "lib",
files: oe,
scripts: X,
repository: se,
keywords: ce,
author: le,
license: "ISC",
dependencies: ue,
devDependencies: de,
tap: fe,
engines: pe,
templateOSS: me
};
})), _e = /* @__PURE__ */ a(((t, n) => {
var r = (ge(), e(ne).default);
n.exports = {
maxSockets: 12,
method: "GET",
registry: "https://registry.npmjs.org/",
timeout: 3e5,
strictSSL: !0,
noProxy: process.env.NOPROXY,
userAgent: `${r.name}@${r.version}/node@${process.version}+${process.arch} (${process.platform})`
};
})), ve = /* @__PURE__ */ a(((e, t) => {
t.exports = {
META: Symbol("proc-log.meta"),
output: {
LEVELS: [
"standard",
"error",
"buffer",
"flush"
],
KEYS: {
standard: "standard",
error: "error",
buffer: "buffer",
flush: "flush"
},
standard: function(...e) {
return process.emit("output", "standard", ...e);
},
error: function(...e) {
return process.emit("output", "error", ...e);
},
buffer: function(...e) {
return process.emit("output", "buffer", ...e);
},
flush: function(...e) {
return process.emit("output", "flush", ...e);
}
},
log: {
LEVELS: [
"notice",
"error",
"warn",
"info",
"verbose",
"http",
"silly",
"timing",
"pause",
"resume"
],
KEYS: {
notice: "notice",
error: "error",
warn: "warn",
info: "info",
verbose: "verbose",
http: "http",
silly: "silly",
timing: "timing",
pause: "pause",
resume: "resume"
},
error: function(...e) {
return process.emit("log", "error", ...e);
},
notice: function(...e) {
return process.emit("log", "notice", ...e);
},
warn: function(...e) {
return process.emit("log", "warn", ...e);
},
info: function(...e) {
return process.emit("log", "info", ...e);
},
verbose: function(...e) {
return process.emit("log", "verbose", ...e);
},
http: function(...e) {
return process.emit("log", "http", ...e);
},
silly: function(...e) {
return process.emit("log", "silly", ...e);
},
timing: function(...e) {
return process.emit("log", "timing", ...e);
},
pause: function() {
return process.emit("log", "pause");
},
resume: function() {
return process.emit("log", "resume");
}
},
time: {
LEVELS: ["start", "end"],
KEYS: {
start: "start",
end: "end"
},
start: function(e, t) {
process.emit("time", "start", e);
function n() {
return process.emit("time", "end", e);
}
if (typeof t == "function") {
let e = t();
return e && e.finally ? e.finally(n) : (n(), e);
}
return n;
},
end: function(e) {
return process.emit("time", "end", e);
}
},
input: {
LEVELS: [
"start",
"end",
"read"
],
KEYS: {
start: "start",
end: "end",
read: "read"
},
start: function(...e) {
let t;
typeof e[0] == "function" && (t = e.shift()), process.emit("input", "start", ...e);
function n() {
return process.emit("input", "end", ...e);
}
if (typeof t == "function") {
let e = t();
return e && e.finally ? e.finally(n) : (n(), e);
}
return n;
},
end: function(...e) {
return process.emit("input", "end", ...e);
},
read: function(...e) {
let t, n, r = new Promise((e, r) => {
t = e, n = r;
});
return process.emit("input", "read", t, n, ...e), r;
}
}
};
})), ye = /* @__PURE__ */ a(((e, t) => {
var n = "regex", r = "url", i = "path";
t.exports = {
TYPE_REGEX: n,
TYPE_URL: r,
TYPE_PATH: i,
NPM_SECRET: {
type: n,
pattern: /\b(npms?_)[a-zA-Z0-9]{36,48}\b/gi,
replacement: "[REDACTED_NPM_SECRET]"
},
AUTH_HEADER: {
type: n,
pattern: /\b(Basic\s+|Bearer\s+)[\w+=\-.]+\b/gi,
replacement: "[REDACTED_AUTH_HEADER]"
},
JSON_WEB_TOKEN: {
type: n,
pattern: /\b[A-Za-z0-9-_]{10,}(?!\.\d+\.)\.[A-Za-z0-9-_]{3,}\.[A-Za-z0-9-_]{20,}\b/gi,
replacement: "[REDACTED_JSON_WEB_TOKEN]"
},
UUID: {
type: n,
pattern: /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,
replacement: "[REDACTED_UUID]"
},
URL_MATCHER: {
type: n,
pattern: /(?:https?|ftp):\/\/[^\s/"$.?#].[^\s"]*/gi,
replacement: "[REDACTED_URL]"
},
DEEP_HEADER_AUTHORIZATION: {
type: i,
predicate: ({ path: e }) => e.endsWith(".headers.authorization"),
replacement: "[REDACTED_HEADER_AUTHORIZATION]"
},
DEEP_HEADER_SET_COOKIE: {
type: i,
predicate: ({ path: e }) => e.endsWith(".headers.set-cookie"),
replacement: "[REDACTED_HEADER_SET_COOKIE]"
},
DEEP_HEADER_COOKIE: {
type: i,
predicate: ({ path: e }) => e.endsWith(".headers.cookie"),
replacement: "[REDACTED_HEADER_COOKIE]"
},
REWRITE_REQUEST: {
type: i,
predicate: ({ path: e }) => e.endsWith(".request"),
replacement: (e) => ({
method: e?.method,
path: e?.path,
headers: e?.headers,
url: e?.url
})
},
REWRITE_RESPONSE: {
type: i,
predicate: ({ path: e }) => e.endsWith(".response"),
replacement: (e) => ({
data: e?.data,
status: e?.status,
headers: e?.headers
})
}
};
})), be = /* @__PURE__ */ a(((e, t) => {
var { URL_MATCHER: n, TYPE_URL: r, TYPE_REGEX: i, TYPE_PATH: a } = ye(), o = (e = 0) => (e = typeof e == "string" ? e.length : e, e < 8 ? "*".repeat(8) : "*".repeat(e)), s = (e) => e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), c = (e) => [.../* @__PURE__ */ new Set([
encodeURIComponent(e),
decodeURIComponent(e),
e
])].map(s).join("|"), l = (e, ...t) => {
let n = "";
for (let r = 0; r < t.length; r++) n += e[r] + `(${c(t[r])})`;
return n += e[e.length - 1], new RegExp(n);
}, u = ({ hostname: e, replacement: t } = {}) => ({
type: r,
predicate: ({ url: t }) => t.hostname === e,
pattern: ({ url: e }) => l`(^${e.protocol}//${e.username}:.+@)?${e.hostname}`,
replacement: `$1${t || o()}`
}), d = ({ param: e, replacement: t } = {}) => ({
type: r,
predicate: ({ url: t }) => t.searchParams.has(e),
pattern: ({ url: t }) => l`(${e}=)${t.searchParams.get(e)}`,
replacement: `$1${t || o()}`
}), f = ({ replacement: e } = {}) => ({
type: r,
predicate: ({ url: e }) => e.password,
pattern: ({ url: e }) => l`(^${e.protocol}//${e.username}:)${e.password}`,
replacement: `$1${e || o()}`
}), p = (...e) => (t) => {
try {
let n = new URL(t);
return _(...e)(t, { url: n });
} catch {
return t;
}
}, m = (...e) => ({
...n,
replacement: p(...e)
}), h = {
[i]: (e) => (t) => (typeof t == "string" && (t = t.replace(e.pattern, e.replacement)), t),
[r]: (e) => (t, n) => {
if (typeof t == "string") try {
let r = n?.url || new URL(t), { predicate: i, pattern: a } = e;
i({ url: r }) && (t = t.replace(a({ url: r }), e.replacement));
} catch {
return t;
}
return t;
},
[a]: (e) => (t, n) => {
let r = n?.path, i = r.join(".").toLowerCase(), { predicate: a, replacement: o } = e, s = typeof o == "function" ? o : () => o;
return a({
rawPath: r,
path: i
}) && (t = s(t, {
rawPath: r,
path: i
})), t;
}
}, g = (e) => h[e.type](e), _ = (...e) => (t, n) => e.flat().reduce((e, t) => (typeof t == "function" ? t : g(t))(e, n), t);
t.exports = {
asterisk: o,
escapeRegExp: s,
urlEncodeRegexGroup: c,
urlEncodeRegexTag: l,
redactUrlHostnameMatcher: u,
redactUrlSearchParamsMatcher: d,
redactUrlPasswordMatcher: f,
redactUrlMatcher: m,
redactUrlReplacement: p,
redactDynamicReplacement: () => (e, t) => typeof t == "number" ? o(e) : t + o(e.substring(t.length).length),
redactFixedReplacement: (e) => (t, n) => typeof n == "number" ? o(e) : n + o(e),
redactMatchers: _,
redactUrlPassword: (e, t) => _(f({ replacement: t }))(e)
};
})), xe = /* @__PURE__ */ a(((e, t) => {
var n = ye(), { redactUrlPassword: r } = be(), i = "***", a = (e) => typeof e != "string" || !e ? e : r(e, i).replace(n.NPM_SECRET.pattern, `npm_${i}`).replace(n.UUID.pattern, i), o = (e) => {
let t = /[\s=]/g, n = null, r = "", i = 0;
for (; n = t.exec(e);) r += a(e.slice(i, n.index)) + n[0], i = t.lastIndex;
return r + a(e.slice(i));
};
t.exports = {
redact: a,
redactLog: (e) => typeof e == "string" ? o(e) : Array.isArray(e) ? e.map((e) => typeof e == "string" ? o(e) : e) : e
};
})), Se = /* @__PURE__ */ a(((e, t) => {
var n = v(), { Response: r } = Y(), i = _e(), { log: a } = ve(), { redact: o } = xe(), s = "https://github.com/npm/cli/wiki/No-auth-for-URI,-but-auth-present-for-scoped-registry";
t.exports = async ({ method: e, uri: t, res: n, startTime: o, auth: u, opts: d }) => (d = {
...i,
...d
}, n.headers.has("npm-notice") && !n.headers.has("x-local-cache") && a.notice("", n.headers.get("npm-notice")), n.status >= 400 ? (c(e, n, o), u && u.scopeAuthKey && !u.token && !u.auth && a.warn("registry", `No auth for URI, but auth present for scoped registry.
URI: ${t}
Scoped Registry Key: ${u.scopeAuthKey}
More info here: ${s}`), l(e, n, o, d)) : (n.body.on("end", () => c(e, n, o, d)), d.ignoreBody ? (n.body.resume(), new r(null, n)) : n));
function c(e, t, n) {
let r = Date.now() - n, i = t.headers.get("x-fetch-attempts"), s = i && i > 1 ? ` attempt #${i}` : "", c = t.headers.get("x-local-cache-status"), l = c ? ` (cache ${c})` : "", u = o(t.url);
c === "hit" ? a.http("cache", `${u} ${r}ms${s}${l}`) : a.http("fetch", `${e.toUpperCase()} ${t.status} ${u} ${r}ms${s}${l}`);
}
function l(e, t, r, i) {
return t.buffer().catch(() => null).then((r) => {
let a = r;
try {
a = JSON.parse(r.toString("utf8"));
} catch {}
if (t.status === 401 && t.headers.get("www-authenticate")) {
let r = t.headers.get("www-authenticate").split(/,\s*/).map((e) => e.toLowerCase());
throw r.indexOf("ipaddress") === -1 ? r.indexOf("otp") === -1 ? new n.HttpErrorAuthUnknown(e, t, a, i.spec) : new n.HttpErrorAuthOTP(e, t, a, i.spec) : new n.HttpErrorAuthIPAddress(e, t, a, i.spec);
}
throw t.status === 401 && r != null && /one-time pass/.test(r.toString("utf8")) ? new n.HttpErrorAuthOTP(e, t, a, i.spec) : new n.HttpErrorGeneral(e, t, a, i.spec);
});
}
})), Ce = /* @__PURE__ */ i({ default: () => we }), we, Te = n((() => {
we = /* @__PURE__ */ "_http_agent._http_client._http_common._http_incoming._http_outgoing._http_server._stream_duplex._stream_passthrough._stream_readable._stream_transform._stream_wrap._stream_writable._tls_common._tls_wrap.assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib.node:sea.node:sqlite.node:test.node:test/reporters".split(".");
})), Ee = /* @__PURE__ */ a(((t, n) => {
var r = (Te(), e(Ce).default), i = /* @__PURE__ */ RegExp("^(?:@([^/]+?)[/])?([^/]+?)$"), a = ["node_modules", "favicon.ico"];
function o(e) {
var t = [], n = [];
if (e === null) return n.push("name cannot be null"), s(t, n);
if (e === void 0) return n.push("name cannot be undefined"), s(t, n);
if (typeof e != "string") return n.push("name must be a string"), s(t, n);
if (e.length || n.push("name length must be greater than zero"), e.startsWith(".") && n.push("name cannot start with a period"), e.startsWith("-") && n.push("name cannot start with a hyphen"), e.match(/^_/) && n.push("name cannot start with an underscore"), e.trim() !== e && n.push("name cannot contain leading or trailing spaces"), a.forEach(function(t) {
e.toLowerCase() === t && n.push(t + " is not a valid package name");
}), r.includes(e.toLowerCase()) && t.push(e + " is a core module name"), e.length > 214 && t.push("name can no longer contain more than 214 characters"), e.toLowerCase() !== e && t.push("name can no longer contain capital letters"), /[~'!()*]/.test(e.split("/").slice(-1)[0]) && t.push("name can no longer contain special characters (\"~'!()*\")"), encodeURIComponent(e) !== e) {
var o = e.match(i);
if (o) {
var c = o[1], l = o[2];
if (l.startsWith(".") && n.push("name cannot start with a period"), encodeURIComponent(c) === c && encodeURIComponent(l) === l) return s(t, n);
}
n.push("name can only contain URL-friendly characters");
}
return s(t, n);
}
var s = function(e, t) {
var n = {
validForNewPackages: t.length === 0 && e.length === 0,
validForOldPackages: t.length === 0,
warnings: e,
errors: t
};
return n.warnings.length || delete n.warnings, n.errors.length || delete n.errors, n;
};
n.exports = o;
})), De = /* @__PURE__ */ a(((e, n) => {
var r = process.platform === "win32", { URL: i } = t("node:url"), a = t(r ? "node:path/win32" : "node:path"), { homedir: c } = t("node:os"), l = o(), u = s(), d = Ee(), { log: f } = ve(), p = r ? /\\|[/]/ : /[/]/, m = /^(?:git[+])?[a-z]+:/i, h = /^[^@]+@[^:.]+\.[^:]+:.+$/i, g = /[.](?:tgz|tar\.gz|tar)$/i, _ = /:[0-9]+(\/|$)/i, v = /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/, y = /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/, b = "https://registry.npmjs.org";
function x(e, t) {
let n, r;
if (typeof e == "object") return e instanceof k && (!t || t === e.where) ? e : e.name && e.rawSpec ? x.resolve(e.name, e.rawSpec, t || e.where) : x(e.raw, t || e.where);
let i = e.indexOf("@", 1), a = i > 0 ? e.slice(0, i) : e;
return m.test(e) ? r = e : h.test(e) ? r = `git+ssh://${e}` : !a.startsWith("@") && (p.test(a) || g.test(a)) ? r = e : i > 0 ? (n = a, r = e.slice(i + 1) || "*") : d(e).validForOldPackages ? (n = e, r = "*") : r = e, w(n, r, t, e);
}
function S(e) {
return e ? e.toLowerCase().startsWith("file:") ? !0 : r ? v.test(e) : y.test(e) : !1;
}
function C(e) {
return e ? e.toLowerCase().startsWith("npm:") : !1;
}
function w(e, t, n, r) {
let i = new k({
raw: r,
name: e,
rawSpec: t,
fromArgument: r != null
});
if (e && (i.name = e), n ||= process.cwd(), S(t)) return N(i, n);
if (C(t)) return L(i, n);
let a = l.fromUrl(t, {
noGitPlus: !0,
noCommittish: !0
});
return a ? P(i, a) : t && m.test(t) ? I(i) : t && (p.test(t) || g.test(t)) ? N(i, n) : R(i);
}
function T(e, t = b) {
let n = x(e);
if (n.type !== "version") throw O(n.type, n.raw);
let r = "pkg:npm/" + n.name.replace(/^@/, "%40") + "@" + n.rawSpec;
return t !== b && (r += "?repository_url=" + t), r;
}
function E(e, t, n) {
let r = /* @__PURE__ */ Error(`Invalid package name "${e}" of package "${n}": ${t.errors.join("; ")}.`);
return r.code = "EINVALIDPACKAGENAME", r;
}
function D(e, t) {
let n = /* @__PURE__ */ Error(`Invalid tag name "${e}" of package "${t}": Tags may not have any characters that encodeURIComponent encodes.`);
return n.code = "EINVALIDTAGNAME", n;
}
function O(e, t) {
let n = /* @__PURE__ */ Error(`Invalid type "${e}" of package "${t}": Purl can only be generated for "version" types.`);
return n.code = "EINVALIDPURLTYPE", n;
}
var k = class {
constructor(e) {
this.type = e.type, this.registry = e.registry, this.where = e.where, this.raw = e.raw == null ? e.name ? `${e.name}@${e.rawSpec}` : e.rawSpec : e.raw, this.name = void 0, this.escapedName = void 0, this.scope = void 0, this.rawSpec = e.rawSpec || "", this.saveSpec = e.saveSpec, this.fetchSpec = e.fetchSpec, e.name && this.setName(e.name), this.gitRange = e.gitRange, this.gitCommittish = e.gitCommittish, this.gitSubdir = e.gitSubdir, this.hosted = e.hosted;
}
setName(e) {
let t = d(e);
if (!t.validForOldPackages) throw E(e, t, this.raw);
return this.name = e, this.scope = e[0] === "@" ? e.slice(0, e.indexOf("/")) : void 0, this.escapedName = e.replace("/", "%2f"), this;
}
toString() {
let e = [];
this.name != null && this.name !== "" && e.push(this.name);
let t = this.saveSpec || this.fetchSpec || this.rawSpec;
return t != null && t !== "" && e.push(t), e.length ? e.join("@") : this.raw;
}
toJSON() {
let e = Object.assign({}, this);
return delete e.hosted, e;
}
};
function A(e, t) {
if (!t) {
e.gitCommittish = null;
return;
}
for (let n of t.split("::")) {
if (!n.includes(":")) {
if (e.gitRange) throw Error("cannot override existing semver range with a committish");
if (e.gitCommittish) throw Error("cannot override existing committish with a second committish");
e.gitCommittish = n;
continue;
}
let [t, r] = n.split(":");
if (t === "semver") {
if (e.gitCommittish) throw Error("cannot override existing committish with a semver range");
if (e.gitRange) throw Error("cannot override existing semver range with a second semver range");
e.gitRange = decodeURIComponent(r);
continue;
}
if (t === "path") {
if (e.gitSubdir) throw Error("cannot override existing path with a second path");
e.gitSubdir = `/${r}`;
continue;
}
f.warn("npm-package-arg", `ignoring unknown key "${t}"`);
}
}
var j = /* @__PURE__ */ new Map([
["\0", "%00"],
[" ", "%09"],
["\n", "%0A"],
["\r", "%0D"],
[" ", "%20"],
["\"", "%22"],
["#", "%23"],
["%", "%25"],
["?", "%3F"],
["[", "%5B"],
["\\", r ? "/" : "%5C"],
["]", "%5D"],
["^", "%5E"],
["|", "%7C"],
["~", "%7E"]
]);
function M(e) {
let t = "";
for (let n = 0; n < e.length; n++) t = `${t}${j.get(e[n]) ?? e[n]}`;
return t.startsWith("file:") ? t : `file:${t}`;
}
function N(e, t) {
e.type = g.test(e.rawSpec) ? "file" : "directory", e.where = t;
let n = M(e.rawSpec);
n.startsWith("file:/") && (/^file:\/\/[^/]/.test(n) && (n = `file:/${n.slice(5)}`), /^\/{1,3}\.\.?(\/|$)/.test(n.slice(5)) && (n = n.replace(/^file:\/{1,3}/, "file:")));
let o, s;
try {
o = new i(n, `${M(a.resolve(t))}/`), s = new i(n);
} catch (n) {
throw Object.assign(/* @__PURE__ */ Error("Invalid file: URL, must comply with RFC 8089"), {
raw: e.rawSpec,
spec: e,
where: t,
originalError: n
});
}
let l = decodeURIComponent(s.pathname), u = decodeURIComponent(o.pathname);
return r && (l = l.replace(/^\/+([a-z]:\/)/i, "$1"), u = u.replace(/^\/+([a-z]:\/)/i, "$1")), /^\/~(\/|$)/.test(l) ? (e.saveSpec = `file:${l.substr(1)}`, u = a.resolve(c(), l.substr(3))) : e.saveSpec = a.isAbsolute(n.slice(5)) ? `file:${a.resolve(u)}` : `file:${a.relative(t, u)}`, e.fetchSpec = a.resolve(t, u), e.saveSpec = e.saveSpec.split("\\").join("/"), e.saveSpec.startsWith("file://") && (e.saveSpec = `file:/${e.saveSpec.slice(7)}`), e;
}
function P(e, t) {
return e.type = "git", e.hosted = t, e.saveSpec = t.toString({
noGitPlus: !1,
noCommittish: !1
}), e.fetchSpec = t.getDefaultRepresentation() === "shortcut" ? null : t.toString(), A(e, t.committish), e;
}
function F(e, t) {
let n = /* @__PURE__ */ Error(`Unsupported URL Type "${e}": ${t}`);
return n.code = "EUNSUPPORTEDPROTOCOL", n;
}
function I(e) {
let t = e.rawSpec;
if (e.saveSpec = t, t.startsWith("git+ssh:")) {
let n = t.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i);
if (n && !n[1].match(_)) return e.type = "git", A(e, n[2]), e.fetchSpec = n[1], e;
} else t.startsWith("git+file://") && (t = t.replace(/\\/g, "/"));
let n = new i(t);
switch (n.protocol) {
case "git:":
case "git+http:":
case "git+https:":
case "git+rsync:":
case "git+ftp:":
case "git+file:":
case "git+ssh:":
e.type = "git", A(e, n.hash.slice(1)), n.protocol === "git+file:" && /^git\+file:\/\/[a-z]:/i.test(t) ? e.fetchSpec = `git+file://${n.host.toLowerCase()}:${n.pathname}` : (n.hash = "", e.fetchSpec = n.toString()), e.fetchSpec.startsWith("git+") && (e.fetchSpec = e.fetchSpec.slice(4));
break;
case "http:":
case "https:":
e.type = "remote", e.fetchSpec = e.saveSpec;
break;
default: throw F(n.protocol, t);
}
return e;
}
function L(e, t) {
let n = x(e.rawSpec.substr(4), t);
if (n.type === "alias") throw Error("nested aliases not supported");
if (!n.registry) throw Error("aliases only work for registry deps");
if (!n.name) throw Error("aliases must have a name");
return e.subSpec = n, e.registry = !0, e.type = "alias", e.saveSpec = null, e.fetchSpec = null, e;
}
function R(e) {
e.registry = !0;
let t = e.rawSpec.trim();
e.saveSpec = null, e.fetchSpec = t;
let n = u.valid(t, !0), r = u.validRange(t, !0);
if (n) e.type = "version";
else if (r) e.type = "range";
else {
if (encodeURIComponent(t) !== t) throw D(t, e.raw);
e.type = "tag";
}
return e;
}
n.exports = x, n.exports.resolve = w, n.exports.toPurl = T, n.exports.Result = k;
})), Oe = /* @__PURE__ */ a(((e, n) => {
var r = t("fs"), i = De(), { URL: a } = t("url"), o = (e, t) => {
let n = new a(e), r = `//${n.host}${n.pathname}`;
for (; r.length > 2;) {
let e = s(r, t);
if (e) return {
regKey: r,
authKey: e
};
r = r.replace(/([^/]+|\/)$/, "");
}
return {
regKey: !1,
authKey: null
};
}, s = (e, t) => t[`${e}:_authToken`] ? "_authToken" : t[`${e}:_auth`] ? "_auth" : t[`${e}:username`] && t[`${e}:_password`] ? "username" : t[`${e}:certfile`] && t[`${e}:keyfile`] ? "certfile" : !1, c = (e, t) => {
let n = new a(e), r = new a(t);
return n.host === r.host;
}, l = (e) => {
let { spec: t } = e, { scope: n, subSpec: r } = t ? i(t) : {}, a = r && r.scope, o = r ? a : n;
return o && e[`${o}:registry`] || e.registry;
}, u = (e) => {
try {
return r.readFileSync(e, "utf8");
} catch (e) {
if (e.code !== "ENOENT") throw e;
return null;
}
}, d = (e, t = {}) => {
let { forceAuth: n } = t;
if (!e) throw Error("URI is required");
let { regKey: r, authKey: i } = o(e, n || t);
if (n && !r) return new f({
regKey: !1,
authKey: null,
scopeAuthKey: null,
token: n._authToken || n.token,
username: n.username,
password: n._password || n.password,
auth: n._auth || n.auth,
certfile: n.certfile,
keyfile: n.keyfile
});
if (!r) {
let n = l(t);
if (n && e !== n && c(e, n)) return d(n, t);
if (n !== t.registry) {
let { regKey: e, authKey: r } = o(n, t);
return new f({
scopeAuthKey: e,
regKey: e,
authKey: r
});
}
}
let { [`${r}:_authToken`]: a, [`${r}:username`]: s, [`${r}:_password`]: u, [`${r}:_auth`]: p, [`${r}:certfile`]: m, [`${r}:keyfile`]: h } = t;
return new f({
scopeAuthKey: null,
regKey: r,
authKey: i,
token: a,
auth: p,
username: s,
password: u,
certfile: m,
keyfile: h
});
}, f = class {
constructor({ token: e, auth: t, username: n, password: r, scopeAuthKey: i, certfile: a, keyfile: o, regKey: s, authKey: c }) {
if (this.scopeAuthKey = i, this.regKey = s, this.authKey = c, this.token = null, this.auth = null, this.isBasicAuth = !1, this.cert = null, this.key = null, e) this.token = e;
else if (t) this.auth = t;
else if (n && r) {
let e = Buffer.from(r, "base64").toString("utf8");
this.auth = Buffer.from(`${n}:${e}`, "utf8").toString("base64"), this.isBasicAuth = !0;
}
if (a && o) {
let e = u(a, "utf-8"), t = u(o, "utf-8");
e && t && (this.cert = e, this.key = t);
}
}
};
n.exports = d;
})), ke = /* @__PURE__ */ a(((e, n) => {
var r = t("dns"), i = [
"if-modified-since",
"if-none-match",
"if-unmodified-since",
"if-match",
"if-range"
];
n.exports = (e) => {
let { strictSSL: t, ...n } = { ...e };
if (n.method = n.method ? n.method.toUpperCase() : "GET", n.rejectUnauthorized = t == null ? process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0" : t !== !1, !n.retry) n.retry = { retries: 0 };
else if (typeof n.retry == "string") {
let e = parseInt(n.retry, 10);
n.retry = isFinite(e) ? { retries: e } : { retries: 0 };
} else n.retry = typeof n.retry == "number" ? { retries: n.retry } : {
retries: 0,
...n.retry
};
return n.dns = {
ttl: 3e5,
lookup: r.lookup,
...n.dns
}, n.cache = n.cache || "default", n.cache === "default" && Object.keys(n.headers || {}).some((e) => i.includes(e.toLowerCase())) && (n.cache = "no-store"), n.cacheAdditionalHeaders = n.cacheAdditionalHeaders || [], n.cacheManager && !n.cachePath && (n.cachePath = n.cacheManager), n;
};
})), Ae = /* @__PURE__ */ a(((e, t) => {
var n = /* @__PURE__ */ new Set([
200,
203,
204,
206,
300,
301,
308,
404,
405,
410,
414,
501
]), r = /* @__PURE__ */ new Set([
200,
203,
204,
300,
301,
302,
303,
307,
308,
404,
405,
410,
414,
501
]), i = /* @__PURE__ */ new Set([
500,
502,
503,
504
]), a = {
date: !0,
connection: !0,
"keep-alive": !0,
"proxy-authenticate": !0,
"proxy-authorization": !0,
te: !0,
trailer: !0,
"transfer-encoding": !0,
upgrade: !0
}, o = {
"content-length": !0,
"content-encoding": !0,
"transfer-encoding": !0,
"content-range": !0
};
function s(e) {
let t = parseInt(e, 10);
return isFinite(t) ? t : 0;
}
function c(e) {
return !e || i.has(e.status);
}
function l(e) {
let t = {};
if (!e) return t;
let n = e.trim().split(/,/);
for (let e of n) {
let [n, r] = e.split(/=/, 2);
t[n.trim()] = r === void 0 || r.trim().replace(/^"|"$/g, "");
}
return t;
}
function u(e) {
let t = [];
for (let n in e) {
let r = e[n];
t.push(r === !0 ? n : n + "=" + r);
}
if (t.length) return t.join(", ");
}
t.exports = class {
constructor(e, t, { shared: n, cacheHeuristic: r, immutableMinTimeToLive: i, ignoreCargoCult: a, _fromObject: o } = {}) {
if (o) {
this._fromObject(o);
return;
}
if (!t || !t.headers) throw Error("Response headers missing");
this._assertRequestHasHeaders(e), this._responseTime = this.now(), this._isShared = n !== !1, this._ignoreCargoCult = !!a, this._cacheHeuristic = r === void 0 ? .1 : r, this._immutableMinTtl = i === void 0 ? 864e5 : i, this._status = "status" in t ? t.status : 200, this._resHeaders = t.headers, this._rescc = l(t.headers["cache-control"]), this._method = "method" in e ? e.method : "GET", this._url = e.url, this._host = e.headers.host, this._noAuthorization = !e.headers.authorization, this._reqHeaders = t.headers.vary ? e.headers : null, this._reqcc = l(e.headers["cache-control"]), this._ignoreCargoCult && "pre-check" in this._rescc && "post-check" in this._rescc && (delete this._rescc["pre-check"], delete this._rescc["post-check"], delete this._rescc["no-cache"], delete this._rescc["no-store"], delete this._rescc["must-revalidate"], this._resHeaders = Object.assign({}, this._resHeaders, { "cache-control": u(this._rescc) }), delete this._resHeaders.expires, delete this._resHeaders.pragma), t.headers["cache-control"] == null && /no-cache/.test(t.headers.pragma) && (this._rescc["no-cache"] = !0);
}
now() {
return Date.now();
}
storable() {
return !!(!this._reqcc["no-store"] && (this._method === "GET" || this._method === "HEAD" || this._method === "POST" && this._hasExplicitExpiration()) && r.has(this._status) && !this._rescc["no-store"] && (!this._isShared || !this._rescc.private) && (!this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && (this._resHeaders.expires || this._rescc["max-age"] || this._isShared && this._rescc["s-maxage"] || this._rescc.public || n.has(this._status)));
}
_hasExplicitExpiration() {
return !!(this._isShared && this._rescc["s-maxage"] || this._rescc["max-age"] || this._resHeaders.expires);
}
_assertRequestHasHeaders(e) {
if (!e || !e.headers) throw Error("Request headers missing");
}
satisfiesWithoutRevalidation(e) {
return !this.evaluateRequest(e).revalidation;
}
_evaluateRequestHitResult(e) {
return {
response: { headers: this.responseHeaders() },
revalidation: e
};
}
_evaluateRequestRevalidation(e, t) {
return {
synchronous: t,
headers: this.revalidationHeaders(e)
};
}
_evaluateRequestMissResult(e) {
return {
response: void 0,
revalidation: this._evaluateRequestRevalidation(e, !0)
};
}
evaluateRequest(e) {
if (this._assertRequestHasHeaders(e), this._rescc["must-revalidate"] || !this._requestMatches(e, !1)) return this._evaluateRequestMissResult(e);
let t = l(e.headers["cache-control"]);
return t["no-cache"] || /no-cache/.test(e.headers.pragma) || t["max-age"] && this.age() > s(t["max-age"]) || t["min-fresh"] && this.maxAge() - this.age() < s(t["min-fresh"]) ? this._evaluateRequestMissResult(e) : this.stale() ? "max-stale" in t && (!0 === t["max-stale"] || t["max-stale"] > this.age() - this.maxAge()) ? this._evaluateRequestHitResult(void 0) : this.useStaleWhileRevalidate() ? this._evaluateRequestHitResult(this._evaluateRequestRevalidation(e, !1)) : this._evaluateRequestMissResult(e) : this._evaluateRequestHitResult(void 0);
}
_requestMatches(e, t) {
return !!((!this._url || this._url === e.url) && this._host === e.headers.host && (!e.method || this._method === e.method || t && e.method === "HEAD") && this._varyMatches(e));
}
_allowsStoringAuthenticated() {
return !!(this._rescc["must-revalidate"] || this._rescc.public || this._rescc["s-maxage"]);
}
_varyMatches(e) {
if (!this._resHeaders.vary) return !0;
if (this._resHeaders.vary === "*") return !1;
let t = this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);
for (let n of t) if (e.headers[n] !== this._reqHeaders[n]) return !1;
return !0;
}
_copyWithoutHopByHopHeaders(e) {
let t = {};
for (let n in e) a[n] || (t[n] = e[n]);
if (e.connection) {
let n = e.connection.trim().split(/\s*,\s*/);
for (let e of n) delete t[e];
}
if (t.warning) {
let e = t.warning.split(/,/).filter((e) => !/^\s*1[0-9][0-9]/.test(e));
e.length ? t.warning = e.join(",").trim() : delete t.warning;
}
return t;
}
responseHeaders() {
let e = this._copyWithoutHopByHopHeaders(this._resHeaders), t = this.age();
return t > 86400 && !this._hasExplicitExpiration() && this.maxAge() > 86400 && (e.warning = (e.warning ? `${e.warning}, ` : "") + "113 - \"rfc7234 5.5.4\""), e.age = `${Math.round(t)}`, e.date = new Date(this.now()).toUTCString(), e;
}
date() {
let e = Date.parse(this._resHeaders.date);
return isFinite(e) ? e : this._responseTime;
}
age() {
return this._ageValue() + (this.now() - this._responseTime) / 1e3;
}
_ageValue() {
return s(this._resHeaders.age);
}
maxAge() {
if (!this.storable() || this._rescc["no-cache"] || this._isShared && this._resHeaders["set-cookie"] && !this._rescc.public && !this._rescc.immutable || this._resHeaders.vary === "*") return 0;
if (this._isShared) {
if (this._rescc["proxy-revalidate"]) return 0;
if (this._rescc["s-maxage"]) return s(this._rescc["s-maxage"]);
}
if (this._rescc["max-age"]) return s(this._rescc["max-age"]);
let e = this._rescc.immutable ? this._immutableMinTtl : 0, t = this.date();
if (this._resHeaders.expires) {
let n = Date.parse(this._resHeaders.expires);
return Number.isNaN(n) || n < t ? 0 : Math.max(e, (n - t) / 1e3);
}
if (this._resHeaders["last-modified"]) {
let n = Date.parse(this._resHeaders["last-modified"]);
if (isFinite(n) && t > n) return Math.max(e, (t - n) / 1e3 * this._cacheHeuristic);
}
return e;
}
timeToLive() {
let e = this.maxAge() - this.age(), t = e + s(this._rescc["stale-if-error"]), n = e + s(this._rescc["stale-while-revalidate"]);
return Math.round(Math.max(0, e, t, n) * 1e3);
}
stale() {
return this.maxAge() <= this.age();
}
_useStaleIfError() {
return this.maxAge() + s(this._rescc["stale-if-error"]) > this.age();
}
useStaleWhileRevalidate() {
let e = s(this._rescc["stale-while-revalidate"]);
return e > 0 && this.maxAge() + e > this.age();
}
static fromObject(e) {
return new this(void 0, void 0, { _fromObject: e });
}
_fromObject(e) {
if (this._responseTime) throw Error("Reinitialized");
if (!e || e.v !== 1) throw Error("Invalid serialization");
this._responseTime = e.t, this._isShared = e.sh, this._cacheHeuristic = e.ch, this._immutableMinTtl = e.imm === void 0 ? 864e5 : e.imm, this._ignoreCargoCult = !!e.icc, this._status = e.st, this._resHeaders = e.resh, this._rescc = e.rescc, this._method = e.m, this._url = e.u, this._host = e.h, this._noAuthorization = e.a, this._reqHeaders = e.reqh, this._reqcc = e.reqcc;
}
toObject() {
return {
v: 1,
t: this._responseTime,
sh: this._isShared,
ch: this._cacheHeuristic,
imm: this._immutableMinTtl,
icc: this._ignoreCargoCult,
st: this._status,
resh: this._resHeaders,
rescc: this._rescc,
m: this._method,
u: this._url,
h: this._host,
a: this._noAuthorization,
reqh: this._reqHeaders,
reqcc: this._reqcc
};
}
revalidationHeaders(e) {
this._assertRequestHasHeaders(e);
let t = this._copyWithoutHopByHopHeaders(e.headers);
if (delete t["if-range"], !this._requestMatches(e, !0) || !this.storable()) return delete t["if-none-match"], delete t["if-modified-since"], t;
if (this._resHeaders.etag && (t["if-none-match"] = t["if-none-match"] ? `${t["if-none-match"]}, ${this._resHeaders.etag}` : this._resHeaders.etag), t["accept-ranges"] || t["if-match"] || t["if-unmodified-since"] || this._method && this._method != "GET") {
if (delete t["if-modified-since"], t["if-none-match"]) {
let e = t["if-none-match"].split(/,/).filter((e) => !/^\s*W\//.test(e));
e.length ? t["if-none-match"] = e.join(",").trim() : delete t["if-none-match"];
}
} else this._resHeaders["last-modified"] && !t["if-modified-since"] && (t["if-modified-since"] = this._resHeaders["last-modified"]);
return t;
}
revalidatedPolicy(e, t) {
if (this._assertRequestHasHeaders(e), this._useStaleIfError() && c(t)) return {
policy: this,
modified: !1,
matches: !0
};
if (!t || !t.headers) throw Error("Response headers missing");
let n = !1;
t.status !== void 0 && t.status != 304 ? n = !1 : t.headers.etag && !/^\s*W\//.test(t.headers.etag) ? n = this._resHeaders.etag && this._resHeaders.etag.replace(/^\s*W\//, "") === t.headers.etag : this._resHeaders.etag && t.headers.etag ? n = this._resHeaders.etag.replace(/^\s*W\//, "") === t.headers.etag.replace(/^\s*W\//, "") : this._resHeaders["last-modified"] ? n = this._resHeaders["last-modified"] === t.headers["last-modified"] : !this._resHeaders.etag && !this._resHeaders["last-modified"] && !t.headers.etag && !t.headers["last-modified"] && (n = !0);
let r = {
shared: this._isShared,
cacheHeuristic: this._cacheHeuristic,
immutableMinTimeToLive: this._immutableMinTtl,
ignoreCargoCult: this._ignoreCargoCult
};
if (!n) return {
policy: new this.constructor(e, t, r),
modified: t.status != 304,
matches: !1
};
let i = {};
for (let e in this._resHeaders) i[e] = e in t.headers && !o[e] ? t.headers[e] : this._resHeaders[e];
let a = Object.assign({}, t, {
status: this._status,
method: this._method,
headers: i
});
return {
policy: new this.constructor(e, a, r),
modified: !1,
matches: !0
};
}
};
})), je = /* @__PURE__ */ a(((e, t) => {
t.exports = s, t.exports.preferredCharsets = s;
var n = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
function r(e) {
for (var t = e.split(","), n = 0, r = 0; n < t.length; n++) {
var a = i(t[n].trim(), n);
a && (t[r++] = a);
}
return t.length = r, t;
}
function i(e, t) {
var r = n.exec(e);
if (!r) return null;
var i = r[1], a = 1;
if (r[2]) for (var o = r[2].split(";"), s = 0; s < o.length; s++) {
var c = o[s].trim().split("=");
if (c[0] === "q") {
a = parseFloat(c[1]);
break;
}
}
return {
charset: i,
q: a,
i: t
};
}
function a(e, t, n) {
for (var r = {
o: -1,
q: 0,
s: 0
}, i = 0; i < t.length; i++) {
var a = o(e, t[i], n);
a && (r.s - a.s || r.q - a.q || r.o - a.o) < 0 && (r = a);
}
return r;
}
function o(e, t, n) {
var r = 0;
if (t.charset.toLowerCase() === e.toLowerCase()) r |= 1;
else if (t.charset !== "*") return null;
return {
i: n,
o: t.i,
q: t.q,
s: r
};
}
function s(e, t) {
var n = r(e === void 0 ? "*" : e || "");
if (!t) return n.filter(u).sort(c).map(l);
var i = t.map(function(e, t) {
return a(e, n, t);
});
return i.filter(u).sort(c).map(function(e) {
return t[i.indexOf(e)];
});
}
function c(e, t) {
return t.q - e.q || t.s - e.s || e.o - t.o || e.i - t.i || 0;
}
function l(e) {
return e.charset;
}
function u(e) {
return e.q > 0;
}
})), Me = /* @__PURE__ */ a(((e, t) => {
t.exports = s, t.exports.preferredEncodings = s;
var n = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
function r(e) {
for (var t = e.split(","), n = !1, r = 1, a = 0, s = 0; a < t.length; a++) {
var c = i(t[a].trim(), a);
c && (t[s++] = c, n ||= o("identity", c), r = Math.min(r, c.q || 1));
}
return n || (t[s++] = {
encoding: "identity",
q: r,
i: a
}), t.length = s, t;
}
function i(e, t) {
var r = n.exec(e);
if (!r) return null;
var i = r[1], a = 1;
if (r[2]) for (var o = r[2].split(";"), s = 0; s < o.length; s++) {
var c = o[s].trim().split("=");
if (c[0] === "q") {
a = parseFloat(c[1]);
break;
}
}
return {
encoding: i,
q: a,
i: t
};
}
function a(e, t, n) {
for (var r = {
encoding: e,
o: -1,
q: 0,
s: 0
}, i = 0; i < t.length; i++) {
var a = o(e, t[i], n);
a && (r.s - a.s || r.q - a.q || r.o - a.o) < 0 && (r = a);
}
return r;
}
function o(e, t, n) {
var r = 0;
if (t.encoding.toLowerCase() === e.toLowerCase()) r |= 1;
else if (t.encoding !== "*") return null;
return {
encoding: e,
i: n,
o: t.i,
q: t.q,
s: r
};
}
function s(e, t, n) {
var i = r(e || ""), o = n ? function(e, t) {
if (e.q !== t.q) return t.q - e.q;
var r = n.indexOf(e.encoding), i = n.indexOf(t.encoding);
return r === -1 && i === -1 ? t.s - e.s || e.o - t.o || e.i - t.i : r !== -1 && i !== -1 ? r - i : r === -1 ? 1 : -1;
} : c;
if (!t) return i.filter(u).sort(o).map(l);
var s = t.map(function(e, t) {
return a(e, i, t);
});
return s.filter(u).sort(o).map(function(e) {
return t[s.indexOf(e)];
});
}
function c(e, t) {
return t.q - e.q || t.s - e.s || e.o - t.o || e.i - t.i;
}
function l(e) {
return e.encoding;
}
function u(e) {
return e.q > 0;
}
})), Ne = /* @__PURE__ */ a(((e, t) => {
t.exports = s, t.exports.preferredLanguages = s;
var n = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
function r(e) {
for (var t = e.split(","), n = 0, r = 0; n < t.length; n++) {
var a = i(t[n].trim(), n);
a && (t[r++] = a);
}
return t.length = r, t;
}
function i(e, t) {
var r = n.exec(e);
if (!r) return null;
var i = r[1], a = r[2], o = i;
a && (o += "-" + a);
var s = 1;
if (r[3]) for (var c = r[3].split(";"), l = 0; l < c.length; l++) {
var u = c[l].split("=");
u[0] === "q" && (s = parseFloat(u[1]));
}
return {
prefix: i,
suffix: a,
q: s,
i: t,
full: o
};
}
function a(e, t, n) {
for (var r = {
o: -1,
q: 0,
s: 0
}, i = 0; i < t.length; i++) {
var a = o(e, t[i], n);
a && (r.s - a.s || r.q - a.q || r.o - a.o) < 0 && (r = a);
}
return r;
}
function o(e, t, n) {
var r = i(e);
if (!r) return null;
var a = 0;
if (t.full.toLowerCase() === r.full.toLowerCase()) a |= 4;
else if (t.prefix.toLowerCase() === r.full.toLowerCase()) a |= 2;
else if (t.full.toLowerCase() === r.prefix.toLowerCase()) a |= 1;
else if (t.full !== "*") return null;
return {
i: n,
o: t.i,
q: t.q,
s: a
};
}
function s(e, t) {
var n = r(e === void 0 ? "*" : e || "");
if (!t) return n.filter(u).sort(c).map(l);
var i = t.map(function(e, t) {
return a(e, n, t);
});
return i.filter(u).sort(c).map(function(e) {
return t[i.indexOf(e)];
});
}
function c(e, t) {
return t.q - e.q || t.s - e.s || e.o - t.o || e.i - t.i || 0;
}
function l(e) {
return e.full;
}
function u(e) {
return e.q > 0;
}
})), Pe = /* @__PURE__ */ a(((e, t) => {
t.exports = s, t.exports.preferredMediaTypes = s;
var n = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
function r(e) {
for (var t = p(e), n = 0, r = 0; n < t.length; n++) {
var a = i(t[n].trim(), n);
a && (t[r++] = a);
}
return t.length = r, t;
}
function i(e, t) {
var r = n.exec(e);
if (!r) return null;
var i = Object.create(null), a = 1, o = r[2], s = r[1];
if (r[3]) for (var c = m(r[3]).map(f), l = 0; l < c.length; l++) {
var u = c[l], d = u[0].toLowerCase(), p = u[1], h = p && p[0] === "\"" && p[p.length - 1] === "\"" ? p.slice(1, -1) : p;
if (d === "q") {
a = parseFloat(h);
break;
}
i[d] = h;
}
return {
type: s,
subtype: o,
params: i,
q: a,
i: t
};
}
function a(e, t, n) {
for (var r = {
o: -1,
q: 0,
s: 0
}, i = 0; i < t.length; i++) {
var a = o(e, t[i], n);
a && (r.s - a.s || r.q - a.q || r.o - a.o) < 0 && (r = a);
}
return r;
}
function o(e, t, n) {
var r = i(e), a = 0;
if (!r) return null;
if (t.type.toLowerCase() == r.type.toLowerCase()) a |= 4;
else if (t.type != "*") return null;
if (t.subtype.toLowerCase() == r.subtype.toLowerCase()) a |= 2;
else if (t.subtype != "*") return null;
var o = Object.keys(t.params);
if (o.length > 0) {
if (o.every(function(e) {
return t.params[e] == "*" || (t.params[e] || "").toLowerCase() == (r.params[e] || "").toLowerCase();
})) a |= 1;
else return null;
}
return {
i: n,
o: t.i,
q: t.q,
s: a
};
}
function s(e, t) {
var n = r(e === void 0 ? "*/*" : e || "");
if (!t) return n.filter(u).sort(c).map(l);
var i = t.map(function(e, t) {
return a(e, n, t);
});
return i.filter(u).sort(c).map(function(e) {
return t[i.indexOf(e)];
});
}
function c(e, t) {
return t.q - e.q || t.s - e.s || e.o - t.o || e.i - t.i || 0;
}
function l(e) {
return e.type + "/" + e.subtype;
}
function u(e) {
return e.q > 0;
}
function d(e) {
for (var t = 0, n = 0; (n = e.indexOf("\"", n)) !== -1;) t++, n++;
return t;
}
function f(e) {
var t = e.indexOf("="), n, r;
return t === -1 ? n = e : (n = e.slice(0, t), r = e.slice(t + 1)), [n, r];
}
function p(e) {
for (var t = e.split(","), n = 1, r = 0; n < t.length; n++) d(t[r]) % 2 == 0 ? t[++r] = t[n] : t[r] += "," + t[n];
return t.length = r + 1, t;
}
function m(e) {
for (var t = e.split(";"), n = 1, r = 0; n < t.length; n++) d(t[r]) % 2 == 0 ? t[++r] = t[n] : t[r] += ";" + t[n];
t.length = r + 1;
for (var n = 0; n < t.length; n++) t[n] = t[n].trim();
return t;
}
})), Fe = /* @__PURE__ */ a(((e, t) => {
var n = je(), r = Me(), i = Ne(), a = Pe();
t.exports = o, t.exports.Negotiator = o;
function o(e) {
if (!(this instanceof o)) return new o(e);
this.request = e;
}
o.prototype.charset = function(e) {
var t = this.charsets(e);
return t && t[0];
}, o.prototype.charsets = function(e) {
return n(this.request.headers["accept-charset"], e);
}, o.prototype.encoding = function(e, t) {
var n = this.encodings(e, t);
return n && n[0];
}, o.prototype.encodings = function(e, t) {
var n = t || {};
return r(this.request.headers["accept-encoding"], e, n.preferred);
}, o.prototype.language = function(e) {
var t = this.languages(e);
return t && t[0];
}, o.prototype.languages = function(e) {
return i(this.request.headers["accept-language"], e);
}, o.prototype.mediaType = function(e) {
var t = this.mediaTypes(e);
return t && t[0];
}, o.prototype.mediaTypes = function(e) {
return a(this.request.headers.accept, e);
}, o.prototype.preferredCharset = o.prototype.charset, o.prototype.preferredCharsets = o.prototype.charsets, o.prototype.preferredEncoding = o.prototype.encoding, o.prototype.preferredEncodings = o.prototype.encodings, o.prototype.preferredLanguage = o.prototype.language, o.prototype.preferredLanguages = o.prototype.languages, o.prototype.preferredMediaType = o.prototype.mediaType, o.prototype.preferredMediaTypes = o.prototype.mediaTypes;
})), Z = /* @__PURE__ */ a(((e, n) => {
var r = t("crypto"), { Minipass: i } = y(), a = [
"sha512",
"sha384",
"sha256"
], o = ["sha512"], s = r.getHashes(), c = /^[a-z0-9+/]+(?:=?=?)$/i, l = /^([a-z0-9]+)-([^?]+)(\?[?\S*]*)?$/, u = /^([a-z0-9]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)?$/, d = /^[\x21-\x7E]+$/, f = [
"md5",
"whirlpool",
"sha1",
"sha224",
"sha256",
"sha384",
"sha512",
"sha3",
"sha3-256",
"sha3-384",
"sha3-512",
"sha3_256",
"sha3_384",
"sha3_512"
].filter((e) => s.includes(e)), p = (e) => e?.length ? `?${e.join("?")}` : "", m = class extends i {
#e;
#t;
#n;
constructor(e) {
super(), this.size = 0, this.opts = e, this.#r(), this.algorithms = e?.algorithms ? [...e.algorithms] : [...o], this.algorithm !== null && !this.algorithms.includes(this.algorithm) && this.algorithms.push(this.algorithm), this.hashes = this.algorithms.map(r.createHash);
}
#r() {
this.sri = this.opts?.integrity ? v(this.opts?.integrity, this.opts) : null, this.expectedSize = this.opts?.size, this.sri ? this.sri.isHash ? (this.goodSri = !0, this.algorithm = this.sri.algorithm) : (this.goodSri = !this.sri.isEmpty(), this.algorithm = this.sri.pickAlgorithm(this.opts)) : this.algorithm = null, this.digests = this.goodSri ? this.sri[this.algorithm] : null, this.optString = p(this.opts?.options);
}
on(e, t) {
return e === "size" && this.#t ? t(this.#t) : e === "integrity" && this.#e ? t(this.#e) : e === "verified" && this.#n ? t(this.#n) : super.on(e, t);
}
emit(e, t) {
return e === "end" && this.#i(), super.emit(e, t);
}
write(e) {
return this.size += e.length, this.hashes.forEach((t) => t.update(e)), super.write(e);
}
#i() {
this.goodSri || this.#r();
let e = v(this.hashes.map((e, t) => `${this.algorithms[t]}-${e.digest("base64")}${this.optString}`).join(" "), this.opts), t = this.goodSri && e.match(this.sri, this.opts);
if (typeof this.expectedSize == "number" && this.size !== this.expectedSize) {
let e = /* @__PURE__ */ Error(`stream size mismatch when checking ${this.sri}.\n Wanted: ${this.expectedSize}\n Found: ${this.size}`);
e.code = "EBADSIZE", e.found = this.size, e.expected = this.expectedSize, e.sri = this.sri, this.emit("error", e);
} else if (this.sri && !t) {
let t = /* @__PURE__ */ Error(`${this.sri} integrity checksum failed when using ${this.algorithm}: wanted ${this.digests} but got ${e}. (${this.size} bytes)`);
t.code = "EINTEGRITY", t.found = e, t.expected = this.digests, t.algorithm = this.algorithm, t.sri = this.sri, this.emit("error", t);
} else this.#t = this.size, this.emit("size", this.size), this.#e = e, this.emit("integrity", e), t && (this.#n = t, this.emit("verified", t));
}
}, h = class {
get isHash() {
return !0;
}
constructor(e, t) {
let n = t?.strict;
this.source = e.trim(), this.digest = "", this.algorithm = "", this.options = [];
let r = this.source.match(n ? u : l);
if (!r || n && !a.includes(r[1]) || !s.includes(r[1])) return;
this.algorithm = r[1], this.digest = r[2];
let i = r[3];
i && (this.options = i.slice(1).split("?"));
}
hexDigest() {
return this.digest && Buffer.from(this.digest, "base64").toString("hex");
}
toJSON() {
return this.toString();
}
match(e, t) {
let n = v(e, t);
if (!n) return !1;
if (n.isIntegrity) {
let e = n.pickAlgorithm(t, [this.algorithm]);
return e && n[e].find((e) => e.digest === this.digest) || !1;
}
return n.digest === this.digest && n;
}
toString(e) {
return e?.strict && !(a.includes(this.algorithm) && this.digest.match(c) && this.options.every((e) => e.match(d))) ? "" : `${this.algorithm}-${this.digest}${p(this.options)}`;
}
};
function g(e, t, n, r) {
let i = e !== "", a = !1, o = "", s = r.length - 1;
for (let e = 0; e < s; e++) {
let i = h.prototype.toString.call(r[e], n);
i && (a = !0, o += i, o += t);
}
let c = h.prototype.toString.call(r[s], n);
return c && (a = !0, o += c), i && a ? e + t + o : e + o;
}
var _ = class {
get isIntegrity() {
return !0;
}
toJSON() {
return this.toString();
}
isEmpty() {
return Object.keys(this).length === 0;
}
toString(e) {
let t = e?.sep || " ", n = "";
if (e?.strict) {
t = t.replace(/\S+/g, " ");
for (let r of a) this[r] && (n = g(n, t, e, this[r]));
} else for (let r of Object.keys(this)) n = g(n, t, e, this[r]);
return n;
}
concat(e, t) {
let n = typeof e == "string" ? e : x(e, t);
return v(`${this.toString(t)} ${n}`, t);
}
hexDigest() {
return v(this, { single: !0 }).hexDigest();
}
merge(e, t) {
let n = v(e, t);
for (let e in n) if (this[e]) {
if (!this[e].find((t) => n[e].find((e) => t.digest === e.digest))) throw Error("hashes do not match, cannot update integrity");
} else this[e] = n[e];
}
match(e, t) {
let n = v(e, t);
if (!n) return !1;
let r = n.pickAlgorithm(t, Object.keys(this));
return !!r && this[r].find((e) => n[r].find((t) => e.digest === t.digest)) || !1;
}
pickAlgorithm(e, t) {
let n = e?.pickAlgorithm || k, r = Object.keys(this);
return t?.length && (r = r.filter((e) => t.includes(e))), r.length ? r.reduce((e, t) => n(e, t) || e) : null;
}
};
n.exports.parse = v;
function v(e, t) {
if (!e) return null;
if (typeof e == "string") return b(e, t);
if (e.algorithm && e.digest) {
let n = new _();
return n[e.algorithm] = [e], b(x(n, t), t);
}
return b(x(e, t), t);
}
function b(e, t) {
if (t?.single) return new h(e, t);
let n = e.trim().split(/\s+/).reduce((e, n) => {
let r = new h(n, t);
if (r.algorithm && r.digest) {
let t = r.algorithm;
Object.keys(e).includes(t) || (e[t] = []), e[t].push(r);
}
return e;
}, new _());
return n.isEmpty() ? null : n;
}
n.exports.stringify = x;
function x(e, t) {
return e.algorithm && e.digest ? h.prototype.toString.call(e, t) : typeof e == "string" ? x(v(e, t), t) : _.prototype.toString.call(e, t);
}
n.exports.fromHex = S;
function S(e, t, n) {
let r = p(n?.options);
return v(`${t}-${Buffer.from(e, "hex").toString("base64")}${r}`, n);
}
n.exports.fromData = C;
function C(e, t) {
let n = t?.algorithms || [...o], i = p(t?.options);
return n.reduce((n, a) => {
let o = new h(`${a}-${r.createHash(a).update(e).digest("base64")}${i}`, t);
// istanbul ignore else - it would be VERY strange if the string we just calculated with an algo did not have an algo or digest.
if (o.algorithm && o.digest) {
let e = o.algorithm;
n[e] || (n[e] = []), n[e].push(o);
}
return n;
}, new _());
}
n.exports.fromStream = w;
function w(e, t) {
let n = D(t);
return new Promise((t, r) => {
e.pipe(n), e.on("error", r), n.on("error", r);
let i;
n.on("integrity", (e) => {
i = e;
}), n.on("end", () => t(i)), n.resume();
});
}
n.exports.checkData = T;
function T(e, t, n) {
if (t = v(t, n), !t || !Object.keys(t).length) {
if (n?.error) throw Object.assign(/* @__PURE__ */ Error("No valid integrity hashes to check against"), { code: "EINTEGRITY" });
return !1;
}
let i = t.pickAlgorithm(n), a = v({
algorithm: i,
digest: r.createHash(i).update(e).digest("base64")
}), o = a.match(t, n);
if (n ||= {}, o || !n.error) return o;
if (typeof n.size == "number" && e.length !== n.size) {
let r = /* @__PURE__ */ Error(`data size mismatch when checking ${t}.\n Wanted: ${n.size}\n Found: ${e.length}`);
throw r.code = "EBADSIZE", r.found = e.length, r.expected = n.size, r.sri = t, r;
}
{
let n = /* @__PURE__ */ Error(`Integrity checksum failed when using ${i}: Wanted ${t}, but got ${a}. (${e.length} bytes)`);
throw n.code = "EINTEGRITY", n.found = a, n.expected = t, n.algorithm = i, n.sri = t, n;
}
}
n.exports.checkStream = E;
function E(e, t, n) {
if (n ||= Object.create(null), n.integrity = t, t = v(t, n), !t || !Object.keys(t).length) return Promise.reject(Object.assign(/* @__PURE__ */ Error("No valid integrity hashes to check against"), { code: "EINTEGRITY" }));
let r = D(n);
return new Promise((t, n) => {
e.pipe(r), e.on("error", n), r.on("error", n);
let i;
r.on("verified", (e) => {
i = e;
}), r.on("end", () => t(i)), r.resume();
});
}
n.exports.integrityStream = D;
function D(e = Object.create(null)) {
return new m(e);
}
n.exports.create = O;
function O(e) {
let t = e?.algorithms || [...o], n = p(e?.options), i = t.map(r.createHash);
return {
update: function(e, t) {
return i.forEach((n) => n.update(e, t)), this;
},
digest: function() {
return t.reduce((t, r) => {
let a = new h(`${r}-${i.shift().digest("base64")}${n}`, e);
return t[a.algorithm] || (t[a.algorithm] = []), t[a.algorithm].push(a), t;
}, new _());
}
};
}
function k(e, t) {
return f.indexOf(e.toLowerCase()) >= f.indexOf(t.toLowerCase()) ? e : t;
}
})), Ie = /* @__PURE__ */ a(((e, t) => {
var n = Ae(), r = Fe(), i = Z(), a = {
shared: !1,
ignoreCargoCult: !0
}, o = {
status: 200,
headers: {}
}, s = (e) => {
let t = {
method: e.method,
url: e.url,
headers: {},
compress: e.compress
};
return e.headers.forEach((e, n) => {
t.headers[n] = e;
}), t;
}, c = (e) => {
let t = {
status: e.status,
headers: {}
};
return e.headers.forEach((e, n) => {
t.headers[n] = e;
}), t;
};
t.exports = class {
constructor({ entry: e, request: t, response: r, options: i }) {
this.entry = e, this.request = s(t), this.response = c(r), this.options = i, this.policy = new n(this.request, this.response, a), this.entry && (this.policy._responseTime = this.entry.metadata.time);
}
static storable(e, t) {
return !t.cachePath || t.cache === "no-store" || !["GET", "HEAD"].includes(e.method) ? !1 : new n(s(e), o, a).storable();
}
satisfies(e) {
let t = s(e);
if (this.request.headers.host !== t.headers.host || this.request.compress !== t.compress) return !1;
let n = new r(this.request), a = new r(t);
return JSON.stringify(n.mediaTypes()) !== JSON.stringify(a.mediaTypes()) || JSON.stringify(n.languages()) !== JSON.stringify(a.languages()) || JSON.stringify(n.encodings()) !== JSON.stringify(a.encodings()) ? !1 : !this.options.integrity || i.parse(this.options.integrity).match(this.entry.integrity);
}
storable() {
return this.policy.storable();
}
get mustRevalidate() {
return !!this.policy._rescc["must-revalidate"];
}
needsRevalidation(e) {
let t = s(e);
return t.method = "GET", !this.policy.satisfiesWithoutRevalidation(t);
}
responseHeaders() {
return this.policy.responseHeaders();
}
revalidationHeaders(e) {
let t = s(e);
return this.policy.revalidationHeaders(t);
}
revalidated(e, t) {
let n = s(e), r = c(t);
return !this.policy.revalidatedPolicy(n, r).modified;
}
};
})), Le = /* @__PURE__ */ a(((e, t) => {
t.exports = { NotCachedError: class extends Error {
constructor(e) {
super(`request to ${e} failed: cache mode is 'only-if-cached' but no cached response is available.`), this.code = "ENOTCACHED";
}
} };
})), Re = /* @__PURE__ */ a(((e, n) => {
var r = typeof process == "object" && process ? process : {
stdout: null,
stderr: null
}, i = t("events"), a = t("stream"), o = t("string_decoder").StringDecoder, s = Symbol("EOF"), c = Symbol("maybeEmitEnd"), l = Symbol("emittedEnd"), u = Symbol("emittingEnd"), d = Symbol("emittedError"), f = Symbol("closed"), p = Symbol("read"), m = Symbol("flush"), h = Symbol("flushChunk"), g = Symbol("encoding"), _ = Symbol("decoder"), v = Symbol("flowing"), y = Symbol("paused"), b = Symbol("resume"), x = Symbol("bufferLength"), S = Symbol("bufferPush"), C = Symbol("bufferShift"), w = Symbol("objectMode"), T = Symbol("destroyed"), E = Symbol("emitData"), D = Symbol("emitEnd"), O = Symbol("emitEnd2"), k = Symbol("async"), A = (e) => Promise.resolve().then(e), j = global._MP_NO_ITERATOR_SYMBOLS_ !== "1", M = j && Symbol.asyncIterator || Symbol("asyncIterator not implemented"), N = j && Symbol.iterator || Symbol("iterator not implemented"), P = (e) => e === "end" || e === "finish" || e === "prefinish", F = (e) => e instanceof ArrayBuffer || typeof e == "object" && e.constructor && e.constructor.name === "ArrayBuffer" && e.byteLength >= 0, I = (e) => !Buffer.isBuffer(e) && ArrayBuffer.isView(e), L = class {
constructor(e, t, n) {
this.src = e, this.dest = t, this.opts = n, this.ondrain = () => e[b](), t.on("drain", this.ondrain);
}
unpipe() {
this.dest.removeListener("drain", this.ondrain);
}
// istanbul ignore next - only here for the prototype
proxyErrors() {}
end() {
this.unpipe(), this.opts.end && this.dest.end();
}
}, R = class extends L {
unpipe() {
this.src.removeListener("error", this.proxyErrors), super.unpipe();
}
constructor(e, t, n) {
super(e, t, n), this.proxyErrors = (e) => t.emit("error", e), e.on("error", this.proxyErrors);
}
};
n.exports = class e extends a {
constructor(e) {
super(), this[v] = !1, this[y] = !1, this.pipes = [], this.buffer = [], this[w] = e && e.objectMode || !1, this[g] = this[w] ? null : e && e.encoding || null, this[g] === "buffer" && (this[g] = null), this[k] = e && !!e.async || !1, this[_] = this[g] ? new o(this[g]) : null, this[s] = !1, this[l] = !1, this[u] = !1, this[f] = !1, this[d] = null, this.writable = !0, this.readable = !0, this[x] = 0, this[T] = !1;
}
get bufferLength() {
return this[x];
}
get encoding() {
return this[g];
}
set encoding(e) {
if (this[w]) throw Error("cannot set encoding in objectMode");
if (this[g] && e !== this[g] && (this[_] && this[_].lastNeed || this[x])) throw Error("cannot change encoding");
this[g] !== e && (this[_] = e ? new o(e) : null, this.buffer.length && (this.buffer = this.buffer.map((e) => this[_].write(e)))), this[g] = e;
}
setEncoding(e) {
this.encoding = e;
}
get objectMode() {
return this[w];
}
set objectMode(e) {
this[w] = this[w] || !!e;
}
get async() {
return this[k];
}
set async(e) {
this[k] = this[k] || !!e;
}
write(e, t, n) {
if (this[s]) throw Error("write after end");
if (this[T]) return this.emit("error", Object.assign(/* @__PURE__ */ Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
typeof t == "function" && (n = t, t = "utf8"), t ||= "utf8";
let r = this[k] ? A : (e) => e();
return !this[w] && !Buffer.isBuffer(e) && (I(e) ? e = Buffer.from(e.buffer, e.byteOffset, e.byteLength) : F(e) ? e = Buffer.from(e) : typeof e != "string" && (this.objectMode = !0)), this[w] ?
/* istanbul ignore if - maybe impossible? */
(this.flowing && this[x] !== 0 && this[m](!0), this.flowing ? this.emit("data", e) : this[S](e), this[x] !== 0 && this.emit("readable"), n && r(n), this.flowing) : e.length ? (typeof e == "string" && !(t === this[g] && !this[_].lastNeed) && (e = Buffer.from(e, t)), Buffer.isBuffer(e) && this[g] && (e = this[_].write(e)), this.flowing && this[x] !== 0 && this[m](!0), this.flowing ? this.emit("data", e) : this[S](e), this[x] !== 0 && this.emit("readable"), n && r(n), this.flowing) : (this[x] !== 0 && this.emit("readable"), n && r(n), this.flowing);
}
read(e) {
if (this[T]) return null;
if (this[x] === 0 || e === 0 || e > this[x]) return this[c](), null;
this[w] && (e = null), this.buffer.length > 1 && !this[w] && (this.buffer = this.encoding ? [this.buffer.join("")] : [Buffer.concat(this.buffer, this[x])]);
let t = this[p](e || null, this.buffer[0]);
return this[c](), t;
}
[p](e, t) {
return e === t.length || e === null ? this[C]() : (this.buffer[0] = t.slice(e), t = t.slice(0, e), this[x] -= e), this.emit("data", t), !this.buffer.length && !this[s] && this.emit("drain"), t;
}
end(e, t, n) {
return typeof e == "function" && (n = e, e = null), typeof t == "function" && (n = t, t = "utf8"), e && this.write(e, t), n && this.once("end", n), this[s] = !0, this.writable = !1, (this.flowing || !this[y]) && this[c](), this;
}
[b]() {
this[T] || (this[y] = !1, this[v] = !0, this.emit("resume"), this.buffer.length ? this[m]() : this[s] ? this[c]() : this.emit("drain"));
}
resume() {
return this[b]();
}
pause() {
this[v] = !1, this[y] = !0;
}
get destroyed() {
return this[T];
}
get flowing() {
return this[v];
}
get paused() {
return this[y];
}
[S](e) {
this[w] ? this[x] += 1 : this[x] += e.length, this.buffer.push(e);
}
[C]() {
return this.buffer.length && (this[w] ? --this[x] : this[x] -= this.buffer[0].length), this.buffer.shift();
}
[m](e) {
do ;
while (this[h](this[C]()));
!e && !this.buffer.length && !this[s] && this.emit("drain");
}
[h](e) {
return e ? (this.emit("data", e), this.flowing) : !1;
}
pipe(e, t) {
if (this[T]) return;
let n = this[l];
return t ||= {}, e === r.stdout || e === r.stderr ? t.end = !1 : t.end = t.end !== !1, t.proxyErrors = !!t.proxyErrors, n ? t.end && e.end() : (this.pipes.push(t.proxyErrors ? new R(this, e, t) : new L(this, e, t)), this[k] ? A(() => this[b]()) : this[b]()), e;
}
unpipe(e) {
let t = this.pipes.find((t) => t.dest === e);
t && (this.pipes.splice(this.pipes.indexOf(t), 1), t.unpipe());
}
addListener(e, t) {
return this.on(e, t);
}
on(e, t) {
let n = super.on(e, t);
return e === "data" && !this.pipes.length && !this.flowing ? this[b]() : e === "readable" && this[x] !== 0 ? super.emit("readable") : P(e) && this[l] ? (super.emit(e), this.removeAllListeners(e)) : e === "error" && this[d] && (this[k] ? A(() => t.call(this, this[d])) : t.call(this, this[d])), n;
}
get emittedEnd() {
return this[l];
}
[c]() {
!this[u] && !this[l] && !this[T] && this.buffer.length === 0 && this[s] && (this[u] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[f] && this.emit("close"), this[u] = !1);
}
emit(e, t, ...n) {
if (e !== "error" && e !== "close" && e !== T && this[T]) return;
if (e === "data") return t ? this[k] ? A(() => this[E](t)) : this[E](t) : !1;
if (e === "end") return this[D]();
if (e === "close") {
if (this[f] = !0, !this[l] && !this[T]) return;
let e = super.emit("close");
return this.removeAllListeners("close"), e;
}
if (e === "error") {
this[d] = t;
let e = super.emit("error", t);
return this[c](), e;
}
if (e === "resume") {
let e = super.emit("resume");
return this[c](), e;
}
if (e === "finish" || e === "prefinish") {
let t = super.emit(e);
return this.removeAllListeners(e), t;
}
let r = super.emit(e, t, ...n);
return this[c](), r;
}
[E](e) {
for (let t of this.pipes) t.dest.write(e) === !1 && this.pause();
let t = super.emit("data", e);
return this[c](), t;
}
[D]() {
this[l] || (this[l] = !0, this.readable = !1, this[k] ? A(() => this[O]()) : this[O]());
}
[O]() {
if (this[_]) {
let e = this[_].end();
if (e) {
for (let t of this.pipes) t.dest.write(e);
super.emit("data", e);
}
}
for (let e of this.pipes) e.end();
let e = super.emit("end");
return this.removeAllListeners("end"), e;
}
collect() {
let e = [];
this[w] || (e.dataLength = 0);
let t = this.promise();
return this.on("data", (t) => {
e.push(t), this[w] || (e.dataLength += t.length);
}), t.then(() => e);
}
concat() {
return this[w] ? Promise.reject(/* @__PURE__ */ Error("cannot concat in objectMode")) : this.collect().then((e) => this[w] ? Promise.reject(/* @__PURE__ */ Error("cannot concat in objectMode")) : this[g] ? e.join("") : Buffer.concat(e, e.dataLength));
}
promise() {
return new Promise((e, t) => {
this.on(T, () => t(/* @__PURE__ */ Error("stream destroyed"))), this.on("error", (e) => t(e)), this.on("end", () => e());
});
}
[M]() {
return { next: () => {
let e = this.read();
if (e !== null) return Promise.resolve({
done: !1,
value: e
});
if (this[s]) return Promise.resolve({ done: !0 });
let t = null, n = null, r = (e) => {
this.removeListener("data", i), this.removeListener("end", a), n(e);
}, i = (e) => {
this.removeListener("error", r), this.removeListener("end", a), this.pause(), t({
value: e,
done: !!this[s]
});
}, a = () => {
this.removeListener("error", r), this.removeListener("data", i), t({ done: !0 });
}, o = () => r(/* @__PURE__ */ Error("stream destroyed"));
return new Promise((e, s) => {
n = s, t = e, this.once(T, o), this.once("error", r), this.once("end", a), this.once("data", i);
});
} };
}
[N]() {
return { next: () => {
let e = this.read();
return {
value: e,
done: e === null
};
} };
}
destroy(e) {
return this[T] ? (e ? this.emit("error", e) : this.emit(T), this) : (this[T] = !0, this.buffer.length = 0, this[x] = 0, typeof this.close == "function" && !this[f] && this.close(), e ? this.emit("error", e) : this.emit(T), this);
}
static isStream(t) {
return !!t && (t instanceof e || t instanceof a || t instanceof i && (typeof t.pipe == "function" || typeof t.write == "function" && typeof t.end == "function"));
}
};
})), ze = /* @__PURE__ */ a(((e, t) => {
var n = Re(), r = Symbol("_flush"), i = Symbol("_flushed"), a = Symbol("_flushing");
t.exports = class extends n {
constructor(e = {}) {
if (typeof e == "function" && (e = { flush: e }), super(e), typeof e.flush != "function" && typeof this.flush != "function") throw TypeError("must provide flush function in options");
this[r] = e.flush || this.flush;
}
emit(e, ...t) {
if (e !== "end" && e !== "finish" || this[i]) return super.emit(e, ...t);
if (this[a]) return;
this[a] = !0;
let n = (e) => {
this[i] = !0, e ? super.emit("error", e) : super.emit("end");
}, o = this[r](n);
o && o.then && o.then(() => n(), (e) => n(e));
}
};
})), Be = /* @__PURE__ */ a(((e, t) => {
var { Minipass: n } = y(), r = Symbol("_data"), i = Symbol("_length");
t.exports = class extends n {
constructor(e) {
super(e), this[r] = [], this[i] = 0;
}
write(e, t, n) {
typeof t == "function" && (n = t, t = "utf8"), t ||= "utf8";
let a = Buffer.isBuffer(e) ? e : Buffer.from(e, t);
return this[r].push(a), this[i] += a.length, n && n(), !0;
}
end(e, t, n) {
typeof e == "function" && (n = e, e = null), typeof t == "function" && (n = t, t = "utf8"), e && this.write(e, t);
let a = Buffer.concat(this[r], this[i]);
return super.write(a), super.end(n);
}
};
var a = class extends n {
constructor(e) {
super(e), this[r] = [], this[i] = 0;
}
write(e, t, n) {
typeof t == "function" && (n = t, t = "utf8"), t ||= "utf8";
let a = Buffer.isBuffer(e) ? e : Buffer.from(e, t);
return this[r].push(a), this[i] += a.length, super.write(e, t, n);
}
end(e, t, n) {
typeof e == "function" && (n = e, e = null), typeof t == "function" && (n = t, t = "utf8"), e && this.write(e, t);
let a = Buffer.concat(this[r], this[i]);
return this.emit("collect", a), super.end(n);
}
};
t.exports.PassThrough = a;
})), Ve = /* @__PURE__ */ a(((e, n) => {
var r = typeof process == "object" && process ? process : {
stdout: null,
stderr: null
}, i = t("events"), a = t("stream"), o = t("string_decoder").StringDecoder, s = Symbol("EOF"), c = Symbol("maybeEmitEnd"), l = Symbol("emittedEnd"), u = Symbol("emittingEnd"), d = Symbol("emittedError"), f = Symbol("closed"), p = Symbol("read"), m = Symbol("flush"), h = Symbol("flushChunk"), g = Symbol("encoding"), _ = Symbol("decoder"), v = Symbol("flowing"), y = Symbol("paused"), b = Symbol("resume"), x = Symbol("bufferLength"), S = Symbol("bufferPush"), C = Symbol("bufferShift"), w = Symbol("objectMode"), T = Symbol("destroyed"), E = Symbol("emitData"), D = Symbol("emitEnd"), O = Symbol("emitEnd2"), k = Symbol("async"), A = (e) => Promise.resolve().then(e), j = global._MP_NO_ITERATOR_SYMBOLS_ !== "1", M = j && Symbol.asyncIterator || Symbol("asyncIterator not implemented"), N = j && Symbol.iterator || Symbol("iterator not implemented"), P = (e) => e === "end" || e === "finish" || e === "prefinish", F = (e) => e instanceof ArrayBuffer || typeof e == "object" && e.constructor && e.constructor.name === "ArrayBuffer" && e.byteLength >= 0, I = (e) => !Buffer.isBuffer(e) && ArrayBuffer.isView(e), L = class {
constructor(e, t, n) {
this.src = e, this.dest = t, this.opts = n, this.ondrain = () => e[b](), t.on("drain", this.ondrain);
}
unpipe() {
this.dest.removeListener("drain", this.ondrain);
}
// istanbul ignore next - only here for the prototype
proxyErrors() {}
end() {
this.unpipe(), this.opts.end && this.dest.end();
}
}, R = class extends L {
unpipe() {
this.src.removeListener("error", this.proxyErrors), super.unpipe();
}
constructor(e, t, n) {
super(e, t, n), this.proxyErrors = (e) => t.emit("error", e), e.on("error", this.proxyErrors);
}
};
n.exports = class e extends a {
constructor(e) {
super(), this[v] = !1, this[y] = !1, this.pipes = [], this.buffer = [], this[w] = e && e.objectMode || !1, this[g] = this[w] ? null : e && e.encoding || null, this[g] === "buffer" && (this[g] = null), this[k] = e && !!e.async || !1, this[_] = this[g] ? new o(this[g]) : null, this[s] = !1, this[l] = !1, this[u] = !1, this[f] = !1, this[d] = null, this.writable = !0, this.readable = !0, this[x] = 0, this[T] = !1;
}
get bufferLength() {
return this[x];
}
get encoding() {
return this[g];
}
set encoding(e) {
if (this[w]) throw Error("cannot set encoding in objectMode");
if (this[g] && e !== this[g] && (this[_] && this[_].lastNeed || this[x])) throw Error("cannot change encoding");
this[g] !== e && (this[_] = e ? new o(e) : null, this.buffer.length && (this.buffer = this.buffer.map((e) => this[_].write(e)))), this[g] = e;
}
setEncoding(e) {
this.encoding = e;
}
get objectMode() {
return this[w];
}
set objectMode(e) {
this[w] = this[w] || !!e;
}
get async() {
return this[k];
}
set async(e) {
this[k] = this[k] || !!e;
}
write(e, t, n) {
if (this[s]) throw Error("write after end");
if (this[T]) return this.emit("error", Object.assign(/* @__PURE__ */ Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
typeof t == "function" && (n = t, t = "utf8"), t ||= "utf8";
let r = this[k] ? A : (e) => e();
return !this[w] && !Buffer.isBuffer(e) && (I(e) ? e = Buffer.from(e.buffer, e.byteOffset, e.byteLength) : F(e) ? e = Buffer.from(e) : typeof e != "string" && (this.objectMode = !0)), this[w] ?
/* istanbul ignore if - maybe impossible? */
(this.flowing && this[x] !== 0 && this[m](!0), this.flowing ? this.emit("data", e) : this[S](e), this[x] !== 0 && this.emit("readable"), n && r(n), this.flowing) : e.length ? (typeof e == "string" && !(t === this[g] && !this[_].lastNeed) && (e = Buffer.from(e, t)), Buffer.isBuffer(e) && this[g] && (e = this[_].write(e)), this.flowing && this[x] !== 0 && this[m](!0), this.flowing ? this.emit("data", e) : this[S](e), this[x] !== 0 && this.emit("readable"), n && r(n), this.flowing) : (this[x] !== 0 && this.emit("readable"), n && r(n), this.flowing);
}
read(e) {
if (this[T]) return null;
if (this[x] === 0 || e === 0 || e > this[x]) return this[c](), null;
this[w] && (e = null), this.buffer.length > 1 && !this[w] && (this.buffer = this.encoding ? [this.buffer.join("")] : [Buffer.concat(this.buffer, this[x])]);
let t = this[p](e || null, this.buffer[0]);
return this[c](), t;
}
[p](e, t) {
return e === t.length || e === null ? this[C]() : (this.buffer[0] = t.slice(e), t = t.slice(0, e), this[x] -= e), this.emit("data", t), !this.buffer.length && !this[s] && this.emit("drain"), t;
}
end(e, t, n) {
return typeof e == "function" && (n = e, e = null), typeof t == "function" && (n = t, t = "utf8"), e && this.write(e, t), n && this.once("end", n), this[s] = !0, this.writable = !1, (this.flowing || !this[y]) && this[c](), this;
}
[b]() {
this[T] || (this[y] = !1, this[v] = !0, this.emit("resume"), this.buffer.length ? this[m]() : this[s] ? this[c]() : this.emit("drain"));
}
resume() {
return this[b]();
}
pause() {
this[v] = !1, this[y] = !0;
}
get destroyed() {
return this[T];
}
get flowing() {
return this[v];
}
get paused() {
return this[y];
}
[S](e) {
this[w] ? this[x] += 1 : this[x] += e.length, this.buffer.push(e);
}
[C]() {
return this.buffer.length && (this[w] ? --this[x] : this[x] -= this.buffer[0].length), this.buffer.shift();
}
[m](e) {
do ;
while (this[h](this[C]()));
!e && !this.buffer.length && !this[s] && this.emit("drain");
}
[h](e) {
return e ? (this.emit("data", e), this.flowing) : !1;
}
pipe(e, t) {
if (this[T]) return;
let n = this[l];
return t ||= {}, e === r.stdout || e === r.stderr ? t.end = !1 : t.end = t.end !== !1, t.proxyErrors = !!t.proxyErrors, n ? t.end && e.end() : (this.pipes.push(t.proxyErrors ? new R(this, e, t) : new L(this, e, t)), this[k] ? A(() => this[b]()) : this[b]()), e;
}
unpipe(e) {
let t = this.pipes.find((t) => t.dest === e);
t && (this.pipes.splice(this.pipes.indexOf(t), 1), t.unpipe());
}
addListener(e, t) {
return this.on(e, t);
}
on(e, t) {
let n = super.on(e, t);
return e === "data" && !this.pipes.length && !this.flowing ? this[b]() : e === "readable" && this[x] !== 0 ? super.emit("readable") : P(e) && this[l] ? (super.emit(e), this.removeAllListeners(e)) : e === "error" && this[d] && (this[k] ? A(() => t.call(this, this[d])) : t.call(this, this[d])), n;
}
get emittedEnd() {
return this[l];
}
[c]() {
!this[u] && !this[l] && !this[T] && this.buffer.length === 0 && this[s] && (this[u] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[f] && this.emit("close"), this[u] = !1);
}
emit(e, t, ...n) {
if (e !== "error" && e !== "close" && e !== T && this[T]) return;
if (e === "data") return t ? this[k] ? A(() => this[E](t)) : this[E](t) : !1;
if (e === "end") return this[D]();
if (e === "close") {
if (this[f] = !0, !this[l] && !this[T]) return;
let e = super.emit("close");
return this.removeAllListeners("close"), e;
}
if (e === "error") {
this[d] = t;
let e = super.emit("error", t);
return this[c](), e;
}
if (e === "resume") {
let e = super.emit("resume");
return this[c](), e;
}
if (e === "finish" || e === "prefinish") {
let t = super.emit(e);
return this.removeAllListeners(e), t;
}
let r = super.emit(e, t, ...n);
return this[c](), r;
}
[E](e) {
for (let t of this.pipes) t.dest.write(e) === !1 && this.pause();
let t = super.emit("data", e);
return this[c](), t;
}
[D]() {
this[l] || (this[l] = !0, this.readable = !1, this[k] ? A(() => this[O]()) : this[O]());
}
[O]() {
if (this[_]) {
let e = this[_].end();
if (e) {
for (let t of this.pipes) t.dest.write(e);
super.emit("data", e);
}
}
for (let e of this.pipes) e.end();
let e = super.emit("end");
return this.removeAllListeners("end"), e;
}
collect() {
let e = [];
this[w] || (e.dataLength = 0);
let t = this.promise();
return this.on("data", (t) => {
e.push(t), this[w] || (e.dataLength += t.length);
}), t.then(() => e);
}
concat() {
return this[w] ? Promise.reject(/* @__PURE__ */ Error("cannot concat in objectMode")) : this.collect().then((e) => this[w] ? Promise.reject(/* @__PURE__ */ Error("cannot concat in objectMode")) : this[g] ? e.join("") : Buffer.concat(e, e.dataLength));
}
promise() {
return new Promise((e, t) => {
this.on(T, () => t(/* @__PURE__ */ Error("stream destroyed"))), this.on("error", (e) => t(e)), this.on("end", () => e());
});
}
[M]() {
return { next: () => {
let e = this.read();
if (e !== null) return Promise.resolve({
done: !1,
value: e
});
if (this[s]) return Promise.resolve({ done: !0 });
let t = null, n = null, r = (e) => {
this.removeListener("data", i), this.removeListener("end", a), n(e);
}, i = (e) => {
this.removeListener("error", r), this.removeListener("end", a), this.pause(), t({
value: e,
done: !!this[s]
});
}, a = () => {
this.removeListener("error", r), this.removeListener("data", i), t({ done: !0 });
}, o = () => r(/* @__PURE__ */ Error("stream destroyed"));
return new Promise((e, s) => {
n = s, t = e, this.once(T, o), this.once("error", r), this.once("end", a), this.once("data", i);
});
} };
}
[N]() {
return { next: () => {
let e = this.read();
return {
value: e,
done: e === null
};
} };
}
destroy(e) {
return this[T] ? (e ? this.emit("error", e) : this.emit(T), this) : (this[T] = !0, this.buffer.length = 0, this[x] = 0, typeof this.close == "function" && !this[f] && this.close(), e ? this.emit("error", e) : this.emit(T), this);
}
static isStream(t) {
return !!t && (t instanceof e || t instanceof a || t instanceof i && (typeof t.pipe == "function" || typeof t.write == "function" && typeof t.end == "function"));
}
};
})), He = /* @__PURE__ */ a(((e, n) => {
var r = Ve(), i = t("events"), a = (e) => e && e instanceof i && (typeof e.pipe == "function" || typeof e.write == "function" && typeof e.end == "function"), o = Symbol("_head"), s = Symbol("_tail"), c = Symbol("_linkStreams"), l = Symbol("_setHead"), u = Symbol("_setTail"), d = Symbol("_onError"), f = Symbol("_onData"), p = Symbol("_onEnd"), m = Symbol("_onDrain"), h = Symbol("_streams");
n.exports = class extends r {
constructor(e, ...t) {
a(e) && (t.unshift(e), e = {}), super(e), this[h] = [], t.length && this.push(...t);
}
[c](e) {
return e.reduce((e, t) => (e.on("error", (e) => t.emit("error", e)), e.pipe(t), t));
}
push(...e) {
this[h].push(...e), this[s] && e.unshift(this[s]);
let t = this[c](e);
this[u](t), this[o] || this[l](e[0]);
}
unshift(...e) {
this[h].unshift(...e), this[o] && e.push(this[o]);
let t = this[c](e);
this[l](e[0]), this[s] || this[u](t);
}
destroy(e) {
return this[h].forEach((e) => typeof e.destroy == "function" && e.destroy()), super.destroy(e);
}
[u](e) {
this[s] = e, e.on("error", (t) => this[d](e, t)), e.on("data", (t) => this[f](e, t)), e.on("end", () => this[p](e)), e.on("finish", () => this[p](e));
}
[d](e, t) {
e === this[s] && this.emit("error", t);
}
[f](e, t) {
e === this[s] && super.write(t);
}
[p](e) {
e === this[s] && super.end();
}
pause() {
return super.pause(), this[s] && this[s].pause && this[s].pause();
}
emit(e, ...t) {
return e === "resume" && this[s] && this[s].resume && this[s].resume(), super.emit(e, ...t);
}
[l](e) {
this[o] = e, e.on("drain", () => this[m](e));
}
[m](e) {
e === this[o] && this.emit("drain");
}
write(e, t, n) {
return this[o].write(e, t, n) && (this.flowing || this.buffer.length === 0);
}
end(e, t, n) {
return this[o].end(e, t, n), this;
}
};
})), Ue = /* @__PURE__ */ a(((e, t) => {
t.exports = (e, { copy: t, wrap: n }) => {
let r = {};
if (e && typeof e == "object") for (let n of t) e[n] !== void 0 && (r[n] = e[n]);
else r[n] = e;
return r;
};
})), We = /* @__PURE__ */ a(((e, t) => {
var n = s();
t.exports = { satisfies: (e) => n.satisfies(process.version, e, { includePrerelease: !0 }) };
})), Ge = /* @__PURE__ */ a(((e, n) => {
var { inspect: r } = t("util"), i = class {
constructor(e, t, n) {
let r = `${t}: ${n.syscall} returned ${n.code} (${n.message})`;
n.path !== void 0 && (r += ` ${n.path}`), n.dest !== void 0 && (r += ` => ${n.dest}`), this.code = e, Object.defineProperties(this, {
name: {
value: "SystemError",
enumerable: !1,
writable: !0,
configurable: !0
},
message: {
value: r,
enumerable: !1,
writable: !0,
configurable: !0
},
info: {
value: n,
enumerable: !0,
configurable: !0,
writable: !1
},
errno: {
get() {
return n.errno;
},
set(e) {
n.errno = e;
},
enumerable: !0,
configurable: !0
},
syscall: {
get() {
return n.syscall;
},
set(e) {
n.syscall = e;
},
enumerable: !0,
configurable: !0
}
}), n.path !== void 0 && Object.defineProperty(this, "path", {
get() {
return n.path;
},
set(e) {
n.path = e;
},
enumerable: !0,
configurable: !0
}), n.dest !== void 0 && Object.defineProperty(this, "dest", {
get() {
return n.dest;
},
set(e) {
n.dest = e;
},
enumerable: !0,
configurable: !0
});
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
[Symbol.for("nodejs.util.inspect.custom")](e, t) {
return r(this, {
...t,
getters: !0,
customInspect: !1
});
}
};
function a(e, t) {
n.exports[e] = class extends i {
constructor(n) {
super(e, t, n);
}
};
}
a("ERR_FS_CP_DIR_TO_NON_DIR", "Cannot overwrite directory with non-directory"), a("ERR_FS_CP_EEXIST", "Target already exists"), a("ERR_FS_CP_EINVAL", "Invalid src or dest"), a("ERR_FS_CP_FIFO_PIPE", "Cannot copy a FIFO pipe"), a("ERR_FS_CP_NON_DIR_TO_DIR", "Cannot overwrite non-directory with directory"), a("ERR_FS_CP_SOCKET", "Cannot copy a socket file"), a("ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY", "Cannot overwrite symlink in subdirectory of self"), a("ERR_FS_CP_UNKNOWN", "Cannot copy an unknown file type"), a("ERR_FS_EISDIR", "Path is a directory"), n.exports.ERR_INVALID_ARG_TYPE = class extends Error {
constructor(e, t, n) {
super(), this.code = "ERR_INVALID_ARG_TYPE", this.message = `The ${e} argument must be ${t}. Received ${typeof n}`;
}
};
})), Ke = /* @__PURE__ */ a(((e, n) => {
var { ERR_FS_CP_DIR_TO_NON_DIR: r, ERR_FS_CP_EEXIST: i, ERR_FS_CP_EINVAL: a, ERR_FS_CP_FIFO_PIPE: o, ERR_FS_CP_NON_DIR_TO_DIR: s, ERR_FS_CP_SOCKET: c, ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY: l, ERR_FS_CP_UNKNOWN: u, ERR_FS_EISDIR: d, ERR_INVALID_ARG_TYPE: f } = Ge(), { constants: { errno: { EEXIST: p, EISDIR: m, EINVAL: h, ENOTDIR: g } } } = t("os"), { chmod: _, copyFile: v, lstat: y, mkdir: b, readdir: x, readlink: S, stat: C, symlink: w, unlink: T, utimes: E } = t("fs/promises"), { dirname: D, isAbsolute: O, join: k, parse: A, resolve: j, sep: M, toNamespacedPath: N } = t("path"), { fileURLToPath: P } = t("url"), F = {
dereference: !1,
errorOnExist: !1,
filter: void 0,
force: !0,
preserveTimestamps: !1,
recursive: !1
};
async function I(e, t, n) {
if (n != null && typeof n != "object") throw new f("options", ["Object"], n);
return R(N(L(e)), N(L(t)), {
...F,
...n
});
}
function L(e) {
return e != null && e.href && e.origin ? P(e) : e;
}
async function R(e, t, n) {
// istanbul ignore next
n.preserveTimestamps && process.arch === "ia32" && process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended", "TimestampPrecisionWarning");
let { srcStat: r, destStat: i } = await z(e, t, n);
return await W(e, r, t), n.filter ? q(H, i, e, t, n) : H(i, e, t, n);
}
async function z(e, t, n) {
let { 0: i, 1: o } = await V(e, t, n);
if (o) {
if (B(i, o)) throw new a({
message: "src and dest cannot be the same",
path: t,
syscall: "cp",
errno: h
});
if (i.isDirectory() && !o.isDirectory()) throw new r({
message: `cannot overwrite directory ${e} with non-directory ${t}`,
path: t,
syscall: "cp",
errno: m
});
if (!i.isDirectory() && o.isDirectory()) throw new s({
message: `cannot overwrite non-directory ${e} with directory ${t}`,
path: t,
syscall: "cp",
errno: g
});
}
if (i.isDirectory() && K(e, t)) throw new a({
message: `cannot copy ${e} to a subdirectory of self ${t}`,
path: t,
syscall: "cp",
errno: h
});
return {
srcStat: i,
destStat: o
};
}
function B(e, t) {
return t.ino && t.dev && t.ino === e.ino && t.dev === e.dev;
}
function V(e, t, n) {
let r = n.dereference ? (e) => C(e, { bigint: !0 }) : (e) => y(e, { bigint: !0 });
return Promise.all([r(e), r(t).catch((e) => {
// istanbul ignore next: unsure how to cover.
if (e.code === "ENOENT") return null;
// istanbul ignore next: unsure how to cover.
throw e;
})]);
}
async function H(e, t, n, r) {
let i = D(n);
return await U(i) || await b(i, { recursive: !0 }), J(e, t, n, r);
}
function U(e) {
return C(e).then(
() => !0,
// istanbul ignore next: not sure when this would occur
(e) => e.code !== "ENOENT" && Promise.reject(e)
);
}
async function W(e, t, n) {
let r = j(D(e)), i = j(D(n));
if (i === r || i === A(i).root) return;
let o;
try {
o = await C(i, { bigint: !0 });
} catch (e) {
// istanbul ignore else: not sure when this would occur
if (e.code === "ENOENT") return;
// istanbul ignore next: not sure when this would occur
throw e;
}
if (B(t, o)) throw new a({
message: `cannot copy ${e} to a subdirectory of self ${n}`,
path: n,
syscall: "cp",
errno: h
});
return W(e, t, i);
}
var G = (e) => j(e).split(M).filter(Boolean);
function K(e, t) {
let n = G(e), r = G(t);
return n.every((e, t) => r[t] === e);
}
async function q(e, t, n, r, i, a) {
if (await i.filter(n, r)) return e(t, n, r, i, a);
}
function ee(e, t, n, r) {
return r.filter ? q(J, e, t, n, r) : J(e, t, n, r);
}
async function J(e, t, n, r) {
let i = await (r.dereference ? C : y)(t);
// istanbul ignore else: can't portably test FIFO
if (i.isDirectory() && r.recursive) return ce(i, e, t, n, r);
if (i.isDirectory()) throw new d({
message: `${t} is a directory (not copied)`,
path: t,
syscall: "cp",
errno: h
});
if (i.isFile() || i.isCharacterDevice() || i.isBlockDevice()) return te(i, e, t, n, r);
if (i.isSymbolicLink()) return de(e, t, n);
// istanbul ignore next: should be unreachable
throw i.isSocket() ? new c({
message: `cannot copy a socket file: ${n}`,
path: n,
syscall: "cp",
errno: h
}) : i.isFIFO() ? new o({
message: `cannot copy a FIFO pipe: ${n}`,
path: n,
syscall: "cp",
errno: h
}) : new u({
message: `cannot copy an unknown file type: ${n}`,
path: n,
syscall: "cp",
errno: h
});
}
function te(e, t, n, r, i) {
return t ? Y(e, n, r, i) : ne(e, n, r, i);
}
async function Y(e, t, n, r) {
if (r.force) return await T(n), ne(e, t, n, r);
if (r.errorOnExist) throw new i({
message: `${n} already exists`,
path: n,
syscall: "cp",
errno: p
});
}
async function ne(e, t, n, r) {
return await v(t, n), r.preserveTimestamps ? re(e.mode, t, n) : X(n, e.mode);
}
async function re(e, t, n) {
return ie(e) && await ae(n, e), oe(e, t, n);
}
function ie(e) {
return !(e & 128);
}
function ae(e, t) {
return X(e, t | 128);
}
async function oe(e, t, n) {
return await se(t, n), X(n, e);
}
function X(e, t) {
return _(e, t);
}
async function se(e, t) {
let n = await C(e);
return E(t, n.atime, n.mtime);
}
function ce(e, t, n, r, i) {
return t ? ue(n, r, i) : le(e.mode, n, r, i);
}
async function le(e, t, n, r) {
return await b(n), await ue(t, n, r), X(n, e);
}
async function ue(e, t, n) {
let r = await x(e);
for (let i = 0; i < r.length; i++) {
let a = r[i], o = k(e, a), s = k(t, a), { destStat: c } = await z(o, s, n);
await ee(c, o, s, n);
}
}
async function de(e, t, n) {
let r = await S(t);
if (O(r) || (r = j(D(t), r)), !e) return w(r, n);
let i;
try {
i = await S(n);
} catch (e) {
// istanbul ignore next: can only test on windows
if (e.code === "EINVAL" || e.code === "UNKNOWN") return w(r, n);
// istanbul ignore next: should not be possible
throw e;
}
if (O(i) || (i = j(D(n), i)), K(r, i)) throw new a({
message: `cannot copy ${r} to a subdirectory of self ${i}`,
path: n,
syscall: "cp",
errno: h
});
if ((await C(t)).isDirectory() && K(i, r)) throw new l({
message: `cannot overwrite ${i} with ${r}`,
path: n,
syscall: "cp",
errno: h
});
return fe(r, n);
}
async function fe(e, t) {
return await T(t), w(e, t);
}
n.exports = I;
})), qe = /* @__PURE__ */ a(((e, n) => {
var r = t("fs/promises"), i = Ue(), a = We(), o = Ke(), s = a.satisfies(">=16.7.0");
n.exports = async (e, t, n) => {
let a = i(n, { copy: [
"dereference",
"errorOnExist",
"filter",
"force",
"preserveTimestamps",
"recursive"
] });
// istanbul ignore next
return s ? r.cp(e, t, a) : o(e, t, a);
};
})), Je = /* @__PURE__ */ a(((e, n) => {
var { join: r, sep: i } = t("path"), a = Ue(), { mkdir: o, mkdtemp: s, rm: c } = t("fs/promises");
n.exports = async (e, t, n) => {
let l = a(n, { copy: ["tmpPrefix"] });
await o(e, { recursive: !0 });
let u = await s(r(`${e}${i}`, l.tmpPrefix || "")), d, f;
try {
f = await t(u);
} catch (e) {
d = e;
}
try {
await c(u, {
force: !0,
recursive: !0
});
} catch {}
if (d) throw d;
return f;
};
})), Ye = /* @__PURE__ */ a(((e, n) => {
var { readdir: r } = t("fs/promises"), { join: i } = t("path");
n.exports = async (e) => {
let t = [];
for (let n of await r(e)) if (n.startsWith("@")) for (let a of await r(i(e, n))) t.push(i(n, a));
else t.push(n);
return t;
};
})), Xe = /* @__PURE__ */ a(((e, n) => {
var { dirname: r, join: i, resolve: a, relative: o, isAbsolute: s } = t("path"), c = t("fs/promises"), l = async (e) => {
try {
return await c.access(e), !0;
} catch (e) {
return e.code !== "ENOENT";
}
}, u = async (e, t, n = {}, d = !0, f = []) => {
if (!e || !t) throw TypeError("`source` and `destination` file required");
if (n = {
overwrite: !0,
...n
}, !n.overwrite && await l(t)) throw Error(`The destination file exists: ${t}`);
await c.mkdir(r(t), { recursive: !0 });
try {
await c.rename(e, t);
} catch (r) {
if (r.code === "EXDEV" || r.code === "EPERM") {
let r = await c.lstat(e);
if (r.isDirectory()) {
let r = await c.readdir(e);
await Promise.all(r.map((r) => u(i(e, r), i(t, r), n, !1, f)));
} else r.isSymbolicLink() ? f.push({
source: e,
destination: t
}) : await c.copyFile(e, t);
} else throw r;
}
d && (await Promise.all(f.map(async ({ source: e, destination: t }) => {
let n = await c.readlink(e);
s(n) && (n = a(t, o(e, n)));
let i = "file";
try {
(await c.stat(a(r(e), n))).isDirectory() && (i = "junction");
} catch {}
await c.symlink(n, t, i);
})), await c.rm(e, {
recursive: !0,
force: !0
}));
};
n.exports = u;
})), Ze = /* @__PURE__ */ a(((e, t) => {
t.exports = {
cp: qe(),
withTempDir: Je(),
readdirScoped: Ye(),
moveFile: Xe()
};
})), Qe = /* @__PURE__ */ a(((e, n) => {
var r = t("fs/promises"), i = t("path"), a = "Signature: 8a477f597d28d172789f06886806bc55\n# This file is a cache directory tag created by cacache.\n# For information about cache directory tags, see https://bford.info/cachedir/\n";
async function o(e) {
await r.mkdir(e, {
recursive: !0,
owner: "inherit"
}), await s(e);
}
async function s(e) {
try {
await r.writeFile(i.join(e, "CACHEDIR.TAG"), a, { flag: "wx" });
} catch (e) {
if (e.code !== "EEXIST") throw e;
}
}
n.exports = {
mkdir: o,
tagContent: a
};
})), $e = /* @__PURE__ */ a(((e, n) => {
var r = t("crypto"), { withTempDir: i } = Ze(), a = t("fs/promises"), o = t("path"), s = Qe();
n.exports.mkdir = c, n.exports.tmpName = function(e, t) {
let n = r.randomUUID();
return o.join(e, "tmp", t ? `${t}-${n}` : n);
};
async function c(e, t = {}) {
let { tmpPrefix: n } = t, r = o.join(e, "tmp");
await s.mkdir(e), await a.mkdir(r, {
recursive: !0,
owner: "inherit"
});
let i = `${r}${o.sep}${n || ""}`;
return a.mkdtemp(i, { owner: "inherit" });
}
n.exports.withTmp = l;
function l(e, t, n) {
return n || (n = t, t = {}), s.mkdir(e).then(() => i(o.join(e, "tmp"), n, t));
}
})), et = /* @__PURE__ */ i({
author: () => pt,
default: () => ht,
dependencies: () => lt,
description: () => rt,
devDependencies: () => ut,
engines: () => dt,
files: () => at,
keywords: () => ct,
license: () => "ISC",
main: () => it,
name: () => tt,
repository: () => st,
scripts: () => ot,
tap: () => mt,
templateOSS: () => ft,
version: () => nt
}), tt, nt, rt, it, at, ot, st, ct, lt, ut, dt, ft, pt, mt, ht, gt = n((() => {
tt = "cacache", nt = "21.0.1", rt = "Fast, fault-tolerant, cross-platform, disk-based, data-agnostic, content-addressable cache.", it = "lib/index.js", at = ["bin/", "lib/"], ot = {
test: "tap",
snap: "tap",
coverage: "tap",
"test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test",
lint: "npm run eslint",
npmclilint: "npmcli-lint",
lintfix: "npm run eslint -- --fix",
postsnap: "npm run lintfix --",
postlint: "template-oss-check",
posttest: "npm run lint",
"template-oss-apply": "template-oss-apply --force",
eslint: "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
}, st = {
type: "git",
url: "git+https://github.com/npm/cacache.git"
}, ct = [
"cache",
"caching",
"content-addressable",
"sri",
"sri hash",
"subresource integrity",
"cache",
"storage",
"store",
"file store",
"filesystem",
"disk cache",
"disk storage"
], lt = {
"@npmcli/fs": "^6.0.0",
"fs-minipass": "^3.0.0",
glob: "^13.0.0",
"lru-cache": "^11.1.0",
minipass: "^7.0.3",
"minipass-collect": "^2.0.1",
"minipass-flush": "^1.0.5",
"minipass-pipeline": "^1.2.4",
"p-map": "^7.0.2",
ssri: "^14.0.0"
}, ut = {
"@npmcli/eslint-config": "^7.0.0",
"@npmcli/template-oss": "5.1.0",
tap: "^16.0.0"
}, dt = { node: "^22.22.2 || ^24.15.0 || >=26.0.0" }, ft = {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
windowsCI: !1,
version: "5.1.0",
publish: "true"
}, pt = "GitHub Inc.", mt = { "nyc-arg": ["--exclude", "tap-snapshots/**"] }, ht = {
name: tt,
version: nt,
"cache-version": {
content: "2",
index: "5"
},
description: rt,
main: it,
files: at,
scripts: ot,
repository: st,
keywords: ct,
license: "ISC",
dependencies: lt,
devDependencies: ut,
engines: dt,
templateOSS: ft,
author: pt,
tap: mt
};
})), _t = /* @__PURE__ */ a(((e, t) => {
t.exports = n;
function n(e) {
return [
e.slice(0, 2),
e.slice(2, 4),
e.slice(4)
];
}
})), vt = /* @__PURE__ */ a(((n, r) => {
var i = (gt(), e(et).default)["cache-version"].content, a = _t(), o = t("path"), s = Z();
r.exports = c;
function c(e, t) {
let n = s.parse(t, { single: !0 });
return o.join(l(e), n.algorithm, ...a(n.hexDigest()));
}
r.exports.contentDir = l;
function l(e) {
return o.join(e, `content-v${i}`);
}
})), yt = /* @__PURE__ */ a(((n, r) => {
var i = t("crypto"), { appendFile: a, mkdir: o, readFile: s, readdir: c, rm: l, writeFile: u } = t("fs/promises"), { Minipass: d } = y(), f = t("path"), p = Z(), { tmpName: m } = $e(), h = Qe(), g = vt(), _ = _t(), v = (gt(), e(et).default)["cache-version"].index, { moveFile: b } = Ze(), x = 5;
r.exports.NotFoundError = class extends Error {
constructor(e, t) {
super(`No cache entry for ${t} found in ${e}`), this.code = "ENOENT", this.cache = e, this.key = t;
}
}, r.exports.compact = S;
async function S(e, t, n, r = {}) {
let i = j(e, t), a = await O(i), s = [];
for (let e = a.length - 1; e >= 0; --e) {
let t = a[e];
if (t.integrity === null && !r.validateEntry) break;
(!r.validateEntry || r.validateEntry(t) === !0) && (s.length === 0 || !s.find((e) => n(e, t))) && s.unshift(t);
}
let c = "\n" + s.map((e) => {
let t = JSON.stringify(e);
return `${N(t)}\t${t}`;
}).join("\n"), d = async () => {
let t = m(e, r.tmpPrefix);
return await h.mkdir(e), await o(f.dirname(t), { recursive: !0 }), {
target: t,
moved: !1
};
}, p = async (e) => {
if (!e.moved) return l(e.target, {
recursive: !0,
force: !0
});
}, g = async (e) => {
await u(e.target, c, { flag: "wx" }), await o(f.dirname(i), { recursive: !0 }), await b(e.target, i), e.moved = !0;
}, _ = await d();
try {
await g(_);
} finally {
await p(_);
}
return s.reverse().map((t) => F(e, t, !0));
}
r.exports.insert = C;
async function C(e, t, n, r = {}) {
let { metadata: i, size: s, time: c } = r, l = j(e, t), u = {
key: t,
integrity: n && p.stringify(n),
time: c || Date.now(),
size: s,
metadata: i
};
try {
await h.mkdir(e), await o(f.dirname(l), { recursive: !0 });
let t = JSON.stringify(u);
await a(l, `\n${N(t)}\t${t}`);
} catch (e) {
if (e.code === "ENOENT") return;
throw e;
}
return F(e, u);
}
r.exports.find = w;
async function w(e, t) {
let n = j(e, t);
try {
return (await O(n)).reduce((n, r) => r && r.key === t ? F(e, r) : n, null);
} catch (e) {
if (e.code === "ENOENT") return null;
throw e;
}
}
r.exports.delete = T;
function T(e, t, n = {}) {
return n.removeFully ? l(j(e, t), {
recursive: !0,
force: !0
}) : C(e, t, null, n);
}
r.exports.lsStream = E;
function E(e) {
let t = A(e), n = new d({ objectMode: !0 });
return Promise.resolve().then(async () => {
let { default: r } = await import("../index.js").then((e) => (e.t(), e.n));
return await r(await I(t), async (i) => {
let a = f.join(t, i), o = await I(a);
await r(o, async (t) => {
let i = f.join(a, t), o = await I(i);
await r(o, async (t) => {
let r = f.join(i, t);
try {
let t = (await O(r)).reduce((e, t) => (e.set(t.key, t), e), /* @__PURE__ */ new Map());
for (let r of t.values()) {
let t = F(e, r);
t && n.write(t);
}
} catch (e) {
if (e.code === "ENOENT") return;
throw e;
}
}, { concurrency: x });
}, { concurrency: x });
}, { concurrency: x }), n.end(), n;
}).catch((e) => n.emit("error", e)), n;
}
r.exports.ls = D;
async function D(e) {
return (await E(e).collect()).reduce((e, t) => (e[t.key] = t, e), {});
}
r.exports.bucketEntries = O;
async function O(e, t) {
return k(await s(e, "utf8"), t);
}
function k(e) {
let t = [];
return e.split("\n").forEach((e) => {
if (!e) return;
let n = e.split(" ");
if (!n[1] || N(n[1]) !== n[0]) return;
let r;
try {
r = JSON.parse(n[1]);
} catch {}
// istanbul ignore else
r && t.push(r);
}), t;
}
r.exports.bucketDir = A;
function A(e) {
return f.join(e, `index-v${v}`);
}
r.exports.bucketPath = j;
function j(e, t) {
let n = M(t);
return f.join.apply(f, [A(e)].concat(_(n)));
}
r.exports.hashKey = M;
function M(e) {
return P(e, "sha256");
}
r.exports.hashEntry = N;
function N(e) {
return P(e, "sha1");
}
function P(e, t) {
return i.createHash(t).update(e).digest("hex");
}
function F(e, t, n) {
return !t.integrity && !n ? null : {
key: t.key,
integrity: t.integrity,
path: t.integrity ? g(e, t.integrity) : void 0,
size: t.size,
time: t.time,
metadata: t.metadata
};
}
function I(e) {
return c(e).catch((e) => {
if (e.code === "ENOENT" || e.code === "ENOTDIR") return [];
throw e;
});
}
})), bt = /* @__PURE__ */ a(((e, t) => {
var { LRUCache: n } = c(), r = new n({
max: 500,
maxSize: 52428800,
ttl: 18e4,
sizeCalculation: (e, t) => t.startsWith("key:") ? e.data.length : e.length
});
t.exports.clearMemoized = i;
function i() {
let e = {};
return r.forEach((t, n) => {
e[n] = t;
}), r.clear(), e;
}
t.exports.put = a;
function a(e, t, n, r) {
d(r).set(`key:${e}:${t.key}`, {
entry: t,
data: n
}), o(e, t.integrity, n, r);
}
t.exports.put.byDigest = o;
function o(e, t, n, r) {
d(r).set(`digest:${e}:${t}`, n);
}
t.exports.get = s;
function s(e, t, n) {
return d(n).get(`key:${e}:${t}`);
}
t.exports.get.byDigest = l;
function l(e, t, n) {
return d(n).get(`digest:${e}:${t}`);
}
var u = class {
constructor(e) {
this.obj = e;
}
get(e) {
return this.obj[e];
}
set(e, t) {
this.obj[e] = t;
}
};
function d(e) {
return !e || !e.memoize ? r : e.memoize.get && e.memoize.set ? e.memoize : typeof e.memoize == "object" ? new u(e.memoize) : r;
}
})), xt = /* @__PURE__ */ a(((e) => {
var { Minipass: n } = y(), r = t("events").EventEmitter, i = t("fs"), a = i.writev, o = Symbol("_autoClose"), s = Symbol("_close"), c = Symbol("_ended"), l = Symbol("_fd"), u = Symbol("_finished"), d = Symbol("_flags"), f = Symbol("_flush"), p = Symbol("_handleChunk"), m = Symbol("_makeBuf"), h = Symbol("_mode"), g = Symbol("_needDrain"), _ = Symbol("_onerror"), v = Symbol("_onopen"), b = Symbol("_onread"), x = Symbol("_onwrite"), S = Symbol("_open"), C = Symbol("_path"), w = Symbol("_pos"), T = Symbol("_queue"), E = Symbol("_read"), D = Symbol("_readSize"), O = Symbol("_reading"), k = Symbol("_remain"), A = Symbol("_size"), j = Symbol("_write"), M = Symbol("_writing"), N = Symbol("_defaultFlag"), P = Symbol("_errored"), F = class extends n {
constructor(e, t) {
if (t ||= {}, super(t), this.readable = !0, this.writable = !1, typeof e != "string") throw TypeError("path must be a string");
this[P] = !1, this[l] = typeof t.fd == "number" ? t.fd : null, this[C] = e, this[D] = t.readSize || 16777216, this[O] = !1, this[A] = typeof t.size == "number" ? t.size : Infinity, this[k] = this[A], this[o] = typeof t.autoClose != "boolean" || t.autoClose, typeof this[l] == "number" ? this[E]() : this[S]();
}
get fd() {
return this[l];
}
get path() {
return this[C];
}
write() {
throw TypeError("this is a readable stream");
}
end() {
throw TypeError("this is a readable stream");
}
[S]() {
i.open(this[C], "r", (e, t) => this[v](e, t));
}
[v](e, t) {
e ? this[_](e) : (this[l] = t, this.emit("open", t), this[E]());
}
[m]() {
return Buffer.allocUnsafe(Math.min(this[D], this[k]));
}
[E]() {
if (!this[O]) {
this[O] = !0;
let e = this[m]();
/* istanbul ignore if */
if (e.length === 0) return process.nextTick(() => this[b](null, 0, e));
i.read(this[l], e, 0, e.length, null, (e, t, n) => this[b](e, t, n));
}
}
[b](e, t, n) {
this[O] = !1, e ? this[_](e) : this[p](t, n) && this[E]();
}
[s]() {
if (this[o] && typeof this[l] == "number") {
let e = this[l];
this[l] = null, i.close(e, (e) => e ? this.emit("error", e) : this.emit("close"));
}
}
[_](e) {
this[O] = !0, this[s](), this.emit("error", e);
}
[p](e, t) {
let n = !1;
return this[k] -= e, e > 0 && (n = super.write(e < t.length ? t.slice(0, e) : t)), (e === 0 || this[k] <= 0) && (n = !1, this[s](), super.end()), n;
}
emit(e, t) {
switch (e) {
case "prefinish":
case "finish": break;
case "drain":
typeof this[l] == "number" && this[E]();
break;
case "error": return this[P] ? void 0 : (this[P] = !0, super.emit(e, t));
default: return super.emit(e, t);
}
}
}, I = class extends F {
[S]() {
let e = !0;
try {
this[v](null, i.openSync(this[C], "r")), e = !1;
} finally {
e && this[s]();
}
}
[E]() {
let e = !0;
try {
if (!this[O]) {
this[O] = !0;
do {
let e = this[m](), t = e.length === 0 ? 0 : i.readSync(this[l], e, 0, e.length, null);
if (!this[p](t, e)) break;
} while (!0);
this[O] = !1;
}
e = !1;
} finally {
e && this[s]();
}
}
[s]() {
if (this[o] && typeof this[l] == "number") {
let e = this[l];
this[l] = null, i.closeSync(e), this.emit("close");
}
}
}, L = class extends r {
constructor(e, t) {
t ||= {}, super(t), this.readable = !1, this.writable = !0, this[P] = !1, this[M] = !1, this[c] = !1, this[g] = !1, this[T] = [], this[C] = e, this[l] = typeof t.fd == "number" ? t.fd : null, this[h] = t.mode === void 0 ? 438 : t.mode, this[w] = typeof t.start == "number" ? t.start : null, this[o] = typeof t.autoClose != "boolean" || t.autoClose;
let n = this[w] === null ? "w" : "r+";
this[N] = t.flags === void 0, this[d] = this[N] ? n : t.flags, this[l] === null && this[S]();
}
emit(e, t) {
if (e === "error") {
if (this[P]) return;
this[P] = !0;
}
return super.emit(e, t);
}
get fd() {
return this[l];
}
get path() {
return this[C];
}
[_](e) {
this[s](), this[M] = !0, this.emit("error", e);
}
[S]() {
i.open(this[C], this[d], this[h], (e, t) => this[v](e, t));
}
[v](e, t) {
this[N] && this[d] === "r+" && e && e.code === "ENOENT" ? (this[d] = "w", this[S]()) : e ? this[_](e) : (this[l] = t, this.emit("open", t), this[M] || this[f]());
}
end(e, t) {
return e && this.write(e, t), this[c] = !0, !this[M] && !this[T].length && typeof this[l] == "number" && this[x](null, 0), this;
}
write(e, t) {
return typeof e == "string" && (e = Buffer.from(e, t)), this[c] ? (this.emit("error", /* @__PURE__ */ Error("write() after end()")), !1) : this[l] === null || this[M] || this[T].length ? (this[T].push(e), this[g] = !0, !1) : (this[M] = !0, this[j](e), !0);
}
[j](e) {
i.write(this[l], e, 0, e.length, this[w], (e, t) => this[x](e, t));
}
[x](e, t) {
e ? this[_](e) : (this[w] !== null && (this[w] += t), this[T].length ? this[f]() : (this[M] = !1, this[c] && !this[u] ? (this[u] = !0, this[s](), this.emit("finish")) : this[g] && (this[g] = !1, this.emit("drain"))));
}
[f]() {
if (this[T].length === 0) this[c] && this[x](null, 0);
else if (this[T].length === 1) this[j](this[T].pop());
else {
let e = this[T];
this[T] = [], a(this[l], e, this[w], (e, t) => this[x](e, t));
}
}
[s]() {
if (this[o] && typeof this[l] == "number") {
let e = this[l];
this[l] = null, i.close(e, (e) => e ? this.emit("error", e) : this.emit("close"));
}
}
}, R = class extends L {
[S]() {
let e;
if (this[N] && this[d] === "r+") try {
e = i.openSync(this[C], this[d], this[h]);
} catch (e) {
if (e.code === "ENOENT") return this[d] = "w", this[S]();
throw e;
}
else e = i.openSync(this[C], this[d], this[h]);
this[v](null, e);
}
[s]() {
if (this[o] && typeof this[l] == "number") {
let e = this[l];
this[l] = null, i.closeSync(e), this.emit("close");
}
}
[j](e) {
let t = !0;
try {
this[x](null, i.writeSync(this[l], e, 0, e.length, this[w])), t = !1;
} finally {
if (t) try {
this[s]();
} catch {}
}
}
};
e.ReadStream = F, e.ReadStreamSync = I, e.WriteStream = L, e.WriteStreamSync = R;
})), St = /* @__PURE__ */ a(((e, n) => {
var r = t("fs/promises"), i = xt(), a = Z(), o = vt(), s = He();
n.exports = l;
var c = 67108864;
async function l(e, t, n = {}) {
let { size: i } = n, { stat: o, cpath: l, sri: d } = await m(e, t, async (e, t) => ({
stat: i ? { size: i } : await r.stat(e),
cpath: e,
sri: t
}));
if (o.size > c) return u(l, o.size, d, new s()).concat();
let f = await r.readFile(l, { encoding: null });
if (o.size !== f.length) throw h(o.size, f.length);
if (!a.checkData(f, d)) throw g(d, l);
return f;
}
var u = (e, t, n, r) => (r.push(new i.ReadStream(e, {
size: t,
readSize: c
}), a.integrityStream({
integrity: n,
size: t
})), r);
n.exports.stream = d, n.exports.readStream = d;
function d(e, t, n = {}) {
let { size: i } = n, a = new s();
return Promise.resolve().then(async () => {
let { stat: n, cpath: o, sri: s } = await m(e, t, async (e, t) => ({
stat: i ? { size: i } : await r.stat(e),
cpath: e,
sri: t
}));
return u(o, n.size, s, a);
}).catch((e) => a.emit("error", e)), a;
}
n.exports.copy = f;
function f(e, t, n) {
return m(e, t, (e) => r.copyFile(e, n));
}
n.exports.hasContent = p;
async function p(e, t) {
if (!t) return !1;
try {
return await m(e, t, async (e, t) => {
let n = await r.stat(e);
return {
size: n.size,
sri: t,
stat: n
};
});
} catch (e) {
if (e.code === "ENOENT") return !1;
if (e.code === "EPERM") {
/* istanbul ignore else */
if (process.platform !== "win32") throw e;
return !1;
}
}
}
async function m(e, t, n) {
let r = a.parse(t), i = r[r.pickAlgorithm()];
if (i.length <= 1) return n(o(e, i[0]), i[0]);
{
let t = await Promise.all(i.map(async (t) => {
try {
return await m(e, t, n);
} catch (e) {
return e.code === "ENOENT" ? Object.assign(/* @__PURE__ */ Error("No matching content found for " + r.toString()), { code: "ENOENT" }) : e;
}
})), a = t.find((e) => !(e instanceof Error));
if (a) return a;
throw t.find((e) => e.code === "ENOENT") || t.find((e) => e instanceof Error);
}
}
function h(e, t) {
let n = /* @__PURE__ */ Error(`Bad data size: expected inserted data to be ${e} bytes, but got ${t} instead`);
return n.expected = e, n.found = t, n.code = "EBADSIZE", n;
}
function g(e, t) {
let n = /* @__PURE__ */ Error(`Integrity verification failed for ${e} (${t})`);
return n.code = "EINTEGRITY", n.sri = e, n.path = t, n;
}
})), Ct = /* @__PURE__ */ a(((e, t) => {
var n = Be(), { Minipass: r } = y(), i = He(), a = yt(), o = bt(), s = St();
async function c(e, t, n = {}) {
let { integrity: r, memoize: i, size: c } = n, l = o.get(e, t, n);
if (l && i !== !1) return {
metadata: l.entry.metadata,
data: l.data,
integrity: l.entry.integrity,
size: l.entry.size
};
let u = await a.find(e, t, n);
if (!u) throw new a.NotFoundError(e, t);
let d = await s(e, u.integrity, {
integrity: r,
size: c
});
return i && o.put(e, u, d, n), {
data: d,
metadata: u.metadata,
size: u.size,
integrity: u.integrity
};
}
t.exports = c;
async function l(e, t, n = {}) {
let { integrity: r, memoize: i, size: a } = n, c = o.get.byDigest(e, t, n);
if (c && i !== !1) return c;
let l = await s(e, t, {
integrity: r,
size: a
});
return i && o.put.byDigest(e, t, l, n), l;
}
t.exports.byDigest = l;
var u = (e) => {
let t = new r();
return t.on("newListener", function(t, n) {
t === "metadata" && n(e.entry.metadata), t === "integrity" && n(e.entry.integrity), t === "size" && n(e.entry.size);
}), t.end(e.data), t;
};
function d(e, t, r = {}) {
let { memoize: c, size: l } = r, d = o.get(e, t, r);
if (d && c !== !1) return u(d);
let f = new i();
return Promise.resolve().then(async () => {
let i = await a.find(e, t);
if (!i) throw new a.NotFoundError(e, t);
f.emit("metadata", i.metadata), f.emit("integrity", i.integrity), f.emit("size", i.size), f.on("newListener", function(e, t) {
e === "metadata" && t(i.metadata), e === "integrity" && t(i.integrity), e === "size" && t(i.size);
});
let u = s.readStream(e, i.integrity, {
...r,
size: typeof l == "number" ? l : i.size
});
if (c) {
let t = new n.PassThrough();
t.on("collect", (t) => o.put(e, i, t, r)), f.unshift(t);
}
return f.unshift(u), f;
}).catch((e) => f.emit("error", e)), f;
}
t.exports.stream = d;
function f(e, t, a = {}) {
let { memoize: c } = a, l = o.get.byDigest(e, t, a);
if (l && c !== !1) {
let e = new r();
return e.end(l), e;
}
{
let r = s.readStream(e, t, a);
if (!c) return r;
let l = new n.PassThrough();
return l.on("collect", (n) => o.put.byDigest(e, t, n, a)), new i(r, l);
}
}
t.exports.stream.byDigest = f;
function p(e, t, n = {}) {
let { memoize: r } = n, i = o.get(e, t, n);
return i && r !== !1 ? Promise.resolve(i.entry) : a.find(e, t);
}
t.exports.info = p;
async function m(e, t, n, r = {}) {
let i = await a.find(e, t, r);
if (!i) throw new a.NotFoundError(e, t);
return await s.copy(e, i.integrity, n, r), {
metadata: i.metadata,
size: i.size,
integrity: i.integrity
};
}
t.exports.copy = m;
async function h(e, t, n, r = {}) {
return await s.copy(e, t, n, r), t;
}
t.exports.copy.byDigest = h, t.exports.hasContent = s.hasContent;
})), wt = /* @__PURE__ */ a(((e, n) => {
var r = t("events"), i = vt(), a = t("fs/promises"), { moveFile: o } = Ze(), { Minipass: s } = y(), c = He(), l = ze(), u = t("path"), d = Z(), f = Qe(), { tmpName: p } = $e(), m = xt();
n.exports = g;
var h = /* @__PURE__ */ new Map();
async function g(e, t, n = {}) {
let { algorithms: r, size: i, integrity: o } = n;
if (typeof i == "number" && t.length !== i) throw w(i, t.length);
let s = d.fromData(t, r ? { algorithms: r } : {});
if (o && !d.checkData(t, o, n)) throw T(o, s);
for (let r in s) {
let i = await S(e, n), o = s[r].toString();
try {
await a.writeFile(i.target, t, { flag: "wx" }), await C(i, e, o, n);
} finally {
i.moved || await a.rm(i.target, {
recursive: !0,
force: !0
});
}
}
return {
integrity: s,
size: t.length
};
}
n.exports.stream = v;
var _ = class extends l {
constructor(e, t) {
super(), this.opts = t, this.cache = e, this.inputStream = new s(), this.inputStream.on("error", (e) => this.emit("error", e)), this.inputStream.on("drain", () => this.emit("drain")), this.handleContentP = null;
}
write(e, t, n) {
return this.handleContentP || (this.handleContentP = b(this.inputStream, this.cache, this.opts), this.handleContentP.catch((e) => this.emit("error", e))), this.inputStream.write(e, t, n);
}
flush(e) {
this.inputStream.end(() => {
if (!this.handleContentP) {
let t = /* @__PURE__ */ Error("Cache input stream was empty");
return t.code = "ENODATA", Promise.reject(t).catch(e);
}
this.handleContentP.then((t) => {
t.integrity && this.emit("integrity", t.integrity), t.size !== null && this.emit("size", t.size), e();
}, (t) => e(t));
});
}
};
function v(e, t = {}) {
return new _(e, t);
}
async function b(e, t, n) {
let r = await S(t, n);
try {
let i = await x(e, t, r.target, n);
return await C(r, t, i.integrity, n), i;
} finally {
r.moved || await a.rm(r.target, {
recursive: !0,
force: !0
});
}
}
async function x(e, t, n, i) {
let a = new m.WriteStream(n, { flags: "wx" });
if (i.integrityEmitter) {
let [t, n] = await Promise.all([
r.once(i.integrityEmitter, "integrity").then((e) => e[0]),
r.once(i.integrityEmitter, "size").then((e) => e[0]),
new c(e, a).promise()
]);
return {
integrity: t,
size: n
};
}
let o, s, l = d.integrityStream({
integrity: i.integrity,
algorithms: i.algorithms,
size: i.size
});
return l.on("integrity", (e) => {
o = e;
}), l.on("size", (e) => {
s = e;
}), await new c(e, l, a).promise(), {
integrity: o,
size: s
};
}
async function S(e, t) {
let n = p(e, t.tmpPrefix);
return await f.mkdir(e), await a.mkdir(u.dirname(n), { recursive: !0 }), {
target: n,
moved: !1
};
}
async function C(e, t, n) {
let r = i(t, n), s = u.dirname(r);
return h.has(r) || h.set(r, a.mkdir(s, { recursive: !0 }).then(async () => (await o(e.target, r, { overwrite: !1 }), e.moved = !0, e.moved)).catch((e) => {
if (!e.message.startsWith("The destination file exists")) throw Object.assign(e, { code: "EEXIST" });
}).finally(() => {
h.delete(r);
})), h.get(r);
}
function w(e, t) {
let n = /* @__PURE__ */ Error(`Bad data size: expected inserted data to be ${e} bytes, but got ${t} instead`);
return n.expected = e, n.found = t, n.code = "EBADSIZE", n;
}
function T(e, t) {
let n = /* @__PURE__ */ Error(`Integrity check failed:
Wanted: ${e}
Found: ${t}`);
return n.code = "EINTEGRITY", n.expected = e, n.found = t, n;
}
})), Tt = /* @__PURE__ */ a(((e, t) => {
var n = yt(), r = bt(), i = wt(), a = ze(), { PassThrough: o } = Be(), s = He(), c = (e) => ({
algorithms: ["sha512"],
...e
});
t.exports = l;
async function l(e, t, a, o = {}) {
let { memoize: s } = o;
o = c(o);
let l = await i(e, a, o), u = await n.insert(e, t, l.integrity, {
...o,
size: l.size
});
return s && r.put(e, u, a, o), l.integrity;
}
t.exports.stream = u;
function u(e, t, l = {}) {
let { memoize: u } = l;
l = c(l);
let d, f, p, m, h = new s();
if (u) {
let e = new o().on("collect", (e) => {
m = e;
});
h.push(e);
}
let g = i.stream(e, l).on("integrity", (e) => {
d = e;
}).on("size", (e) => {
f = e;
}).on("error", (e) => {
p = e;
});
return h.push(g), h.push(new a({ async flush() {
if (!p) {
let i = await n.insert(e, t, d, {
...l,
size: f
});
u && m && r.put(e, i, m, l), h.emit("integrity", d), h.emit("size", f);
}
} })), h;
}
})), Et = /* @__PURE__ */ a(((e) => {
var n = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), r = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.range = e.balanced = void 0, e.balanced = (n, r, i) => {
let a = n instanceof RegExp ? t(n, i) : n, o = r instanceof RegExp ? t(r, i) : r, s = a !== null && o != null && (0, e.range)(a, o, i);
return s && {
start: s[0],
end: s[1],
pre: i.slice(0, s[0]),
body: i.slice(s[0] + a.length, s[1]),
post: i.slice(s[1] + o.length)
};
};
var t = (e, t) => {
let n = t.match(e);
return n ? n[0] : null;
};
e.range = (e, t, n) => {
let r, i, a, o, s, c = n.indexOf(e), l = n.indexOf(t, c + 1), u = c;
if (c >= 0 && l > 0) {
if (e === t) return [c, l];
for (r = [], a = n.length; u >= 0 && !s;) {
if (u === c) r.push(u), c = n.indexOf(e, u + 1);
else if (r.length === 1) {
let e = r.pop();
e !== void 0 && (s = [e, l]);
} else i = r.pop(), i !== void 0 && i < a && (a = i, o = l), l = n.indexOf(t, u + 1);
u = c < l && c >= 0 ? c : l;
}
r.length && o !== void 0 && (s = [a, o]);
}
return s;
};
}), i = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.EXPANSION_MAX = void 0, e.expand = S;
var t = r(), n = "\0SLASH" + Math.random() + "\0", i = "\0OPEN" + Math.random() + "\0", a = "\0CLOSE" + Math.random() + "\0", o = "\0COMMA" + Math.random() + "\0", s = "\0PERIOD" + Math.random() + "\0", c = new RegExp(n, "g"), l = new RegExp(i, "g"), u = new RegExp(a, "g"), d = new RegExp(o, "g"), f = new RegExp(s, "g"), p = /\\\\/g, m = /\\{/g, h = /\\}/g, g = /\\,/g, _ = /\\./g;
e.EXPANSION_MAX = 1e5;
function v(e) {
return isNaN(e) ? e.charCodeAt(0) : parseInt(e, 10);
}
function y(e) {
return e.replace(p, n).replace(m, i).replace(h, a).replace(g, o).replace(_, s);
}
function b(e) {
return e.replace(c, "\\").replace(l, "{").replace(u, "}").replace(d, ",").replace(f, ".");
}
function x(e) {
if (!e) return [""];
let n = [], r = (0, t.balanced)("{", "}", e);
if (!r) return e.split(",");
let { pre: i, body: a, post: o } = r, s = i.split(",");
s[s.length - 1] += "{" + a + "}";
let c = x(o);
return o.length && (s[s.length - 1] += c.shift(), s.push.apply(s, c)), n.push.apply(n, s), n;
}
function S(t, n = {}) {
if (!t) return [];
let { max: r = e.EXPANSION_MAX } = n;
return t.slice(0, 2) === "{}" && (t = "\\{\\}" + t.slice(2)), D(y(t), r, !0).map(b);
}
function C(e) {
return "{" + e + "}";
}
function w(e) {
return /^-?0\d/.test(e);
}
function T(e, t) {
return e <= t;
}
function E(e, t) {
return e >= t;
}
function D(e, n, r) {
let i = [], o = (0, t.balanced)("{", "}", e);
if (!o) return [e];
let s = o.pre, c = o.post.length ? D(o.post, n, !1) : [""];
if (/\$$/.test(o.pre)) for (let e = 0; e < c.length && e < n; e++) {
let t = s + "{" + o.body + "}" + c[e];
i.push(t);
}
else {
let t = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body), l = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body), u = t || l, d = o.body.indexOf(",") >= 0;
if (!u && !d) return o.post.match(/,(?!,).*\}/) ? (e = o.pre + "{" + o.body + a + o.post, D(e, n, !0)) : [e];
let f;
if (u) f = o.body.split(/\.\./);
else if (f = x(o.body), f.length === 1 && f[0] !== void 0 && (f = D(f[0], n, !1).map(C), f.length === 1)) return c.map((e) => o.pre + f[0] + e);
let p;
if (u && f[0] !== void 0 && f[1] !== void 0) {
let e = v(f[0]), t = v(f[1]), n = Math.max(f[0].length, f[1].length), r = f.length === 3 && f[2] !== void 0 ? Math.abs(v(f[2])) : 1, i = T;
t < e && (r *= -1, i = E);
let a = f.some(w);
p = [];
for (let o = e; i(o, t); o += r) {
let e;
if (l) e = String.fromCharCode(o), e === "\\" && (e = "");
else if (e = String(o), a) {
let t = n - e.length;
if (t > 0) {
let n = Array(t + 1).join("0");
e = o < 0 ? "-" + n + e.slice(1) : n + e;
}
}
p.push(e);
}
} else {
p = [];
for (let e = 0; e < f.length; e++) p.push.apply(p, D(f[e], n, !1));
}
for (let e = 0; e < p.length; e++) for (let t = 0; t < c.length && i.length < n; t++) {
let n = s + p[e] + c[t];
(!r || u || n) && i.push(n);
}
}
return i;
}
}), a = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.assertValidPattern = void 0;
var t = 65536;
e.assertValidPattern = (e) => {
if (typeof e != "string") throw TypeError("invalid pattern");
if (e.length > t) throw TypeError("pattern is too long");
};
}), o = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.parseClass = void 0;
var t = {
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
"[:alpha:]": ["\\p{L}\\p{Nl}", !0],
"[:ascii:]": ["\\x00-\\x7f", !1],
"[:blank:]": ["\\p{Zs}\\t", !0],
"[:cntrl:]": ["\\p{Cc}", !0],
"[:digit:]": ["\\p{Nd}", !0],
"[:graph:]": [
"\\p{Z}\\p{C}",
!0,
!0
],
"[:lower:]": ["\\p{Ll}", !0],
"[:print:]": ["\\p{C}", !0],
"[:punct:]": ["\\p{P}", !0],
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
"[:upper:]": ["\\p{Lu}", !0],
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
"[:xdigit:]": ["A-Fa-f0-9", !1]
}, n = (e) => e.replace(/[[\]\\-]/g, "\\$&"), r = (e) => e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), i = (e) => e.join("");
e.parseClass = (e, a) => {
let o = a;
if (e.charAt(o) !== "[") throw Error("not in a brace expression");
let s = [], c = [], l = o + 1, u = !1, d = !1, f = !1, p = !1, m = o, h = "";
t: for (; l < e.length;) {
let r = e.charAt(l);
if ((r === "!" || r === "^") && l === o + 1) {
p = !0, l++;
continue;
}
if (r === "]" && u && !f) {
m = l + 1;
break;
}
if (u = !0, r === "\\" && !f) {
f = !0, l++;
continue;
}
if (r === "[" && !f) {
for (let [n, [r, i, a]] of Object.entries(t)) if (e.startsWith(n, l)) {
if (h) return [
"$.",
!1,
e.length - o,
!0
];
l += n.length, a ? c.push(r) : s.push(r), d ||= i;
continue t;
}
}
if (f = !1, h) {
r > h ? s.push(n(h) + "-" + n(r)) : r === h && s.push(n(r)), h = "", l++;
continue;
}
if (e.startsWith("-]", l + 1)) {
s.push(n(r + "-")), l += 2;
continue;
}
if (e.startsWith("-", l + 1)) {
h = r, l += 2;
continue;
}
s.push(n(r)), l++;
}
if (m < l) return [
"",
!1,
0,
!1
];
if (!s.length && !c.length) return [
"$.",
!1,
e.length - o,
!0
];
if (c.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !p) return [
r(s[0].length === 2 ? s[0].slice(-1) : s[0]),
!1,
m - o,
!1
];
let g = "[" + (p ? "^" : "") + i(s) + "]", _ = "[" + (p ? "" : "^") + i(c) + "]";
return [
s.length && c.length ? "(" + g + "|" + _ + ")" : s.length ? g : _,
d,
m - o,
!0
];
};
}), s = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.unescape = void 0, e.unescape = (e, { windowsPathsNoEscape: t = !1, magicalBraces: n = !0 } = {}) => n ? t ? e.replace(/\[([^\/\\])\]/g, "$1") : e.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1") : t ? e.replace(/\[([^\/\\{}])\]/g, "$1") : e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
}), c = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.AST = void 0;
var t = o(), n = s(), r = /* @__PURE__ */ new Set([
"!",
"?",
"+",
"*",
"@"
]), i = (e) => r.has(e), a = "(?!(?:^|/)\\.\\.?(?:$|/))", c = "(?!\\.)", l = /* @__PURE__ */ new Set(["[", "."]), u = /* @__PURE__ */ new Set(["..", "."]), d = /* @__PURE__ */ new Set("().*{}+?[]^$\\!"), f = (e) => e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), p = "[^/]", m = p + "*?", h = p + "+?";
e.AST = class e {
type;
#e;
#t;
#n = !1;
#r = [];
#i;
#a;
#o;
#s = !1;
#c;
#l;
#u = !1;
constructor(e, t, n = {}) {
this.type = e, e && (this.#t = !0), this.#i = t, this.#e = this.#i ? this.#i.#e : this, this.#c = this.#e === this ? n : this.#e.#c, this.#o = this.#e === this ? [] : this.#e.#o, e === "!" && !this.#e.#s && this.#o.push(this), this.#a = this.#i ? this.#i.#r.length : 0;
}
get hasMagic() {
if (this.#t !== void 0) return this.#t;
for (let e of this.#r) if (typeof e != "string" && (e.type || e.hasMagic)) return this.#t = !0;
return this.#t;
}
toString() {
return this.#l === void 0 ? this.#l = this.type ? this.type + "(" + this.#r.map((e) => String(e)).join("|") + ")" : this.#r.map((e) => String(e)).join("") : this.#l;
}
#d() {
if (this !== this.#e) throw Error("should only call on root");
if (this.#s) return this;
this.toString(), this.#s = !0;
let e;
for (; e = this.#o.pop();) {
if (e.type !== "!") continue;
let t = e, n = t.#i;
for (; n;) {
for (let r = t.#a + 1; !n.type && r < n.#r.length; r++) for (let t of e.#r) {
if (typeof t == "string") throw Error("string part in extglob AST??");
t.copyIn(n.#r[r]);
}
t = n, n = t.#i;
}
}
return this;
}
push(...t) {
for (let n of t) if (n !== "") {
if (typeof n != "string" && !(n instanceof e && n.#i === this)) throw Error("invalid part: " + n);
this.#r.push(n);
}
}
toJSON() {
let e = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
return this.isStart() && !this.type && e.unshift([]), this.isEnd() && (this === this.#e || this.#e.#s && this.#i?.type === "!") && e.push({}), e;
}
isStart() {
if (this.#e === this) return !0;
if (!this.#i?.isStart()) return !1;
if (this.#a === 0) return !0;
let t = this.#i;
for (let n = 0; n < this.#a; n++) {
let r = t.#r[n];
if (!(r instanceof e && r.type === "!")) return !1;
}
return !0;
}
isEnd() {
if (this.#e === this || this.#i?.type === "!") return !0;
if (!this.#i?.isEnd()) return !1;
if (!this.type) return this.#i?.isEnd();
let e = this.#i ? this.#i.#r.length : 0;
return this.#a === e - 1;
}
copyIn(e) {
typeof e == "string" ? this.push(e) : this.push(e.clone(this));
}
clone(t) {
let n = new e(this.type, t);
for (let e of this.#r) n.copyIn(e);
return n;
}
static #f(t, n, r, a) {
let o = !1, s = !1, c = -1, l = !1;
if (n.type === null) {
let u = r, d = "";
for (; u < t.length;) {
let r = t.charAt(u++);
if (o || r === "\\") {
o = !o, d += r;
continue;
}
if (s) {
u === c + 1 ? (r === "^" || r === "!") && (l = !0) : r === "]" && !(u === c + 2 && l) && (s = !1), d += r;
continue;
}
if (r === "[") {
s = !0, c = u, l = !1, d += r;
continue;
}
if (!a.noext && i(r) && t.charAt(u) === "(") {
n.push(d), d = "";
let i = new e(r, n);
u = e.#f(t, i, u, a), n.push(i);
continue;
}
d += r;
}
return n.push(d), u;
}
let u = r + 1, d = new e(null, n), f = [], p = "";
for (; u < t.length;) {
let r = t.charAt(u++);
if (o || r === "\\") {
o = !o, p += r;
continue;
}
if (s) {
u === c + 1 ? (r === "^" || r === "!") && (l = !0) : r === "]" && !(u === c + 2 && l) && (s = !1), p += r;
continue;
}
if (r === "[") {
s = !0, c = u, l = !1, p += r;
continue;
}
if (i(r) && t.charAt(u) === "(") {
d.push(p), p = "";
let n = new e(r, d);
d.push(n), u = e.#f(t, n, u, a);
continue;
}
if (r === "|") {
d.push(p), p = "", f.push(d), d = new e(null, n);
continue;
}
if (r === ")") return p === "" && n.#r.length === 0 && (n.#u = !0), d.push(p), p = "", n.push(...f, d), u;
p += r;
}
return n.type = null, n.#t = void 0, n.#r = [t.substring(r - 1)], u;
}
static fromGlob(t, n = {}) {
let r = new e(null, void 0, n);
return e.#f(t, r, 0, n), r;
}
toMMPattern() {
if (this !== this.#e) return this.#e.toMMPattern();
let e = this.toString(), [t, n, r, i] = this.toRegExpSource();
if (!(r || this.#t || this.#c.nocase && !this.#c.nocaseMagicOnly && e.toUpperCase() !== e.toLowerCase())) return n;
let a = (this.#c.nocase ? "i" : "") + (i ? "u" : "");
return Object.assign(RegExp(`^${t}$`, a), {
_src: t,
_glob: e
});
}
get options() {
return this.#c;
}
toRegExpSource(t) {
let r = t ?? !!this.#c.dot;
if (this.#e === this && this.#d(), !this.type) {
let i = this.isStart() && this.isEnd() && !this.#r.some((e) => typeof e != "string"), o = this.#r.map((n) => {
let [r, a, o, s] = typeof n == "string" ? e.#m(n, this.#t, i) : n.toRegExpSource(t);
return this.#t = this.#t || o, this.#n = this.#n || s, r;
}).join(""), s = "";
if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && u.has(this.#r[0]))) {
let e = l, n = r && e.has(o.charAt(0)) || o.startsWith("\\.") && e.has(o.charAt(2)) || o.startsWith("\\.\\.") && e.has(o.charAt(4)), i = !r && !t && e.has(o.charAt(0));
s = n ? a : i ? c : "";
}
let d = "";
return this.isEnd() && this.#e.#s && this.#i?.type === "!" && (d = "(?:$|\\/)"), [
s + o + d,
(0, n.unescape)(o),
this.#t = !!this.#t,
this.#n
];
}
let i = this.type === "*" || this.type === "+", o = this.type === "!" ? "(?:(?!(?:" : "(?:", s = this.#p(r);
if (this.isStart() && this.isEnd() && !s && this.type !== "!") {
let e = this.toString();
return this.#r = [e], this.type = null, this.#t = void 0, [
e,
(0, n.unescape)(this.toString()),
!1,
!1
];
}
let d = !i || t || r || !c ? "" : this.#p(!0);
d === s && (d = ""), d && (s = `(?:${s})(?:${d})*?`);
let f = "";
if (this.type === "!" && this.#u) f = (this.isStart() && !r ? c : "") + h;
else {
let e = this.type === "!" ? "))" + (this.isStart() && !r && !t ? c : "") + m + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && d ? ")" : this.type === "*" && d ? ")?" : `)${this.type}`;
f = o + s + e;
}
return [
f,
(0, n.unescape)(s),
this.#t = !!this.#t,
this.#n
];
}
#p(e) {
return this.#r.map((t) => {
if (typeof t == "string") throw Error("string type in extglob ast??");
let [n, r, i, a] = t.toRegExpSource(e);
return this.#n = this.#n || a, n;
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
}
static #m(e, r, i = !1) {
let a = !1, o = "", s = !1, c = !1;
for (let n = 0; n < e.length; n++) {
let l = e.charAt(n);
if (a) {
a = !1, o += (d.has(l) ? "\\" : "") + l;
continue;
}
if (l === "*") {
if (c) continue;
c = !0, o += i && /^[*]+$/.test(e) ? h : m, r = !0;
continue;
}
if (c = !1, l === "\\") {
n === e.length - 1 ? o += "\\\\" : a = !0;
continue;
}
if (l === "[") {
let [i, a, c, l] = (0, t.parseClass)(e, n);
if (c) {
o += i, s ||= a, n += c - 1, r ||= l;
continue;
}
}
if (l === "?") {
o += p, r = !0;
continue;
}
o += f(l);
}
return [
o,
(0, n.unescape)(e),
!!r,
s
];
}
};
}), l = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.escape = void 0, e.escape = (e, { windowsPathsNoEscape: t = !1, magicalBraces: n = !1 } = {}) => n ? t ? e.replace(/[?*()[\]{}]/g, "[$&]") : e.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? e.replace(/[?*()[\]]/g, "[$&]") : e.replace(/[?*()[\]\\]/g, "\\$&");
}), u = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.unescape = e.escape = e.AST = e.Minimatch = e.match = e.makeRe = e.braceExpand = e.defaults = e.filter = e.GLOBSTAR = e.sep = e.minimatch = void 0;
var t = i(), n = a(), r = c(), o = l(), u = s();
e.minimatch = (e, t, r = {}) => ((0, n.assertValidPattern)(t), !r.nocomment && t.charAt(0) === "#" ? !1 : new z(t, r).match(e));
var d = /^\*+([^+@!?\*\[\(]*)$/, f = (e) => (t) => !t.startsWith(".") && t.endsWith(e), p = (e) => (t) => t.endsWith(e), m = (e) => (e = e.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(e)), h = (e) => (e = e.toLowerCase(), (t) => t.toLowerCase().endsWith(e)), g = /^\*+\.\*+$/, _ = (e) => !e.startsWith(".") && e.includes("."), v = (e) => e !== "." && e !== ".." && e.includes("."), y = /^\.\*+$/, b = (e) => e !== "." && e !== ".." && e.startsWith("."), x = /^\*+$/, S = (e) => e.length !== 0 && !e.startsWith("."), C = (e) => e.length !== 0 && e !== "." && e !== "..", w = /^\?+([^+@!?\*\[\(]*)?$/, T = ([e, t = ""]) => {
let n = k([e]);
return t ? (t = t.toLowerCase(), (e) => n(e) && e.toLowerCase().endsWith(t)) : n;
}, E = ([e, t = ""]) => {
let n = A([e]);
return t ? (t = t.toLowerCase(), (e) => n(e) && e.toLowerCase().endsWith(t)) : n;
}, D = ([e, t = ""]) => {
let n = A([e]);
return t ? (e) => n(e) && e.endsWith(t) : n;
}, O = ([e, t = ""]) => {
let n = k([e]);
return t ? (e) => n(e) && e.endsWith(t) : n;
}, k = ([e]) => {
let t = e.length;
return (e) => e.length === t && !e.startsWith(".");
}, A = ([e]) => {
let t = e.length;
return (e) => e.length === t && e !== "." && e !== "..";
}, j = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", M = {
win32: { sep: "\\" },
posix: { sep: "/" }
};
e.sep = j === "win32" ? M.win32.sep : M.posix.sep, e.minimatch.sep = e.sep, e.GLOBSTAR = Symbol("globstar **"), e.minimatch.GLOBSTAR = e.GLOBSTAR;
var N = "[^/]*?", P = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", F = "(?:(?!(?:\\/|^)\\.).)*?";
e.filter = (t, n = {}) => (r) => (0, e.minimatch)(r, t, n), e.minimatch.filter = e.filter;
var I = (e, t = {}) => Object.assign({}, e, t);
e.defaults = (t) => {
if (!t || typeof t != "object" || !Object.keys(t).length) return e.minimatch;
let n = e.minimatch;
return Object.assign((e, r, i = {}) => n(e, r, I(t, i)), {
Minimatch: class extends n.Minimatch {
constructor(e, n = {}) {
super(e, I(t, n));
}
static defaults(e) {
return n.defaults(I(t, e)).Minimatch;
}
},
AST: class extends n.AST {
constructor(e, n, r = {}) {
super(e, n, I(t, r));
}
static fromGlob(e, r = {}) {
return n.AST.fromGlob(e, I(t, r));
}
},
unescape: (e, r = {}) => n.unescape(e, I(t, r)),
escape: (e, r = {}) => n.escape(e, I(t, r)),
filter: (e, r = {}) => n.filter(e, I(t, r)),
defaults: (e) => n.defaults(I(t, e)),
makeRe: (e, r = {}) => n.makeRe(e, I(t, r)),
braceExpand: (e, r = {}) => n.braceExpand(e, I(t, r)),
match: (e, r, i = {}) => n.match(e, r, I(t, i)),
sep: n.sep,
GLOBSTAR: e.GLOBSTAR
});
}, e.minimatch.defaults = e.defaults, e.braceExpand = (e, r = {}) => ((0, n.assertValidPattern)(e), r.nobrace || !/\{(?:(?!\{).)*\}/.test(e) ? [e] : (0, t.expand)(e, { max: r.braceExpandMax })), e.minimatch.braceExpand = e.braceExpand, e.makeRe = (e, t = {}) => new z(e, t).makeRe(), e.minimatch.makeRe = e.makeRe, e.match = (e, t, n = {}) => {
let r = new z(t, n);
return e = e.filter((e) => r.match(e)), r.options.nonull && !e.length && e.push(t), e;
}, e.minimatch.match = e.match;
var L = /[?*]|[+@!]\(.*?\)|\[|\]/, R = (e) => e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), z = class {
options;
set;
pattern;
windowsPathsNoEscape;
nonegate;
negate;
comment;
empty;
preserveMultipleSlashes;
partial;
globSet;
globParts;
nocase;
isWindows;
platform;
windowsNoMagicRoot;
regexp;
constructor(e, t = {}) {
(0, n.assertValidPattern)(e), t ||= {}, this.options = t, this.pattern = e, this.platform = t.platform || j, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!t.windowsPathsNoEscape || t.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!t.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!t.nonegate, this.comment = !1, this.empty = !1, this.partial = !!t.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = t.windowsNoMagicRoot === void 0 ? !!(this.isWindows && this.nocase) : t.windowsNoMagicRoot, this.globSet = [], this.globParts = [], this.set = [], this.make();
}
hasMagic() {
if (this.options.magicalBraces && this.set.length > 1) return !0;
for (let e of this.set) for (let t of e) if (typeof t != "string") return !0;
return !1;
}
debug(...e) {}
make() {
let e = this.pattern, t = this.options;
if (!t.nocomment && e.charAt(0) === "#") {
this.comment = !0;
return;
}
if (!e) {
this.empty = !0;
return;
}
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], t.debug && (this.debug = (...e) => console.error(...e)), this.debug(this.pattern, this.globSet);
let n = this.globSet.map((e) => this.slashSplit(e));
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
let r = this.globParts.map((e, t, n) => {
if (this.isWindows && this.windowsNoMagicRoot) {
let t = e[0] === "" && e[1] === "" && (e[2] === "?" || !L.test(e[2])) && !L.test(e[3]), n = /^[a-z]:/i.test(e[0]);
if (t) return [...e.slice(0, 4), ...e.slice(4).map((e) => this.parse(e))];
if (n) return [e[0], ...e.slice(1).map((e) => this.parse(e))];
}
return e.map((e) => this.parse(e));
});
if (this.debug(this.pattern, r), this.set = r.filter((e) => e.indexOf(!1) === -1), this.isWindows) for (let e = 0; e < this.set.length; e++) {
let t = this.set[e];
t[0] === "" && t[1] === "" && this.globParts[e][2] === "?" && typeof t[3] == "string" && /^[a-z]:$/i.test(t[3]) && (t[2] = "?");
}
this.debug(this.pattern, this.set);
}
preprocess(e) {
if (this.options.noglobstar) for (let t = 0; t < e.length; t++) for (let n = 0; n < e[t].length; n++) e[t][n] === "**" && (e[t][n] = "*");
let { optimizationLevel: t = 1 } = this.options;
return t >= 2 ? (e = this.firstPhasePreProcess(e), e = this.secondPhasePreProcess(e)) : e = t >= 1 ? this.levelOneOptimize(e) : this.adjascentGlobstarOptimize(e), e;
}
adjascentGlobstarOptimize(e) {
return e.map((e) => {
let t = -1;
for (; (t = e.indexOf("**", t + 1)) !== -1;) {
let n = t;
for (; e[n + 1] === "**";) n++;
n !== t && e.splice(t, n - t);
}
return e;
});
}
levelOneOptimize(e) {
return e.map((e) => (e = e.reduce((e, t) => {
let n = e[e.length - 1];
return t === "**" && n === "**" ? e : t === ".." && n && n !== ".." && n !== "." && n !== "**" ? (e.pop(), e) : (e.push(t), e);
}, []), e.length === 0 ? [""] : e));
}
levelTwoFileOptimize(e) {
Array.isArray(e) || (e = this.slashSplit(e));
let t = !1;
do {
if (t = !1, !this.preserveMultipleSlashes) {
for (let n = 1; n < e.length - 1; n++) {
let r = e[n];
n === 1 && r === "" && e[0] === "" || (r === "." || r === "") && (t = !0, e.splice(n, 1), n--);
}
e[0] === "." && e.length === 2 && (e[1] === "." || e[1] === "") && (t = !0, e.pop());
}
let n = 0;
for (; (n = e.indexOf("..", n + 1)) !== -1;) {
let r = e[n - 1];
r && r !== "." && r !== ".." && r !== "**" && (t = !0, e.splice(n - 1, 2), n -= 2);
}
} while (t);
return e.length === 0 ? [""] : e;
}
firstPhasePreProcess(e) {
let t = !1;
do {
t = !1;
for (let n of e) {
let r = -1;
for (; (r = n.indexOf("**", r + 1)) !== -1;) {
let i = r;
for (; n[i + 1] === "**";) i++;
i > r && n.splice(r + 1, i - r);
let a = n[r + 1], o = n[r + 2], s = n[r + 3];
if (a !== ".." || !o || o === "." || o === ".." || !s || s === "." || s === "..") continue;
t = !0, n.splice(r, 1);
let c = n.slice(0);
c[r] = "**", e.push(c), r--;
}
if (!this.preserveMultipleSlashes) {
for (let e = 1; e < n.length - 1; e++) {
let r = n[e];
e === 1 && r === "" && n[0] === "" || (r === "." || r === "") && (t = !0, n.splice(e, 1), e--);
}
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (t = !0, n.pop());
}
let i = 0;
for (; (i = n.indexOf("..", i + 1)) !== -1;) {
let e = n[i - 1];
if (e && e !== "." && e !== ".." && e !== "**") {
t = !0;
let e = i === 1 && n[i + 1] === "**" ? ["."] : [];
n.splice(i - 1, 2, ...e), n.length === 0 && n.push(""), i -= 2;
}
}
}
} while (t);
return e;
}
secondPhasePreProcess(e) {
for (let t = 0; t < e.length - 1; t++) for (let n = t + 1; n < e.length; n++) {
let r = this.partsMatch(e[t], e[n], !this.preserveMultipleSlashes);
if (r) {
e[t] = [], e[n] = r;
break;
}
}
return e.filter((e) => e.length);
}
partsMatch(e, t, n = !1) {
let r = 0, i = 0, a = [], o = "";
for (; r < e.length && i < t.length;) if (e[r] === t[i]) a.push(o === "b" ? t[i] : e[r]), r++, i++;
else if (n && e[r] === "**" && t[i] === e[r + 1]) a.push(e[r]), r++;
else if (n && t[i] === "**" && e[r] === t[i + 1]) a.push(t[i]), i++;
else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
if (o === "b") return !1;
o = "a", a.push(e[r]), r++, i++;
} else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
if (o === "a") return !1;
o = "b", a.push(t[i]), r++, i++;
} else return !1;
return e.length === t.length && a;
}
parseNegate() {
if (this.nonegate) return;
let e = this.pattern, t = !1, n = 0;
for (let r = 0; r < e.length && e.charAt(r) === "!"; r++) t = !t, n++;
n && (this.pattern = e.slice(n)), this.negate = t;
}
matchOne(t, n, r = !1) {
let i = this.options;
if (this.isWindows) {
let e = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), r = !e && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), i = typeof n[0] == "string" && /^[a-z]:$/i.test(n[0]), a = !i && n[0] === "" && n[1] === "" && n[2] === "?" && typeof n[3] == "string" && /^[a-z]:$/i.test(n[3]), o = r ? 3 : e ? 0 : void 0, s = a ? 3 : i ? 0 : void 0;
if (typeof o == "number" && typeof s == "number") {
let [e, r] = [t[o], n[s]];
e.toLowerCase() === r.toLowerCase() && (n[s] = e, s > o ? n = n.slice(s) : o > s && (t = t.slice(o)));
}
}
let { optimizationLevel: a = 1 } = this.options;
a >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, {
file: t,
pattern: n
}), this.debug("matchOne", t.length, n.length);
for (var o = 0, s = 0, c = t.length, l = n.length; o < c && s < l; o++, s++) {
this.debug("matchOne loop");
var u = n[s], d = t[o];
if (this.debug(n, u, d), u === !1) return !1;
if (u === e.GLOBSTAR) {
this.debug("GLOBSTAR", [
n,
u,
d
]);
var f = o, p = s + 1;
if (p === l) {
for (this.debug("** at the end"); o < c; o++) if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".") return !1;
return !0;
}
for (; f < c;) {
var m = t[f];
if (this.debug("\nglobstar while", t, f, n, p, m), this.matchOne(t.slice(f), n.slice(p), r)) return this.debug("globstar found match!", f, c, m), !0;
if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
this.debug("dot detected!", t, f, n, p);
break;
}
this.debug("globstar swallow a segment, and continue"), f++;
}
return !!(r && (this.debug("\n>>> no match, partial?", t, f, n, p), f === c));
}
let a;
if (typeof u == "string" ? (a = d === u, this.debug("string match", u, d, a)) : (a = u.test(d), this.debug("pattern match", u, d, a)), !a) return !1;
}
if (o === c && s === l) return !0;
if (o === c) return r;
if (s === l) return o === c - 1 && t[o] === "";
throw Error("wtf?");
}
braceExpand() {
return (0, e.braceExpand)(this.pattern, this.options);
}
parse(t) {
(0, n.assertValidPattern)(t);
let i = this.options;
if (t === "**") return e.GLOBSTAR;
if (t === "") return "";
let a, o = null;
(a = t.match(x)) ? o = i.dot ? C : S : (a = t.match(d)) ? o = (i.nocase ? i.dot ? h : m : i.dot ? p : f)(a[1]) : (a = t.match(w)) ? o = (i.nocase ? i.dot ? E : T : i.dot ? D : O)(a) : (a = t.match(g)) ? o = i.dot ? v : _ : (a = t.match(y)) && (o = b);
let s = r.AST.fromGlob(t, this.options).toMMPattern();
return o && typeof s == "object" && Reflect.defineProperty(s, "test", { value: o }), s;
}
makeRe() {
if (this.regexp || this.regexp === !1) return this.regexp;
let t = this.set;
if (!t.length) return this.regexp = !1, this.regexp;
let n = this.options, r = n.noglobstar ? N : n.dot ? P : F, i = new Set(n.nocase ? ["i"] : []), a = t.map((t) => {
let n = t.map((t) => {
if (t instanceof RegExp) for (let e of t.flags.split("")) i.add(e);
return typeof t == "string" ? R(t) : t === e.GLOBSTAR ? e.GLOBSTAR : t._src;
});
n.forEach((t, i) => {
let a = n[i + 1], o = n[i - 1];
t !== e.GLOBSTAR || o === e.GLOBSTAR || (o === void 0 ? a !== void 0 && a !== e.GLOBSTAR ? n[i + 1] = "(?:\\/|" + r + "\\/)?" + a : n[i] = r : a === void 0 ? n[i - 1] = o + "(?:\\/|\\/" + r + ")?" : a !== e.GLOBSTAR && (n[i - 1] = o + "(?:\\/|\\/" + r + "\\/)" + a, n[i + 1] = e.GLOBSTAR));
});
let a = n.filter((t) => t !== e.GLOBSTAR);
if (this.partial && a.length >= 1) {
let e = [];
for (let t = 1; t <= a.length; t++) e.push(a.slice(0, t).join("/"));
return "(?:" + e.join("|") + ")";
}
return a.join("/");
}).join("|"), [o, s] = t.length > 1 ? ["(?:", ")"] : ["", ""];
a = "^" + o + a + s + "$", this.partial && (a = "^(?:\\/|" + o + a.slice(1, -1) + s + ")$"), this.negate && (a = "^(?!" + a + ").+$");
try {
this.regexp = new RegExp(a, [...i].join(""));
} catch {
this.regexp = !1;
}
return this.regexp;
}
slashSplit(e) {
return this.preserveMultipleSlashes ? e.split("/") : this.isWindows && /^\/\/[^\/]+/.test(e) ? ["", ...e.split(/\/+/)] : e.split(/\/+/);
}
match(e, t = this.partial) {
if (this.debug("match", e, this.pattern), this.comment) return !1;
if (this.empty) return e === "";
if (e === "/" && t) return !0;
let n = this.options;
this.isWindows && (e = e.split("\\").join("/"));
let r = this.slashSplit(e);
this.debug(this.pattern, "split", r);
let i = this.set;
this.debug(this.pattern, "set", i);
let a = r[r.length - 1];
if (!a) for (let e = r.length - 2; !a && e >= 0; e--) a = r[e];
for (let e = 0; e < i.length; e++) {
let o = i[e], s = r;
if (n.matchBase && o.length === 1 && (s = [a]), this.matchOne(s, o, t)) return n.flipNegate ? !0 : !this.negate;
}
return !n.flipNegate && this.negate;
}
static defaults(t) {
return e.minimatch.defaults(t).Minimatch;
}
};
e.Minimatch = z;
var B = c();
Object.defineProperty(e, "AST", {
enumerable: !0,
get: function() {
return B.AST;
}
});
var V = l();
Object.defineProperty(e, "escape", {
enumerable: !0,
get: function() {
return V.escape;
}
});
var H = s();
Object.defineProperty(e, "unescape", {
enumerable: !0,
get: function() {
return H.unescape;
}
}), e.minimatch.AST = r.AST, e.minimatch.Minimatch = z, e.minimatch.escape = o.escape, e.minimatch.unescape = u.unescape;
}), d = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.LRUCache = void 0;
var t = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, n = /* @__PURE__ */ new Set(), r = typeof process == "object" && process ? process : {}, i = (e, t, n, i) => {
typeof r.emitWarning == "function" ? r.emitWarning(e, t, n, i) : console.error(`[${n}] ${t}: ${e}`);
}, a = globalThis.AbortController, o = globalThis.AbortSignal;
if (typeof a > "u") {
o = class {
onabort;
_onabort = [];
reason;
aborted = !1;
addEventListener(e, t) {
this._onabort.push(t);
}
}, a = class {
constructor() {
t();
}
signal = new o();
abort(e) {
if (!this.signal.aborted) {
this.signal.reason = e, this.signal.aborted = !0;
for (let t of this.signal._onabort) t(e);
this.signal.onabort?.(e);
}
}
};
let e = r.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
e && (e = !1, i("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
};
}
var s = (e) => !n.has(e), c = (e) => e && e === Math.floor(e) && e > 0 && isFinite(e), l = (e) => c(e) ? e <= 256 ? Uint8Array : e <= 2 ** 16 ? Uint16Array : e <= 2 ** 32 ? Uint32Array : e <= 2 ** 53 - 1 ? u : null : null, u = class extends Array {
constructor(e) {
super(e), this.fill(0);
}
}, d = class e {
heap;
length;
static #e = !1;
static create(t) {
let n = l(t);
if (!n) return [];
e.#e = !0;
let r = new e(t, n);
return e.#e = !1, r;
}
constructor(t, n) {
if (!e.#e) throw TypeError("instantiate Stack using Stack.create(n)");
this.heap = new n(t), this.length = 0;
}
push(e) {
this.heap[this.length++] = e;
}
pop() {
return this.heap[--this.length];
}
};
e.LRUCache = class e {
#e;
#t;
#n;
#r;
#i;
#a;
#o;
#s;
get perf() {
return this.#s;
}
ttl;
ttlResolution;
ttlAutopurge;
updateAgeOnGet;
updateAgeOnHas;
allowStale;
noDisposeOnSet;
noUpdateTTL;
maxEntrySize;
sizeCalculation;
noDeleteOnFetchRejection;
noDeleteOnStaleGet;
allowStaleOnFetchAbort;
allowStaleOnFetchRejection;
ignoreFetchAbort;
#c;
#l;
#u;
#d;
#f;
#p;
#m;
#h;
#g;
#_;
#v;
#y;
#b;
#x;
#S;
#C;
#w;
#T;
#E;
static unsafeExposeInternals(e) {
return {
starts: e.#b,
ttls: e.#x,
autopurgeTimers: e.#S,
sizes: e.#y,
keyMap: e.#u,
keyList: e.#d,
valList: e.#f,
next: e.#p,
prev: e.#m,
get head() {
return e.#h;
},
get tail() {
return e.#g;
},
free: e.#_,
isBackgroundFetch: (t) => e.#V(t),
backgroundFetch: (t, n, r, i) => e.#B(t, n, r, i),
moveToTail: (t) => e.#U(t),
indexes: (t) => e.#I(t),
rindexes: (t) => e.#L(t),
isStale: (t) => e.#j(t)
};
}
get max() {
return this.#e;
}
get maxSize() {
return this.#t;
}
get calculatedSize() {
return this.#l;
}
get size() {
return this.#c;
}
get fetchMethod() {
return this.#a;
}
get memoMethod() {
return this.#o;
}
get dispose() {
return this.#n;
}
get onInsert() {
return this.#r;
}
get disposeAfter() {
return this.#i;
}
constructor(r) {
let { max: a = 0, ttl: o, ttlResolution: u = 1, ttlAutopurge: f, updateAgeOnGet: p, updateAgeOnHas: m, allowStale: h, dispose: g, onInsert: _, disposeAfter: v, noDisposeOnSet: y, noUpdateTTL: b, maxSize: x = 0, maxEntrySize: S = 0, sizeCalculation: C, fetchMethod: w, memoMethod: T, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: D, allowStaleOnFetchRejection: O, allowStaleOnFetchAbort: k, ignoreFetchAbort: A, perf: j } = r;
if (j !== void 0 && typeof j?.now != "function") throw TypeError("perf option must have a now() method if specified");
if (this.#s = j ?? t, a !== 0 && !c(a)) throw TypeError("max option must be a nonnegative integer");
let M = a ? l(a) : Array;
if (!M) throw Error("invalid max value: " + a);
if (this.#e = a, this.#t = x, this.maxEntrySize = S || this.#t, this.sizeCalculation = C, this.sizeCalculation) {
if (!this.#t && !this.maxEntrySize) throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
if (typeof this.sizeCalculation != "function") throw TypeError("sizeCalculation set to non-function");
}
if (T !== void 0 && typeof T != "function") throw TypeError("memoMethod must be a function if defined");
if (this.#o = T, w !== void 0 && typeof w != "function") throw TypeError("fetchMethod must be a function if specified");
if (this.#a = w, this.#w = !!w, this.#u = /* @__PURE__ */ new Map(), this.#d = Array(a).fill(void 0), this.#f = Array(a).fill(void 0), this.#p = new M(a), this.#m = new M(a), this.#h = 0, this.#g = 0, this.#_ = d.create(a), this.#c = 0, this.#l = 0, typeof g == "function" && (this.#n = g), typeof _ == "function" && (this.#r = _), typeof v == "function" ? (this.#i = v, this.#v = []) : (this.#i = void 0, this.#v = void 0), this.#C = !!this.#n, this.#E = !!this.#r, this.#T = !!this.#i, this.noDisposeOnSet = !!y, this.noUpdateTTL = !!b, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!O, this.allowStaleOnFetchAbort = !!k, this.ignoreFetchAbort = !!A, this.maxEntrySize !== 0) {
if (this.#t !== 0 && !c(this.#t)) throw TypeError("maxSize must be a positive integer if specified");
if (!c(this.maxEntrySize)) throw TypeError("maxEntrySize must be a positive integer if specified");
this.#M();
}
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!D, this.updateAgeOnGet = !!p, this.updateAgeOnHas = !!m, this.ttlResolution = c(u) || u === 0 ? u : 1, this.ttlAutopurge = !!f, this.ttl = o || 0, this.ttl) {
if (!c(this.ttl)) throw TypeError("ttl must be a positive integer if specified");
this.#D();
}
if (this.#e === 0 && this.ttl === 0 && this.#t === 0) throw TypeError("At least one of max, maxSize, or ttl is required");
if (!this.ttlAutopurge && !this.#e && !this.#t) {
let t = "LRU_CACHE_UNBOUNDED";
s(t) && (n.add(t), i("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", t, e));
}
}
getRemainingTTL(e) {
return this.#u.has(e) ? 1 / 0 : 0;
}
#D() {
let e = new u(this.#e), t = new u(this.#e);
this.#x = e, this.#b = t;
let n = this.ttlAutopurge ? Array(this.#e) : void 0;
this.#S = n, this.#A = (r, i, a = this.#s.now()) => {
if (t[r] = i === 0 ? 0 : a, e[r] = i, n?.[r] && (clearTimeout(n[r]), n[r] = void 0), i !== 0 && n) {
let e = setTimeout(() => {
this.#j(r) && this.#W(this.#d[r], "expire");
}, i + 1);
e.unref && e.unref(), n[r] = e;
}
}, this.#O = (n) => {
t[n] = e[n] === 0 ? 0 : this.#s.now();
}, this.#k = (n, a) => {
if (e[a]) {
let o = e[a], s = t[a];
if (!o || !s) return;
n.ttl = o, n.start = s, n.now = r || i(), n.remainingTTL = o - (n.now - s);
}
};
let r = 0, i = () => {
let e = this.#s.now();
if (this.ttlResolution > 0) {
r = e;
let t = setTimeout(() => r = 0, this.ttlResolution);
t.unref && t.unref();
}
return e;
};
this.getRemainingTTL = (n) => {
let a = this.#u.get(n);
if (a === void 0) return 0;
let o = e[a], s = t[a];
return !o || !s ? 1 / 0 : o - ((r || i()) - s);
}, this.#j = (n) => {
let a = t[n], o = e[n];
return !!o && !!a && (r || i()) - a > o;
};
}
#O = () => {};
#k = () => {};
#A = () => {};
#j = () => !1;
#M() {
let e = new u(this.#e);
this.#l = 0, this.#y = e, this.#N = (t) => {
this.#l -= e[t], e[t] = 0;
}, this.#F = (e, t, n, r) => {
if (this.#V(t)) return 0;
if (!c(n)) {
if (r) {
if (typeof r != "function") throw TypeError("sizeCalculation must be a function");
if (n = r(t, e), !c(n)) throw TypeError("sizeCalculation return invalid (expect positive integer)");
} else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
}
return n;
}, this.#P = (t, n, r) => {
if (e[t] = n, this.#t) {
let n = this.#t - e[t];
for (; this.#l > n;) this.#z(!0);
}
this.#l += e[t], r && (r.entrySize = n, r.totalCalculatedSize = this.#l);
};
}
#N = (e) => {};
#P = (e, t, n) => {};
#F = (e, t, n, r) => {
if (n || r) throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
return 0;
};
*#I({ allowStale: e = this.allowStale } = {}) {
if (this.#c) for (let t = this.#g; !(!this.#R(t) || ((e || !this.#j(t)) && (yield t), t === this.#h));) t = this.#m[t];
}
*#L({ allowStale: e = this.allowStale } = {}) {
if (this.#c) for (let t = this.#h; !(!this.#R(t) || ((e || !this.#j(t)) && (yield t), t === this.#g));) t = this.#p[t];
}
#R(e) {
return e !== void 0 && this.#u.get(this.#d[e]) === e;
}
*entries() {
for (let e of this.#I()) this.#f[e] !== void 0 && this.#d[e] !== void 0 && !this.#V(this.#f[e]) && (yield [this.#d[e], this.#f[e]]);
}
*rentries() {
for (let e of this.#L()) this.#f[e] !== void 0 && this.#d[e] !== void 0 && !this.#V(this.#f[e]) && (yield [this.#d[e], this.#f[e]]);
}
*keys() {
for (let e of this.#I()) {
let t = this.#d[e];
t !== void 0 && !this.#V(this.#f[e]) && (yield t);
}
}
*rkeys() {
for (let e of this.#L()) {
let t = this.#d[e];
t !== void 0 && !this.#V(this.#f[e]) && (yield t);
}
}
*values() {
for (let e of this.#I()) this.#f[e] !== void 0 && !this.#V(this.#f[e]) && (yield this.#f[e]);
}
*rvalues() {
for (let e of this.#L()) this.#f[e] !== void 0 && !this.#V(this.#f[e]) && (yield this.#f[e]);
}
[Symbol.iterator]() {
return this.entries();
}
[Symbol.toStringTag] = "LRUCache";
find(e, t = {}) {
for (let n of this.#I()) {
let r = this.#f[n], i = this.#V(r) ? r.__staleWhileFetching : r;
if (i !== void 0 && e(i, this.#d[n], this)) return this.get(this.#d[n], t);
}
}
forEach(e, t = this) {
for (let n of this.#I()) {
let r = this.#f[n], i = this.#V(r) ? r.__staleWhileFetching : r;
i !== void 0 && e.call(t, i, this.#d[n], this);
}
}
rforEach(e, t = this) {
for (let n of this.#L()) {
let r = this.#f[n], i = this.#V(r) ? r.__staleWhileFetching : r;
i !== void 0 && e.call(t, i, this.#d[n], this);
}
}
purgeStale() {
let e = !1;
for (let t of this.#L({ allowStale: !0 })) this.#j(t) && (this.#W(this.#d[t], "expire"), e = !0);
return e;
}
info(e) {
let t = this.#u.get(e);
if (t === void 0) return;
let n = this.#f[t], r = this.#V(n) ? n.__staleWhileFetching : n;
if (r === void 0) return;
let i = { value: r };
if (this.#x && this.#b) {
let e = this.#x[t], n = this.#b[t];
e && n && (i.ttl = e - (this.#s.now() - n), i.start = Date.now());
}
return this.#y && (i.size = this.#y[t]), i;
}
dump() {
let e = [];
for (let t of this.#I({ allowStale: !0 })) {
let n = this.#d[t], r = this.#f[t], i = this.#V(r) ? r.__staleWhileFetching : r;
if (i === void 0 || n === void 0) continue;
let a = { value: i };
if (this.#x && this.#b) {
a.ttl = this.#x[t];
let e = this.#s.now() - this.#b[t];
a.start = Math.floor(Date.now() - e);
}
this.#y && (a.size = this.#y[t]), e.unshift([n, a]);
}
return e;
}
load(e) {
this.clear();
for (let [t, n] of e) {
if (n.start) {
let e = Date.now() - n.start;
n.start = this.#s.now() - e;
}
this.set(t, n.value, n);
}
}
set(e, t, n = {}) {
if (t === void 0) return this.delete(e), this;
let { ttl: r = this.ttl, start: i, noDisposeOnSet: a = this.noDisposeOnSet, sizeCalculation: o = this.sizeCalculation, status: s } = n, { noUpdateTTL: c = this.noUpdateTTL } = n, l = this.#F(e, t, n.size || 0, o);
if (this.maxEntrySize && l > this.maxEntrySize) return s && (s.set = "miss", s.maxEntrySizeExceeded = !0), this.#W(e, "set"), this;
let u = this.#c === 0 ? void 0 : this.#u.get(e);
if (u === void 0) u = this.#c === 0 ? this.#g : this.#_.length === 0 ? this.#c === this.#e ? this.#z(!1) : this.#c : this.#_.pop(), this.#d[u] = e, this.#f[u] = t, this.#u.set(e, u), this.#p[this.#g] = u, this.#m[u] = this.#g, this.#g = u, this.#c++, this.#P(u, l, s), s && (s.set = "add"), c = !1, this.#E && this.#r?.(t, e, "add");
else {
this.#U(u);
let n = this.#f[u];
if (t !== n) {
if (this.#w && this.#V(n)) {
n.__abortController.abort(/* @__PURE__ */ Error("replaced"));
let { __staleWhileFetching: t } = n;
t !== void 0 && !a && (this.#C && this.#n?.(t, e, "set"), this.#T && this.#v?.push([
t,
e,
"set"
]));
} else a || (this.#C && this.#n?.(n, e, "set"), this.#T && this.#v?.push([
n,
e,
"set"
]));
if (this.#N(u), this.#P(u, l, s), this.#f[u] = t, s) {
s.set = "replace";
let e = n && this.#V(n) ? n.__staleWhileFetching : n;
e !== void 0 && (s.oldValue = e);
}
} else s && (s.set = "update");
this.#E && this.onInsert?.(t, e, t === n ? "update" : "replace");
}
if (r !== 0 && !this.#x && this.#D(), this.#x && (c || this.#A(u, r, i), s && this.#k(s, u)), !a && this.#T && this.#v) {
let e = this.#v, t;
for (; t = e?.shift();) this.#i?.(...t);
}
return this;
}
pop() {
try {
for (; this.#c;) {
let e = this.#f[this.#h];
if (this.#z(!0), this.#V(e)) {
if (e.__staleWhileFetching) return e.__staleWhileFetching;
} else if (e !== void 0) return e;
}
} finally {
if (this.#T && this.#v) {
let e = this.#v, t;
for (; t = e?.shift();) this.#i?.(...t);
}
}
}
#z(e) {
let t = this.#h, n = this.#d[t], r = this.#f[t];
return this.#w && this.#V(r) ? r.__abortController.abort(/* @__PURE__ */ Error("evicted")) : (this.#C || this.#T) && (this.#C && this.#n?.(r, n, "evict"), this.#T && this.#v?.push([
r,
n,
"evict"
])), this.#N(t), this.#S?.[t] && (clearTimeout(this.#S[t]), this.#S[t] = void 0), e && (this.#d[t] = void 0, this.#f[t] = void 0, this.#_.push(t)), this.#c === 1 ? (this.#h = this.#g = 0, this.#_.length = 0) : this.#h = this.#p[t], this.#u.delete(n), this.#c--, t;
}
has(e, t = {}) {
let { updateAgeOnHas: n = this.updateAgeOnHas, status: r } = t, i = this.#u.get(e);
if (i !== void 0) {
let e = this.#f[i];
if (this.#V(e) && e.__staleWhileFetching === void 0) return !1;
if (this.#j(i)) r && (r.has = "stale", this.#k(r, i));
else return n && this.#O(i), r && (r.has = "hit", this.#k(r, i)), !0;
} else r && (r.has = "miss");
return !1;
}
peek(e, t = {}) {
let { allowStale: n = this.allowStale } = t, r = this.#u.get(e);
if (r === void 0 || !n && this.#j(r)) return;
let i = this.#f[r];
return this.#V(i) ? i.__staleWhileFetching : i;
}
#B(e, t, n, r) {
let i = t === void 0 ? void 0 : this.#f[t];
if (this.#V(i)) return i;
let o = new a(), { signal: s } = n;
s?.addEventListener("abort", () => o.abort(s.reason), { signal: o.signal });
let c = {
signal: o.signal,
options: n,
context: r
}, l = (r, i = !1) => {
let { aborted: a } = o.signal, s = n.ignoreFetchAbort && r !== void 0, l = n.ignoreFetchAbort || !!(n.allowStaleOnFetchAbort && r !== void 0);
if (n.status && (a && !i ? (n.status.fetchAborted = !0, n.status.fetchError = o.signal.reason, s && (n.status.fetchAbortIgnored = !0)) : n.status.fetchResolved = !0), a && !s && !i) return d(o.signal.reason, l);
let u = p, f = this.#f[t];
return (f === p || s && i && f === void 0) && (r === void 0 ? u.__staleWhileFetching === void 0 ? this.#W(e, "fetch") : this.#f[t] = u.__staleWhileFetching : (n.status && (n.status.fetchUpdated = !0), this.set(e, r, c.options))), r;
}, u = (e) => (n.status && (n.status.fetchRejected = !0, n.status.fetchError = e), d(e, !1)), d = (r, i) => {
let { aborted: a } = o.signal, s = a && n.allowStaleOnFetchAbort, c = s || n.allowStaleOnFetchRejection, l = c || n.noDeleteOnFetchRejection, u = p;
if (this.#f[t] === p && (!l || !i && u.__staleWhileFetching === void 0 ? this.#W(e, "fetch") : s || (this.#f[t] = u.__staleWhileFetching)), c) return n.status && u.__staleWhileFetching !== void 0 && (n.status.returnedStale = !0), u.__staleWhileFetching;
if (u.__returned === u) throw r;
}, f = (t, r) => {
let a = this.#a?.(e, i, c);
a && a instanceof Promise && a.then((e) => t(e === void 0 ? void 0 : e), r), o.signal.addEventListener("abort", () => {
(!n.ignoreFetchAbort || n.allowStaleOnFetchAbort) && (t(void 0), n.allowStaleOnFetchAbort && (t = (e) => l(e, !0)));
});
};
n.status && (n.status.fetchDispatched = !0);
let p = new Promise(f).then(l, u), m = Object.assign(p, {
__abortController: o,
__staleWhileFetching: i,
__returned: void 0
});
return t === void 0 ? (this.set(e, m, {
...c.options,
status: void 0
}), t = this.#u.get(e)) : this.#f[t] = m, m;
}
#V(e) {
if (!this.#w) return !1;
let t = e;
return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof a;
}
async fetch(e, t = {}) {
let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, ttl: a = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: s = 0, sizeCalculation: c = this.sizeCalculation, noUpdateTTL: l = this.noUpdateTTL, noDeleteOnFetchRejection: u = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: m, forceRefresh: h = !1, status: g, signal: _ } = t;
if (!this.#w) return g && (g.fetch = "get"), this.get(e, {
allowStale: n,
updateAgeOnGet: r,
noDeleteOnStaleGet: i,
status: g
});
let v = {
allowStale: n,
updateAgeOnGet: r,
noDeleteOnStaleGet: i,
ttl: a,
noDisposeOnSet: o,
size: s,
sizeCalculation: c,
noUpdateTTL: l,
noDeleteOnFetchRejection: u,
allowStaleOnFetchRejection: d,
allowStaleOnFetchAbort: p,
ignoreFetchAbort: f,
status: g,
signal: _
}, y = this.#u.get(e);
if (y === void 0) {
g && (g.fetch = "miss");
let t = this.#B(e, y, v, m);
return t.__returned = t;
}
{
let t = this.#f[y];
if (this.#V(t)) {
let e = n && t.__staleWhileFetching !== void 0;
return g && (g.fetch = "inflight", e && (g.returnedStale = !0)), e ? t.__staleWhileFetching : t.__returned = t;
}
let i = this.#j(y);
if (!h && !i) return g && (g.fetch = "hit"), this.#U(y), r && this.#O(y), g && this.#k(g, y), t;
let a = this.#B(e, y, v, m), o = a.__staleWhileFetching !== void 0 && n;
return g && (g.fetch = i ? "stale" : "refresh", o && i && (g.returnedStale = !0)), o ? a.__staleWhileFetching : a.__returned = a;
}
}
async forceFetch(e, t = {}) {
let n = await this.fetch(e, t);
if (n === void 0) throw Error("fetch() returned undefined");
return n;
}
memo(e, t = {}) {
let n = this.#o;
if (!n) throw Error("no memoMethod provided to constructor");
let { context: r, forceRefresh: i, ...a } = t, o = this.get(e, a);
if (!i && o !== void 0) return o;
let s = n(e, o, {
options: a,
context: r
});
return this.set(e, s, a), s;
}
get(e, t = {}) {
let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, status: a } = t, o = this.#u.get(e);
if (o !== void 0) {
let t = this.#f[o], s = this.#V(t);
return a && this.#k(a, o), this.#j(o) ? (a && (a.get = "stale"), s ? (a && n && t.__staleWhileFetching !== void 0 && (a.returnedStale = !0), n ? t.__staleWhileFetching : void 0) : (i || this.#W(e, "expire"), a && n && (a.returnedStale = !0), n ? t : void 0)) : (a && (a.get = "hit"), s ? t.__staleWhileFetching : (this.#U(o), r && this.#O(o), t));
}
a && (a.get = "miss");
}
#H(e, t) {
this.#m[t] = e, this.#p[e] = t;
}
#U(e) {
e !== this.#g && (e === this.#h ? this.#h = this.#p[e] : this.#H(this.#m[e], this.#p[e]), this.#H(this.#g, e), this.#g = e);
}
delete(e) {
return this.#W(e, "delete");
}
#W(e, t) {
let n = !1;
if (this.#c !== 0) {
let r = this.#u.get(e);
if (r !== void 0) {
if (this.#S?.[r] && (clearTimeout(this.#S?.[r]), this.#S[r] = void 0), n = !0, this.#c === 1) this.#G(t);
else {
this.#N(r);
let n = this.#f[r];
if (this.#V(n) ? n.__abortController.abort(/* @__PURE__ */ Error("deleted")) : (this.#C || this.#T) && (this.#C && this.#n?.(n, e, t), this.#T && this.#v?.push([
n,
e,
t
])), this.#u.delete(e), this.#d[r] = void 0, this.#f[r] = void 0, r === this.#g) this.#g = this.#m[r];
else if (r === this.#h) this.#h = this.#p[r];
else {
let e = this.#m[r];
this.#p[e] = this.#p[r];
let t = this.#p[r];
this.#m[t] = this.#m[r];
}
this.#c--, this.#_.push(r);
}
}
}
if (this.#T && this.#v?.length) {
let e = this.#v, t;
for (; t = e?.shift();) this.#i?.(...t);
}
return n;
}
clear() {
return this.#G("delete");
}
#G(e) {
for (let t of this.#L({ allowStale: !0 })) {
let n = this.#f[t];
if (this.#V(n)) n.__abortController.abort(/* @__PURE__ */ Error("deleted"));
else {
let r = this.#d[t];
this.#C && this.#n?.(n, r, e), this.#T && this.#v?.push([
n,
r,
e
]);
}
}
if (this.#u.clear(), this.#f.fill(void 0), this.#d.fill(void 0), this.#x && this.#b) {
this.#x.fill(0), this.#b.fill(0);
for (let e of this.#S ?? []) e !== void 0 && clearTimeout(e);
this.#S?.fill(void 0);
}
if (this.#y && this.#y.fill(0), this.#h = 0, this.#g = 0, this.#_.length = 0, this.#l = 0, this.#c = 0, this.#T && this.#v) {
let e = this.#v, t;
for (; t = e?.shift();) this.#i?.(...t);
}
}
};
}), f = n((e) => {
var n = e && e.__importDefault || function(e) {
return e && e.__esModule ? e : { default: e };
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.Minipass = e.isWritable = e.isReadable = e.isStream = void 0;
var r = typeof process == "object" && process ? process : {
stdout: null,
stderr: null
}, i = t("node:events"), a = n(t("node:stream")), o = t("node:string_decoder");
e.isStream = (t) => !!t && typeof t == "object" && (t instanceof q || t instanceof a.default || (0, e.isReadable)(t) || (0, e.isWritable)(t)), e.isReadable = (e) => !!e && typeof e == "object" && e instanceof i.EventEmitter && typeof e.pipe == "function" && e.pipe !== a.default.Writable.prototype.pipe, e.isWritable = (e) => !!e && typeof e == "object" && e instanceof i.EventEmitter && typeof e.write == "function" && typeof e.end == "function";
var s = Symbol("EOF"), c = Symbol("maybeEmitEnd"), l = Symbol("emittedEnd"), u = Symbol("emittingEnd"), d = Symbol("emittedError"), f = Symbol("closed"), p = Symbol("read"), m = Symbol("flush"), h = Symbol("flushChunk"), g = Symbol("encoding"), _ = Symbol("decoder"), v = Symbol("flowing"), y = Symbol("paused"), b = Symbol("resume"), x = Symbol("buffer"), S = Symbol("pipes"), C = Symbol("bufferLength"), w = Symbol("bufferPush"), T = Symbol("bufferShift"), E = Symbol("objectMode"), D = Symbol("destroyed"), O = Symbol("error"), k = Symbol("emitData"), A = Symbol("emitEnd"), j = Symbol("emitEnd2"), M = Symbol("async"), N = Symbol("abort"), P = Symbol("aborted"), F = Symbol("signal"), I = Symbol("dataListeners"), L = Symbol("discarded"), R = (e) => Promise.resolve().then(e), z = (e) => e(), B = (e) => e === "end" || e === "finish" || e === "prefinish", V = (e) => e instanceof ArrayBuffer || !!e && typeof e == "object" && e.constructor && e.constructor.name === "ArrayBuffer" && e.byteLength >= 0, H = (e) => !Buffer.isBuffer(e) && ArrayBuffer.isView(e), U = class {
src;
dest;
opts;
ondrain;
constructor(e, t, n) {
this.src = e, this.dest = t, this.opts = n, this.ondrain = () => e[b](), this.dest.on("drain", this.ondrain);
}
unpipe() {
this.dest.removeListener("drain", this.ondrain);
}
proxyErrors(e) {}
end() {
this.unpipe(), this.opts.end && this.dest.end();
}
}, W = class extends U {
unpipe() {
this.src.removeListener("error", this.proxyErrors), super.unpipe();
}
constructor(e, t, n) {
super(e, t, n), this.proxyErrors = (e) => this.dest.emit("error", e), e.on("error", this.proxyErrors);
}
}, G = (e) => !!e.objectMode, K = (e) => !e.objectMode && !!e.encoding && e.encoding !== "buffer", q = class extends i.EventEmitter {
[v] = !1;
[y] = !1;
[S] = [];
[x] = [];
[E];
[g];
[M];
[_];
[s] = !1;
[l] = !1;
[u] = !1;
[f] = !1;
[d] = null;
[C] = 0;
[D] = !1;
[F];
[P] = !1;
[I] = 0;
[L] = !1;
writable = !0;
readable = !0;
constructor(...e) {
let t = e[0] || {};
if (super(), t.objectMode && typeof t.encoding == "string") throw TypeError("Encoding and objectMode may not be used together");
G(t) ? (this[E] = !0, this[g] = null) : K(t) ? (this[g] = t.encoding, this[E] = !1) : (this[E] = !1, this[g] = null), this[M] = !!t.async, this[_] = this[g] ? new o.StringDecoder(this[g]) : null, t && t.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[x] }), t && t.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[S] });
let { signal: n } = t;
n && (this[F] = n, n.aborted ? this[N]() : n.addEventListener("abort", () => this[N]()));
}
get bufferLength() {
return this[C];
}
get encoding() {
return this[g];
}
set encoding(e) {
throw Error("Encoding must be set at instantiation time");
}
setEncoding(e) {
throw Error("Encoding must be set at instantiation time");
}
get objectMode() {
return this[E];
}
set objectMode(e) {
throw Error("objectMode must be set at instantiation time");
}
get async() {
return this[M];
}
set async(e) {
this[M] = this[M] || !!e;
}
[N]() {
this[P] = !0, this.emit("abort", this[F]?.reason), this.destroy(this[F]?.reason);
}
get aborted() {
return this[P];
}
set aborted(e) {}
write(e, t, n) {
if (this[P]) return !1;
if (this[s]) throw Error("write after end");
if (this[D]) return this.emit("error", Object.assign(/* @__PURE__ */ Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
typeof t == "function" && (n = t, t = "utf8"), t ||= "utf8";
let r = this[M] ? R : z;
if (!this[E] && !Buffer.isBuffer(e)) {
if (H(e)) e = Buffer.from(e.buffer, e.byteOffset, e.byteLength);
else if (V(e)) e = Buffer.from(e);
else if (typeof e != "string") throw Error("Non-contiguous data written to non-objectMode stream");
}
return this[E] ? (this[v] && this[C] !== 0 && this[m](!0), this[v] ? this.emit("data", e) : this[w](e), this[C] !== 0 && this.emit("readable"), n && r(n), this[v]) : e.length ? (typeof e == "string" && !(t === this[g] && !this[_]?.lastNeed) && (e = Buffer.from(e, t)), Buffer.isBuffer(e) && this[g] && (e = this[_].write(e)), this[v] && this[C] !== 0 && this[m](!0), this[v] ? this.emit("data", e) : this[w](e), this[C] !== 0 && this.emit("readable"), n && r(n), this[v]) : (this[C] !== 0 && this.emit("readable"), n && r(n), this[v]);
}
read(e) {
if (this[D]) return null;
if (this[L] = !1, this[C] === 0 || e === 0 || e && e > this[C]) return this[c](), null;
this[E] && (e = null), this[x].length > 1 && !this[E] && (this[x] = [this[g] ? this[x].join("") : Buffer.concat(this[x], this[C])]);
let t = this[p](e || null, this[x][0]);
return this[c](), t;
}
[p](e, t) {
if (this[E]) this[T]();
else {
let n = t;
e === n.length || e === null ? this[T]() : typeof n == "string" ? (this[x][0] = n.slice(e), t = n.slice(0, e), this[C] -= e) : (this[x][0] = n.subarray(e), t = n.subarray(0, e), this[C] -= e);
}
return this.emit("data", t), !this[x].length && !this[s] && this.emit("drain"), t;
}
end(e, t, n) {
return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = "utf8"), e !== void 0 && this.write(e, t), n && this.once("end", n), this[s] = !0, this.writable = !1, (this[v] || !this[y]) && this[c](), this;
}
[b]() {
this[D] || (!this[I] && !this[S].length && (this[L] = !0), this[y] = !1, this[v] = !0, this.emit("resume"), this[x].length ? this[m]() : this[s] ? this[c]() : this.emit("drain"));
}
resume() {
return this[b]();
}
pause() {
this[v] = !1, this[y] = !0, this[L] = !1;
}
get destroyed() {
return this[D];
}
get flowing() {
return this[v];
}
get paused() {
return this[y];
}
[w](e) {
this[E] ? this[C] += 1 : this[C] += e.length, this[x].push(e);
}
[T]() {
return this[E] ? --this[C] : this[C] -= this[x][0].length, this[x].shift();
}
[m](e = !1) {
do ;
while (this[h](this[T]()) && this[x].length);
!e && !this[x].length && !this[s] && this.emit("drain");
}
[h](e) {
return this.emit("data", e), this[v];
}
pipe(e, t) {
if (this[D]) return e;
this[L] = !1;
let n = this[l];
return t ||= {}, e === r.stdout || e === r.stderr ? t.end = !1 : t.end = t.end !== !1, t.proxyErrors = !!t.proxyErrors, n ? t.end && e.end() : (this[S].push(t.proxyErrors ? new W(this, e, t) : new U(this, e, t)), this[M] ? R(() => this[b]()) : this[b]()), e;
}
unpipe(e) {
let t = this[S].find((t) => t.dest === e);
t && (this[S].length === 1 ? (this[v] && this[I] === 0 && (this[v] = !1), this[S] = []) : this[S].splice(this[S].indexOf(t), 1), t.unpipe());
}
addListener(e, t) {
return this.on(e, t);
}
on(e, t) {
let n = super.on(e, t);
if (e === "data") this[L] = !1, this[I]++, !this[S].length && !this[v] && this[b]();
else if (e === "readable" && this[C] !== 0) super.emit("readable");
else if (B(e) && this[l]) super.emit(e), this.removeAllListeners(e);
else if (e === "error" && this[d]) {
let e = t;
this[M] ? R(() => e.call(this, this[d])) : e.call(this, this[d]);
}
return n;
}
removeListener(e, t) {
return this.off(e, t);
}
off(e, t) {
let n = super.off(e, t);
return e === "data" && (this[I] = this.listeners("data").length, this[I] === 0 && !this[L] && !this[S].length && (this[v] = !1)), n;
}
removeAllListeners(e) {
let t = super.removeAllListeners(e);
return (e === "data" || e === void 0) && (this[I] = 0, !this[L] && !this[S].length && (this[v] = !1)), t;
}
get emittedEnd() {
return this[l];
}
[c]() {
!this[u] && !this[l] && !this[D] && this[x].length === 0 && this[s] && (this[u] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[f] && this.emit("close"), this[u] = !1);
}
emit(e, ...t) {
let n = t[0];
if (e !== "error" && e !== "close" && e !== D && this[D]) return !1;
if (e === "data") return !this[E] && !n ? !1 : this[M] ? (R(() => this[k](n)), !0) : this[k](n);
if (e === "end") return this[A]();
if (e === "close") {
if (this[f] = !0, !this[l] && !this[D]) return !1;
let e = super.emit("close");
return this.removeAllListeners("close"), e;
}
if (e === "error") {
this[d] = n, super.emit(O, n);
let e = !this[F] || this.listeners("error").length ? super.emit("error", n) : !1;
return this[c](), e;
}
if (e === "resume") {
let e = super.emit("resume");
return this[c](), e;
}
if (e === "finish" || e === "prefinish") {
let t = super.emit(e);
return this.removeAllListeners(e), t;
}
let r = super.emit(e, ...t);
return this[c](), r;
}
[k](e) {
for (let t of this[S]) t.dest.write(e) === !1 && this.pause();
let t = !this[L] && super.emit("data", e);
return this[c](), t;
}
[A]() {
return !this[l] && (this[l] = !0, this.readable = !1, this[M] ? (R(() => this[j]()), !0) : this[j]());
}
[j]() {
if (this[_]) {
let e = this[_].end();
if (e) {
for (let t of this[S]) t.dest.write(e);
this[L] || super.emit("data", e);
}
}
for (let e of this[S]) e.end();
let e = super.emit("end");
return this.removeAllListeners("end"), e;
}
async collect() {
let e = Object.assign([], { dataLength: 0 });
this[E] || (e.dataLength = 0);
let t = this.promise();
return this.on("data", (t) => {
e.push(t), this[E] || (e.dataLength += t.length);
}), await t, e;
}
async concat() {
if (this[E]) throw Error("cannot concat in objectMode");
let e = await this.collect();
return this[g] ? e.join("") : Buffer.concat(e, e.dataLength);
}
async promise() {
return new Promise((e, t) => {
this.on(D, () => t(/* @__PURE__ */ Error("stream destroyed"))), this.on("error", (e) => t(e)), this.on("end", () => e());
});
}
[Symbol.asyncIterator]() {
this[L] = !1;
let e = !1, t = async () => (this.pause(), e = !0, {
value: void 0,
done: !0
});
return {
next: () => {
if (e) return t();
let n = this.read();
if (n !== null) return Promise.resolve({
done: !1,
value: n
});
if (this[s]) return t();
let r, i, a = (e) => {
this.off("data", o), this.off("end", c), this.off(D, l), t(), i(e);
}, o = (e) => {
this.off("error", a), this.off("end", c), this.off(D, l), this.pause(), r({
value: e,
done: !!this[s]
});
}, c = () => {
this.off("error", a), this.off("data", o), this.off(D, l), t(), r({
done: !0,
value: void 0
});
}, l = () => a(/* @__PURE__ */ Error("stream destroyed"));
return new Promise((e, t) => {
i = t, r = e, this.once(D, l), this.once("error", a), this.once("end", c), this.once("data", o);
});
},
throw: t,
return: t,
[Symbol.asyncIterator]() {
return this;
},
[Symbol.asyncDispose]: async () => {}
};
}
[Symbol.iterator]() {
this[L] = !1;
let e = !1, t = () => (this.pause(), this.off(O, t), this.off(D, t), this.off("end", t), e = !0, {
done: !0,
value: void 0
});
return this.once("end", t), this.once(O, t), this.once(D, t), {
next: () => {
if (e) return t();
let n = this.read();
return n === null ? t() : {
done: !1,
value: n
};
},
throw: t,
return: t,
[Symbol.iterator]() {
return this;
},
[Symbol.dispose]: () => {}
};
}
destroy(e) {
if (this[D]) return e ? this.emit("error", e) : this.emit(D), this;
this[D] = !0, this[L] = !0, this[x].length = 0, this[C] = 0;
let t = this;
return typeof t.close == "function" && !this[f] && t.close(), e ? this.emit("error", e) : this.emit(D), this;
}
static get isStream() {
return e.isStream;
}
};
e.Minipass = q;
}), p = n((e) => {
var n = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), r = e && e.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
}) : function(e, t) {
e.default = t;
}), i = e && e.__importStar || function(e) {
if (e && e.__esModule) return e;
var t = {};
if (e != null) for (var i in e) i !== "default" && Object.prototype.hasOwnProperty.call(e, i) && n(t, e, i);
return r(t, e), t;
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.PathScurry = e.Path = e.PathScurryDarwin = e.PathScurryPosix = e.PathScurryWin32 = e.PathScurryBase = e.PathPosix = e.PathWin32 = e.PathBase = e.ChildrenCache = e.ResolveCache = void 0;
var a = d(), o = t("node:path"), s = t("node:url"), c = t("fs"), l = i(t("node:fs")), u = c.realpathSync.native, p = t("node:fs/promises"), m = f(), h = {
lstatSync: c.lstatSync,
readdir: c.readdir,
readdirSync: c.readdirSync,
readlinkSync: c.readlinkSync,
realpathSync: u,
promises: {
lstat: p.lstat,
readdir: p.readdir,
readlink: p.readlink,
realpath: p.realpath
}
}, g = (e) => !e || e === h || e === l ? h : {
...h,
...e,
promises: {
...h.promises,
...e.promises || {}
}
}, _ = /^\\\\\?\\([a-z]:)\\?$/i, v = (e) => e.replace(/\//g, "\\").replace(_, "$1\\"), y = /[\\\/]/, b = 0, x = 1, S = 2, C = 4, w = 6, T = 8, E = 10, D = 12, O = 15, k = ~O, A = 16, j = 32, M = 64, N = 128, P = 256, F = 512, I = M | N | F, L = 1023, R = (e) => e.isFile() ? T : e.isDirectory() ? C : e.isSymbolicLink() ? E : e.isCharacterDevice() ? S : e.isBlockDevice() ? w : e.isSocket() ? D : e.isFIFO() ? x : b, z = new a.LRUCache({ max: 4096 }), B = (e) => {
let t = z.get(e);
if (t) return t;
let n = e.normalize("NFKD");
return z.set(e, n), n;
}, V = new a.LRUCache({ max: 4096 }), H = (e) => {
let t = V.get(e);
if (t) return t;
let n = B(e.toLowerCase());
return V.set(e, n), n;
}, U = class extends a.LRUCache {
constructor() {
super({ max: 256 });
}
};
e.ResolveCache = U;
var W = class extends a.LRUCache {
constructor(e = 16384) {
super({
maxSize: e,
sizeCalculation: (e) => e.length + 1
});
}
};
e.ChildrenCache = W;
var G = Symbol("PathScurry setAsCwd"), K = class {
name;
root;
roots;
parent;
nocase;
isCWD = !1;
#e;
#t;
get dev() {
return this.#t;
}
#n;
get mode() {
return this.#n;
}
#r;
get nlink() {
return this.#r;
}
#i;
get uid() {
return this.#i;
}
#a;
get gid() {
return this.#a;
}
#o;
get rdev() {
return this.#o;
}
#s;
get blksize() {
return this.#s;
}
#c;
get ino() {
return this.#c;
}
#l;
get size() {
return this.#l;
}
#u;
get blocks() {
return this.#u;
}
#d;
get atimeMs() {
return this.#d;
}
#f;
get mtimeMs() {
return this.#f;
}
#p;
get ctimeMs() {
return this.#p;
}
#m;
get birthtimeMs() {
return this.#m;
}
#h;
get atime() {
return this.#h;
}
#g;
get mtime() {
return this.#g;
}
#_;
get ctime() {
return this.#_;
}
#v;
get birthtime() {
return this.#v;
}
#y;
#b;
#x;
#S;
#C;
#w;
#T;
#E;
#D;
#O;
get parentPath() {
return (this.parent || this).fullpath();
}
get path() {
return this.parentPath;
}
constructor(e, t = b, n, r, i, a, o) {
this.name = e, this.#y = i ? H(e) : B(e), this.#T = t & L, this.nocase = i, this.roots = r, this.root = n || this, this.#E = a, this.#x = o.fullpath, this.#C = o.relative, this.#w = o.relativePosix, this.parent = o.parent, this.#e = this.parent ? this.parent.#e : g(o.fs);
}
depth() {
return this.#b === void 0 ? this.#b = this.parent ? this.parent.depth() + 1 : 0 : this.#b;
}
childrenCache() {
return this.#E;
}
resolve(e) {
if (!e) return this;
let t = this.getRootString(e), n = e.substring(t.length).split(this.splitSep);
return t ? this.getRoot(t).#k(n) : this.#k(n);
}
#k(e) {
let t = this;
for (let n of e) t = t.child(n);
return t;
}
children() {
let e = this.#E.get(this);
if (e) return e;
let t = Object.assign([], { provisional: 0 });
return this.#E.set(this, t), this.#T &= ~A, t;
}
child(e, t) {
if (e === "" || e === ".") return this;
if (e === "..") return this.parent || this;
let n = this.children(), r = this.nocase ? H(e) : B(e);
for (let e of n) if (e.#y === r) return e;
let i = this.parent ? this.sep : "", a = this.#x ? this.#x + i + e : void 0, o = this.newChild(e, b, {
...t,
parent: this,
fullpath: a
});
return this.canReaddir() || (o.#T |= N), n.push(o), o;
}
relative() {
if (this.isCWD) return "";
if (this.#C !== void 0) return this.#C;
let e = this.name, t = this.parent;
if (!t) return this.#C = this.name;
let n = t.relative();
return n + (!n || !t.parent ? "" : this.sep) + e;
}
relativePosix() {
if (this.sep === "/") return this.relative();
if (this.isCWD) return "";
if (this.#w !== void 0) return this.#w;
let e = this.name, t = this.parent;
if (!t) return this.#w = this.fullpathPosix();
let n = t.relativePosix();
return n + (!n || !t.parent ? "" : "/") + e;
}
fullpath() {
if (this.#x !== void 0) return this.#x;
let e = this.name, t = this.parent;
if (!t) return this.#x = this.name;
let n = t.fullpath() + (t.parent ? this.sep : "") + e;
return this.#x = n;
}
fullpathPosix() {
if (this.#S !== void 0) return this.#S;
if (this.sep === "/") return this.#S = this.fullpath();
if (!this.parent) {
let e = this.fullpath().replace(/\\/g, "/");
return this.#S = /^[a-z]:\//i.test(e) ? `//?/${e}` : e;
}
let e = this.parent, t = e.fullpathPosix(), n = t + (!t || !e.parent ? "" : "/") + this.name;
return this.#S = n;
}
isUnknown() {
return (this.#T & O) === b;
}
isType(e) {
return this[`is${e}`]();
}
getType() {
return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
}
isFile() {
return (this.#T & O) === T;
}
isDirectory() {
return (this.#T & O) === C;
}
isCharacterDevice() {
return (this.#T & O) === S;
}
isBlockDevice() {
return (this.#T & O) === w;
}
isFIFO() {
return (this.#T & O) === x;
}
isSocket() {
return (this.#T & O) === D;
}
isSymbolicLink() {
return (this.#T & E) === E;
}
lstatCached() {
return this.#T & j ? this : void 0;
}
readlinkCached() {
return this.#D;
}
realpathCached() {
return this.#O;
}
readdirCached() {
let e = this.children();
return e.slice(0, e.provisional);
}
canReadlink() {
if (this.#D) return !0;
if (!this.parent) return !1;
let e = this.#T & O;
return !(e !== b && e !== E || this.#T & P || this.#T & N);
}
calledReaddir() {
return !!(this.#T & A);
}
isENOENT() {
return !!(this.#T & N);
}
isNamed(e) {
return this.nocase ? this.#y === H(e) : this.#y === B(e);
}
async readlink() {
let e = this.#D;
if (e) return e;
if (this.canReadlink() && this.parent) try {
let e = await this.#e.promises.readlink(this.fullpath()), t = (await this.parent.realpath())?.resolve(e);
if (t) return this.#D = t;
} catch (e) {
this.#L(e.code);
return;
}
}
readlinkSync() {
let e = this.#D;
if (e) return e;
if (this.canReadlink() && this.parent) try {
let e = this.#e.readlinkSync(this.fullpath()), t = this.parent.realpathSync()?.resolve(e);
if (t) return this.#D = t;
} catch (e) {
this.#L(e.code);
return;
}
}
#A(e) {
this.#T |= A;
for (let t = e.provisional; t < e.length; t++) {
let n = e[t];
n && n.#j();
}
}
#j() {
this.#T & N || (this.#T = (this.#T | N) & k, this.#M());
}
#M() {
let e = this.children();
e.provisional = 0;
for (let t of e) t.#j();
}
#N() {
this.#T |= F, this.#P();
}
#P() {
if (this.#T & M) return;
let e = this.#T;
(e & O) === C && (e &= k), this.#T = e | M, this.#M();
}
#F(e = "") {
e === "ENOTDIR" || e === "EPERM" ? this.#P() : e === "ENOENT" ? this.#j() : this.children().provisional = 0;
}
#I(e = "") {
e === "ENOTDIR" ? this.parent.#P() : e === "ENOENT" && this.#j();
}
#L(e = "") {
let t = this.#T;
t |= P, e === "ENOENT" && (t |= N), (e === "EINVAL" || e === "UNKNOWN") && (t &= k), this.#T = t, e === "ENOTDIR" && this.parent && this.parent.#P();
}
#R(e, t) {
return this.#B(e, t) || this.#z(e, t);
}
#z(e, t) {
let n = R(e), r = this.newChild(e.name, n, { parent: this }), i = r.#T & O;
return i !== C && i !== E && i !== b && (r.#T |= M), t.unshift(r), t.provisional++, r;
}
#B(e, t) {
for (let n = t.provisional; n < t.length; n++) {
let r = t[n];
if ((this.nocase ? H(e.name) : B(e.name)) === r.#y) return this.#V(e, r, n, t);
}
}
#V(e, t, n, r) {
let i = t.name;
return t.#T = t.#T & k | R(e), i !== e.name && (t.name = e.name), n !== r.provisional && (n === r.length - 1 ? r.pop() : r.splice(n, 1), r.unshift(t)), r.provisional++, t;
}
async lstat() {
if ((this.#T & N) === 0) try {
return this.#H(await this.#e.promises.lstat(this.fullpath())), this;
} catch (e) {
this.#I(e.code);
}
}
lstatSync() {
if ((this.#T & N) === 0) try {
return this.#H(this.#e.lstatSync(this.fullpath())), this;
} catch (e) {
this.#I(e.code);
}
}
#H(e) {
let { atime: t, atimeMs: n, birthtime: r, birthtimeMs: i, blksize: a, blocks: o, ctime: s, ctimeMs: c, dev: l, gid: u, ino: d, mode: f, mtime: p, mtimeMs: m, nlink: h, rdev: g, size: _, uid: v } = e;
this.#h = t, this.#d = n, this.#v = r, this.#m = i, this.#s = a, this.#u = o, this.#_ = s, this.#p = c, this.#t = l, this.#a = u, this.#c = d, this.#n = f, this.#g = p, this.#f = m, this.#r = h, this.#o = g, this.#l = _, this.#i = v;
let y = R(e);
this.#T = this.#T & k | y | j, y !== b && y !== C && y !== E && (this.#T |= M);
}
#U = [];
#W = !1;
#G(e) {
this.#W = !1;
let t = this.#U.slice();
this.#U.length = 0, t.forEach((t) => t(null, e));
}
readdirCB(e, t = !1) {
if (!this.canReaddir()) {
t ? e(null, []) : queueMicrotask(() => e(null, []));
return;
}
let n = this.children();
if (this.calledReaddir()) {
let r = n.slice(0, n.provisional);
t ? e(null, r) : queueMicrotask(() => e(null, r));
return;
}
if (this.#U.push(e), this.#W) return;
this.#W = !0;
let r = this.fullpath();
this.#e.readdir(r, { withFileTypes: !0 }, (e, t) => {
if (e) this.#F(e.code), n.provisional = 0;
else {
for (let e of t) this.#R(e, n);
this.#A(n);
}
this.#G(n.slice(0, n.provisional));
});
}
#K;
async readdir() {
if (!this.canReaddir()) return [];
let e = this.children();
if (this.calledReaddir()) return e.slice(0, e.provisional);
let t = this.fullpath();
if (this.#K) await this.#K;
else {
let n = () => {};
this.#K = new Promise((e) => n = e);
try {
for (let n of await this.#e.promises.readdir(t, { withFileTypes: !0 })) this.#R(n, e);
this.#A(e);
} catch (t) {
this.#F(t.code), e.provisional = 0;
}
this.#K = void 0, n();
}
return e.slice(0, e.provisional);
}
readdirSync() {
if (!this.canReaddir()) return [];
let e = this.children();
if (this.calledReaddir()) return e.slice(0, e.provisional);
let t = this.fullpath();
try {
for (let n of this.#e.readdirSync(t, { withFileTypes: !0 })) this.#R(n, e);
this.#A(e);
} catch (t) {
this.#F(t.code), e.provisional = 0;
}
return e.slice(0, e.provisional);
}
canReaddir() {
if (this.#T & I) return !1;
let e = O & this.#T;
return e === b || e === C || e === E;
}
shouldWalk(e, t) {
return (this.#T & C) === C && !(this.#T & I) && !e.has(this) && (!t || t(this));
}
async realpath() {
if (this.#O) return this.#O;
if (!((F | P | N) & this.#T)) try {
let e = await this.#e.promises.realpath(this.fullpath());
return this.#O = this.resolve(e);
} catch {
this.#N();
}
}
realpathSync() {
if (this.#O) return this.#O;
if (!((F | P | N) & this.#T)) try {
let e = this.#e.realpathSync(this.fullpath());
return this.#O = this.resolve(e);
} catch {
this.#N();
}
}
[G](e) {
if (e === this) return;
e.isCWD = !1, this.isCWD = !0;
let t = /* @__PURE__ */ new Set([]), n = [], r = this;
for (; r && r.parent;) t.add(r), r.#C = n.join(this.sep), r.#w = n.join("/"), r = r.parent, n.push("..");
for (r = e; r && r.parent && !t.has(r);) r.#C = void 0, r.#w = void 0, r = r.parent;
}
};
e.PathBase = K;
var q = class e extends K {
sep = "\\";
splitSep = y;
constructor(e, t = b, n, r, i, a, o) {
super(e, t, n, r, i, a, o);
}
newChild(t, n = b, r = {}) {
return new e(t, n, this.root, this.roots, this.nocase, this.childrenCache(), r);
}
getRootString(e) {
return o.win32.parse(e).root;
}
getRoot(e) {
if (e = v(e.toUpperCase()), e === this.root.name) return this.root;
for (let [t, n] of Object.entries(this.roots)) if (this.sameRoot(e, t)) return this.roots[e] = n;
return this.roots[e] = new te(e, this).root;
}
sameRoot(e, t = this.root.name) {
return e = e.toUpperCase().replace(/\//g, "\\").replace(_, "$1\\"), e === t;
}
};
e.PathWin32 = q;
var ee = class e extends K {
splitSep = "/";
sep = "/";
constructor(e, t = b, n, r, i, a, o) {
super(e, t, n, r, i, a, o);
}
getRootString(e) {
return e.startsWith("/") ? "/" : "";
}
getRoot(e) {
return this.root;
}
newChild(t, n = b, r = {}) {
return new e(t, n, this.root, this.roots, this.nocase, this.childrenCache(), r);
}
};
e.PathPosix = ee;
var J = class {
root;
rootPath;
roots;
cwd;
#e;
#t;
#n;
nocase;
#r;
constructor(e = process.cwd(), t, n, { nocase: r, childrenCacheSize: i = 16384, fs: a = h } = {}) {
this.#r = g(a), (e instanceof URL || e.startsWith("file://")) && (e = (0, s.fileURLToPath)(e));
let o = t.resolve(e);
this.roots = Object.create(null), this.rootPath = this.parseRootPath(o), this.#e = new U(), this.#t = new U(), this.#n = new W(i);
let c = o.substring(this.rootPath.length).split(n);
if (c.length === 1 && !c[0] && c.pop(), r === void 0) throw TypeError("must provide nocase setting to PathScurryBase ctor");
this.nocase = r, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
let l = this.root, u = c.length - 1, d = t.sep, f = this.rootPath, p = !1;
for (let e of c) {
let t = u--;
l = l.child(e, {
relative: Array(t).fill("..").join(d),
relativePosix: Array(t).fill("..").join("/"),
fullpath: f += (p ? "" : d) + e
}), p = !0;
}
this.cwd = l;
}
depth(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), e.depth();
}
childrenCache() {
return this.#n;
}
resolve(...e) {
let t = "";
for (let n = e.length - 1; n >= 0; n--) {
let r = e[n];
if (!(!r || r === ".") && (t = t ? `${r}/${t}` : r, this.isAbsolute(r))) break;
}
let n = this.#e.get(t);
if (n !== void 0) return n;
let r = this.cwd.resolve(t).fullpath();
return this.#e.set(t, r), r;
}
resolvePosix(...e) {
let t = "";
for (let n = e.length - 1; n >= 0; n--) {
let r = e[n];
if (!(!r || r === ".") && (t = t ? `${r}/${t}` : r, this.isAbsolute(r))) break;
}
let n = this.#t.get(t);
if (n !== void 0) return n;
let r = this.cwd.resolve(t).fullpathPosix();
return this.#t.set(t, r), r;
}
relative(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), e.relative();
}
relativePosix(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), e.relativePosix();
}
basename(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), e.name;
}
dirname(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), (e.parent || e).fullpath();
}
async readdir(e = this.cwd, t = { withFileTypes: !0 }) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n } = t;
if (e.canReaddir()) {
let t = await e.readdir();
return n ? t : t.map((e) => e.name);
}
return [];
}
readdirSync(e = this.cwd, t = { withFileTypes: !0 }) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n = !0 } = t;
return e.canReaddir() ? n ? e.readdirSync() : e.readdirSync().map((e) => e.name) : [];
}
async lstat(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), e.lstat();
}
lstatSync(e = this.cwd) {
return typeof e == "string" && (e = this.cwd.resolve(e)), e.lstatSync();
}
async readlink(e = this.cwd, { withFileTypes: t } = { withFileTypes: !1 }) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e.withFileTypes, e = this.cwd);
let n = await e.readlink();
return t ? n : n?.fullpath();
}
readlinkSync(e = this.cwd, { withFileTypes: t } = { withFileTypes: !1 }) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e.withFileTypes, e = this.cwd);
let n = e.readlinkSync();
return t ? n : n?.fullpath();
}
async realpath(e = this.cwd, { withFileTypes: t } = { withFileTypes: !1 }) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e.withFileTypes, e = this.cwd);
let n = await e.realpath();
return t ? n : n?.fullpath();
}
realpathSync(e = this.cwd, { withFileTypes: t } = { withFileTypes: !1 }) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e.withFileTypes, e = this.cwd);
let n = e.realpathSync();
return t ? n : n?.fullpath();
}
async walk(e = this.cwd, t = {}) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n = !0, follow: r = !1, filter: i, walkFilter: a } = t, o = [];
(!i || i(e)) && o.push(n ? e : e.fullpath());
let s = /* @__PURE__ */ new Set(), c = (e, t) => {
s.add(e), e.readdirCB((e, l) => {
if (e) return t(e);
let u = l.length;
if (!u) return t();
let d = () => {
--u === 0 && t();
};
for (let e of l) (!i || i(e)) && o.push(n ? e : e.fullpath()), r && e.isSymbolicLink() ? e.realpath().then((e) => e?.isUnknown() ? e.lstat() : e).then((e) => e?.shouldWalk(s, a) ? c(e, d) : d()) : e.shouldWalk(s, a) ? c(e, d) : d();
}, !0);
}, l = e;
return new Promise((e, t) => {
c(l, (n) => {
if (n) return t(n);
e(o);
});
});
}
walkSync(e = this.cwd, t = {}) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n = !0, follow: r = !1, filter: i, walkFilter: a } = t, o = [];
(!i || i(e)) && o.push(n ? e : e.fullpath());
let s = /* @__PURE__ */ new Set([e]);
for (let e of s) {
let t = e.readdirSync();
for (let e of t) {
(!i || i(e)) && o.push(n ? e : e.fullpath());
let t = e;
if (e.isSymbolicLink()) {
if (!(r && (t = e.realpathSync()))) continue;
t.isUnknown() && t.lstatSync();
}
t.shouldWalk(s, a) && s.add(t);
}
}
return o;
}
[Symbol.asyncIterator]() {
return this.iterate();
}
iterate(e = this.cwd, t = {}) {
return typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd), this.stream(e, t)[Symbol.asyncIterator]();
}
[Symbol.iterator]() {
return this.iterateSync();
}
*iterateSync(e = this.cwd, t = {}) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n = !0, follow: r = !1, filter: i, walkFilter: a } = t;
(!i || i(e)) && (yield n ? e : e.fullpath());
let o = /* @__PURE__ */ new Set([e]);
for (let e of o) {
let t = e.readdirSync();
for (let e of t) {
(!i || i(e)) && (yield n ? e : e.fullpath());
let t = e;
if (e.isSymbolicLink()) {
if (!(r && (t = e.realpathSync()))) continue;
t.isUnknown() && t.lstatSync();
}
t.shouldWalk(o, a) && o.add(t);
}
}
}
stream(e = this.cwd, t = {}) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n = !0, follow: r = !1, filter: i, walkFilter: a } = t, o = new m.Minipass({ objectMode: !0 });
(!i || i(e)) && o.write(n ? e : e.fullpath());
let s = /* @__PURE__ */ new Set(), c = [e], l = 0, u = () => {
let e = !1;
for (; !e;) {
let t = c.shift();
if (!t) {
l === 0 && o.end();
return;
}
l++, s.add(t);
let d = (t, p, m = !1) => {
if (t) return o.emit("error", t);
if (r && !m) {
let e = [];
for (let t of p) t.isSymbolicLink() && e.push(t.realpath().then((e) => e?.isUnknown() ? e.lstat() : e));
if (e.length) {
Promise.all(e).then(() => d(null, p, !0));
return;
}
}
for (let t of p) t && (!i || i(t)) && (o.write(n ? t : t.fullpath()) || (e = !0));
l--;
for (let e of p) {
let t = e.realpathCached() || e;
t.shouldWalk(s, a) && c.push(t);
}
e && !o.flowing ? o.once("drain", u) : f || u();
}, f = !0;
t.readdirCB(d, !0), f = !1;
}
};
return u(), o;
}
streamSync(e = this.cwd, t = {}) {
typeof e == "string" ? e = this.cwd.resolve(e) : e instanceof K || (t = e, e = this.cwd);
let { withFileTypes: n = !0, follow: r = !1, filter: i, walkFilter: a } = t, o = new m.Minipass({ objectMode: !0 }), s = /* @__PURE__ */ new Set();
(!i || i(e)) && o.write(n ? e : e.fullpath());
let c = [e], l = 0, u = () => {
let e = !1;
for (; !e;) {
let t = c.shift();
if (!t) {
l === 0 && o.end();
return;
}
l++, s.add(t);
let u = t.readdirSync();
for (let t of u) (!i || i(t)) && (o.write(n ? t : t.fullpath()) || (e = !0));
l--;
for (let e of u) {
let t = e;
if (e.isSymbolicLink()) {
if (!(r && (t = e.realpathSync()))) continue;
t.isUnknown() && t.lstatSync();
}
t.shouldWalk(s, a) && c.push(t);
}
}
e && !o.flowing && o.once("drain", u);
};
return u(), o;
}
chdir(e = this.cwd) {
let t = this.cwd;
this.cwd = typeof e == "string" ? this.cwd.resolve(e) : e, this.cwd[G](t);
}
};
e.PathScurryBase = J;
var te = class extends J {
sep = "\\";
constructor(e = process.cwd(), t = {}) {
let { nocase: n = !0 } = t;
super(e, o.win32, "\\", {
...t,
nocase: n
}), this.nocase = n;
for (let e = this.cwd; e; e = e.parent) e.nocase = this.nocase;
}
parseRootPath(e) {
return o.win32.parse(e).root.toUpperCase();
}
newRoot(e) {
return new q(this.rootPath, C, void 0, this.roots, this.nocase, this.childrenCache(), { fs: e });
}
isAbsolute(e) {
return e.startsWith("/") || e.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(e);
}
};
e.PathScurryWin32 = te;
var Y = class extends J {
sep = "/";
constructor(e = process.cwd(), t = {}) {
let { nocase: n = !1 } = t;
super(e, o.posix, "/", {
...t,
nocase: n
}), this.nocase = n;
}
parseRootPath(e) {
return "/";
}
newRoot(e) {
return new ee(this.rootPath, C, void 0, this.roots, this.nocase, this.childrenCache(), { fs: e });
}
isAbsolute(e) {
return e.startsWith("/");
}
};
e.PathScurryPosix = Y;
var ne = class extends Y {
constructor(e = process.cwd(), t = {}) {
let { nocase: n = !0 } = t;
super(e, {
...t,
nocase: n
});
}
};
e.PathScurryDarwin = ne, e.Path = process.platform === "win32" ? q : ee, e.PathScurry = process.platform === "win32" ? te : process.platform === "darwin" ? ne : Y;
}), m = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.Pattern = void 0;
var t = u(), n = (e) => e.length >= 1, r = (e) => e.length >= 1, i = Symbol.for("nodejs.util.inspect.custom");
e.Pattern = class e {
#e;
#t;
#n;
length;
#r;
#i;
#a;
#o;
#s;
#c;
#l = !0;
constructor(e, t, i, a) {
if (!n(e)) throw TypeError("empty pattern list");
if (!r(t)) throw TypeError("empty glob list");
if (t.length !== e.length) throw TypeError("mismatched pattern list and glob list lengths");
if (this.length = e.length, i < 0 || i >= this.length) throw TypeError("index out of range");
if (this.#e = e, this.#t = t, this.#n = i, this.#r = a, this.#n === 0) {
if (this.isUNC()) {
let [e, t, n, r, ...i] = this.#e, [a, o, s, c, ...l] = this.#t;
i[0] === "" && (i.shift(), l.shift());
let u = [
e,
t,
n,
r,
""
].join("/"), d = [
a,
o,
s,
c,
""
].join("/");
this.#e = [u, ...i], this.#t = [d, ...l], this.length = this.#e.length;
} else if (this.isDrive() || this.isAbsolute()) {
let [e, ...t] = this.#e, [n, ...r] = this.#t;
t[0] === "" && (t.shift(), r.shift());
let i = e + "/", a = n + "/";
this.#e = [i, ...t], this.#t = [a, ...r], this.length = this.#e.length;
}
}
}
[i]() {
return "Pattern <" + this.#t.slice(this.#n).join("/") + ">";
}
pattern() {
return this.#e[this.#n];
}
isString() {
return typeof this.#e[this.#n] == "string";
}
isGlobstar() {
return this.#e[this.#n] === t.GLOBSTAR;
}
isRegExp() {
return this.#e[this.#n] instanceof RegExp;
}
globString() {
return this.#a = this.#a || (this.#n === 0 ? this.isAbsolute() ? this.#t[0] + this.#t.slice(1).join("/") : this.#t.join("/") : this.#t.slice(this.#n).join("/"));
}
hasMore() {
return this.length > this.#n + 1;
}
rest() {
return this.#i === void 0 ? this.hasMore() ? (this.#i = new e(this.#e, this.#t, this.#n + 1, this.#r), this.#i.#c = this.#c, this.#i.#s = this.#s, this.#i.#o = this.#o, this.#i) : this.#i = null : this.#i;
}
isUNC() {
let e = this.#e;
return this.#s === void 0 ? this.#s = this.#r === "win32" && this.#n === 0 && e[0] === "" && e[1] === "" && typeof e[2] == "string" && !!e[2] && typeof e[3] == "string" && !!e[3] : this.#s;
}
isDrive() {
let e = this.#e;
return this.#o === void 0 ? this.#o = this.#r === "win32" && this.#n === 0 && this.length > 1 && typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]) : this.#o;
}
isAbsolute() {
let e = this.#e;
return this.#c === void 0 ? this.#c = e[0] === "" && e.length > 1 || this.isDrive() || this.isUNC() : this.#c;
}
root() {
let e = this.#e[0];
return typeof e == "string" && this.isAbsolute() && this.#n === 0 ? e : "";
}
checkFollowGlobstar() {
return !(this.#n === 0 || !this.isGlobstar() || !this.#l);
}
markFollowGlobstar() {
return this.#n === 0 || !this.isGlobstar() || !this.#l ? !1 : (this.#l = !1, !0);
}
};
}), h = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.Ignore = void 0;
var t = u(), n = m(), r = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
e.Ignore = class {
relative;
relativeChildren;
absolute;
absoluteChildren;
platform;
mmopts;
constructor(e, { nobrace: t, nocase: n, noext: i, noglobstar: a, platform: o = r }) {
this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = o, this.mmopts = {
dot: !0,
nobrace: t,
nocase: n,
noext: i,
noglobstar: a,
optimizationLevel: 2,
platform: o,
nocomment: !0,
nonegate: !0
};
for (let t of e) this.add(t);
}
add(e) {
let r = new t.Minimatch(e, this.mmopts);
for (let e = 0; e < r.set.length; e++) {
let i = r.set[e], a = r.globParts[e];
if (!i || !a) throw Error("invalid pattern object");
for (; i[0] === "." && a[0] === ".";) i.shift(), a.shift();
let o = new n.Pattern(i, a, 0, this.platform), s = new t.Minimatch(o.globString(), this.mmopts), c = a[a.length - 1] === "**", l = o.isAbsolute();
l ? this.absolute.push(s) : this.relative.push(s), c && (l ? this.absoluteChildren.push(s) : this.relativeChildren.push(s));
}
}
ignored(e) {
let t = e.fullpath(), n = `${t}/`, r = e.relative() || ".", i = `${r}/`;
for (let e of this.relative) if (e.match(r) || e.match(i)) return !0;
for (let e of this.absolute) if (e.match(t) || e.match(n)) return !0;
return !1;
}
childrenIgnored(e) {
let t = e.fullpath() + "/", n = (e.relative() || ".") + "/";
for (let e of this.relativeChildren) if (e.match(n)) return !0;
for (let e of this.absoluteChildren) if (e.match(t)) return !0;
return !1;
}
};
}), g = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.Processor = e.SubWalks = e.MatchRecord = e.HasWalkedCache = void 0;
var t = u(), n = class e {
store;
constructor(e = /* @__PURE__ */ new Map()) {
this.store = e;
}
copy() {
return new e(new Map(this.store));
}
hasWalked(e, t) {
return this.store.get(e.fullpath())?.has(t.globString());
}
storeWalked(e, t) {
let n = e.fullpath(), r = this.store.get(n);
r ? r.add(t.globString()) : this.store.set(n, /* @__PURE__ */ new Set([t.globString()]));
}
};
e.HasWalkedCache = n;
var r = class {
store = /* @__PURE__ */ new Map();
add(e, t, n) {
let r = (t ? 2 : 0) | !!n, i = this.store.get(e);
this.store.set(e, i === void 0 ? r : r & i);
}
entries() {
return [...this.store.entries()].map(([e, t]) => [
e,
!!(t & 2),
!!(t & 1)
]);
}
};
e.MatchRecord = r;
var i = class {
store = /* @__PURE__ */ new Map();
add(e, t) {
if (!e.canReaddir()) return;
let n = this.store.get(e);
n ? n.find((e) => e.globString() === t.globString()) || n.push(t) : this.store.set(e, [t]);
}
get(e) {
let t = this.store.get(e);
if (!t) throw Error("attempting to walk unknown path");
return t;
}
entries() {
return this.keys().map((e) => [e, this.store.get(e)]);
}
keys() {
return [...this.store.keys()].filter((e) => e.canReaddir());
}
};
e.SubWalks = i, e.Processor = class e {
hasWalkedCache;
matches = new r();
subwalks = new i();
patterns;
follow;
dot;
opts;
constructor(e, t) {
this.opts = e, this.follow = !!e.follow, this.dot = !!e.dot, this.hasWalkedCache = t ? t.copy() : new n();
}
processPatterns(e, n) {
this.patterns = n;
let r = n.map((t) => [e, t]);
for (let [e, n] of r) {
this.hasWalkedCache.storeWalked(e, n);
let r = n.root(), i = n.isAbsolute() && this.opts.absolute !== !1;
if (r) {
e = e.resolve(r === "/" && this.opts.root !== void 0 ? this.opts.root : r);
let t = n.rest();
if (t) n = t;
else {
this.matches.add(e, !0, !1);
continue;
}
}
if (e.isENOENT()) continue;
let a, o, s = !1;
for (; typeof (a = n.pattern()) == "string" && (o = n.rest());) e = e.resolve(a), n = o, s = !0;
if (a = n.pattern(), o = n.rest(), s) {
if (this.hasWalkedCache.hasWalked(e, n)) continue;
this.hasWalkedCache.storeWalked(e, n);
}
if (typeof a == "string") {
let t = a === ".." || a === "" || a === ".";
this.matches.add(e.resolve(a), i, t);
continue;
}
if (a === t.GLOBSTAR) {
(!e.isSymbolicLink() || this.follow || n.checkFollowGlobstar()) && this.subwalks.add(e, n);
let t = o?.pattern(), r = o?.rest();
if (!o || (t === "" || t === ".") && !r) this.matches.add(e, i, t === "" || t === ".");
else if (t === "..") {
let t = e.parent || e;
r ? this.hasWalkedCache.hasWalked(t, r) || this.subwalks.add(t, r) : this.matches.add(t, i, !0);
}
} else a instanceof RegExp && this.subwalks.add(e, n);
}
return this;
}
subwalkTargets() {
return this.subwalks.keys();
}
child() {
return new e(this.opts, this.hasWalkedCache);
}
filterEntries(e, n) {
let r = this.subwalks.get(e), i = this.child();
for (let e of n) for (let n of r) {
let r = n.isAbsolute(), a = n.pattern(), o = n.rest();
a === t.GLOBSTAR ? i.testGlobstar(e, n, o, r) : a instanceof RegExp ? i.testRegExp(e, a, o, r) : i.testString(e, a, o, r);
}
return i;
}
testGlobstar(e, t, n, r) {
if ((this.dot || !e.name.startsWith(".")) && (t.hasMore() || this.matches.add(e, r, !1), e.canReaddir() && (this.follow || !e.isSymbolicLink() ? this.subwalks.add(e, t) : e.isSymbolicLink() && (n && t.checkFollowGlobstar() ? this.subwalks.add(e, n) : t.markFollowGlobstar() && this.subwalks.add(e, t)))), n) {
let t = n.pattern();
if (typeof t == "string" && t !== ".." && t !== "" && t !== ".") this.testString(e, t, n.rest(), r);
else if (t === "..") {
let t = e.parent || e;
this.subwalks.add(t, n);
} else t instanceof RegExp && this.testRegExp(e, t, n.rest(), r);
}
}
testRegExp(e, t, n, r) {
t.test(e.name) && (n ? this.subwalks.add(e, n) : this.matches.add(e, r, !1));
}
testString(e, t, n, r) {
e.isNamed(t) && (n ? this.subwalks.add(e, n) : this.matches.add(e, r, !1));
}
};
}), _ = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.GlobStream = e.GlobWalker = e.GlobUtil = void 0;
var t = f(), n = h(), r = g(), i = (e, t) => typeof e == "string" ? new n.Ignore([e], t) : Array.isArray(e) ? new n.Ignore(e, t) : e, a = class {
path;
patterns;
opts;
seen = /* @__PURE__ */ new Set();
paused = !1;
aborted = !1;
#e = [];
#t;
#n;
signal;
maxDepth;
includeChildMatches;
constructor(e, t, n) {
if (this.patterns = e, this.path = t, this.opts = n, this.#n = !n.posix && n.platform === "win32" ? "\\" : "/", this.includeChildMatches = n.includeChildMatches !== !1, (n.ignore || !this.includeChildMatches) && (this.#t = i(n.ignore ?? [], n), !this.includeChildMatches && typeof this.#t.add != "function")) throw Error("cannot ignore child matches, ignore lacks add() method.");
this.maxDepth = n.maxDepth || 1 / 0, n.signal && (this.signal = n.signal, this.signal.addEventListener("abort", () => {
this.#e.length = 0;
}));
}
#r(e) {
return this.seen.has(e) || !!this.#t?.ignored?.(e);
}
#i(e) {
return !!this.#t?.childrenIgnored?.(e);
}
pause() {
this.paused = !0;
}
resume() {
if (this.signal?.aborted) return;
this.paused = !1;
let e;
for (; !this.paused && (e = this.#e.shift());) e();
}
onResume(e) {
this.signal?.aborted || (this.paused ? this.#e.push(e) : e());
}
async matchCheck(e, t) {
if (t && this.opts.nodir) return;
let n;
if (this.opts.realpath) {
if (n = e.realpathCached() || await e.realpath(), !n) return;
e = n;
}
let r = e.isUnknown() || this.opts.stat ? await e.lstat() : e;
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
let e = await r.realpath();
e && (e.isUnknown() || this.opts.stat) && await e.lstat();
}
return this.matchCheckTest(r, t);
}
matchCheckTest(e, t) {
return e && (this.maxDepth === 1 / 0 || e.depth() <= this.maxDepth) && (!t || e.canReaddir()) && (!this.opts.nodir || !e.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !e.isSymbolicLink() || !e.realpathCached()?.isDirectory()) && !this.#r(e) ? e : void 0;
}
matchCheckSync(e, t) {
if (t && this.opts.nodir) return;
let n;
if (this.opts.realpath) {
if (n = e.realpathCached() || e.realpathSync(), !n) return;
e = n;
}
let r = e.isUnknown() || this.opts.stat ? e.lstatSync() : e;
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
let e = r.realpathSync();
e && (e?.isUnknown() || this.opts.stat) && e.lstatSync();
}
return this.matchCheckTest(r, t);
}
matchFinish(e, t) {
if (this.#r(e)) return;
if (!this.includeChildMatches && this.#t?.add) {
let t = `${e.relativePosix()}/**`;
this.#t.add(t);
}
let n = this.opts.absolute === void 0 ? t : this.opts.absolute;
this.seen.add(e);
let r = this.opts.mark && e.isDirectory() ? this.#n : "";
if (this.opts.withFileTypes) this.matchEmit(e);
else if (n) {
let t = this.opts.posix ? e.fullpathPosix() : e.fullpath();
this.matchEmit(t + r);
} else {
let t = this.opts.posix ? e.relativePosix() : e.relative(), n = this.opts.dotRelative && !t.startsWith(".." + this.#n) ? "." + this.#n : "";
this.matchEmit(t ? n + t + r : "." + r);
}
}
async match(e, t, n) {
let r = await this.matchCheck(e, n);
r && this.matchFinish(r, t);
}
matchSync(e, t, n) {
let r = this.matchCheckSync(e, n);
r && this.matchFinish(r, t);
}
walkCB(e, t, n) {
this.signal?.aborted && n(), this.walkCB2(e, t, new r.Processor(this.opts), n);
}
walkCB2(e, t, n, r) {
if (this.#i(e)) return r();
if (this.signal?.aborted && r(), this.paused) {
this.onResume(() => this.walkCB2(e, t, n, r));
return;
}
n.processPatterns(e, t);
let i = 1, a = () => {
--i === 0 && r();
};
for (let [e, t, r] of n.matches.entries()) this.#r(e) || (i++, this.match(e, t, r).then(() => a()));
for (let e of n.subwalkTargets()) {
if (this.maxDepth !== 1 / 0 && e.depth() >= this.maxDepth) continue;
i++;
let t = e.readdirCached();
e.calledReaddir() ? this.walkCB3(e, t, n, a) : e.readdirCB((t, r) => this.walkCB3(e, r, n, a), !0);
}
a();
}
walkCB3(e, t, n, r) {
n = n.filterEntries(e, t);
let i = 1, a = () => {
--i === 0 && r();
};
for (let [e, t, r] of n.matches.entries()) this.#r(e) || (i++, this.match(e, t, r).then(() => a()));
for (let [e, t] of n.subwalks.entries()) i++, this.walkCB2(e, t, n.child(), a);
a();
}
walkCBSync(e, t, n) {
this.signal?.aborted && n(), this.walkCB2Sync(e, t, new r.Processor(this.opts), n);
}
walkCB2Sync(e, t, n, r) {
if (this.#i(e)) return r();
if (this.signal?.aborted && r(), this.paused) {
this.onResume(() => this.walkCB2Sync(e, t, n, r));
return;
}
n.processPatterns(e, t);
let i = 1, a = () => {
--i === 0 && r();
};
for (let [e, t, r] of n.matches.entries()) this.#r(e) || this.matchSync(e, t, r);
for (let e of n.subwalkTargets()) {
if (this.maxDepth !== 1 / 0 && e.depth() >= this.maxDepth) continue;
i++;
let t = e.readdirSync();
this.walkCB3Sync(e, t, n, a);
}
a();
}
walkCB3Sync(e, t, n, r) {
n = n.filterEntries(e, t);
let i = 1, a = () => {
--i === 0 && r();
};
for (let [e, t, r] of n.matches.entries()) this.#r(e) || this.matchSync(e, t, r);
for (let [e, t] of n.subwalks.entries()) i++, this.walkCB2Sync(e, t, n.child(), a);
a();
}
};
e.GlobUtil = a, e.GlobWalker = class extends a {
matches = /* @__PURE__ */ new Set();
constructor(e, t, n) {
super(e, t, n);
}
matchEmit(e) {
this.matches.add(e);
}
async walk() {
if (this.signal?.aborted) throw this.signal.reason;
return this.path.isUnknown() && await this.path.lstat(), await new Promise((e, t) => {
this.walkCB(this.path, this.patterns, () => {
this.signal?.aborted ? t(this.signal.reason) : e(this.matches);
});
}), this.matches;
}
walkSync() {
if (this.signal?.aborted) throw this.signal.reason;
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
if (this.signal?.aborted) throw this.signal.reason;
}), this.matches;
}
}, e.GlobStream = class extends a {
results;
constructor(e, n, r) {
super(e, n, r), this.results = new t.Minipass({
signal: this.signal,
objectMode: !0
}), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
}
matchEmit(e) {
this.results.write(e), this.results.flowing || this.pause();
}
stream() {
let e = this.path;
return e.isUnknown() ? e.lstat().then(() => {
this.walkCB(e, this.patterns, () => this.results.end());
}) : this.walkCB(e, this.patterns, () => this.results.end()), this.results;
}
streamSync() {
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
}
};
}), v = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.Glob = void 0;
var n = u(), r = t("node:url"), i = p(), a = m(), o = _(), s = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
e.Glob = class {
absolute;
cwd;
root;
dot;
dotRelative;
follow;
ignore;
magicalBraces;
mark;
matchBase;
maxDepth;
nobrace;
nocase;
nodir;
noext;
noglobstar;
pattern;
platform;
realpath;
scurry;
stat;
signal;
windowsPathsNoEscape;
withFileTypes;
includeChildMatches;
opts;
patterns;
constructor(e, t) {
if (!t) throw TypeError("glob options required");
if (this.withFileTypes = !!t.withFileTypes, this.signal = t.signal, this.follow = !!t.follow, this.dot = !!t.dot, this.dotRelative = !!t.dotRelative, this.nodir = !!t.nodir, this.mark = !!t.mark, t.cwd ? (t.cwd instanceof URL || t.cwd.startsWith("file://")) && (t.cwd = (0, r.fileURLToPath)(t.cwd)) : this.cwd = "", this.cwd = t.cwd || "", this.root = t.root, this.magicalBraces = !!t.magicalBraces, this.nobrace = !!t.nobrace, this.noext = !!t.noext, this.realpath = !!t.realpath, this.absolute = t.absolute, this.includeChildMatches = t.includeChildMatches !== !1, this.noglobstar = !!t.noglobstar, this.matchBase = !!t.matchBase, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : 1 / 0, this.stat = !!t.stat, this.ignore = t.ignore, this.withFileTypes && this.absolute !== void 0) throw Error("cannot set absolute and withFileTypes:true");
if (typeof e == "string" && (e = [e]), this.windowsPathsNoEscape = !!t.windowsPathsNoEscape || t.allowWindowsEscape === !1, this.windowsPathsNoEscape && (e = e.map((e) => e.replace(/\\/g, "/"))), this.matchBase) {
if (t.noglobstar) throw TypeError("base matching requires globstar");
e = e.map((e) => e.includes("/") ? e : `./**/${e}`);
}
if (this.pattern = e, this.platform = t.platform || s, this.opts = {
...t,
platform: this.platform
}, t.scurry) {
if (this.scurry = t.scurry, t.nocase !== void 0 && t.nocase !== t.scurry.nocase) throw Error("nocase option contradicts provided scurry option");
} else {
let e = t.platform === "win32" ? i.PathScurryWin32 : t.platform === "darwin" ? i.PathScurryDarwin : t.platform ? i.PathScurryPosix : i.PathScurry;
this.scurry = new e(this.cwd, {
nocase: t.nocase,
fs: t.fs
});
}
this.nocase = this.scurry.nocase;
let o = this.platform === "darwin" || this.platform === "win32", c = {
braceExpandMax: 1e4,
...t,
dot: this.dot,
matchBase: this.matchBase,
nobrace: this.nobrace,
nocase: this.nocase,
nocaseMagicOnly: o,
nocomment: !0,
noext: this.noext,
nonegate: !0,
optimizationLevel: 2,
platform: this.platform,
windowsPathsNoEscape: this.windowsPathsNoEscape,
debug: !!this.opts.debug
}, [l, u] = this.pattern.map((e) => new n.Minimatch(e, c)).reduce((e, t) => (e[0].push(...t.set), e[1].push(...t.globParts), e), [[], []]);
this.patterns = l.map((e, t) => {
let n = u[t];
if (!n) throw Error("invalid pattern object");
return new a.Pattern(e, n, 0, this.platform);
});
}
async walk() {
return [...await new o.GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth === 1 / 0 ? 1 / 0 : this.maxDepth + this.scurry.cwd.depth(),
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).walk()];
}
walkSync() {
return [...new o.GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth === 1 / 0 ? 1 / 0 : this.maxDepth + this.scurry.cwd.depth(),
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).walkSync()];
}
stream() {
return new o.GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth === 1 / 0 ? 1 / 0 : this.maxDepth + this.scurry.cwd.depth(),
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).stream();
}
streamSync() {
return new o.GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth === 1 / 0 ? 1 / 0 : this.maxDepth + this.scurry.cwd.depth(),
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).streamSync();
}
iterateSync() {
return this.streamSync()[Symbol.iterator]();
}
[Symbol.iterator]() {
return this.iterateSync();
}
iterate() {
return this.stream()[Symbol.asyncIterator]();
}
[Symbol.asyncIterator]() {
return this.iterate();
}
};
}), y = n((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.hasMagic = void 0;
var t = u();
e.hasMagic = (e, n = {}) => {
Array.isArray(e) || (e = [e]);
for (let r of e) if (new t.Minimatch(r, n).hasMagic()) return !0;
return !1;
};
});
Object.defineProperty(e, "__esModule", { value: !0 }), e.glob = e.sync = e.iterate = e.iterateSync = e.stream = e.streamSync = e.Ignore = e.hasMagic = e.Glob = e.unescape = e.escape = void 0, e.globStreamSync = D, e.globStream = O, e.globSync = k, e.globIterateSync = j, e.globIterate = M;
var b = u(), x = v(), S = y(), C = u();
Object.defineProperty(e, "escape", {
enumerable: !0,
get: function() {
return C.escape;
}
}), Object.defineProperty(e, "unescape", {
enumerable: !0,
get: function() {
return C.unescape;
}
});
var w = v();
Object.defineProperty(e, "Glob", {
enumerable: !0,
get: function() {
return w.Glob;
}
});
var T = y();
Object.defineProperty(e, "hasMagic", {
enumerable: !0,
get: function() {
return T.hasMagic;
}
});
var E = h();
Object.defineProperty(e, "Ignore", {
enumerable: !0,
get: function() {
return E.Ignore;
}
});
function D(e, t = {}) {
return new x.Glob(e, t).streamSync();
}
function O(e, t = {}) {
return new x.Glob(e, t).stream();
}
function k(e, t = {}) {
return new x.Glob(e, t).walkSync();
}
async function A(e, t = {}) {
return new x.Glob(e, t).walk();
}
function j(e, t = {}) {
return new x.Glob(e, t).iterateSync();
}
function M(e, t = {}) {
return new x.Glob(e, t).iterate();
}
e.streamSync = D, e.stream = Object.assign(O, { sync: D }), e.iterateSync = j, e.iterate = Object.assign(M, { sync: j }), e.sync = Object.assign(k, {
stream: D,
iterate: j
}), e.glob = Object.assign(A, {
glob: A,
globSync: k,
sync: e.sync,
globStream: O,
stream: e.stream,
globStreamSync: D,
streamSync: e.streamSync,
globIterate: M,
iterate: e.iterate,
globIterateSync: j,
iterateSync: e.iterateSync,
Glob: x.Glob,
hasMagic: S.hasMagic,
escape: b.escape,
unescape: b.unescape
}), e.glob.glob = e.glob;
})), Dt = /* @__PURE__ */ a(((e, n) => {
var { glob: r } = Et(), i = t("path"), a = (e) => e.split(i.win32.sep).join(i.posix.sep);
n.exports = (e, t) => r(a(e), t);
})), Ot = /* @__PURE__ */ a(((e, n) => {
var r = t("fs/promises"), i = vt(), { hasContent: a } = St();
n.exports = o;
async function o(e, t) {
let n = await a(e, t);
return n && n.sri ? (await r.rm(i(e, n.sri), {
recursive: !0,
force: !0
}), !0) : !1;
}
})), kt = /* @__PURE__ */ a(((e, n) => {
var { rm: r } = t("fs/promises"), i = Dt(), a = yt(), o = bt(), s = t("path"), c = Ot();
n.exports = l, n.exports.entry = l;
function l(e, t, n) {
return o.clearMemoized(), a.delete(e, t, n);
}
n.exports.content = u;
function u(e, t) {
return o.clearMemoized(), c(e, t);
}
n.exports.all = d;
async function d(e) {
o.clearMemoized();
let t = await i(s.join(e, "*(content-*|index-*)"), {
silent: !0,
nosort: !0
});
return t.push(s.join(e, "CACHEDIR.TAG")), Promise.all(t.map((e) => r(e, {
recursive: !0,
force: !0
})));
}
})), At = /* @__PURE__ */ a(((e, n) => {
var { readFile: r, rm: i, stat: a, truncate: o, writeFile: s } = t("fs/promises"), c = vt(), l = xt(), u = Dt(), d = yt(), f = Qe(), p = t("path"), m = Z(), h = (e, t) => Object.prototype.hasOwnProperty.call(e, t), g = (e) => ({
concurrency: 20,
log: { silly() {} },
...e
});
n.exports = _;
async function _(e, t) {
t = g(t), t.log.silly("verify", "verifying cache at", e);
let n = [
v,
b,
x,
C,
T,
E,
y
], r = {};
for (let i of n) {
let n = i.name, a = /* @__PURE__ */ new Date(), o = await i(e, t);
o && Object.keys(o).forEach((e) => {
r[e] = o[e];
});
let s = /* @__PURE__ */ new Date();
r.runTime ||= {}, r.runTime[n] = s - a;
}
return r.runTime.total = r.endTime - r.startTime, t.log.silly("verify", "verification finished for", e, "in", `${r.runTime.total}ms`), r;
}
async function v() {
return { startTime: /* @__PURE__ */ new Date() };
}
async function y() {
return { endTime: /* @__PURE__ */ new Date() };
}
async function b(e, t) {
return t.log.silly("verify", "fixing cache permissions"), await f.mkdir(e), null;
}
async function x(e, t) {
t.log.silly("verify", "garbage collecting content");
let { default: n } = await import("../index.js").then((e) => (e.t(), e.n)), r = d.lsStream(e), o = /* @__PURE__ */ new Set();
r.on("data", (e) => {
if (t.filter && !t.filter(e)) return;
let n = m.parse(e.integrity);
for (let e in n) o.add(n[e].toString());
}), await new Promise((e, t) => {
r.on("end", e).on("error", t);
});
let s = c.contentDir(e), l = await u(p.join(s, "**"), {
follow: !1,
nodir: !0,
nosort: !0
}), f = {
verifiedContent: 0,
reclaimedCount: 0,
reclaimedSize: 0,
badContentCount: 0,
keptSize: 0
};
return await n(l, async (e) => {
let t = e.split(/[/\\]/), n = t.slice(t.length - 3).join(""), r = t[t.length - 4], s = m.fromHex(n, r);
if (o.has(s.toString())) {
let t = await S(e, s);
t.valid ? (f.verifiedContent++, f.keptSize += t.size) : (f.reclaimedCount++, f.badContentCount++, f.reclaimedSize += t.size);
} else {
f.reclaimedCount++;
let t = await a(e);
await i(e, {
recursive: !0,
force: !0
}), f.reclaimedSize += t.size;
}
return f;
}, { concurrency: t.concurrency }), f;
}
async function S(e, t) {
let n = {};
try {
let { size: r } = await a(e);
n.size = r, n.valid = !0, await m.checkStream(new l.ReadStream(e), t);
} catch (t) {
if (t.code === "ENOENT") return {
size: 0,
valid: !1
};
if (t.code !== "EINTEGRITY") throw t;
await i(e, {
recursive: !0,
force: !0
}), n.valid = !1;
}
return n;
}
async function C(e, t) {
t.log.silly("verify", "rebuilding index");
let { default: n } = await import("../index.js").then((e) => (e.t(), e.n)), r = await d.ls(e), i = {
missingContent: 0,
rejectedEntries: 0,
totalEntries: 0
}, a = {};
for (let n in r)
/* istanbul ignore else */
if (h(r, n)) {
let o = d.hashKey(n), s = r[n], c = t.filter && !t.filter(s);
c && i.rejectedEntries++, a[o] && !c ? a[o].push(s) : a[o] && c || (c ? (a[o] = [], a[o]._path = d.bucketPath(e, n)) : (a[o] = [s], a[o]._path = d.bucketPath(e, n)));
}
return await n(Object.keys(a), (n) => w(e, a[n], i, t), { concurrency: t.concurrency }), i;
}
async function w(e, t, n) {
await o(t._path);
for (let r of t) {
let t = c(e, r.integrity);
try {
await a(t), await d.insert(e, r.key, r.integrity, {
metadata: r.metadata,
size: r.size,
time: r.time
}), n.totalEntries++;
} catch (e) {
if (e.code === "ENOENT") n.rejectedEntries++, n.missingContent++;
else throw e;
}
}
}
function T(e, t) {
return t.log.silly("verify", "cleaning tmp directory"), i(p.join(e, "tmp"), {
recursive: !0,
force: !0
});
}
async function E(e, t) {
let n = p.join(e, "_lastverified");
return t.log.silly("verify", "writing verifile to " + n), s(n, `${Date.now()}`);
}
n.exports.lastRun = D;
async function D(e) {
let t = await r(p.join(e, "_lastverified"), { encoding: "utf8" });
return /* @__PURE__ */ new Date(+t);
}
})), jt = /* @__PURE__ */ a(((e, t) => {
var n = Ct(), r = Tt(), i = kt(), a = At(), { clearMemoized: o } = bt(), s = $e(), c = yt();
t.exports.index = {}, t.exports.index.compact = c.compact, t.exports.index.insert = c.insert, t.exports.ls = c.ls, t.exports.ls.stream = c.lsStream, t.exports.get = n, t.exports.get.byDigest = n.byDigest, t.exports.get.stream = n.stream, t.exports.get.stream.byDigest = n.stream.byDigest, t.exports.get.copy = n.copy, t.exports.get.copy.byDigest = n.copy.byDigest, t.exports.get.info = n.info, t.exports.get.hasContent = n.hasContent, t.exports.put = r, t.exports.put.stream = r.stream, t.exports.rm = i.entry, t.exports.rm.all = i.all, t.exports.rm.entry = t.exports.rm, t.exports.rm.content = i.content, t.exports.clearMemoized = o, t.exports.tmp = {}, t.exports.tmp.mkdir = s.mkdir, t.exports.tmp.withTmp = s.withTmp, t.exports.verify = a, t.exports.verify.lastRun = a.lastRun;
})), Mt = /* @__PURE__ */ a(((e, t) => {
var n = He();
t.exports = class extends n {
#e = [];
#t = /* @__PURE__ */ new Map();
constructor(e, ...t) {
/* istanbul ignore next - coverage disabled because this is pointless to test here */
super(), this.#e = e.events, t.length && this.push(...t);
}
on(e, t) {
return this.#e.includes(e) && this.#t.has(e) ? t(...this.#t.get(e)) : super.on(e, t);
}
emit(e, ...t) {
return this.#e.includes(e) && this.#t.set(e, t), super.emit(e, ...t);
}
};
})), Nt = /* @__PURE__ */ a(((e, n) => {
var { URL: r, format: i } = t("url"), a = {
auth: !1,
fragment: !1,
search: !0,
unicode: !1
};
n.exports = (e) => `make-fetch-happen:request-cache:${i(new r(e.url), a)}`;
})), Pt = /* @__PURE__ */ a(((e, t) => {
t.exports = { RetryOperation: class {
#e = 1;
#t = null;
#n = [];
#r = null;
#i;
#a = null;
#o;
#s;
#c = null;
#l;
constructor(e, t = {}) {
this.#o = [...e], this.#s = [...e], this.#l = t.unref, this.#i = t.maxRetryTime || Infinity, t.forever && (this.#t = [...this.#s]);
}
get timeouts() {
return [...this.#s];
}
get errors() {
return [...this.#n];
}
get attempts() {
return this.#e;
}
get mainError() {
let e = null;
if (this.#n.length) {
let t = 0, n = {};
for (let r = 0; r < this.#n.length; r++) {
let i = this.#n[r], { message: a } = i;
n[a] || (n[a] = 0), n[a]++, n[a] >= t && (e = i, t = n[a]);
}
}
return e;
}
reset() {
this.#e = 1, this.#s = [...this.#o];
}
stop() {
this.#c && clearTimeout(this.#c), this.#s = [], this.#t = null;
}
retry(e) {
if (this.#n.push(e), (/* @__PURE__ */ new Date()).getTime() - this.#a >= this.#i) return this.#n.unshift(/* @__PURE__ */ Error("RetryOperation timeout occurred")), !1;
let t = this.#s.shift();
if (t === void 0) {
if (this.#t) this.#n.pop(), t = this.#t.at(-1);
else return !1;
}
return this.#c = setTimeout(() => {
this.#e++, this.#r(this.#e);
}, t), this.#l && this.#c.unref(), !0;
}
attempt(e) {
this.#r = e, this.#a = (/* @__PURE__ */ new Date()).getTime(), this.#r(this.#e);
}
} };
})), Ft = /* @__PURE__ */ a(((e, t) => {
var { RetryOperation: n } = Pt(), r = (e, t) => Math.min(Math.round((1 + (t.randomize ? Math.random() : 0)) * Math.max(t.minTimeout, 1) * t.factor ** +e), t.maxTimeout), i = (e) => e?.code === "EPROMISERETRY" && Object.hasOwn(e, "retried");
t.exports = { promiseRetry: async (e, t = {}) => {
let a = [];
if (t instanceof Array) a = [...t];
else {
t.retries === Infinity && (t.forever = !0, delete t.retries);
let e = {
retries: 10,
factor: 2,
minTimeout: 1e3,
maxTimeout: Infinity,
randomize: !1,
...t
};
if (e.minTimeout > e.maxTimeout) throw Error("minTimeout is greater than maxTimeout");
if (e.retries) {
for (let t = 0; t < e.retries; t++) a.push(r(t, e));
a.sort((e, t) => e - t);
} else t.forever && a.push(r(0, e));
}
let o = new n(a, {
forever: t.forever,
unref: t.unref,
maxRetryTime: t.maxRetryTime
});
return new Promise(function(t, n) {
o.attempt(async (r) => {
try {
return t(await e((e) => {
throw Object.assign(/* @__PURE__ */ Error("Retrying"), {
code: "EPROMISERETRY",
retried: e
});
}, r, o));
} catch (e) {
if (!i(e)) return n(e);
if (!o.retry(e.retried || /* @__PURE__ */ Error())) return n(e.retried);
}
});
});
} };
})), It = /* @__PURE__ */ a(((e, n) => {
var { LRUCache: r } = c(), i = t("dns"), a = new r({ max: 50 });
n.exports = {
cache: a,
getOptions: ({ family: e = 0, hints: t = i.ADDRCONFIG, all: n = !1, verbatim: r = void 0, ttl: o = 3e5, lookup: s = i.lookup }) => ({
hints: t,
lookup: (i, ...c) => {
let l = c.pop(), u = c[0] ?? {}, d = {
family: e,
hints: t,
all: n,
verbatim: r,
...typeof u == "number" ? { family: u } : u
}, f = JSON.stringify({
hostname: i,
...d
});
if (a.has(f)) {
let e = a.get(f);
return process.nextTick(l, null, ...e);
}
s(i, d, (e, ...t) => e ? l(e) : (a.set(f, t, { ttl: o }), l(null, ...t)));
}
})
};
})), Lt = /* @__PURE__ */ a(((e, t) => {
var n = It(), r = (e) => {
let t = parseInt(e.family ?? "0", 10), r = e.keepAlive ?? !0, i = {
keepAliveMsecs: r ? 1e3 : void 0,
maxSockets: e.maxSockets ?? 15,
maxTotalSockets: Infinity,
maxFreeSockets: r ? 256 : void 0,
scheduling: "fifo",
...e,
family: t,
keepAlive: r,
timeouts: {
idle: e.timeout ?? 0,
connection: 0,
response: 0,
transfer: 0,
...e.timeouts
},
...n.getOptions({
family: t,
...e.dns
})
};
return delete i.timeout, delete i.headers, i;
}, i = (e) => {
let t = "", n = Object.entries(e).sort((e, t) => e[0] - t[0]);
for (let [e, r] of n) r == null ? r = "null" : r instanceof URL ? r = r.toString() : typeof r == "object" && (r = i(r)), t += `${e}:${r}:`;
return t;
};
t.exports = {
normalizeOptions: r,
cacheOptions: ({ secureEndpoint: e, ...t }) => i({
secureEndpoint: !!e,
family: t.family,
hints: t.hints,
localAddress: t.localAddress,
strictSsl: e ? !!t.rejectUnauthorized : !1,
ca: e ? t.ca : null,
cert: e ? t.cert : null,
key: e ? t.key : null,
keepAlive: t.keepAlive,
keepAliveMsecs: t.keepAliveMsecs,
maxSockets: t.maxSockets,
maxTotalSockets: t.maxTotalSockets,
maxFreeSockets: t.maxFreeSockets,
scheduling: t.scheduling,
timeouts: t.timeouts,
proxy: t.proxy
})
};
})), Rt = /* @__PURE__ */ a(((e, t) => {
var n = 1e3, r = n * 60, i = r * 60, a = i * 24, o = a * 7, s = a * 365.25;
t.exports = function(e, t) {
t ||= {};
var n = typeof e;
if (n === "string" && e.length > 0) return c(e);
if (n === "number" && isFinite(e)) return t.long ? u(e) : l(e);
throw Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(e));
};
function c(e) {
if (e = String(e), !(e.length > 100)) {
var t = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);
if (t) {
var c = parseFloat(t[1]);
switch ((t[2] || "ms").toLowerCase()) {
case "years":
case "year":
case "yrs":
case "yr":
case "y": return c * s;
case "weeks":
case "week":
case "w": return c * o;
case "days":
case "day":
case "d": return c * a;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h": return c * i;
case "minutes":
case "minute":
case "mins":
case "min":
case "m": return c * r;
case "seconds":
case "second":
case "secs":
case "sec":
case "s": return c * n;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms": return c;
default: return;
}
}
}
}
function l(e) {
var t = Math.abs(e);
return t >= a ? Math.round(e / a) + "d" : t >= i ? Math.round(e / i) + "h" : t >= r ? Math.round(e / r) + "m" : t >= n ? Math.round(e / n) + "s" : e + "ms";
}
function u(e) {
var t = Math.abs(e);
return t >= a ? d(e, t, a, "day") : t >= i ? d(e, t, i, "hour") : t >= r ? d(e, t, r, "minute") : t >= n ? d(e, t, n, "second") : e + " ms";
}
function d(e, t, n, r) {
var i = t >= n * 1.5;
return Math.round(e / n) + " " + r + (i ? "s" : "");
}
})), zt = /* @__PURE__ */ a(((e, t) => {
function n(e) {
n.debug = n, n.default = n, n.coerce = c, n.disable = o, n.enable = i, n.enabled = s, n.humanize = Rt(), n.destroy = l, Object.keys(e).forEach((t) => {
n[t] = e[t];
}), n.names = [], n.skips = [], n.formatters = {};
function t(e) {
let t = 0;
for (let n = 0; n < e.length; n++) t = (t << 5) - t + e.charCodeAt(n), t |= 0;
return n.colors[Math.abs(t) % n.colors.length];
}
n.selectColor = t;
function n(e) {
let t, i = null, a, o;
function s(...e) {
if (!s.enabled) return;
let r = s, i = Number(/* @__PURE__ */ new Date());
r.diff = i - (t || i), r.prev = t, r.curr = i, t = i, e[0] = n.coerce(e[0]), typeof e[0] != "string" && e.unshift("%O");
let a = 0;
e[0] = e[0].replace(/%([a-zA-Z%])/g, (t, i) => {
if (t === "%%") return "%";
a++;
let o = n.formatters[i];
if (typeof o == "function") {
let n = e[a];
t = o.call(r, n), e.splice(a, 1), a--;
}
return t;
}), n.formatArgs.call(r, e), (r.log || n.log).apply(r, e);
}
return s.namespace = e, s.useColors = n.useColors(), s.color = n.selectColor(e), s.extend = r, s.destroy = n.destroy, Object.defineProperty(s, "enabled", {
enumerable: !0,
configurable: !1,
get: () => i === null ? (a !== n.namespaces && (a = n.namespaces, o = n.enabled(e)), o) : i,
set: (e) => {
i = e;
}
}), typeof n.init == "function" && n.init(s), s;
}
function r(e, t) {
let r = n(this.namespace + (t === void 0 ? ":" : t) + e);
return r.log = this.log, r;
}
function i(e) {
n.save(e), n.namespaces = e, n.names = [], n.skips = [];
let t = (typeof e == "string" ? e : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
for (let e of t) e[0] === "-" ? n.skips.push(e.slice(1)) : n.names.push(e);
}
function a(e, t) {
let n = 0, r = 0, i = -1, a = 0;
for (; n < e.length;) if (r < t.length && (t[r] === e[n] || t[r] === "*")) t[r] === "*" ? (i = r, a = n, r++) : (n++, r++);
else if (i !== -1) r = i + 1, a++, n = a;
else return !1;
for (; r < t.length && t[r] === "*";) r++;
return r === t.length;
}
function o() {
let e = [...n.names, ...n.skips.map((e) => "-" + e)].join(",");
return n.enable(""), e;
}
function s(e) {
for (let t of n.skips) if (a(e, t)) return !1;
for (let t of n.names) if (a(e, t)) return !0;
return !1;
}
function c(e) {
return e instanceof Error ? e.stack || e.message : e;
}
function l() {
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
return n.enable(n.load()), n;
}
t.exports = n;
})), Bt = /* @__PURE__ */ a(((e, t) => {
e.formatArgs = r, e.save = i, e.load = a, e.useColors = n, e.storage = o(), e.destroy = (() => {
let e = !1;
return () => {
e || (e = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
};
})(), e.colors = /* @__PURE__ */ "#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33".split(".");
function n() {
if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return !0;
if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return !1;
let e;
return typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator < "u" && navigator.userAgent && (e = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(e[1], 10) >= 31 || typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
}
function r(e) {
if (e[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + e[0] + (this.useColors ? "%c " : " ") + "+" + t.exports.humanize(this.diff), !this.useColors) return;
let n = "color: " + this.color;
e.splice(1, 0, n, "color: inherit");
let r = 0, i = 0;
e[0].replace(/%[a-zA-Z%]/g, (e) => {
e !== "%%" && (r++, e === "%c" && (i = r));
}), e.splice(i, 0, n);
}
e.log = console.debug || console.log || (() => {});
function i(t) {
try {
t ? e.storage.setItem("debug", t) : e.storage.removeItem("debug");
} catch {}
}
function a() {
let t;
try {
t = e.storage.getItem("debug") || e.storage.getItem("DEBUG");
} catch {}
return !t && typeof process < "u" && "env" in process && (t = process.env.DEBUG), t;
}
function o() {
try {
return localStorage;
} catch {}
}
t.exports = zt()(e);
var { formatters: s } = t.exports;
s.j = function(e) {
try {
return JSON.stringify(e);
} catch (e) {
return "[UnexpectedJSONParseError]: " + e.message;
}
};
})), Vt = /* @__PURE__ */ a(((e, t) => {
t.exports = (e, t = process.argv) => {
let n = e.startsWith("-") ? "" : e.length === 1 ? "-" : "--", r = t.indexOf(n + e), i = t.indexOf("--");
return r !== -1 && (i === -1 || r < i);
};
})), Ht = /* @__PURE__ */ a(((e, n) => {
var r = t("os"), i = t("tty"), a = Vt(), { env: o } = process, s;
a("no-color") || a("no-colors") || a("color=false") || a("color=never") ? s = 0 : (a("color") || a("colors") || a("color=true") || a("color=always")) && (s = 1);
function c() {
if ("FORCE_COLOR" in o) return o.FORCE_COLOR === "true" ? 1 : o.FORCE_COLOR === "false" ? 0 : o.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(o.FORCE_COLOR, 10), 3);
}
function l(e) {
return e !== 0 && {
level: e,
hasBasic: !0,
has256: e >= 2,
has16m: e >= 3
};
}
function u(e, { streamIsTTY: t, sniffFlags: n = !0 } = {}) {
let i = c();
i !== void 0 && (s = i);
let l = n ? s : i;
if (l === 0) return 0;
if (n) {
if (a("color=16m") || a("color=full") || a("color=truecolor")) return 3;
if (a("color=256")) return 2;
}
if (e && !t && l === void 0) return 0;
let u = l || 0;
if (o.TERM === "dumb") return u;
if (process.platform === "win32") {
let e = r.release().split(".");
return Number(e[0]) >= 10 && Number(e[2]) >= 10586 ? Number(e[2]) >= 14931 ? 3 : 2 : 1;
}
if ("CI" in o) return [
"TRAVIS",
"CIRCLECI",
"APPVEYOR",
"GITLAB_CI",
"GITHUB_ACTIONS",
"BUILDKITE",
"DRONE"
].some((e) => e in o) || o.CI_NAME === "codeship" ? 1 : u;
if ("TEAMCITY_VERSION" in o) return +!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION);
if (o.COLORTERM === "truecolor") return 3;
if ("TERM_PROGRAM" in o) {
let e = Number.parseInt((o.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
switch (o.TERM_PROGRAM) {
case "iTerm.app": return e >= 3 ? 3 : 2;
case "Apple_Terminal": return 2;
}
}
return /-256(color)?$/i.test(o.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM) || "COLORTERM" in o ? 1 : u;
}
function d(e, t = {}) {
return l(u(e, {
streamIsTTY: e && e.isTTY,
...t
}));
}
n.exports = {
supportsColor: d,
stdout: d({ isTTY: i.isatty(1) }),
stderr: d({ isTTY: i.isatty(2) })
};
})), Ut = /* @__PURE__ */ a(((e, n) => {
var r = t("tty"), i = t("util");
e.init = d, e.log = c, e.formatArgs = o, e.save = l, e.load = u, e.useColors = a, e.destroy = i.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."), e.colors = [
6,
2,
3,
4,
5,
1
];
try {
let t = Ht();
t && (t.stderr || t).level >= 2 && (e.colors = [
20,
21,
26,
27,
32,
33,
38,
39,
40,
41,
42,
43,
44,
45,
56,
57,
62,
63,
68,
69,
74,
75,
76,
77,
78,
79,
80,
81,
92,
93,
98,
99,
112,
113,
128,
129,
134,
135,
148,
149,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
178,
179,
184,
185,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
214,
215,
220,
221
]);
} catch {}
e.inspectOpts = Object.keys(process.env).filter((e) => /^debug_/i.test(e)).reduce((e, t) => {
let n = t.substring(6).toLowerCase().replace(/_([a-z])/g, (e, t) => t.toUpperCase()), r = process.env[t];
return r = /^(yes|on|true|enabled)$/i.test(r) ? !0 : /^(no|off|false|disabled)$/i.test(r) ? !1 : r === "null" ? null : Number(r), e[n] = r, e;
}, {});
function a() {
return "colors" in e.inspectOpts ? !!e.inspectOpts.colors : r.isatty(process.stderr.fd);
}
function o(e) {
let { namespace: t, useColors: r } = this;
if (r) {
let r = this.color, i = "\x1B[3" + (r < 8 ? r : "8;5;" + r), a = ` ${i};1m${t} \u001B[0m`;
e[0] = a + e[0].split("\n").join("\n" + a), e.push(i + "m+" + n.exports.humanize(this.diff) + "\x1B[0m");
} else e[0] = s() + t + " " + e[0];
}
function s() {
return e.inspectOpts.hideDate ? "" : (/* @__PURE__ */ new Date()).toISOString() + " ";
}
function c(...t) {
return process.stderr.write(i.formatWithOptions(e.inspectOpts, ...t) + "\n");
}
function l(e) {
e ? process.env.DEBUG = e : delete process.env.DEBUG;
}
function u() {
return process.env.DEBUG;
}
function d(t) {
t.inspectOpts = {};
let n = Object.keys(e.inspectOpts);
for (let r = 0; r < n.length; r++) t.inspectOpts[n[r]] = e.inspectOpts[n[r]];
}
n.exports = zt()(e);
var { formatters: f } = n.exports;
f.o = function(e) {
return this.inspectOpts.colors = this.useColors, i.inspect(e, this.inspectOpts).split("\n").map((e) => e.trim()).join(" ");
}, f.O = function(e) {
return this.inspectOpts.colors = this.useColors, i.inspect(e, this.inspectOpts);
};
})), Wt = /* @__PURE__ */ a(((e, t) => {
t.exports = typeof process > "u" || process.type === "renderer" || process.browser === !0 || process.__nwjs ? Bt() : Ut();
}));
//#endregion
//#region node_modules/agent-base/dist/helpers.js
async function Gt(e) {
let t = 0, n = [];
for await (let r of e) t += r.length, n.push(r);
return Buffer.concat(n, t);
}
async function Kt(e) {
let t = (await Gt(e)).toString("utf8");
try {
return JSON.parse(t);
} catch (e) {
let n = e;
throw n.message += ` (input: ${t})`, n;
}
}
function qt(e, t = {}) {
let n = ((typeof e == "string" ? e : e.href).startsWith("https:") ? p : f).request(e, t), r = new Promise((e, t) => {
n.once("response", e).once("error", t).end();
});
return n.then = r.then.bind(r), n;
}
var Jt = n((() => {})), Yt = /* @__PURE__ */ i({
Agent: () => Xt,
json: () => Kt,
req: () => qt,
toBuffer: () => Gt
}), Q, Xt, Zt = n((() => {
Jt(), Q = Symbol("AgentBaseInternalState"), Xt = class extends f.Agent {
constructor(e) {
super(e), this[Q] = {};
}
isSecureEndpoint(e) {
if (e) {
if (typeof e.secureEndpoint == "boolean") return e.secureEndpoint;
if (typeof e.protocol == "string") return e.protocol === "https:";
}
let { stack: t } = /* @__PURE__ */ Error();
return typeof t == "string" && t.split("\n").some((e) => e.indexOf("(https.js:") !== -1 || e.indexOf("node:https:") !== -1);
}
incrementSockets(e) {
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
this.sockets[e] || (this.sockets[e] = []);
let t = new g.Socket({ writable: !1 });
return this.sockets[e].push(t), this.totalSocketCount++, t;
}
decrementSockets(e, t) {
if (!this.sockets[e] || t === null) return;
let n = this.sockets[e], r = n.indexOf(t);
r !== -1 && (n.splice(r, 1), this.totalSocketCount--, n.length === 0 && delete this.sockets[e]);
}
getName(e) {
return this.isSecureEndpoint(e) ? m.prototype.getName.call(this, e) : super.getName(e);
}
createSocket(e, t, n) {
let r = {
...t,
secureEndpoint: this.isSecureEndpoint(t)
}, i = this.getName(r), a = this.incrementSockets(i);
Promise.resolve().then(() => this.connect(e, r)).then((o) => {
if (this.decrementSockets(i, a), typeof o.addRequest == "function") try {
return o.addRequest(e, r);
} catch (e) {
return n(e);
}
this[Q].currentSocket = o, super.createSocket(e, t, n);
}, (e) => {
this.decrementSockets(i, a), n(e);
});
}
createConnection() {
let e = this[Q].currentSocket;
if (this[Q].currentSocket = void 0, !e) throw Error("No socket was returned in the `connect()` function");
return e;
}
get defaultPort() {
return this[Q].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
}
set defaultPort(e) {
this[Q] && (this[Q].defaultPort = e);
}
get protocol() {
return this[Q].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
}
set protocol(e) {
this[Q] && (this[Q].protocol = e);
}
};
}));
//#endregion
//#region node_modules/proxy-agent-negotiate/dist/index.js
function Qt() {
return async ({ response: e, scheme: t }) => {
if (t.toLowerCase() !== "negotiate") throw Error(`Expected Negotiate scheme but got "${t}"`);
let n;
try {
n = await import("./__vite-optional-peer-dep_kerberos_proxy-agent-negotiate-B5nVn_MB.js");
} catch {
throw Error("The \"kerberos\" package is required for Negotiate proxy authentication. Install it with: npm install kerberos");
}
let r = e.headers["proxy-authenticate"] || "", i = Array.isArray(r) ? r[0] : r, a = typeof i == "string" && i.includes(" ") ? i.split(" ").slice(1).join(" ") : void 0, o = await (await n.initializeClient("HTTP@proxy", { mechOID: n.GSS_MECH_OID_SPNEGO })).step(a || "");
if (!o) throw Error("Kerberos client.step() returned no token");
return { headers: { "Proxy-Authorization": `Negotiate ${o}` } };
};
}
var $t = n((() => {})), en = /* @__PURE__ */ i({ HttpProxyAgent: () => an });
function tn(e, ...t) {
let n = {}, r;
for (r in e) t.includes(r) || (n[r] = e[r]);
return n;
}
var nn, rn, an, on = n((() => {
nn = /* @__PURE__ */ r(Wt(), 1), Zt(), $t(), rn = (0, nn.default)("http-proxy-agent"), an = class extends Xt {
constructor(e, t) {
super(t), this.proxy = typeof e == "string" ? new u(e) : e, this.proxyHeaders = t?.headers ?? {}, rn("Creating new HttpProxyAgent instance: %o", this.proxy.href), t?.negotiate ? this.onProxyAuth = Qt() : t?.onProxyAuth && (this.onProxyAuth = t.onProxyAuth);
let n = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""), r = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
this.connectOpts = {
...t ? tn(t, "headers", "onProxyAuth", "negotiate") : null,
host: n,
port: r
};
}
addRequest(e, t) {
e._header = null, this.setRequestProps(e, t), super.addRequest(e, t);
}
setRequestProps(e, t) {
let { proxy: n } = this, r = `${t.secureEndpoint ? "https:" : "http:"}//${e.getHeader("host") || "localhost"}`, i = new u(e.path, r);
t.port !== 80 && (i.port = String(t.port)), e.path = String(i);
let a = typeof this.proxyHeaders == "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
if (n.username || n.password) {
let e = `${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;
a["Proxy-Authorization"] = `Basic ${Buffer.from(e).toString("base64")}`;
}
a["Proxy-Connection"] ||= this.keepAlive ? "Keep-Alive" : "close";
for (let t of Object.keys(a)) {
let n = a[t];
n && e.setHeader(t, n);
}
}
async connect(e, t) {
e._header = null, e.path.includes("://") || this.setRequestProps(e, t);
let n, r;
rn("Regenerating stored HTTP header string for request"), e._implicitHeader(), e.outputData && e.outputData.length > 0 && (rn("Patching connection write() output buffer with updated header"), n = e.outputData[0].data, r = n.indexOf("\r\n\r\n") + 4, e.outputData[0].data = e._header + n.substring(r), rn("Output buffer: %o", e.outputData[0].data));
let i;
this.proxy.protocol === "https:" ? (rn("Creating `tls.Socket`: %o", this.connectOpts), i = _.connect(this.connectOpts)) : (rn("Creating `net.Socket`: %o", this.connectOpts), i = g.connect(this.connectOpts)), await l(i, "connect");
let a = { socket: i };
return e.emit("proxyConnect", a), this.emit("proxyConnect", a, e), e.emit("proxy", {
proxy: this.proxy.href,
socket: i
}), i;
}
}, an.protocols = ["http", "https"];
}));
//#endregion
//#region node_modules/https-proxy-agent/dist/parse-proxy-response.js
function sn(e) {
return new Promise((t, n) => {
let r = 0, i = [];
function a() {
let t = e.read();
t ? l(t) : e.once("readable", a);
}
function o() {
e.removeListener("end", s), e.removeListener("error", c), e.removeListener("readable", a);
}
function s() {
o(), ln("onend"), n(/* @__PURE__ */ Error("Proxy connection ended before receiving CONNECT response"));
}
function c(e) {
o(), ln("onerror %o", e), n(e);
}
function l(s) {
i.push(s), r += s.length;
let c = Buffer.concat(i, r), l = c.indexOf("\r\n\r\n");
if (l === -1) {
ln("have not received end of HTTP headers yet..."), a();
return;
}
let u = c.slice(0, l).toString("ascii").split("\r\n"), d = u.shift();
if (!d) return e.destroy(), n(/* @__PURE__ */ Error("No header received from proxy CONNECT response"));
let f = d.split(" "), p = +f[1], m = f.slice(2).join(" "), h = {};
for (let t of u) {
if (!t) continue;
let r = t.indexOf(":");
if (r === -1) return e.destroy(), n(/* @__PURE__ */ Error(`Invalid header from proxy CONNECT response: "${t}"`));
let i = t.slice(0, r).toLowerCase(), a = t.slice(r + 1).trimStart(), o = h[i];
typeof o == "string" ? h[i] = [o, a] : Array.isArray(o) ? o.push(a) : h[i] = a;
}
ln("got proxy server response: %o %o", d, h), o(), t({
connect: {
statusCode: p,
statusText: m,
headers: h
},
buffered: c
});
}
e.on("error", c), e.on("end", s), a();
});
}
var cn, ln, un = n((() => {
cn = /* @__PURE__ */ r(Wt(), 1), ln = (0, cn.default)("https-proxy-agent:parse-proxy-response");
})), dn = /* @__PURE__ */ i({ HttpsProxyAgent: () => gn });
function fn(e) {
setImmediate(() => {
e.resume();
});
}
function pn(e, ...t) {
let n = {}, r;
for (r in e) t.includes(r) || (n[r] = e[r]);
return n;
}
var mn, $, hn, gn, _n = n((() => {
mn = /* @__PURE__ */ r(Wt(), 1), Zt(), un(), $t(), $ = (0, mn.default)("https-proxy-agent"), hn = (e) => e.servername === void 0 && e.host && !g.isIP(e.host) ? {
...e,
servername: e.host
} : e, gn = class extends Xt {
constructor(e, t) {
super(t), this.options = { path: void 0 }, this.proxy = typeof e == "string" ? new u(e) : e, this.proxyHeaders = t?.headers ?? {}, $("Creating new HttpsProxyAgent instance: %o", this.proxy.href), t?.negotiate ? this.onProxyAuth = Qt() : t?.onProxyAuth && (this.onProxyAuth = t.onProxyAuth);
let n = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""), r = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
this.connectOpts = {
ALPNProtocols: ["http/1.1"],
...t ? pn(t, "headers", "onProxyAuth", "negotiate") : null,
host: n,
port: r
};
}
async connect(e, t) {
let { proxy: n } = this;
if (!t.host) throw TypeError("No \"host\" provided");
let r;
n.protocol === "https:" ? ($("Creating `tls.Socket`: %o", this.connectOpts), r = _.connect(hn(this.connectOpts))) : ($("Creating `net.Socket`: %o", this.connectOpts), r = g.connect(this.connectOpts));
let i = typeof this.proxyHeaders == "function" ? this.proxyHeaders() : { ...this.proxyHeaders }, a = g.isIPv6(t.host) ? `[${t.host}]` : t.host, o = `CONNECT ${a}:${t.port} HTTP/1.1\r\n`;
if (n.username || n.password) {
let e = `${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;
i["Proxy-Authorization"] = `Basic ${Buffer.from(e).toString("base64")}`;
}
i.Host = `${a}:${t.port}`, i["Proxy-Connection"] ||= this.keepAlive ? "Keep-Alive" : "close";
for (let e of Object.keys(i)) o += `${e}: ${i[e]}\r\n`;
let s = sn(r);
r.write(`${o}\r\n`);
let { connect: c, buffered: l } = await s;
if (e.emit("proxyConnect", c), this.emit("proxyConnect", c, e), e.emit("proxy", {
proxy: this.proxy.href,
socket: r
}), c.statusCode === 200) return e.once("socket", fn), t.secureEndpoint ? ($("Upgrading socket connection to TLS"), _.connect({
...pn(hn(t), "host", "path", "port"),
socket: r
})) : r;
if (c.statusCode === 407 && this.onProxyAuth) {
$("Got 407 response, invoking onProxyAuth callback"), r.destroy();
let n = c.headers["proxy-authenticate"] || "", i = Array.isArray(n) ? n[0].split(/\s/)[0] : n.split(/\s/)[0], a = await this.onProxyAuth({
response: c,
scheme: i
});
return this._connectWithAuth(e, t, a.headers);
}
r.destroy();
let u = new g.Socket({ writable: !1 });
return u.readable = !0, e.once("socket", (e) => {
$("Replaying proxy buffer for failed request"), d(e.listenerCount("data") > 0), e.push(l), e.push(null);
}), u;
}
async _connectWithAuth(e, t, n) {
let { proxy: r } = this, i;
i = r.protocol === "https:" ? _.connect(hn(this.connectOpts)) : g.connect(this.connectOpts);
let a = typeof this.proxyHeaders == "function" ? this.proxyHeaders() : { ...this.proxyHeaders }, o = g.isIPv6(t.host) ? `[${t.host}]` : t.host, s = `CONNECT ${o}:${t.port} HTTP/1.1\r\n`;
if (r.username || r.password) {
let e = `${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;
a["Proxy-Authorization"] = `Basic ${Buffer.from(e).toString("base64")}`;
}
Object.assign(a, n), a.Host = `${o}:${t.port}`, a["Proxy-Connection"] ||= this.keepAlive ? "Keep-Alive" : "close";
for (let e of Object.keys(a)) s += `${e}: ${a[e]}\r\n`;
let c = sn(i);
i.write(`${s}\r\n`);
let { connect: l } = await c;
if (e.emit("proxyConnect", l), this.emit("proxyConnect", l, e), l.statusCode === 200) return e.once("socket", fn), t.secureEndpoint ? ($("Upgrading socket connection to TLS"), _.connect({
...pn(hn(t), "host", "path", "port"),
socket: i
})) : i;
throw i.destroy(), Error(`Proxy authentication failed with status ${l.statusCode} after retry`);
}
}, gn.protocols = ["http", "https"];
})), vn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 });
var n = t("buffer"), r = {
INVALID_ENCODING: "Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",
INVALID_SMARTBUFFER_SIZE: "Invalid size provided. Size must be a valid integer greater than zero.",
INVALID_SMARTBUFFER_BUFFER: "Invalid Buffer provided in SmartBufferOptions.",
INVALID_SMARTBUFFER_OBJECT: "Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",
INVALID_OFFSET: "An invalid offset value was provided.",
INVALID_OFFSET_NON_NUMBER: "An invalid offset value was provided. A numeric value is required.",
INVALID_LENGTH: "An invalid length value was provided.",
INVALID_LENGTH_NON_NUMBER: "An invalid length value was provived. A numeric value is required.",
INVALID_TARGET_OFFSET: "Target offset is beyond the bounds of the internal SmartBuffer data.",
INVALID_TARGET_LENGTH: "Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",
INVALID_READ_BEYOND_BOUNDS: "Attempted to read beyond the bounds of the managed data.",
INVALID_WRITE_BEYOND_BOUNDS: "Attempted to write beyond the bounds of the managed data."
};
e.ERRORS = r;
function i(e) {
if (!n.Buffer.isEncoding(e)) throw Error(r.INVALID_ENCODING);
}
e.checkEncoding = i;
function a(e) {
return typeof e == "number" && isFinite(e) && u(e);
}
e.isFiniteInteger = a;
function o(e, t) {
if (typeof e == "number") {
if (!a(e) || e < 0) throw Error(t ? r.INVALID_OFFSET : r.INVALID_LENGTH);
} else throw Error(t ? r.INVALID_OFFSET_NON_NUMBER : r.INVALID_LENGTH_NON_NUMBER);
}
function s(e) {
o(e, !1);
}
e.checkLengthValue = s;
function c(e) {
o(e, !0);
}
e.checkOffsetValue = c;
function l(e, t) {
if (e < 0 || e > t.length) throw Error(r.INVALID_TARGET_OFFSET);
}
e.checkTargetOffset = l;
function u(e) {
return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
}
function d(e) {
if (typeof BigInt > "u") throw Error("Platform does not support JS BigInt type.");
if (n.Buffer.prototype[e] === void 0) throw Error(`Platform does not support Buffer.prototype.${e}.`);
}
e.bigIntAndBufferInt64Check = d;
})), yn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 });
var t = vn(), n = 4096, r = "utf8";
e.SmartBuffer = class e {
constructor(i) {
if (this.length = 0, this._encoding = r, this._writeOffset = 0, this._readOffset = 0, e.isSmartBufferOptions(i)) {
if (i.encoding && (t.checkEncoding(i.encoding), this._encoding = i.encoding), i.size) {
if (t.isFiniteInteger(i.size) && i.size > 0) this._buff = Buffer.allocUnsafe(i.size);
else throw Error(t.ERRORS.INVALID_SMARTBUFFER_SIZE);
} else if (i.buff) {
if (Buffer.isBuffer(i.buff)) this._buff = i.buff, this.length = i.buff.length;
else throw Error(t.ERRORS.INVALID_SMARTBUFFER_BUFFER);
} else this._buff = Buffer.allocUnsafe(n);
} else {
if (i !== void 0) throw Error(t.ERRORS.INVALID_SMARTBUFFER_OBJECT);
this._buff = Buffer.allocUnsafe(n);
}
}
static fromSize(e, t) {
return new this({
size: e,
encoding: t
});
}
static fromBuffer(e, t) {
return new this({
buff: e,
encoding: t
});
}
static fromOptions(e) {
return new this(e);
}
static isSmartBufferOptions(e) {
let t = e;
return t && (t.encoding !== void 0 || t.size !== void 0 || t.buff !== void 0);
}
readInt8(e) {
return this._readNumberValue(Buffer.prototype.readInt8, 1, e);
}
readInt16BE(e) {
return this._readNumberValue(Buffer.prototype.readInt16BE, 2, e);
}
readInt16LE(e) {
return this._readNumberValue(Buffer.prototype.readInt16LE, 2, e);
}
readInt32BE(e) {
return this._readNumberValue(Buffer.prototype.readInt32BE, 4, e);
}
readInt32LE(e) {
return this._readNumberValue(Buffer.prototype.readInt32LE, 4, e);
}
readBigInt64BE(e) {
return t.bigIntAndBufferInt64Check("readBigInt64BE"), this._readNumberValue(Buffer.prototype.readBigInt64BE, 8, e);
}
readBigInt64LE(e) {
return t.bigIntAndBufferInt64Check("readBigInt64LE"), this._readNumberValue(Buffer.prototype.readBigInt64LE, 8, e);
}
writeInt8(e, t) {
return this._writeNumberValue(Buffer.prototype.writeInt8, 1, e, t), this;
}
insertInt8(e, t) {
return this._insertNumberValue(Buffer.prototype.writeInt8, 1, e, t);
}
writeInt16BE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeInt16BE, 2, e, t);
}
insertInt16BE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeInt16BE, 2, e, t);
}
writeInt16LE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeInt16LE, 2, e, t);
}
insertInt16LE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeInt16LE, 2, e, t);
}
writeInt32BE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeInt32BE, 4, e, t);
}
insertInt32BE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeInt32BE, 4, e, t);
}
writeInt32LE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeInt32LE, 4, e, t);
}
insertInt32LE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeInt32LE, 4, e, t);
}
writeBigInt64BE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigInt64BE"), this._writeNumberValue(Buffer.prototype.writeBigInt64BE, 8, e, n);
}
insertBigInt64BE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigInt64BE"), this._insertNumberValue(Buffer.prototype.writeBigInt64BE, 8, e, n);
}
writeBigInt64LE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigInt64LE"), this._writeNumberValue(Buffer.prototype.writeBigInt64LE, 8, e, n);
}
insertBigInt64LE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigInt64LE"), this._insertNumberValue(Buffer.prototype.writeBigInt64LE, 8, e, n);
}
readUInt8(e) {
return this._readNumberValue(Buffer.prototype.readUInt8, 1, e);
}
readUInt16BE(e) {
return this._readNumberValue(Buffer.prototype.readUInt16BE, 2, e);
}
readUInt16LE(e) {
return this._readNumberValue(Buffer.prototype.readUInt16LE, 2, e);
}
readUInt32BE(e) {
return this._readNumberValue(Buffer.prototype.readUInt32BE, 4, e);
}
readUInt32LE(e) {
return this._readNumberValue(Buffer.prototype.readUInt32LE, 4, e);
}
readBigUInt64BE(e) {
return t.bigIntAndBufferInt64Check("readBigUInt64BE"), this._readNumberValue(Buffer.prototype.readBigUInt64BE, 8, e);
}
readBigUInt64LE(e) {
return t.bigIntAndBufferInt64Check("readBigUInt64LE"), this._readNumberValue(Buffer.prototype.readBigUInt64LE, 8, e);
}
writeUInt8(e, t) {
return this._writeNumberValue(Buffer.prototype.writeUInt8, 1, e, t);
}
insertUInt8(e, t) {
return this._insertNumberValue(Buffer.prototype.writeUInt8, 1, e, t);
}
writeUInt16BE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeUInt16BE, 2, e, t);
}
insertUInt16BE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeUInt16BE, 2, e, t);
}
writeUInt16LE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeUInt16LE, 2, e, t);
}
insertUInt16LE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeUInt16LE, 2, e, t);
}
writeUInt32BE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeUInt32BE, 4, e, t);
}
insertUInt32BE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeUInt32BE, 4, e, t);
}
writeUInt32LE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeUInt32LE, 4, e, t);
}
insertUInt32LE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeUInt32LE, 4, e, t);
}
writeBigUInt64BE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigUInt64BE"), this._writeNumberValue(Buffer.prototype.writeBigUInt64BE, 8, e, n);
}
insertBigUInt64BE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigUInt64BE"), this._insertNumberValue(Buffer.prototype.writeBigUInt64BE, 8, e, n);
}
writeBigUInt64LE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigUInt64LE"), this._writeNumberValue(Buffer.prototype.writeBigUInt64LE, 8, e, n);
}
insertBigUInt64LE(e, n) {
return t.bigIntAndBufferInt64Check("writeBigUInt64LE"), this._insertNumberValue(Buffer.prototype.writeBigUInt64LE, 8, e, n);
}
readFloatBE(e) {
return this._readNumberValue(Buffer.prototype.readFloatBE, 4, e);
}
readFloatLE(e) {
return this._readNumberValue(Buffer.prototype.readFloatLE, 4, e);
}
writeFloatBE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeFloatBE, 4, e, t);
}
insertFloatBE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeFloatBE, 4, e, t);
}
writeFloatLE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeFloatLE, 4, e, t);
}
insertFloatLE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeFloatLE, 4, e, t);
}
readDoubleBE(e) {
return this._readNumberValue(Buffer.prototype.readDoubleBE, 8, e);
}
readDoubleLE(e) {
return this._readNumberValue(Buffer.prototype.readDoubleLE, 8, e);
}
writeDoubleBE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeDoubleBE, 8, e, t);
}
insertDoubleBE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeDoubleBE, 8, e, t);
}
writeDoubleLE(e, t) {
return this._writeNumberValue(Buffer.prototype.writeDoubleLE, 8, e, t);
}
insertDoubleLE(e, t) {
return this._insertNumberValue(Buffer.prototype.writeDoubleLE, 8, e, t);
}
readString(e, n) {
let r;
typeof e == "number" ? (t.checkLengthValue(e), r = Math.min(e, this.length - this._readOffset)) : (n = e, r = this.length - this._readOffset), n !== void 0 && t.checkEncoding(n);
let i = this._buff.slice(this._readOffset, this._readOffset + r).toString(n || this._encoding);
return this._readOffset += r, i;
}
insertString(e, n, r) {
return t.checkOffsetValue(n), this._handleString(e, !0, n, r);
}
writeString(e, t, n) {
return this._handleString(e, !1, t, n);
}
readStringNT(e) {
e !== void 0 && t.checkEncoding(e);
let n = this.length;
for (let e = this._readOffset; e < this.length; e++) if (this._buff[e] === 0) {
n = e;
break;
}
let r = this._buff.slice(this._readOffset, n);
return this._readOffset = n + 1, r.toString(e || this._encoding);
}
insertStringNT(e, n, r) {
return t.checkOffsetValue(n), this.insertString(e, n, r), this.insertUInt8(0, n + e.length), this;
}
writeStringNT(e, t, n) {
return this.writeString(e, t, n), this.writeUInt8(0, typeof t == "number" ? t + e.length : this.writeOffset), this;
}
readBuffer(e) {
e !== void 0 && t.checkLengthValue(e);
let n = typeof e == "number" ? e : this.length, r = Math.min(this.length, this._readOffset + n), i = this._buff.slice(this._readOffset, r);
return this._readOffset = r, i;
}
insertBuffer(e, n) {
return t.checkOffsetValue(n), this._handleBuffer(e, !0, n);
}
writeBuffer(e, t) {
return this._handleBuffer(e, !1, t);
}
readBufferNT() {
let e = this.length;
for (let t = this._readOffset; t < this.length; t++) if (this._buff[t] === 0) {
e = t;
break;
}
let t = this._buff.slice(this._readOffset, e);
return this._readOffset = e + 1, t;
}
insertBufferNT(e, n) {
return t.checkOffsetValue(n), this.insertBuffer(e, n), this.insertUInt8(0, n + e.length), this;
}
writeBufferNT(e, n) {
return n !== void 0 && t.checkOffsetValue(n), this.writeBuffer(e, n), this.writeUInt8(0, typeof n == "number" ? n + e.length : this._writeOffset), this;
}
clear() {
return this._writeOffset = 0, this._readOffset = 0, this.length = 0, this;
}
remaining() {
return this.length - this._readOffset;
}
get readOffset() {
return this._readOffset;
}
set readOffset(e) {
t.checkOffsetValue(e), t.checkTargetOffset(e, this), this._readOffset = e;
}
get writeOffset() {
return this._writeOffset;
}
set writeOffset(e) {
t.checkOffsetValue(e), t.checkTargetOffset(e, this), this._writeOffset = e;
}
get encoding() {
return this._encoding;
}
set encoding(e) {
t.checkEncoding(e), this._encoding = e;
}
get internalBuffer() {
return this._buff;
}
toBuffer() {
return this._buff.slice(0, this.length);
}
toString(e) {
let n = typeof e == "string" ? e : this._encoding;
return t.checkEncoding(n), this._buff.toString(n, 0, this.length);
}
destroy() {
return this.clear(), this;
}
_handleString(e, n, r, i) {
let a = this._writeOffset, o = this._encoding;
typeof r == "number" ? a = r : typeof r == "string" && (t.checkEncoding(r), o = r), typeof i == "string" && (t.checkEncoding(i), o = i);
let s = Buffer.byteLength(e, o);
return n ? this.ensureInsertable(s, a) : this._ensureWriteable(s, a), this._buff.write(e, a, s, o), n ? this._writeOffset += s : typeof r == "number" ? this._writeOffset = Math.max(this._writeOffset, a + s) : this._writeOffset += s, this;
}
_handleBuffer(e, t, n) {
let r = typeof n == "number" ? n : this._writeOffset;
return t ? this.ensureInsertable(e.length, r) : this._ensureWriteable(e.length, r), e.copy(this._buff, r), t ? this._writeOffset += e.length : typeof n == "number" ? this._writeOffset = Math.max(this._writeOffset, r + e.length) : this._writeOffset += e.length, this;
}
ensureReadable(e, n) {
let r = this._readOffset;
if (n !== void 0 && (t.checkOffsetValue(n), r = n), r < 0 || r + e > this.length) throw Error(t.ERRORS.INVALID_READ_BEYOND_BOUNDS);
}
ensureInsertable(e, n) {
t.checkOffsetValue(n), this._ensureCapacity(this.length + e), n < this.length && this._buff.copy(this._buff, n + e, n, this._buff.length), n + e > this.length ? this.length = n + e : this.length += e;
}
_ensureWriteable(e, t) {
let n = typeof t == "number" ? t : this._writeOffset;
this._ensureCapacity(n + e), n + e > this.length && (this.length = n + e);
}
_ensureCapacity(e) {
let t = this._buff.length;
if (e > t) {
let n = this._buff, r = t * 3 / 2 + 1;
r < e && (r = e), this._buff = Buffer.allocUnsafe(r), n.copy(this._buff, 0, 0, t);
}
}
_readNumberValue(e, t, n) {
this.ensureReadable(t, n);
let r = e.call(this._buff, typeof n == "number" ? n : this._readOffset);
return n === void 0 && (this._readOffset += t), r;
}
_insertNumberValue(e, n, r, i) {
return t.checkOffsetValue(i), this.ensureInsertable(n, i), e.call(this._buff, r, i), this._writeOffset += n, this;
}
_writeNumberValue(e, n, r, i) {
if (typeof i == "number") {
if (i < 0) throw Error(t.ERRORS.INVALID_WRITE_BEYOND_BOUNDS);
t.checkOffsetValue(i);
}
let a = typeof i == "number" ? i : this._writeOffset;
return this._ensureWriteable(n, a), e.call(this._buff, r, a), typeof i == "number" ? this._writeOffset = Math.max(this._writeOffset, a + n) : this._writeOffset += n, this;
}
};
})), bn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.SOCKS5_NO_ACCEPTABLE_AUTH = e.SOCKS5_CUSTOM_AUTH_END = e.SOCKS5_CUSTOM_AUTH_START = e.SOCKS_INCOMING_PACKET_SIZES = e.SocksClientState = e.Socks5Response = e.Socks5HostType = e.Socks5Auth = e.Socks4Response = e.SocksCommand = e.ERRORS = e.DEFAULT_TIMEOUT = void 0, e.DEFAULT_TIMEOUT = 3e4, e.ERRORS = {
InvalidSocksCommand: "An invalid SOCKS command was provided. Valid options are connect, bind, and associate.",
InvalidSocksCommandForOperation: "An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.",
InvalidSocksCommandChain: "An invalid SOCKS command was provided. Chaining currently only supports the connect command.",
InvalidSocksClientOptionsDestination: "An invalid destination host was provided.",
InvalidSocksClientOptionsExistingSocket: "An invalid existing socket was provided. This should be an instance of stream.Duplex.",
InvalidSocksClientOptionsProxy: "Invalid SOCKS proxy details were provided.",
InvalidSocksClientOptionsTimeout: "An invalid timeout value was provided. Please enter a value above 0 (in ms).",
InvalidSocksClientOptionsProxiesLength: "At least two socks proxies must be provided for chaining.",
InvalidSocksClientOptionsCustomAuthRange: "Custom auth must be a value between 0x80 and 0xFE.",
InvalidSocksClientOptionsCustomAuthOptions: "When a custom_auth_method is provided, custom_auth_request_handler, custom_auth_response_size, and custom_auth_response_handler must also be provided and valid.",
NegotiationError: "Negotiation error",
SocketClosed: "Socket closed",
ProxyConnectionTimedOut: "Proxy connection timed out",
InternalError: "SocksClient internal error (this should not happen)",
InvalidSocks4HandshakeResponse: "Received invalid Socks4 handshake response",
Socks4ProxyRejectedConnection: "Socks4 Proxy rejected connection",
InvalidSocks4IncomingConnectionResponse: "Socks4 invalid incoming connection response",
Socks4ProxyRejectedIncomingBoundConnection: "Socks4 Proxy rejected incoming bound connection",
InvalidSocks5InitialHandshakeResponse: "Received invalid Socks5 initial handshake response",
InvalidSocks5IntiailHandshakeSocksVersion: "Received invalid Socks5 initial handshake (invalid socks version)",
InvalidSocks5InitialHandshakeNoAcceptedAuthType: "Received invalid Socks5 initial handshake (no accepted authentication type)",
InvalidSocks5InitialHandshakeUnknownAuthType: "Received invalid Socks5 initial handshake (unknown authentication type)",
Socks5AuthenticationFailed: "Socks5 Authentication failed",
InvalidSocks5FinalHandshake: "Received invalid Socks5 final handshake response",
InvalidSocks5FinalHandshakeRejected: "Socks5 proxy rejected connection",
InvalidSocks5IncomingConnectionResponse: "Received invalid Socks5 incoming connection response",
Socks5ProxyRejectedIncomingBoundConnection: "Socks5 Proxy rejected incoming bound connection"
}, e.SOCKS_INCOMING_PACKET_SIZES = {
Socks5InitialHandshakeResponse: 2,
Socks5UserPassAuthenticationResponse: 2,
Socks5ResponseHeader: 5,
Socks5ResponseIPv4: 10,
Socks5ResponseIPv6: 22,
Socks5ResponseHostname: (e) => e + 7,
Socks4Response: 8
};
var t;
(function(e) {
e[e.connect = 1] = "connect", e[e.bind = 2] = "bind", e[e.associate = 3] = "associate";
})(t || (e.SocksCommand = t = {}));
var n;
(function(e) {
e[e.Granted = 90] = "Granted", e[e.Failed = 91] = "Failed", e[e.Rejected = 92] = "Rejected", e[e.RejectedIdent = 93] = "RejectedIdent";
})(n || (e.Socks4Response = n = {}));
var r;
(function(e) {
e[e.NoAuth = 0] = "NoAuth", e[e.GSSApi = 1] = "GSSApi", e[e.UserPass = 2] = "UserPass";
})(r || (e.Socks5Auth = r = {})), e.SOCKS5_CUSTOM_AUTH_START = 128, e.SOCKS5_CUSTOM_AUTH_END = 254, e.SOCKS5_NO_ACCEPTABLE_AUTH = 255;
var i;
(function(e) {
e[e.Granted = 0] = "Granted", e[e.Failure = 1] = "Failure", e[e.NotAllowed = 2] = "NotAllowed", e[e.NetworkUnreachable = 3] = "NetworkUnreachable", e[e.HostUnreachable = 4] = "HostUnreachable", e[e.ConnectionRefused = 5] = "ConnectionRefused", e[e.TTLExpired = 6] = "TTLExpired", e[e.CommandNotSupported = 7] = "CommandNotSupported", e[e.AddressNotSupported = 8] = "AddressNotSupported";
})(i || (e.Socks5Response = i = {}));
var a;
(function(e) {
e[e.IPv4 = 1] = "IPv4", e[e.Hostname = 3] = "Hostname", e[e.IPv6 = 4] = "IPv6";
})(a || (e.Socks5HostType = a = {}));
var o;
(function(e) {
e[e.Created = 0] = "Created", e[e.Connecting = 1] = "Connecting", e[e.Connected = 2] = "Connected", e[e.SentInitialHandshake = 3] = "SentInitialHandshake", e[e.ReceivedInitialHandshakeResponse = 4] = "ReceivedInitialHandshakeResponse", e[e.SentAuthentication = 5] = "SentAuthentication", e[e.ReceivedAuthenticationResponse = 6] = "ReceivedAuthenticationResponse", e[e.SentFinalHandshake = 7] = "SentFinalHandshake", e[e.ReceivedFinalResponse = 8] = "ReceivedFinalResponse", e[e.BoundWaitingForConnection = 9] = "BoundWaitingForConnection", e[e.Established = 10] = "Established", e[e.Disconnected = 11] = "Disconnected", e[e.Error = 99] = "Error";
})(o || (e.SocksClientState = o = {}));
})), xn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.shuffleArray = e.SocksClientError = void 0, e.SocksClientError = class extends Error {
constructor(e, t) {
super(e), this.options = t;
}
};
function t(e) {
for (let t = e.length - 1; t > 0; t--) {
let n = Math.floor(Math.random() * (t + 1));
[e[t], e[n]] = [e[n], e[t]];
}
}
e.shuffleArray = t;
})), Sn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.AddressError = void 0, e.AddressError = class extends Error {
constructor(e, t) {
super(e), this.name = "AddressError", this.parseMessage = t;
}
};
})), Cn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.isInSubnet = n, e.isHostInSubnet = r, e.isCorrect = i, e.prefixLengthFromMask = a, e.assertByteArray = o, e.numberToPaddedHex = s, e.stringToPaddedHex = c, e.testBit = l;
var t = Sn();
function n(e) {
return this.subnetMask < e.subnetMask ? !1 : r.call(this, e);
}
function r(e) {
return this.mask(e.subnetMask) === e.mask();
}
function i(e) {
return function() {
return this.addressMinusSuffix === this.correctForm() ? this.subnetMask === e && !this.parsedSubnet || this.parsedSubnet === String(this.subnetMask) : !1;
};
}
function a(e, n) {
let r = e.toString(2).padStart(n, "0");
if (r.length > n) throw new t.AddressError("Invalid subnet mask.");
let i = r.indexOf("0");
if (i === -1) return n;
if (r.slice(i).includes("1")) throw new t.AddressError("Invalid subnet mask.");
return i;
}
function o(e, n, r, i) {
if (e.length !== n) throw new t.AddressError(`${r} addresses require exactly ${n} bytes`);
for (let n = 0; n < e.length; n++) if (!Number.isInteger(e[n]) || e[n] < i || e[n] > 255) throw new t.AddressError(`All bytes must be integers between ${i} and 255`);
}
function s(e) {
return e.toString(16).padStart(2, "0");
}
function c(e) {
return s(parseInt(e, 10));
}
function l(e, t) {
let { length: n } = e;
if (t > n) return !1;
let r = n - t;
return e.substring(r, r + 1) === "1";
}
})), wn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.RE_SUBNET_STRING = e.RE_ADDRESS = e.GROUPS = e.BITS = void 0, e.BITS = 32, e.GROUPS = 4, e.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g, e.RE_SUBNET_STRING = /\/\d{1,2}$/;
})), Tn = /* @__PURE__ */ a(((e) => {
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), n = e && e.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
}) : function(e, t) {
e.default = t;
}), r = e && e.__importStar || function(e) {
if (e && e.__esModule) return e;
var r = {};
if (e != null) for (var i in e) i !== "default" && Object.prototype.hasOwnProperty.call(e, i) && t(r, e, i);
return n(r, e), r;
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.Address4 = void 0;
var i = r(Cn()), a = r(wn()), o = Sn(), s = i.isCorrect(a.BITS), c = class e {
constructor(e) {
this.addressMinusSuffix = "", this.groups = a.GROUPS, this.parsedAddress = [], this.parsedSubnet = "", this.subnet = "/32", this.subnetMask = 32, this.v4 = !0, this.isCorrect = s, this.isInSubnet = i.isInSubnet, this.isHostInSubnet = i.isHostInSubnet, this.address = e;
let t = a.RE_SUBNET_STRING.exec(e);
if (t) {
if (this.parsedSubnet = t[0].replace("/", ""), this.subnetMask = parseInt(this.parsedSubnet, 10), this.subnet = `/${this.subnetMask}`, this.subnetMask < 0 || this.subnetMask > a.BITS) throw new o.AddressError("Invalid subnet mask.");
e = e.replace(a.RE_SUBNET_STRING, "");
}
this.addressMinusSuffix = e, this.parsedAddress = this.parse(e);
}
static isValid(t) {
try {
return new e(t), !0;
} catch {
return !1;
}
}
parse(e) {
let t = e.split(".");
if (t.some((e) => /^0\d/.test(e))) throw new o.AddressError("IPv4 addresses can't have leading zeroes.");
if (!e.match(a.RE_ADDRESS)) throw new o.AddressError("Invalid IPv4 address.");
return t;
}
correctForm() {
return this.parsedAddress.map((e) => parseInt(e, 10)).join(".");
}
static fromAddressAndMask(t, n) {
let r = i.prefixLengthFromMask(new e(n).bigInt(), a.BITS);
return new e(`${t}/${r}`);
}
static fromAddressAndWildcardMask(t, n) {
let r = new e(n).bigInt() ^ (BigInt(1) << BigInt(a.BITS)) - BigInt(1), o = i.prefixLengthFromMask(r, a.BITS);
return new e(`${t}/${o}`);
}
static fromWildcard(t) {
let n = t.split(".");
if (n.length !== a.GROUPS) throw new o.AddressError("Wildcard pattern must have 4 octets");
let r = -1;
for (let e = 0; e < n.length; e++) if (n[e] === "*") r === -1 && (r = e);
else if (r !== -1) throw new o.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");
let i = r === -1 ? 0 : n.length - r, s = n.map((e) => e === "*" ? "0" : e), c = a.BITS - i * 8;
return new e(`${s.join(".")}/${c}`);
}
static fromHex(t) {
let n = t.replace(/:/g, "");
if (!/^[0-9a-fA-F]{8}$/.test(n)) throw new o.AddressError("IPv4 hex must be exactly 8 hex digits");
let r = [];
for (let e = 0; e < 8; e += 2) r.push(parseInt(n.slice(e, e + 2), 16));
return new e(r.join("."));
}
static fromInteger(t) {
if (!Number.isInteger(t) || t < 0 || t > 4294967295) throw new o.AddressError("IPv4 integer must be in the range 0 to 2**32 - 1");
return e.fromHex(t.toString(16).padStart(8, "0"));
}
static fromArpa(t) {
let n = t.replace(/(\.in-addr\.arpa)?\.$/, "").split(".").reverse().join(".");
return new e(n);
}
toHex() {
return this.parsedAddress.map((e) => i.stringToPaddedHex(e)).join(":");
}
toArray() {
return this.parsedAddress.map((e) => parseInt(e, 10));
}
toGroup6() {
let e = [], t;
for (t = 0; t < a.GROUPS; t += 2) e.push(`${i.stringToPaddedHex(this.parsedAddress[t])}${i.stringToPaddedHex(this.parsedAddress[t + 1])}`);
return e.join(":");
}
bigInt() {
return BigInt(`0x${this.parsedAddress.map((e) => i.stringToPaddedHex(e)).join("")}`);
}
_startAddress() {
return BigInt(`0b${this.mask() + "0".repeat(a.BITS - this.subnetMask)}`);
}
startAddress() {
return e.fromBigInt(this._startAddress());
}
startAddressExclusive() {
let t = BigInt("1");
return e.fromBigInt(this._startAddress() + t);
}
_endAddress() {
return BigInt(`0b${this.mask() + "1".repeat(a.BITS - this.subnetMask)}`);
}
endAddress() {
return e.fromBigInt(this._endAddress());
}
endAddressExclusive() {
let t = BigInt("1");
return e.fromBigInt(this._endAddress() - t);
}
subnetMaskAddress() {
return e.fromBigInt(BigInt(`0b${"1".repeat(this.subnetMask)}${"0".repeat(a.BITS - this.subnetMask)}`));
}
wildcardMask() {
return e.fromBigInt(BigInt(`0b${"0".repeat(this.subnetMask)}${"1".repeat(a.BITS - this.subnetMask)}`));
}
networkForm() {
return `${this.startAddress().correctForm()}/${this.subnetMask}`;
}
static fromBigInt(t) {
if (t < BigInt(0) || t > BigInt(4294967295)) throw new o.AddressError("IPv4 BigInt must be in the range 0 to 2**32 - 1");
return e.fromHex(t.toString(16).padStart(8, "0"));
}
static fromByteArray(e) {
return i.assertByteArray(e, 4, "IPv4", 0), this.fromUnsignedByteArray(e);
}
static fromUnsignedByteArray(t) {
if (t.length !== 4) throw new o.AddressError("IPv4 addresses require exactly 4 bytes");
let n = t.join(".");
return new e(n);
}
mask(e) {
return e === void 0 && (e = this.subnetMask), this.getBitsBase2(0, e);
}
getBitsBase2(e, t) {
return this.binaryZeroPad().slice(e, t);
}
reverseForm(e) {
e ||= {};
let t = this.correctForm().split(".").reverse().join(".");
return e.omitSuffix ? t : `${t}.in-addr.arpa.`;
}
isMulticast() {
return this.isHostInSubnet(l);
}
isPrivate() {
return u.some((e) => this.isHostInSubnet(e));
}
isLoopback() {
return this.isHostInSubnet(d);
}
isLinkLocal() {
return this.isHostInSubnet(f);
}
isUnspecified() {
return this.isHostInSubnet(p);
}
isBroadcast() {
return this.isHostInSubnet(m);
}
isCGNAT() {
return this.isHostInSubnet(h);
}
binaryZeroPad() {
return this._binaryZeroPad === void 0 && (this._binaryZeroPad = this.bigInt().toString(2).padStart(a.BITS, "0")), this._binaryZeroPad;
}
groupForV6() {
let e = this.parsedAddress;
return this.correctForm().replace(a.RE_ADDRESS, `<span class="hover-group group-v4 group-6">${e.slice(0, 2).join(".")}</span>.<span class="hover-group group-v4 group-7">${e.slice(2, 4).join(".")}</span>`);
}
};
e.Address4 = c;
var l = new c("224.0.0.0/4"), u = [
new c("10.0.0.0/8"),
new c("172.16.0.0/12"),
new c("192.168.0.0/16")
], d = new c("127.0.0.0/8"), f = new c("169.254.0.0/16"), p = new c("0.0.0.0/32"), m = new c("255.255.255.255/32"), h = new c("100.64.0.0/10");
})), En = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.RE_URL_WITH_PORT = e.RE_URL = e.RE_ZONE_STRING = e.RE_SUBNET_STRING = e.RE_BAD_ADDRESS = e.RE_BAD_CHARACTERS = e.TYPES = e.SCOPES = e.GROUPS = e.BITS = void 0, e.BITS = 128, e.GROUPS = 8, e.SCOPES = {
0: "Reserved",
1: "Interface local",
2: "Link local",
4: "Admin local",
5: "Site local",
8: "Organization local",
14: "Global",
15: "Reserved"
}, e.TYPES = {
"ff01::1/128": "Multicast (All nodes on this interface)",
"ff01::2/128": "Multicast (All routers on this interface)",
"ff02::1/128": "Multicast (All nodes on this link)",
"ff02::2/128": "Multicast (All routers on this link)",
"ff05::2/128": "Multicast (All routers in this site)",
"ff02::5/128": "Multicast (OSPFv3 AllSPF routers)",
"ff02::6/128": "Multicast (OSPFv3 AllDR routers)",
"ff02::9/128": "Multicast (RIP routers)",
"ff02::a/128": "Multicast (EIGRP routers)",
"ff02::d/128": "Multicast (PIM routers)",
"ff02::16/128": "Multicast (MLDv2 reports)",
"ff01::fb/128": "Multicast (mDNSv6)",
"ff02::fb/128": "Multicast (mDNSv6)",
"ff05::fb/128": "Multicast (mDNSv6)",
"ff02::1:2/128": "Multicast (All DHCP servers and relay agents on this link)",
"ff05::1:2/128": "Multicast (All DHCP servers and relay agents in this site)",
"ff02::1:3/128": "Multicast (All DHCP servers on this link)",
"ff05::1:3/128": "Multicast (All DHCP servers in this site)",
"::/128": "Unspecified",
"::1/128": "Loopback",
"::ffff:0:0/96": "IPv4-mapped",
"ff00::/8": "Multicast",
"fe80::/10": "Link-local unicast",
"fc00::/7": "Unique local",
"2002::/16": "6to4",
"2001:db8::/32": "Documentation",
"64:ff9b::/96": "NAT64 (well-known)",
"64:ff9b:1::/48": "NAT64 (local-use)"
}, e.RE_BAD_CHARACTERS = /([^0-9a-f:/%])/gi, e.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi, e.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/, e.RE_ZONE_STRING = /%.*$/, e.RE_URL = /^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i, e.RE_URL_WITH_PORT = /^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i;
})), Dn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.escapeHtml = t, e.spanAllZeroes = n, e.spanAll = r, e.spanLeadingZeroes = a, e.simpleGroup = o;
function t(e) {
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
function n(e) {
return t(e).replace(/(0+)/g, "<span class=\"zero\">$1</span>");
}
function r(e, r = 0) {
return e.split("").map((e, i) => `<span class="digit value-${t(e)} position-${i + r}">${n(e)}</span>`).join("");
}
function i(e) {
return t(e).replace(/^(0+)/, "<span class=\"zero\">$1</span>");
}
function a(e) {
return e.split(":").map((e) => i(e)).join(":");
}
function o(e, t = 0) {
return e.split(":").map((e, n) => /group-v4/.test(e) ? e : `<span class="hover-group group-${n + t}">${i(e)}</span>`);
}
})), On = /* @__PURE__ */ a(((e) => {
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), n = e && e.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
}) : function(e, t) {
e.default = t;
}), r = e && e.__importStar || function(e) {
if (e && e.__esModule) return e;
var r = {};
if (e != null) for (var i in e) i !== "default" && Object.prototype.hasOwnProperty.call(e, i) && t(r, e, i);
return n(r, e), r;
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.ADDRESS_BOUNDARY = void 0, e.groupPossibilities = a, e.padGroup = o, e.simpleRegularExpression = s, e.possibleElisions = c;
var i = r(En());
function a(e) {
return `(${e.join("|")})`;
}
function o(e) {
return e.length < 4 ? `0{0,${4 - e.length}}${e}` : e;
}
e.ADDRESS_BOUNDARY = "[^A-Fa-f0-9:]";
function s(e) {
let t = [];
e.forEach((e, n) => {
parseInt(e, 16) === 0 && t.push(n);
});
let n = t.map((t) => e.map((e, n) => {
if (n === t) {
let t = n === 0 || n === i.GROUPS - 1 ? ":" : "";
return a([o(e), t]);
}
return o(e);
}).join(":"));
return n.push(e.map(o).join(":")), a(n);
}
function c(e, t, n) {
let r = t ? "" : ":", i = n ? "" : ":", o = [];
!t && !n && o.push("::"), t && n && o.push(""), (n && !t || !n && t) && o.push(":"), o.push(`${r}(:0{1,4}){1,${e - 1}}`), o.push(`(0{1,4}:){1,${e - 1}}${i}`), o.push(`(0{1,4}:){${e - 1}}0{1,4}`);
for (let t = 1; t < e - 1; t++) for (let n = 1; n < e - t; n++) o.push(`(0{1,4}:){${n}}:(0{1,4}:){${e - n - t - 1}}0{1,4}`);
return a(o);
}
})), kn = /* @__PURE__ */ a(((e) => {
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), n = e && e.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
}) : function(e, t) {
e.default = t;
}), r = e && e.__importStar || function(e) {
if (e && e.__esModule) return e;
var r = {};
if (e != null) for (var i in e) i !== "default" && Object.prototype.hasOwnProperty.call(e, i) && t(r, e, i);
return n(r, e), r;
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.Address6 = void 0;
var i = r(Cn()), a = r(wn()), o = r(En()), s = r(Dn()), c = Tn(), l = On(), u = Sn(), d = Cn(), f = i.isCorrect(o.BITS);
function p(e) {
if (!e) throw Error("Assertion failed.");
}
function m(e) {
let t = /(\d+)(\d{3})/;
for (; t.test(e);) e = e.replace(t, "$1,$2");
return e;
}
function h(e) {
return e = e.replace(/^(0{1,})([1-9]+)$/, "<span class=\"parse-error\">$1</span>$2"), e = e.replace(/^(0{1,})(0)$/, "<span class=\"parse-error\">$1</span>$2"), e;
}
function g(e, t) {
let n = [], r = [], i;
for (i = 0; i < e.length; i++) i < t[0] ? n.push(e[i]) : i > t[1] && r.push(e[i]);
return n.concat(["compact"]).concat(r);
}
function _(e) {
return parseInt(e, 16).toString(16).padStart(4, "0");
}
function v(e) {
return e & 255;
}
var y = class e {
constructor(e, t) {
this.addressMinusSuffix = "", this.parsedSubnet = "", this.subnet = "/128", this.subnetMask = 128, this.v4 = !1, this.zone = "", this.isInSubnet = i.isInSubnet, this.isHostInSubnet = i.isHostInSubnet, this.isCorrect = f, this.groups = t === void 0 ? o.GROUPS : t, this.address = e;
let n = o.RE_SUBNET_STRING.exec(e);
if (n) {
if (this.parsedSubnet = n[0].replace("/", ""), this.subnetMask = parseInt(this.parsedSubnet, 10), this.subnet = `/${this.subnetMask}`, Number.isNaN(this.subnetMask) || this.subnetMask < 0 || this.subnetMask > o.BITS) throw new u.AddressError("Invalid subnet mask.");
e = e.replace(o.RE_SUBNET_STRING, "");
}
if (/\//.test(e)) throw new u.AddressError("Invalid subnet mask.");
let r = o.RE_ZONE_STRING.exec(e);
r && (this.zone = r[0], e = e.replace(o.RE_ZONE_STRING, "")), this.addressMinusSuffix = e, this.parsedAddress = this.parse(this.addressMinusSuffix);
}
static isValid(t) {
try {
return new e(t), !0;
} catch {
return !1;
}
}
static fromBigInt(t) {
if (t < BigInt(0) || t > (BigInt(1) << BigInt(o.BITS)) - BigInt(1)) throw new u.AddressError("IPv6 BigInt must be in the range 0 to 2**128 - 1");
let n = t.toString(16).padStart(32, "0"), r = [];
for (let e = 0; e < o.GROUPS; e++) r.push(n.slice(e * 4, (e + 1) * 4));
return new e(r.join(":"));
}
static fromURL(t) {
let n, r = null, i, a, s = t.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
if (s.indexOf("[") !== -1 && s.indexOf("]:") !== -1) {
if (a = "failed to parse address with port", i = o.RE_URL_WITH_PORT.exec(s), i === null) return {
error: a,
address: null,
port: null
};
n = i[1], r = i[2];
} else {
if (a = "failed to parse address from URL", i = o.RE_URL.exec(s), i === null) return {
error: a,
address: null,
port: null
};
n = i[1] ?? i[2];
}
r ? (r = parseInt(r, 10), (r < 0 || r > 65535) && (r = null)) : r = null;
let c;
try {
c = new e(n);
} catch {
return {
error: a,
address: null,
port: null
};
}
return {
address: c,
port: r
};
}
static fromAddressAndMask(t, n) {
let r = i.prefixLengthFromMask(new e(n).bigInt(), o.BITS);
return new e(`${t}/${r}`);
}
static fromAddressAndWildcardMask(t, n) {
let r = new e(n).bigInt() ^ (BigInt(1) << BigInt(o.BITS)) - BigInt(1), a = i.prefixLengthFromMask(r, o.BITS);
return new e(`${t}/${a}`);
}
static fromWildcard(t) {
if (t.includes("%") || t.includes("/")) throw new u.AddressError("Wildcard pattern must not include a zone or CIDR suffix");
let n = t.split("::");
if (n.length > 2) throw new u.AddressError("Wildcard pattern cannot contain more than one '::'");
let r;
if (n.length === 2) {
let e = n[0] === "" ? [] : n[0].split(":"), t = n[1] === "" ? [] : n[1].split(":"), i = o.GROUPS - e.length - t.length;
if (i < 1) throw new u.AddressError("Wildcard pattern with '::' has too many groups");
r = [
...e,
...Array(i).fill("0"),
...t
];
} else r = t.split(":");
if (r.length !== o.GROUPS) throw new u.AddressError("Wildcard pattern must have 8 groups");
let i = -1;
for (let e = 0; e < r.length; e++) if (r[e] === "*") i === -1 && (i = e);
else if (i !== -1) throw new u.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");
let a = i === -1 ? 0 : r.length - i, s = r.map((e) => e === "*" ? "0" : e), c = o.BITS - a * 16;
return new e(`${s.join(":")}/${c}`);
}
static fromAddress4(t) {
let n = new c.Address4(t), r = o.BITS - (a.BITS - n.subnetMask);
return new e(`::ffff:${n.correctForm()}/${r}`);
}
static fromArpa(t) {
let n = t.replace(/(\.ip6\.arpa)?\.$/, "");
if (n.length !== 63) throw new u.AddressError("Invalid 'ip6.arpa' form.");
let r = n.split(".").reverse();
for (let e = 7; e > 0; e--) {
let t = e * 4;
r.splice(t, 0, ":");
}
return n = r.join(""), new e(n);
}
microsoftTranscription() {
return `${this.correctForm().replace(/:/g, "-")}.ipv6-literal.net`;
}
mask(e = this.subnetMask) {
return this.getBitsBase2(0, e);
}
possibleSubnets(e = 128) {
let t = o.BITS - this.subnetMask - Math.abs(e - o.BITS);
return t < 0 ? "0" : m((BigInt("2") ** BigInt(t)).toString(10));
}
_startAddress() {
return BigInt(`0b${this.mask() + "0".repeat(o.BITS - this.subnetMask)}`);
}
startAddress() {
return e.fromBigInt(this._startAddress());
}
startAddressExclusive() {
let t = BigInt("1");
return e.fromBigInt(this._startAddress() + t);
}
_endAddress() {
return BigInt(`0b${this.mask() + "1".repeat(o.BITS - this.subnetMask)}`);
}
endAddress() {
return e.fromBigInt(this._endAddress());
}
endAddressExclusive() {
let t = BigInt("1");
return e.fromBigInt(this._endAddress() - t);
}
subnetMaskAddress() {
return e.fromBigInt(BigInt(`0b${"1".repeat(this.subnetMask)}${"0".repeat(o.BITS - this.subnetMask)}`));
}
wildcardMask() {
return e.fromBigInt(BigInt(`0b${"0".repeat(this.subnetMask)}${"1".repeat(o.BITS - this.subnetMask)}`));
}
networkForm() {
return `${this.startAddress().correctForm()}/${this.subnetMask}`;
}
getScope() {
let e = this.getType();
return e === "Multicast" || e.startsWith("Multicast ") ? o.SCOPES[parseInt(this.getBits(12, 16).toString(10), 10)] || "Unknown" : e === "Link-local unicast" || e === "Loopback" ? "Link local" : e === "Unspecified" ? "Unknown" : "Global";
}
getType() {
for (let e = 0; e < b.length; e++) {
let t = b[e];
if (this.isHostInSubnet(t[0])) return t[1];
}
return "Global unicast";
}
getBits(e, t) {
return BigInt(`0b${this.getBitsBase2(e, t)}`);
}
getBitsBase2(e, t) {
return this.binaryZeroPad().slice(e, t);
}
getBitsBase16(e, t) {
let n = t - e;
if (n % 4 != 0) throw Error("Length of bits to retrieve must be divisible by four");
return this.getBits(e, t).toString(16).padStart(n / 4, "0");
}
getBitsPastSubnet() {
return this.getBitsBase2(this.subnetMask, o.BITS);
}
reverseForm(e) {
e ||= {};
let t = Math.floor(this.subnetMask / 4), n = this.canonicalForm().replace(/:/g, "").split("").slice(0, t).reverse().join(".");
return t > 0 ? e.omitSuffix ? n : `${n}.ip6.arpa.` : e.omitSuffix ? "" : "ip6.arpa.";
}
correctForm() {
let e, t = [], n = 0, r = [];
for (e = 0; e < this.parsedAddress.length; e++) {
let t = parseInt(this.parsedAddress[e], 16);
t === 0 && n++, t !== 0 && n > 0 && (n > 1 && r.push([e - n, e - 1]), n = 0);
}
n > 1 && r.push([this.parsedAddress.length - n, this.parsedAddress.length - 1]);
let i = r.map((e) => e[1] - e[0] + 1);
if (r.length > 0) {
let e = i.indexOf(Math.max(...i));
t = g(this.parsedAddress, r[e]);
} else t = this.parsedAddress;
for (e = 0; e < t.length; e++) t[e] !== "compact" && (t[e] = parseInt(t[e], 16).toString(16));
let a = t.join(":");
return a = a.replace(/^compact$/, "::"), a = a.replace(/(^compact)|(compact$)/, ":"), a = a.replace(/compact/, ""), a;
}
binaryZeroPad() {
return this._binaryZeroPad === void 0 && (this._binaryZeroPad = this.bigInt().toString(2).padStart(o.BITS, "0")), this._binaryZeroPad;
}
parse4in6(e) {
if (e.indexOf(".") === -1) return e;
let t = e.split(":"), n = t.slice(-1)[0], r = n.split(".");
if (r.length === a.GROUPS && r.every((e) => /^\d{1,3}$/.test(e)) && r.some((e) => /^0\d/.test(e))) {
let e = r.map(h).join("."), n = t.slice(0, -1).map(s.escapeHtml).join(":"), i = t.length > 1 ? ":" : "";
throw new u.AddressError("IPv4 addresses can't have leading zeroes.", `${n}${i}${e}`);
}
let i = n.match(a.RE_ADDRESS);
if (i) {
this.parsedAddress4 = i[0];
let n = this.subnetMask >= 96 ? `/${this.subnetMask - 96}` : "";
this.address4 = new c.Address4(`${this.parsedAddress4}${n}`), this.v4 = !0, t[t.length - 1] = this.address4.toGroup6(), e = t.join(":");
}
return e;
}
parse(e) {
e = this.parse4in6(e);
let t = e.match(o.RE_BAD_CHARACTERS);
if (t) throw new u.AddressError(`Bad character${t.length > 1 ? "s" : ""} detected in address: ${t.join("")}`, e.replace(o.RE_BAD_CHARACTERS, "<span class=\"parse-error\">$1</span>"));
let n = e.match(o.RE_BAD_ADDRESS);
if (n) throw new u.AddressError(`Address failed regex: ${n.join("")}`, e.replace(o.RE_BAD_ADDRESS, "<span class=\"parse-error\">$1</span>"));
let r = [], i = e.split("::");
if (i.length === 2) {
let e = i[0].split(":"), t = i[1].split(":");
e.length === 1 && e[0] === "" && (e = []), t.length === 1 && t[0] === "" && (t = []);
let n = this.groups - (e.length + t.length);
if (!n) throw new u.AddressError("Error parsing groups");
this.elidedGroups = n, this.elisionBegin = e.length, this.elisionEnd = e.length + this.elidedGroups, r = r.concat(e);
for (let e = 0; e < n; e++) r.push("0");
r = r.concat(t);
} else if (i.length === 1) r = e.split(":"), this.elidedGroups = 0;
else throw new u.AddressError("Too many :: groups found");
if (r = r.map((e) => parseInt(e, 16).toString(16)), r.length !== this.groups) throw new u.AddressError("Incorrect number of groups found");
return r;
}
canonicalForm() {
return this.parsedAddress.map(_).join(":");
}
decimal() {
return this.parsedAddress.map((e) => parseInt(e, 16).toString(10).padStart(5, "0")).join(":");
}
bigInt() {
return BigInt(`0x${this.parsedAddress.map(_).join("")}`);
}
to4() {
let e = this.binaryZeroPad().split(""), t = BigInt(`0b${e.slice(96, 128).join("")}`).toString(16).padStart(8, "0");
if (this.subnetMask >= 96) {
let e = this.subnetMask - 96, n = [];
for (let e = 0; e < 8; e += 2) n.push(parseInt(t.slice(e, e + 2), 16));
return new c.Address4(`${n.join(".")}/${e}`);
}
return c.Address4.fromHex(t);
}
to4in6() {
let t = this.to4(), n = new e(this.parsedAddress.slice(0, 6).join(":"), 6).correctForm(), r = "";
return /:$/.test(n) || (r = ":"), n + r + t.correctForm();
}
inspectTeredo() {
let e = this.getBitsBase16(0, 32), t = (this.getBits(80, 96) ^ BigInt("0xffff")).toString(), n = c.Address4.fromHex(this.getBitsBase16(32, 64)), r = this.getBits(96, 128), i = c.Address4.fromHex((r ^ BigInt("0xffffffff")).toString(16).padStart(8, "0")), a = this.getBitsBase2(64, 80), o = (0, d.testBit)(a, 15), s = (0, d.testBit)(a, 14), l = (0, d.testBit)(a, 8), u = (0, d.testBit)(a, 9), f = BigInt(`0b${a.slice(2, 6) + a.slice(8, 16)}`).toString(10);
return {
prefix: `${e.slice(0, 4)}:${e.slice(4, 8)}`,
server4: n.address,
client4: i.address,
flags: a,
coneNat: o,
microsoft: {
reserved: s,
universalLocal: u,
groupIndividual: l,
nonce: f
},
udpPort: t
};
}
inspect6to4() {
let e = this.getBitsBase16(0, 16), t = c.Address4.fromHex(this.getBitsBase16(16, 48));
return {
prefix: e.slice(0, 4),
gateway: t.address
};
}
to6to4() {
if (!this.is4()) return null;
let t = [
"2002",
this.getBitsBase16(96, 112),
this.getBitsBase16(112, 128),
"",
"/16"
].join(":");
return new e(t);
}
static fromAddress4Nat64(t, n = "64:ff9b::/96") {
let r = new c.Address4(t), i = new e(n), a = i.subnetMask;
if (a !== 32 && a !== 40 && a !== 48 && a !== 56 && a !== 64 && a !== 96) throw new u.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");
let o = i.binaryZeroPad(), s = r.binaryZeroPad(), l;
if (a === 96) l = o.slice(0, 96) + s;
else {
let e = 64 - a;
l = [
o.slice(0, a),
s.slice(0, e),
"00000000",
s.slice(e),
"0".repeat(56 - (32 - e))
].join("");
}
let d = BigInt(`0b${l}`).toString(16).padStart(32, "0"), f = [];
for (let e = 0; e < 8; e++) f.push(d.slice(e * 4, (e + 1) * 4));
return new e(f.join(":"));
}
toAddress4Nat64(t = "64:ff9b::/96") {
let n = new e(t), r = n.subnetMask;
if (r !== 32 && r !== 40 && r !== 48 && r !== 56 && r !== 64 && r !== 96) throw new u.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");
if (!this.isHostInSubnet(n)) return null;
let i = this.binaryZeroPad(), a;
if (r === 96) a = i.slice(96, 128);
else {
let e = 64 - r;
a = i.slice(r, r + e) + i.slice(72, 72 + (32 - e));
}
let o = [];
for (let e = 0; e < 4; e++) o.push(parseInt(a.slice(e * 8, (e + 1) * 8), 2).toString());
return new c.Address4(o.join("."));
}
toByteArray() {
let e = this.bigInt().toString(16).padStart(o.BITS / 4, "0"), t = [];
for (let n = 0, r = e.length; n < r; n += 2) t.push(parseInt(e.substring(n, n + 2), 16));
return t;
}
toUnsignedByteArray() {
return this.toByteArray().map(v);
}
static fromByteArray(e) {
return i.assertByteArray(e, 16, "IPv6", -128), this.fromUnsignedByteArray(e.map(v));
}
static fromUnsignedByteArray(t) {
i.assertByteArray(t, 16, "IPv6", 0);
let n = BigInt("256"), r = BigInt("0"), a = BigInt("1");
for (let e = t.length - 1; e >= 0; e--) r += a * BigInt(t[e].toString(10)), a *= n;
return e.fromBigInt(r);
}
isCanonical() {
return this.addressMinusSuffix === this.canonicalForm();
}
isLinkLocal() {
let e = this.embeddedIPv4();
return e ? e.isLinkLocal() : this.getBitsBase2(0, 64) === "1111111010000000000000000000000000000000000000000000000000000000";
}
isMulticast() {
let e = this.embeddedIPv4();
if (e) return e.isMulticast();
let t = this.getType();
return t === "Multicast" || t.startsWith("Multicast ");
}
is4() {
return this.v4;
}
isMapped4() {
return this.isHostInSubnet(T);
}
embeddedIPv4() {
return this.isMapped4() || this.isHostInSubnet(E) ? this.to4() : null;
}
isTeredo() {
return this.isHostInSubnet(x);
}
is6to4() {
return this.isHostInSubnet(S);
}
isLoopback() {
let e = this.embeddedIPv4();
return e ? e.isLoopback() : this.getType() === "Loopback";
}
isULA() {
return this.isHostInSubnet(C);
}
isPrivate() {
let e = this.embeddedIPv4();
return e ? e.isPrivate() : this.isULA();
}
isCGNAT() {
let e = this.embeddedIPv4();
return e ? e.isCGNAT() : !1;
}
isBroadcast() {
let e = this.embeddedIPv4();
return e ? e.isBroadcast() : !1;
}
isUnspecified() {
let e = this.embeddedIPv4();
return e ? e.isUnspecified() : this.getType() === "Unspecified";
}
isDocumentation() {
return this.isHostInSubnet(w);
}
href(e) {
return e = e === void 0 ? "" : `:${e}`, `http://[${this.correctForm()}]${e}/`;
}
link(e) {
e ||= {}, e.className === void 0 && (e.className = ""), e.prefix === void 0 && (e.prefix = "/#address="), e.v4 === void 0 && (e.v4 = !1);
let t = this.correctForm;
e.v4 && (t = this.to4in6);
let n = t.call(this), r = s.escapeHtml(`${e.prefix}${n}`), i = s.escapeHtml(n);
return e.className ? `<a href="${r}" class="${s.escapeHtml(e.className)}">${i}</a>` : `<a href="${r}">${i}</a>`;
}
group() {
if (this.elidedGroups === 0) return s.simpleGroup(this.addressMinusSuffix).join(":");
p(typeof this.elidedGroups == "number"), p(typeof this.elisionBegin == "number");
let e = [], [t, n] = this.addressMinusSuffix.split("::");
t.length ? e.push(...s.simpleGroup(t)) : e.push("");
let r = ["hover-group"];
for (let e = this.elisionBegin; e < this.elisionBegin + this.elidedGroups; e++) r.push(`group-${e}`);
return e.push(`<span class="${r.join(" ")}"></span>`), n.length ? e.push(...s.simpleGroup(n, this.elisionEnd)) : e.push(""), this.is4() && (p(this.address4 instanceof c.Address4), e.pop(), e.push(this.address4.groupForV6())), e.join(":");
}
regularExpressionString(t = !1) {
let n = [], r = new e(this.correctForm());
if (r.elidedGroups === 0) n.push((0, l.simpleRegularExpression)(r.parsedAddress));
else if (r.elidedGroups === o.GROUPS) n.push((0, l.possibleElisions)(o.GROUPS));
else {
let e = r.address.split("::");
e[0].length && n.push((0, l.simpleRegularExpression)(e[0].split(":"))), p(typeof r.elidedGroups == "number"), n.push((0, l.possibleElisions)(r.elidedGroups, e[0].length !== 0, e[1].length !== 0)), e[1].length && n.push((0, l.simpleRegularExpression)(e[1].split(":"))), n = [n.join(":")];
}
return t || (n = [
"(?=^|",
l.ADDRESS_BOUNDARY,
"|[^\\w\\:])(",
...n,
")(?=[^\\w\\:]|",
l.ADDRESS_BOUNDARY,
"|$)"
]), n.join("");
}
regularExpression(e = !1) {
return new RegExp(this.regularExpressionString(e), "i");
}
};
e.Address6 = y;
var b = Object.keys(o.TYPES).map((e) => [new y(e), o.TYPES[e]]), x = new y("2001::/32"), S = new y("2002::/16"), C = new y("fc00::/7"), w = new y("2001:db8::/32"), T = new y("::ffff:0:0/96"), E = new y("64:ff9b::/96");
})), An = /* @__PURE__ */ a(((e) => {
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), n = e && e.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
}) : function(e, t) {
e.default = t;
}), r = e && e.__importStar || function(e) {
if (e && e.__esModule) return e;
var r = {};
if (e != null) for (var i in e) i !== "default" && Object.prototype.hasOwnProperty.call(e, i) && t(r, e, i);
return n(r, e), r;
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.v6 = e.AddressError = e.Address6 = e.Address4 = void 0;
var i = Tn();
Object.defineProperty(e, "Address4", {
enumerable: !0,
get: function() {
return i.Address4;
}
});
var a = kn();
Object.defineProperty(e, "Address6", {
enumerable: !0,
get: function() {
return a.Address6;
}
});
var o = Sn();
Object.defineProperty(e, "AddressError", {
enumerable: !0,
get: function() {
return o.AddressError;
}
}), e.v6 = { helpers: r(Dn()) };
})), jn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.ipToBuffer = e.int32ToIpv4 = e.ipv4ToInt32 = e.validateSocksClientChainOptions = e.validateSocksClientOptions = void 0;
var n = xn(), r = bn(), i = t("stream"), a = An(), o = t("net");
function s(e, t = [
"connect",
"bind",
"associate"
]) {
if (!r.SocksCommand[e.command]) throw new n.SocksClientError(r.ERRORS.InvalidSocksCommand, e);
if (t.indexOf(e.command) === -1) throw new n.SocksClientError(r.ERRORS.InvalidSocksCommandForOperation, e);
if (!u(e.destination)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsDestination, e);
if (!d(e.proxy)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsProxy, e);
if (l(e.proxy, e), e.timeout && !f(e.timeout)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsTimeout, e);
if (e.existing_socket && !(e.existing_socket instanceof i.Duplex)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsExistingSocket, e);
}
e.validateSocksClientOptions = s;
function c(e) {
if (e.command !== "connect") throw new n.SocksClientError(r.ERRORS.InvalidSocksCommandChain, e);
if (!u(e.destination)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsDestination, e);
if (!(e.proxies && Array.isArray(e.proxies) && e.proxies.length >= 2)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsProxiesLength, e);
if (e.proxies.forEach((t) => {
if (!d(t)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsProxy, e);
l(t, e);
}), e.timeout && !f(e.timeout)) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsTimeout, e);
}
e.validateSocksClientChainOptions = c;
function l(e, t) {
if (e.custom_auth_method !== void 0) {
if (e.custom_auth_method < r.SOCKS5_CUSTOM_AUTH_START || e.custom_auth_method > r.SOCKS5_CUSTOM_AUTH_END) throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsCustomAuthRange, t);
if (e.custom_auth_request_handler === void 0 || typeof e.custom_auth_request_handler != "function" || e.custom_auth_response_size === void 0 || e.custom_auth_response_handler === void 0 || typeof e.custom_auth_response_handler != "function") throw new n.SocksClientError(r.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, t);
}
}
function u(e) {
return e && typeof e.host == "string" && Buffer.byteLength(e.host) < 256 && typeof e.port == "number" && e.port >= 0 && e.port <= 65535;
}
function d(e) {
return e && (typeof e.host == "string" || typeof e.ipaddress == "string") && typeof e.port == "number" && e.port >= 0 && e.port <= 65535 && (e.type === 4 || e.type === 5);
}
function f(e) {
return typeof e == "number" && e > 0;
}
function p(e) {
return new a.Address4(e).toArray().reduce((e, t) => (e << 8) + t, 0) >>> 0;
}
e.ipv4ToInt32 = p;
function m(e) {
return [
e >>> 24 & 255,
e >>> 16 & 255,
e >>> 8 & 255,
e & 255
].join(".");
}
e.int32ToIpv4 = m;
function h(e) {
if (o.isIPv4(e)) {
let t = new a.Address4(e);
return Buffer.from(t.toArray());
}
if (o.isIPv6(e)) {
let t = new a.Address6(e);
return Buffer.from(t.canonicalForm().split(":").map((e) => e.padStart(4, "0")).join(""), "hex");
}
throw Error("Invalid IP address format");
}
e.ipToBuffer = h;
})), Mn = /* @__PURE__ */ a(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.ReceiveBuffer = void 0, e.ReceiveBuffer = class {
constructor(e = 4096) {
this.buffer = Buffer.allocUnsafe(e), this.offset = 0, this.originalSize = e;
}
get length() {
return this.offset;
}
append(e) {
if (!Buffer.isBuffer(e)) throw Error("Attempted to append a non-buffer instance to ReceiveBuffer.");
if (this.offset + e.length >= this.buffer.length) {
let t = this.buffer;
this.buffer = Buffer.allocUnsafe(Math.max(this.buffer.length + this.originalSize, this.buffer.length + e.length)), t.copy(this.buffer);
}
return e.copy(this.buffer, this.offset), this.offset += e.length;
}
peek(e) {
if (e > this.offset) throw Error("Attempted to read beyond the bounds of the managed internal data.");
return this.buffer.slice(0, e);
}
get(e) {
if (e > this.offset) throw Error("Attempted to read beyond the bounds of the managed internal data.");
let t = Buffer.allocUnsafe(e);
return this.buffer.slice(0, e).copy(t), this.buffer.copyWithin(0, e, e + this.offset - e), this.offset -= e, t;
}
};
})), Nn = /* @__PURE__ */ a(((e) => {
var n = e && e.__awaiter || function(e, t, n, r) {
function i(e) {
return e instanceof n ? e : new n(function(t) {
t(e);
});
}
return new (n ||= Promise)(function(n, a) {
function o(e) {
try {
c(r.next(e));
} catch (e) {
a(e);
}
}
function s(e) {
try {
c(r.throw(e));
} catch (e) {
a(e);
}
}
function c(e) {
e.done ? n(e.value) : i(e.value).then(o, s);
}
c((r = r.apply(e, t || [])).next());
});
};
Object.defineProperty(e, "__esModule", { value: !0 }), e.SocksClientError = e.SocksClient = void 0;
var r = t("events"), i = t("net"), a = yn(), o = bn(), s = jn(), c = Mn(), l = xn();
Object.defineProperty(e, "SocksClientError", {
enumerable: !0,
get: function() {
return l.SocksClientError;
}
});
var u = An();
e.SocksClient = class e extends r.EventEmitter {
constructor(e) {
super(), this.options = Object.assign({}, e), (0, s.validateSocksClientOptions)(e), this.setState(o.SocksClientState.Created);
}
static createConnection(t, n) {
return new Promise((r, i) => {
try {
(0, s.validateSocksClientOptions)(t, ["connect"]);
} catch (e) {
return typeof n == "function" ? (n(e), r(e)) : i(e);
}
let a = new e(t);
a.connect(t.existing_socket), a.once("established", (e) => {
a.removeAllListeners(), typeof n == "function" && n(null, e), r(e);
}), a.once("error", (e) => {
a.removeAllListeners(), typeof n == "function" ? (n(e), r(e)) : i(e);
});
});
}
static createConnectionChain(t, r) {
return new Promise((i, a) => n(this, void 0, void 0, function* () {
try {
(0, s.validateSocksClientChainOptions)(t);
} catch (e) {
return typeof r == "function" ? (r(e), i(e)) : a(e);
}
t.randomizeChain && (0, l.shuffleArray)(t.proxies);
try {
let n;
for (let r = 0; r < t.proxies.length; r++) {
let i = t.proxies[r], a = r === t.proxies.length - 1 ? t.destination : {
host: t.proxies[r + 1].host || t.proxies[r + 1].ipaddress,
port: t.proxies[r + 1].port
}, o = yield e.createConnection({
command: "connect",
proxy: i,
destination: a,
existing_socket: n
});
n ||= o.socket;
}
typeof r == "function" && r(null, { socket: n }), i({ socket: n });
} catch (e) {
typeof r == "function" ? (r(e), i(e)) : a(e);
}
}));
}
static createUDPFrame(e) {
let t = new a.SmartBuffer();
return t.writeUInt16BE(0), t.writeUInt8(e.frameNumber || 0), i.isIPv4(e.remoteHost.host) ? (t.writeUInt8(o.Socks5HostType.IPv4), t.writeUInt32BE((0, s.ipv4ToInt32)(e.remoteHost.host))) : i.isIPv6(e.remoteHost.host) ? (t.writeUInt8(o.Socks5HostType.IPv6), t.writeBuffer((0, s.ipToBuffer)(e.remoteHost.host))) : (t.writeUInt8(o.Socks5HostType.Hostname), t.writeUInt8(Buffer.byteLength(e.remoteHost.host)), t.writeString(e.remoteHost.host)), t.writeUInt16BE(e.remoteHost.port), t.writeBuffer(e.data), t.toBuffer();
}
static parseUDPFrame(e) {
let t = a.SmartBuffer.fromBuffer(e);
t.readOffset = 2;
let n = t.readUInt8(), r = t.readUInt8(), i;
i = r === o.Socks5HostType.IPv4 ? (0, s.int32ToIpv4)(t.readUInt32BE()) : r === o.Socks5HostType.IPv6 ? u.Address6.fromByteArray(Array.from(t.readBuffer(16))).canonicalForm() : t.readString(t.readUInt8());
let c = t.readUInt16BE();
return {
frameNumber: n,
remoteHost: {
host: i,
port: c
},
data: t.readBuffer()
};
}
setState(e) {
this.state !== o.SocksClientState.Error && (this.state = e);
}
connect(e) {
this.onDataReceived = (e) => this.onDataReceivedHandler(e), this.onClose = () => this.onCloseHandler(), this.onError = (e) => this.onErrorHandler(e), this.onConnect = () => this.onConnectHandler();
let t = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || o.DEFAULT_TIMEOUT);
t.unref && typeof t.unref == "function" && t.unref(), this.socket = e || new i.Socket(), this.socket.once("close", this.onClose), this.socket.once("error", this.onError), this.socket.once("connect", this.onConnect), this.socket.on("data", this.onDataReceived), this.setState(o.SocksClientState.Connecting), this.receiveBuffer = new c.ReceiveBuffer(), e ? this.socket.emit("connect") : (this.socket.connect(this.getSocketOptions()), this.options.set_tcp_nodelay !== void 0 && this.options.set_tcp_nodelay !== null && this.socket.setNoDelay(!!this.options.set_tcp_nodelay)), this.prependOnceListener("established", (e) => {
setImmediate(() => {
if (this.receiveBuffer.length > 0) {
let t = this.receiveBuffer.get(this.receiveBuffer.length);
e.socket.emit("data", t);
}
e.socket.resume();
});
});
}
getSocketOptions() {
return Object.assign(Object.assign({}, this.options.socket_options), {
host: this.options.proxy.host || this.options.proxy.ipaddress,
port: this.options.proxy.port
});
}
onEstablishedTimeout() {
this.state !== o.SocksClientState.Established && this.state !== o.SocksClientState.BoundWaitingForConnection && this.closeSocket(o.ERRORS.ProxyConnectionTimedOut);
}
onConnectHandler() {
this.setState(o.SocksClientState.Connected), this.options.proxy.type === 4 ? this.sendSocks4InitialHandshake() : this.sendSocks5InitialHandshake(), this.setState(o.SocksClientState.SentInitialHandshake);
}
onDataReceivedHandler(e) {
this.receiveBuffer.append(e), this.processData();
}
processData() {
for (; this.state !== o.SocksClientState.Established && this.state !== o.SocksClientState.Error && this.receiveBuffer.length >= this.nextRequiredPacketBufferSize;) if (this.state === o.SocksClientState.SentInitialHandshake) this.options.proxy.type === 4 ? this.handleSocks4FinalHandshakeResponse() : this.handleInitialSocks5HandshakeResponse();
else if (this.state === o.SocksClientState.SentAuthentication) this.handleInitialSocks5AuthenticationHandshakeResponse();
else if (this.state === o.SocksClientState.SentFinalHandshake) this.handleSocks5FinalHandshakeResponse();
else if (this.state === o.SocksClientState.BoundWaitingForConnection) this.options.proxy.type === 4 ? this.handleSocks4IncomingConnectionResponse() : this.handleSocks5IncomingConnectionResponse();
else {
this.closeSocket(o.ERRORS.InternalError);
break;
}
}
onCloseHandler() {
this.closeSocket(o.ERRORS.SocketClosed);
}
onErrorHandler(e) {
this.closeSocket(e.message);
}
removeInternalSocketHandlers() {
this.socket.pause(), this.socket.removeListener("data", this.onDataReceived), this.socket.removeListener("close", this.onClose), this.socket.removeListener("error", this.onError), this.socket.removeListener("connect", this.onConnect);
}
closeSocket(e) {
this.state !== o.SocksClientState.Error && (this.setState(o.SocksClientState.Error), this.socket.destroy(), this.removeInternalSocketHandlers(), this.emit("error", new l.SocksClientError(e, this.options)));
}
sendSocks4InitialHandshake() {
let e = this.options.proxy.userId || "", t = new a.SmartBuffer();
t.writeUInt8(4), t.writeUInt8(o.SocksCommand[this.options.command]), t.writeUInt16BE(this.options.destination.port), i.isIPv4(this.options.destination.host) ? (t.writeBuffer((0, s.ipToBuffer)(this.options.destination.host)), t.writeStringNT(e)) : (t.writeUInt8(0), t.writeUInt8(0), t.writeUInt8(0), t.writeUInt8(1), t.writeStringNT(e), t.writeStringNT(this.options.destination.host)), this.nextRequiredPacketBufferSize = o.SOCKS_INCOMING_PACKET_SIZES.Socks4Response, this.socket.write(t.toBuffer());
}
handleSocks4FinalHandshakeResponse() {
let e = this.receiveBuffer.get(8);
if (e[1] !== o.Socks4Response.Granted) this.closeSocket(`${o.ERRORS.Socks4ProxyRejectedConnection} - (${o.Socks4Response[e[1]]})`);
else if (o.SocksCommand[this.options.command] === o.SocksCommand.bind) {
let t = a.SmartBuffer.fromBuffer(e);
t.readOffset = 2;
let n = {
port: t.readUInt16BE(),
host: (0, s.int32ToIpv4)(t.readUInt32BE())
};
n.host === "0.0.0.0" && (n.host = this.options.proxy.ipaddress), this.setState(o.SocksClientState.BoundWaitingForConnection), this.emit("bound", {
remoteHost: n,
socket: this.socket
});
} else this.setState(o.SocksClientState.Established), this.removeInternalSocketHandlers(), this.emit("established", { socket: this.socket });
}
handleSocks4IncomingConnectionResponse() {
let e = this.receiveBuffer.get(8);
if (e[1] !== o.Socks4Response.Granted) this.closeSocket(`${o.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${o.Socks4Response[e[1]]})`);
else {
let t = a.SmartBuffer.fromBuffer(e);
t.readOffset = 2;
let n = {
port: t.readUInt16BE(),
host: (0, s.int32ToIpv4)(t.readUInt32BE())
};
this.setState(o.SocksClientState.Established), this.removeInternalSocketHandlers(), this.emit("established", {
remoteHost: n,
socket: this.socket
});
}
}
sendSocks5InitialHandshake() {
let e = new a.SmartBuffer(), t = [o.Socks5Auth.NoAuth];
(this.options.proxy.userId || this.options.proxy.password) && t.push(o.Socks5Auth.UserPass), this.options.proxy.custom_auth_method !== void 0 && t.push(this.options.proxy.custom_auth_method), e.writeUInt8(5), e.writeUInt8(t.length);
for (let n of t) e.writeUInt8(n);
this.nextRequiredPacketBufferSize = o.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse, this.socket.write(e.toBuffer()), this.setState(o.SocksClientState.SentInitialHandshake);
}
handleInitialSocks5HandshakeResponse() {
let e = this.receiveBuffer.get(2);
e[0] === 5 ? e[1] === o.SOCKS5_NO_ACCEPTABLE_AUTH ? this.closeSocket(o.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType) : e[1] === o.Socks5Auth.NoAuth ? (this.socks5ChosenAuthType = o.Socks5Auth.NoAuth, this.sendSocks5CommandRequest()) : e[1] === o.Socks5Auth.UserPass ? (this.socks5ChosenAuthType = o.Socks5Auth.UserPass, this.sendSocks5UserPassAuthentication()) : e[1] === this.options.proxy.custom_auth_method ? (this.socks5ChosenAuthType = this.options.proxy.custom_auth_method, this.sendSocks5CustomAuthentication()) : this.closeSocket(o.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType) : this.closeSocket(o.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion);
}
sendSocks5UserPassAuthentication() {
let e = this.options.proxy.userId || "", t = this.options.proxy.password || "", n = new a.SmartBuffer();
n.writeUInt8(1), n.writeUInt8(Buffer.byteLength(e)), n.writeString(e), n.writeUInt8(Buffer.byteLength(t)), n.writeString(t), this.nextRequiredPacketBufferSize = o.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse, this.socket.write(n.toBuffer()), this.setState(o.SocksClientState.SentAuthentication);
}
sendSocks5CustomAuthentication() {
return n(this, void 0, void 0, function* () {
this.nextRequiredPacketBufferSize = this.options.proxy.custom_auth_response_size, this.socket.write(yield this.options.proxy.custom_auth_request_handler()), this.setState(o.SocksClientState.SentAuthentication);
});
}
handleSocks5CustomAuthHandshakeResponse(e) {
return n(this, void 0, void 0, function* () {
return yield this.options.proxy.custom_auth_response_handler(e);
});
}
handleSocks5AuthenticationNoAuthHandshakeResponse(e) {
return n(this, void 0, void 0, function* () {
return e[1] === 0;
});
}
handleSocks5AuthenticationUserPassHandshakeResponse(e) {
return n(this, void 0, void 0, function* () {
return e[1] === 0;
});
}
handleInitialSocks5AuthenticationHandshakeResponse() {
return n(this, void 0, void 0, function* () {
this.setState(o.SocksClientState.ReceivedAuthenticationResponse);
let e = !1;
this.socks5ChosenAuthType === o.Socks5Auth.NoAuth ? e = yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2)) : this.socks5ChosenAuthType === o.Socks5Auth.UserPass ? e = yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2)) : this.socks5ChosenAuthType === this.options.proxy.custom_auth_method && (e = yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size))), e ? this.sendSocks5CommandRequest() : this.closeSocket(o.ERRORS.Socks5AuthenticationFailed);
});
}
sendSocks5CommandRequest() {
let e = new a.SmartBuffer();
e.writeUInt8(5), e.writeUInt8(o.SocksCommand[this.options.command]), e.writeUInt8(0), i.isIPv4(this.options.destination.host) ? (e.writeUInt8(o.Socks5HostType.IPv4), e.writeBuffer((0, s.ipToBuffer)(this.options.destination.host))) : i.isIPv6(this.options.destination.host) ? (e.writeUInt8(o.Socks5HostType.IPv6), e.writeBuffer((0, s.ipToBuffer)(this.options.destination.host))) : (e.writeUInt8(o.Socks5HostType.Hostname), e.writeUInt8(this.options.destination.host.length), e.writeString(this.options.destination.host)), e.writeUInt16BE(this.options.destination.port), this.nextRequiredPacketBufferSize = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader, this.socket.write(e.toBuffer()), this.setState(o.SocksClientState.SentFinalHandshake);
}
handleSocks5FinalHandshakeResponse() {
let e = this.receiveBuffer.peek(5);
if (e[0] !== 5 || e[1] !== o.Socks5Response.Granted) this.closeSocket(`${o.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${o.Socks5Response[e[1]]}`);
else {
let t = e[3], n, r;
if (t === o.Socks5HostType.IPv4) {
let e = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;
if (this.receiveBuffer.length < e) {
this.nextRequiredPacketBufferSize = e;
return;
}
r = a.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)), n = {
host: (0, s.int32ToIpv4)(r.readUInt32BE()),
port: r.readUInt16BE()
}, n.host === "0.0.0.0" && (n.host = this.options.proxy.ipaddress);
} else if (t === o.Socks5HostType.Hostname) {
let t = e[4], i = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(t);
if (this.receiveBuffer.length < i) {
this.nextRequiredPacketBufferSize = i;
return;
}
r = a.SmartBuffer.fromBuffer(this.receiveBuffer.get(i).slice(5)), n = {
host: r.readString(t),
port: r.readUInt16BE()
};
} else if (t === o.Socks5HostType.IPv6) {
let e = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;
if (this.receiveBuffer.length < e) {
this.nextRequiredPacketBufferSize = e;
return;
}
r = a.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)), n = {
host: u.Address6.fromByteArray(Array.from(r.readBuffer(16))).canonicalForm(),
port: r.readUInt16BE()
};
}
this.setState(o.SocksClientState.ReceivedFinalResponse), o.SocksCommand[this.options.command] === o.SocksCommand.connect ? (this.setState(o.SocksClientState.Established), this.removeInternalSocketHandlers(), this.emit("established", {
remoteHost: n,
socket: this.socket
})) : o.SocksCommand[this.options.command] === o.SocksCommand.bind ? (this.setState(o.SocksClientState.BoundWaitingForConnection), this.nextRequiredPacketBufferSize = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader, this.emit("bound", {
remoteHost: n,
socket: this.socket
})) : o.SocksCommand[this.options.command] === o.SocksCommand.associate && (this.setState(o.SocksClientState.Established), this.removeInternalSocketHandlers(), this.emit("established", {
remoteHost: n,
socket: this.socket
}));
}
}
handleSocks5IncomingConnectionResponse() {
let e = this.receiveBuffer.peek(5);
if (e[0] !== 5 || e[1] !== o.Socks5Response.Granted) this.closeSocket(`${o.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${o.Socks5Response[e[1]]}`);
else {
let t = e[3], n, r;
if (t === o.Socks5HostType.IPv4) {
let e = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;
if (this.receiveBuffer.length < e) {
this.nextRequiredPacketBufferSize = e;
return;
}
r = a.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)), n = {
host: (0, s.int32ToIpv4)(r.readUInt32BE()),
port: r.readUInt16BE()
}, n.host === "0.0.0.0" && (n.host = this.options.proxy.ipaddress);
} else if (t === o.Socks5HostType.Hostname) {
let t = e[4], i = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(t);
if (this.receiveBuffer.length < i) {
this.nextRequiredPacketBufferSize = i;
return;
}
r = a.SmartBuffer.fromBuffer(this.receiveBuffer.get(i).slice(5)), n = {
host: r.readString(t),
port: r.readUInt16BE()
};
} else if (t === o.Socks5HostType.IPv6) {
let e = o.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;
if (this.receiveBuffer.length < e) {
this.nextRequiredPacketBufferSize = e;
return;
}
r = a.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)), n = {
host: u.Address6.fromByteArray(Array.from(r.readBuffer(16))).canonicalForm(),
port: r.readUInt16BE()
};
}
this.setState(o.SocksClientState.Established), this.removeInternalSocketHandlers(), this.emit("established", {
remoteHost: n,
socket: this.socket
});
}
}
get socksClientOptions() {
return Object.assign({}, this.options);
}
};
})), Pn = /* @__PURE__ */ a(((e) => {
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
r === void 0 && (r = n);
var i = Object.getOwnPropertyDescriptor(t, n);
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
enumerable: !0,
get: function() {
return t[n];
}
}), Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
r === void 0 && (r = n), e[r] = t[n];
})), n = e && e.__exportStar || function(e, n) {
for (var r in e) r !== "default" && !Object.prototype.hasOwnProperty.call(n, r) && t(n, e, r);
};
Object.defineProperty(e, "__esModule", { value: !0 }), n(Nn(), e);
})), Fn = /* @__PURE__ */ i({ SocksProxyAgent: () => Hn });
function In(e) {
let t = !1, n = 5, r = e.hostname, i = parseInt(e.port, 10) || 1080;
switch (e.protocol.replace(":", "")) {
case "socks4":
t = !0, n = 4;
break;
case "socks4a":
n = 4;
break;
case "socks5":
t = !0, n = 5;
break;
case "socks":
n = 5;
break;
case "socks5h":
n = 5;
break;
default: throw TypeError(`A "socks" protocol must be specified! Got: ${String(e.protocol)}`);
}
let a = {
host: r,
port: i,
type: n
};
return e.username && Object.defineProperty(a, "userId", {
value: decodeURIComponent(e.username),
enumerable: !1
}), e.password != null && Object.defineProperty(a, "password", {
value: decodeURIComponent(e.password),
enumerable: !1
}), {
lookup: t,
proxy: a
};
}
function Ln(e, ...t) {
let n = {}, r;
for (r in e) t.includes(r) || (n[r] = e[r]);
return n;
}
var Rn, zn, Bn, Vn, Hn, Un = n((() => {
Rn = Pn(), Zt(), zn = /* @__PURE__ */ r(Wt(), 1), Bn = (0, zn.default)("socks-proxy-agent"), Vn = (e) => e.servername === void 0 && e.host && !g.isIP(e.host) ? {
...e,
servername: e.host
} : e, Hn = class extends Xt {
constructor(e, t) {
super(t);
let n = typeof e == "string" ? new u(e) : e, { proxy: r, lookup: i } = In(n);
this.shouldLookup = i, this.proxy = r, this.proxyUrl = n.href, this.timeout = t?.timeout ?? null, this.socketOptions = t?.socketOptions ?? null;
}
async connect(e, t) {
let { shouldLookup: n, proxy: r, timeout: i } = this;
if (!t.host) throw Error("No `host` defined!");
let { host: a } = t, { port: o, lookup: s = h.lookup } = t;
n && (a = await new Promise((e, t) => {
s(a, {}, (n, r) => {
n ? t(n) : e(typeof r == "string" ? r : r[0].address);
});
}));
let c = {
proxy: r,
destination: {
host: a,
port: typeof o == "number" ? o : parseInt(o, 10)
},
command: "connect",
timeout: i ?? void 0,
socket_options: this.socketOptions ?? void 0
}, l = (t) => {
e.destroy(), u.destroy(), t && t.destroy();
};
Bn("Creating socks proxy connection: %o", c);
let { socket: u } = await Rn.SocksClient.createConnection(c);
if (Bn("Successfully created socks proxy connection"), e.emit("proxy", {
proxy: this.proxyUrl,
socket: u
}), i !== null && (u.setTimeout(i), u.on("timeout", () => l())), t.secureEndpoint) {
Bn("Upgrading socket connection to TLS");
let e = _.connect({
...Ln(Vn(t), "host", "path", "port"),
socket: u
});
return e.once("error", (t) => {
Bn("Socket TLS error", t.message), l(e);
}), e;
}
return u;
}
}, Hn.protocols = [
"socks",
"socks4",
"socks4a",
"socks5",
"socks5h"
];
})), Wn = /* @__PURE__ */ a(((e, t) => {
t.exports = {
InvalidProxyProtocolError: class extends Error {
constructor(e) {
super(`Invalid protocol \`${e.protocol}\` connecting to proxy \`${e.host}\``), this.code = "EINVALIDPROXY", this.proxy = e;
}
},
ConnectionTimeoutError: class extends Error {
constructor(e) {
super(`Timeout connecting to host \`${e}\``), this.code = "ECONNECTIONTIMEOUT", this.host = e;
}
},
IdleTimeoutError: class extends Error {
constructor(e) {
super(`Idle timeout reached for host \`${e}\``), this.code = "EIDLETIMEOUT", this.host = e;
}
},
ResponseTimeoutError: class extends Error {
constructor(e, t) {
let n = "Response timeout ";
t && (n += `from proxy \`${t.host}\` `), n += `connecting to host \`${e.host}\``, super(n), this.code = "ERESPONSETIMEOUT", this.proxy = t, this.request = e;
}
},
TransferTimeoutError: class extends Error {
constructor(e, t) {
let n = "Transfer timeout ";
t && (n += `from proxy \`${t.host}\` `), n += `for \`${e.host}\``, super(n), this.code = "ETRANSFERTIMEOUT", this.proxy = t, this.request = e;
}
}
};
})), Gn = /* @__PURE__ */ a(((t, n) => {
var { HttpProxyAgent: r } = (on(), e(en)), { HttpsProxyAgent: i } = (_n(), e(dn)), { SocksProxyAgent: a } = (Un(), e(Fn)), { LRUCache: o } = c(), { InvalidProxyProtocolError: s } = Wn(), l = new o({ max: 20 }), u = new Set(a.protocols), d = /* @__PURE__ */ new Set([
"https_proxy",
"http_proxy",
"proxy",
"no_proxy"
]), f = Object.entries(process.env).reduce((e, [t, n]) => (t = t.toLowerCase(), d.has(t) && (e[t] = n), e), {}), p = (e) => {
e = new URL(e);
let t = e.protocol.slice(0, -1);
if (u.has(t)) return a;
if (t === "https" || t === "http") return [r, i];
throw new s(e);
}, m = (e, t) => {
if (typeof t == "string" && (t = t.split(",").map((e) => e.trim()).filter(Boolean)), !t || !t.length) return !1;
let n = e.hostname.split(".").reverse();
return t.some((e) => {
let t = e.split(".").filter(Boolean).reverse();
if (!t.length) return !1;
for (let e = 0; e < t.length; e++) if (n[e] !== t[e]) return !1;
return !0;
});
};
n.exports = {
getProxyAgent: p,
getProxy: (e, { proxy: t, noProxy: n }) => (e = new URL(e), t ||= e.protocol === "https:" ? f.https_proxy : f.https_proxy || f.http_proxy || f.proxy, n ||= f.no_proxy, !t || m(e, n) ? null : new URL(t)),
proxyCache: l
};
})), Kn = /* @__PURE__ */ a(((n, r) => {
var i = t("net"), a = t("tls"), { once: o } = t("events"), s = t("timers/promises"), { normalizeOptions: c, cacheOptions: l } = Lt(), { getProxy: u, getProxyAgent: d, proxyCache: f } = Gn(), p = Wn(), { Agent: m } = (Zt(), e(Yt));
r.exports = class extends m {
#e;
#t;
#n;
#r;
#i;
constructor(e = {}) {
let { timeouts: t, proxy: n, noProxy: r, ...i } = c(e);
super(i), this.#e = i, this.#t = t, n && (this.#n = new URL(n), this.#r = r, this.#i = d(n));
}
get proxy() {
return this.#n ? { url: this.#n } : {};
}
#a(e) {
if (!this.#n) return;
let t = u(`${e.protocol}//${e.host}:${e.port}`, {
proxy: this.#n,
noProxy: this.#r
});
if (!t) return;
let n = l({
...e,
...this.#e,
timeouts: this.#t,
proxy: t
});
if (f.has(n)) return f.get(n);
let r = this.#i;
Array.isArray(r) && (r = this.isSecureEndpoint(e) ? r[1] : r[0]);
let i = new r(t, {
...this.#e,
socketOptions: { family: this.#e.family }
});
return f.set(n, i), i;
}
async #o({ promises: e, options: t, timeout: n }, r = new AbortController()) {
if (n) {
let i = s.setTimeout(n, null, { signal: r.signal }).then(() => {
throw new p.ConnectionTimeoutError(`${t.host}:${t.port}`);
}).catch((e) => {
if (e.name !== "AbortError") throw e;
});
e.push(i);
}
let i;
try {
i = await Promise.race(e), r.abort();
} catch (e) {
throw r.abort(), e;
}
return i;
}
async connect(e, t) {
t.lookup ??= this.#e.lookup;
let n, r = this.#t.connection, s = this.isSecureEndpoint(t), c = this.#a(t);
if (c) {
let i = Date.now();
n = await this.#o({
options: t,
timeout: r,
promises: [c.connect(e, t)]
}), r && (r -= Date.now() - i);
} else n = (s ? a : i).connect(t);
n.setKeepAlive(this.keepAlive, this.keepAliveMsecs), n.setNoDelay(this.keepAlive);
let l = new AbortController(), { signal: u } = l, d = n[s ? "secureConnecting" : "connecting"] ? o(n, s ? "secureConnect" : "connect", { signal: u }) : Promise.resolve();
return await this.#o({
options: t,
timeout: r,
promises: [d, o(n, "error", { signal: u }).then((e) => {
throw e[0];
})]
}, l), this.#t.idle && n.setTimeout(this.#t.idle, () => {
n.destroy(new p.IdleTimeoutError(`${t.host}:${t.port}`));
}), n;
}
keepSocketAlive(e) {
let t = super.keepSocketAlive(e);
return t && this.#t.idle && e.setTimeout(this.#t.idle), t;
}
addRequest(e, t) {
let n = this.#a(t);
if (n?.setRequestProps && n.setRequestProps(e, t), e.setHeader("connection", this.keepAlive ? "keep-alive" : "close"), this.#t.response) {
let t;
e.once("finish", () => {
setTimeout(() => {
e.destroy(new p.ResponseTimeoutError(e, this.#n));
}, this.#t.response);
}), e.once("response", () => {
clearTimeout(t);
});
}
if (this.#t.transfer) {
let t;
e.once("response", (n) => {
setTimeout(() => {
n.destroy(new p.TransferTimeoutError(e, this.#n));
}, this.#t.transfer), n.once("close", () => {
clearTimeout(t);
});
});
}
return super.addRequest(e, t);
}
createSocket(e, t, n) {
super.createSocket(e, t, (r, i) => {
r && this.#s(e, t), n(r, i);
});
}
#s(e, t) {
let n = this.getName(t), r = this.requests[n];
if (!r || r.length === 0) return;
let i = r.indexOf(e);
if (i !== -1 && r.splice(i, 1), r.length === 0) {
delete this.requests[n];
return;
}
if ((this.sockets[n] ? this.sockets[n].length : 0) >= this.maxSockets || this.totalSocketCount >= this.maxTotalSockets) return;
let a = r.shift();
r.length === 0 && delete this.requests[n], this.createSocket(a, t, (e, t) => {
e ? a.onSocket(null, e) : a.onSocket(t);
});
}
};
})), qn = /* @__PURE__ */ a(((e, t) => {
var { LRUCache: n } = c(), { normalizeOptions: r, cacheOptions: i } = Lt(), { getProxy: a, proxyCache: o } = Gn(), s = It(), l = Kn(), u = new n({ max: 20 });
t.exports = {
getAgent: (e, { agent: t, proxy: n, noProxy: o, ...s } = {}) => {
if (t != null) return t;
e = new URL(e);
let c = a(e, {
proxy: n,
noProxy: o
}), d = {
...r(s),
proxy: c
}, f = i({
...d,
secureEndpoint: e.protocol === "https:"
});
if (u.has(f)) return u.get(f);
let p = new l(d);
return u.set(f, p), p;
},
Agent: l,
HttpAgent: l,
HttpsAgent: l,
cache: {
proxy: o,
agent: u,
dns: s.cache,
clear: () => {
o.clear(), u.clear(), s.cache.clear();
}
}
};
})), Jn = /* @__PURE__ */ i({
author: () => rr,
default: () => lr,
dependencies: () => ir,
description: () => Zn,
devDependencies: () => ar,
engines: () => or,
files: () => $n,
keywords: () => nr,
license: () => "ISC",
main: () => Qn,
name: () => Yn,
repository: () => tr,
scripts: () => er,
tap: () => sr,
templateOSS: () => cr,
version: () => Xn
}), Yn, Xn, Zn, Qn, $n, er, tr, nr, rr, ir, ar, or, sr, cr, lr, ur = n((() => {
Yn = "make-fetch-happen", Xn = "16.0.1", Zn = "Opinionated, caching, retrying fetch client", Qn = "lib/index.js", $n = ["bin/", "lib/"], er = {
test: "tap",
posttest: "npm run lint",
eslint: "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
lint: "npm run eslint",
lintfix: "npm run eslint -- --fix",
postlint: "template-oss-check",
snap: "tap",
"template-oss-apply": "template-oss-apply --force"
}, tr = {
type: "git",
url: "git+https://github.com/npm/make-fetch-happen.git"
}, nr = [
"http",
"request",
"fetch",
"mean girls",
"caching",
"cache",
"subresource integrity"
], rr = "GitHub Inc.", ir = {
"@gar/promise-retry": "^1.0.0",
"@npmcli/agent": "^5.0.0",
"@npmcli/redact": "^5.0.0",
cacache: "^21.0.0",
"http-cache-semantics": "^4.1.1",
minipass: "^7.0.2",
"minipass-fetch": "^6.0.0",
"minipass-flush": "^1.0.5",
"minipass-pipeline": "^1.2.4",
negotiator: "^1.0.0",
"proc-log": "^7.0.0",
ssri: "^14.0.0"
}, ar = {
"@npmcli/eslint-config": "^7.0.0",
"@npmcli/template-oss": "5.1.0",
nock: "^13.2.4",
"safe-buffer": "^5.2.1",
"standard-version": "^9.3.2",
tap: "^16.0.0"
}, or = { node: "^22.22.2 || ^24.15.0 || >=26.0.0" }, sr = {
color: 1,
files: "test/*.js",
"check-coverage": !0,
timeout: 60,
"nyc-arg": ["--exclude", "tap-snapshots/**"]
}, cr = {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
version: "5.1.0",
publish: "true"
}, lr = {
name: Yn,
version: Xn,
description: Zn,
main: Qn,
files: $n,
scripts: er,
repository: tr,
keywords: nr,
author: rr,
license: "ISC",
dependencies: ir,
devDependencies: ar,
engines: or,
tap: sr,
templateOSS: cr
};
})), dr = /* @__PURE__ */ a(((t, n) => {
var { Minipass: r } = y(), i = Y(), { promiseRetry: a } = Ft(), o = Z(), { log: s } = ve(), { redact: c } = xe(), l = Mt(), { getAgent: u } = qn(), d = (ur(), e(Jn).default), f = `${d.name}/${d.version} (+https://npm.im/${d.name})`, p = [
"ECONNRESET",
"ECONNREFUSED",
"EADDRINUSE",
"ETIMEDOUT",
"ECONNECTIONTIMEOUT",
"EIDLETIMEOUT",
"ERESPONSETIMEOUT",
"ETRANSFERTIMEOUT"
], m = ["request-timeout"];
n.exports = (e, t) => {
let n = u(e.url, {
...t,
signal: void 0
});
e.headers.has("connection") || e.headers.set("connection", n ? "keep-alive" : "close"), e.headers.has("user-agent") || e.headers.set("user-agent", f);
let d = {
...t,
agent: n,
redirect: "manual"
};
return a(async (n, a) => {
let u = new i.Request(e, d), f = c(u.url);
try {
let e = await i(u, d);
if (d.integrity && e.status === 200) {
let t = o.integrityStream({
algorithms: d.algorithms,
integrity: d.integrity,
size: d.size
}), n = new l({ events: ["integrity", "size"] }, e.body, t);
t.on("integrity", (e) => n.emit("integrity", e)), t.on("size", (e) => n.emit("size", e)), e = new i.Response(n, e), e.body.hasIntegrityEmitter = !0;
}
e.headers.set("x-fetch-attempts", a);
let c = r.isStream(u.body);
return u.method !== "POST" && !c && ([
408,
420,
429
].includes(e.status) || e.status >= 500) ? (typeof t.onRetry == "function" && t.onRetry(e), s.http("fetch", `${u.method} ${f} attempt ${a} failed with ${e.status}`), n(e)) : e;
} catch (e) {
let r = e.code === "EPROMISERETRY" ? e.retried.code : e.code, o = e.retried instanceof i.Response || p.includes(r) && m.includes(e.type);
if (u.method === "POST" || o) throw e;
return typeof t.onRetry == "function" && t.onRetry(e), s.http("fetch", `${u.method} ${f} attempt ${a} failed with ${e.code}`), n(e);
}
}, t.retry).catch((e) => {
if (e.status >= 400 && e.type !== "system") return e;
throw e;
});
};
})), fr = /* @__PURE__ */ a(((e, n) => {
var { Request: r, Response: i } = Y(), { Minipass: a } = y(), o = ze(), s = jt(), c = t("url"), l = Mt(), u = Ie(), d = Nt(), f = dr(), p = (e, t) => Object.prototype.hasOwnProperty.call(e, t), m = [
"accept-charset",
"accept-encoding",
"accept-language",
"accept",
"cache-control"
], h = [
"cache-control",
"content-encoding",
"content-language",
"content-type",
"date",
"etag",
"expires",
"last-modified",
"link",
"location",
"pragma",
"vary"
], g = (e, t, n) => {
let r = {
time: Date.now(),
url: e.url,
reqHeaders: {},
resHeaders: {},
options: { compress: n.compress == null ? e.compress : n.compress }
};
t.status !== 200 && t.status !== 304 && (r.status = t.status);
for (let t of m) e.headers.has(t) && (r.reqHeaders[t] = e.headers.get(t));
let i = e.headers.get("host"), a = new c.URL(e.url);
if (i && a.host !== i && (r.reqHeaders.host = i), t.headers.has("vary")) {
let n = t.headers.get("vary");
if (n !== "*") {
let t = n.trim().toLowerCase().split(/\s*,\s*/);
for (let n of t) e.headers.has(n) && (r.reqHeaders[n] = e.headers.get(n));
}
}
for (let e of h) t.headers.has(e) && (r.resHeaders[e] = t.headers.get(e));
for (let e of n.cacheAdditionalHeaders) t.headers.has(e) && (r.resHeaders[e] = t.headers.get(e));
return r;
}, _ = Symbol("request"), v = Symbol("response"), b = Symbol("policy");
n.exports = class e {
constructor({ entry: e, request: t, response: n, options: r }) {
e ? (this.key = e.key, this.entry = e, this.entry.metadata.time = this.entry.metadata.time || this.entry.time) : this.key = d(t), this.options = r, this[_] = t, this[v] = n, this[b] = null;
}
static async find(t, n) {
try {
var r = await s.index.compact(n.cachePath, d(t), (t, r) => {
let i = new e({
entry: t,
options: n
}), a = new e({
entry: r,
options: n
});
return i.policy.satisfies(a.request);
}, { validateEntry: (e) => e.metadata && e.metadata.resHeaders && e.metadata.resHeaders["content-encoding"] === null ? !1 : e.integrity !== null || !!(e.metadata && e.metadata.status) });
} catch {
return;
}
if (n.cache === "reload") return;
let i;
for (let a of r) {
let r = new e({
entry: a,
options: n
});
if (r.policy.satisfies(t)) {
i = r;
break;
}
}
return i;
}
static async invalidate(e, t) {
let n = d(e);
try {
await s.rm.entry(t.cachePath, n, { removeFully: !0 });
} catch {}
}
get request() {
return this[_] || (this[_] = new r(this.entry.metadata.url, {
method: "GET",
headers: this.entry.metadata.reqHeaders,
...this.entry.metadata.options
})), this[_];
}
get response() {
return this[v] || (this[v] = new i(null, {
url: this.entry.metadata.url,
counter: this.options.counter,
status: this.entry.metadata.status || 200,
headers: {
...this.entry.metadata.resHeaders,
"content-length": this.entry.size
}
})), this[v];
}
get policy() {
return this[b] || (this[b] = new u({
entry: this.entry,
request: this.request,
response: this.response,
options: this.options
})), this[b];
}
async store(e) {
if (this.request.method !== "GET" || ![
200,
301,
308
].includes(this.response.status) || !this.policy.storable()) return this.response.headers.set("x-local-cache-status", "skip"), this.response;
let t = this.response.headers.get("content-length"), n = {
algorithms: this.options.algorithms,
metadata: g(this.request, this.response, this.options),
size: t,
integrity: this.options.integrity,
integrityEmitter: this.response.body.hasIntegrityEmitter && this.response.body
}, r = null;
if (this.response.status === 200) {
let e, t, i = new Promise((n, r) => {
e = n, t = r;
}).catch((e) => {
r.emit("error", e);
});
r = new l({ events: ["integrity", "size"] }, new o({ flush() {
return i;
} })), r.hasIntegrityEmitter = !0;
let c = () => {
let i = new a(), o = s.put.stream(this.options.cachePath, this.key, n);
o.on("integrity", (e) => r.emit("integrity", e)), o.on("size", (e) => r.emit("size", e)), i.pipe(o), o.promise().then(e, t), r.unshift(i), r.unshift(this.response.body);
};
r.once("resume", c), r.once("end", () => r.removeListener("resume", c));
} else await s.index.insert(this.options.cachePath, this.key, null, n);
return this.response.headers.set("x-local-cache", encodeURIComponent(this.options.cachePath)), this.response.headers.set("x-local-cache-key", encodeURIComponent(this.key)), this.response.headers.set("x-local-cache-mode", "stream"), this.response.headers.set("x-local-cache-status", e), this.response.headers.set("x-local-cache-time", (/* @__PURE__ */ new Date()).toISOString()), new i(r, {
url: this.response.url,
status: this.response.status,
headers: this.response.headers,
counter: this.options.counter
});
}
async respond(t, n, r) {
let o;
if (t === "HEAD" || [301, 308].includes(this.response.status)) o = this.response;
else {
let t = new a(), r = { ...this.policy.responseHeaders() }, c = () => {
let n = s.get.stream.byDigest(this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize });
n.on("error", async (r) => {
n.pause(), r.code === "EINTEGRITY" && await s.rm.content(this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize }), (r.code === "ENOENT" || r.code === "EINTEGRITY") && await e.invalidate(this.request, this.options), t.emit("error", r), n.resume();
}), t.emit("integrity", this.entry.integrity), t.emit("size", Number(r["content-length"])), n.pipe(t);
};
t.once("resume", c), t.once("end", () => t.removeListener("resume", c)), o = new i(t, {
url: this.entry.metadata.url,
counter: n.counter,
status: 200,
headers: r
});
}
return o.headers.set("x-local-cache", encodeURIComponent(this.options.cachePath)), o.headers.set("x-local-cache-hash", encodeURIComponent(this.entry.integrity)), o.headers.set("x-local-cache-key", encodeURIComponent(this.key)), o.headers.set("x-local-cache-mode", "stream"), o.headers.set("x-local-cache-status", r), o.headers.set("x-local-cache-time", new Date(this.entry.metadata.time).toUTCString()), o;
}
async revalidate(t, n) {
let i = new r(t, { headers: this.policy.revalidationHeaders(t) });
try {
var a = await f(i, {
...n,
headers: void 0
});
} catch (e) {
if (!this.policy.mustRevalidate) return this.respond(t.method, n, "stale");
throw e;
}
if (this.policy.revalidated(i, a)) {
let e = g(t, a, n);
for (let t of h) !p(e.resHeaders, t) && p(this.entry.metadata.resHeaders, t) && (e.resHeaders[t] = this.entry.metadata.resHeaders[t]);
for (let t of n.cacheAdditionalHeaders) {
let n = p(e.resHeaders, t), r = p(this.entry.metadata.resHeaders, t), i = p(this.policy.response.headers, t);
!n && r && (e.resHeaders[t] = this.entry.metadata.resHeaders[t]), !i && n && (this.policy.response.headers[t] = e.resHeaders[t]);
}
try {
await s.index.insert(n.cachePath, this.key, this.entry.integrity, {
size: this.entry.size,
metadata: e
});
} catch {}
return this.respond(t.method, n, "revalidated");
}
return new e({
request: t,
response: a,
options: n
}).store("updated");
}
};
})), pr = /* @__PURE__ */ a(((e, t) => {
var { NotCachedError: n } = Le(), r = fr(), i = dr(), a = async (e, t) => {
let a = await r.find(e, t);
if (!a) {
if (t.cache === "only-if-cached") throw new n(e.url);
return new r({
request: e,
response: await i(e, t),
options: t
}).store("miss");
}
if (t.cache === "no-cache") return a.revalidate(e, t);
let o = a.policy.needsRevalidation(e);
return t.cache === "force-cache" || t.cache === "only-if-cached" || !o ? a.respond(e.method, t, o ? "stale" : "hit") : a.revalidate(e, t);
};
a.invalidate = async (e, t) => {
if (t.cachePath) return r.invalidate(e, t);
}, t.exports = a;
})), mr = /* @__PURE__ */ a(((e, n) => {
var { FetchError: r, Request: i, isRedirect: a } = Y(), o = t("url"), s = Ie(), c = pr(), l = dr(), u = (e, t, n) => {
if (!a(t.status) || n.redirect === "manual") return !1;
if (n.redirect === "error") throw new r(`redirect mode is set to error: ${e.url}`, "no-redirect", { code: "ENOREDIRECT" });
if (!t.headers.has("location")) throw new r(`redirect location header missing for: ${e.url}`, "no-location", { code: "EINVALIDREDIRECT" });
if (e.counter >= e.follow) throw new r(`maximum redirect reached at: ${e.url}`, "max-redirect", { code: "EMAXREDIRECT" });
return !0;
}, d = (e, t, n) => {
let r = { ...n }, a = t.headers.get("location"), s = new o.URL(a, /^https?:/.test(a) ? void 0 : e.url);
return new o.URL(e.url).hostname !== s.hostname && (e.headers.delete("authorization"), e.headers.delete("cookie")), (t.status === 303 || e.method === "POST" && [301, 302].includes(t.status)) && (r.method = "GET", r.body = null, e.headers.delete("content-length")), r.headers = {}, e.headers.forEach((e, t) => {
r.headers[t] = e;
}), r.counter = ++e.counter, {
request: new i(o.format(s), r),
options: r
};
}, f = async (e, t) => {
let n = s.storable(e, t) ? await c(e, t) : await l(e, t);
if (!["GET", "HEAD"].includes(e.method) && n.status >= 200 && n.status <= 399 && await c.invalidate(e, t), !u(e, n, t)) return n;
let r = d(e, n, t);
return f(r.request, r.options);
};
n.exports = f;
})), hr = /* @__PURE__ */ a(((e, t) => {
var { FetchError: n, Headers: r, Request: i, Response: a } = Y(), o = ke(), s = mr(), c = (e, t) => {
let n = o(t);
return s(new i(e, n), n);
};
c.defaults = (e, t = {}, n = c) => {
typeof e == "object" && (t = e, e = null);
let r = (r, i = {}) => n(r || e, {
...t,
...i,
headers: {
...t.headers,
...i.headers
}
});
return r.defaults = (e, t = {}) => c.defaults(e, t, r), r;
}, t.exports = c, t.exports.FetchError = n, t.exports.Headers = r, t.exports.Request = i, t.exports.Response = a;
})), gr = /* @__PURE__ */ a(((e, t) => {
var n = {}, r = n.LEFT_BRACE = 1, i = n.RIGHT_BRACE = 2, a = n.LEFT_BRACKET = 3, o = n.RIGHT_BRACKET = 4, s = n.COLON = 5, c = n.COMMA = 6, l = n.TRUE = 7, u = n.FALSE = 8, d = n.NULL = 9, f = n.STRING = 10, p = n.NUMBER = 11, m = n.START = 17, h = n.STOP = 18, g = n.TRUE1 = 33, _ = n.TRUE2 = 34, v = n.TRUE3 = 35, y = n.FALSE1 = 49, b = n.FALSE2 = 50, x = n.FALSE3 = 51, S = n.FALSE4 = 52, C = n.NULL1 = 65, w = n.NULL2 = 66, T = n.NULL3 = 67, E = n.NUMBER1 = 81, D = n.NUMBER3 = 83, O = n.STRING1 = 97, k = n.STRING2 = 98, A = n.STRING3 = 99, j = n.STRING4 = 100, M = n.STRING5 = 101, N = n.STRING6 = 102, P = n.VALUE = 113, F = n.KEY = 114, I = n.OBJECT = 129, L = n.ARRAY = 130, R = 92, z = 47, B = 8, V = 12, H = 10, U = 13, W = 9, G = 65536;
function K() {
this.tState = m, this.value = void 0, this.string = void 0, this.stringBuffer = Buffer.alloc ? Buffer.alloc(G) : new Buffer(G), this.stringBufferOffset = 0, this.unicode = void 0, this.highSurrogate = void 0, this.key = void 0, this.mode = void 0, this.stack = [], this.state = P, this.bytes_remaining = 0, this.bytes_in_sequence = 0, this.temp_buffs = {
2: new Buffer(2),
3: new Buffer(3),
4: new Buffer(4)
}, this.offset = -1;
}
K.toknam = function(e) {
for (var t = Object.keys(n), r = 0, i = t.length; r < i; r++) {
var a = t[r];
if (n[a] === e) return a;
}
return e && "0x" + e.toString(16);
};
var q = K.prototype;
q.onError = function(e) {
throw e;
}, q.charError = function(e, t) {
this.tState = h, this.onError(/* @__PURE__ */ Error("Unexpected " + JSON.stringify(String.fromCharCode(e[t])) + " at position " + t + " in state " + K.toknam(this.tState)));
}, q.appendStringChar = function(e) {
this.stringBufferOffset >= G && (this.string += this.stringBuffer.toString("utf8"), this.stringBufferOffset = 0), this.stringBuffer[this.stringBufferOffset++] = e;
}, q.appendStringBuf = function(e, t, n) {
var r = e.length;
typeof t == "number" && (r = typeof n == "number" ? n < 0 ? e.length - t + n : n - t : e.length - t), r < 0 && (r = 0), this.stringBufferOffset + r > G && (this.string += this.stringBuffer.toString("utf8", 0, this.stringBufferOffset), this.stringBufferOffset = 0), e.copy(this.stringBuffer, this.stringBufferOffset, t, n), this.stringBufferOffset += r;
}, q.write = function(e) {
typeof e == "string" && (e = new Buffer(e));
for (var t, n = 0, h = e.length; n < h; n++) if (this.tState === m) {
if (t = e[n], this.offset++, t === 123) this.onToken(r, "{");
else if (t === 125) this.onToken(i, "}");
else if (t === 91) this.onToken(a, "[");
else if (t === 93) this.onToken(o, "]");
else if (t === 58) this.onToken(s, ":");
else if (t === 44) this.onToken(c, ",");
else if (t === 116) this.tState = g;
else if (t === 102) this.tState = y;
else if (t === 110) this.tState = C;
else if (t === 34) this.string = "", this.stringBufferOffset = 0, this.tState = O;
else if (t === 45) this.string = "-", this.tState = E;
else if (t >= 48 && t < 64) this.string = String.fromCharCode(t), this.tState = D;
else if (t !== 32 && t !== 9 && t !== 10 && t !== 13) return this.charError(e, n);
} else if (this.tState === O) {
if (t = e[n], this.bytes_remaining > 0) {
for (var P = 0; P < this.bytes_remaining; P++) this.temp_buffs[this.bytes_in_sequence][this.bytes_in_sequence - this.bytes_remaining + P] = e[P];
this.appendStringBuf(this.temp_buffs[this.bytes_in_sequence]), this.bytes_in_sequence = this.bytes_remaining = 0, n = n + P - 1;
} else if (this.bytes_remaining === 0 && t >= 128) {
if (t <= 193 || t > 244) return this.onError(/* @__PURE__ */ Error("Invalid UTF-8 character at position " + n + " in state " + K.toknam(this.tState)));
if (t >= 194 && t <= 223 && (this.bytes_in_sequence = 2), t >= 224 && t <= 239 && (this.bytes_in_sequence = 3), t >= 240 && t <= 244 && (this.bytes_in_sequence = 4), this.bytes_in_sequence + n > e.length) {
for (var F = 0; F <= e.length - 1 - n; F++) this.temp_buffs[this.bytes_in_sequence][F] = e[n + F];
this.bytes_remaining = n + this.bytes_in_sequence - e.length, n = e.length - 1;
} else this.appendStringBuf(e, n, n + this.bytes_in_sequence), n = n + this.bytes_in_sequence - 1;
} else if (t === 34) this.tState = m, this.string += this.stringBuffer.toString("utf8", 0, this.stringBufferOffset), this.stringBufferOffset = 0, this.onToken(f, this.string), this.offset += Buffer.byteLength(this.string, "utf8") + 1, this.string = void 0;
else if (t === 92) this.tState = k;
else if (t >= 32) this.appendStringChar(t);
else return this.charError(e, n);
} else if (this.tState === k) {
if (t = e[n], t === 34) this.appendStringChar(t), this.tState = O;
else if (t === 92) this.appendStringChar(R), this.tState = O;
else if (t === 47) this.appendStringChar(z), this.tState = O;
else if (t === 98) this.appendStringChar(B), this.tState = O;
else if (t === 102) this.appendStringChar(V), this.tState = O;
else if (t === 110) this.appendStringChar(H), this.tState = O;
else if (t === 114) this.appendStringChar(U), this.tState = O;
else if (t === 116) this.appendStringChar(W), this.tState = O;
else if (t === 117) this.unicode = "", this.tState = A;
else return this.charError(e, n);
} else if (this.tState === A || this.tState === j || this.tState === M || this.tState === N) {
if (t = e[n], t >= 48 && t < 64 || t > 64 && t <= 70 || t > 96 && t <= 102) {
if (this.unicode += String.fromCharCode(t), this.tState++ === N) {
var I = parseInt(this.unicode, 16);
this.unicode = void 0, this.highSurrogate !== void 0 && I >= 56320 && I < 57344 ? (this.appendStringBuf(new Buffer(String.fromCharCode(this.highSurrogate, I))), this.highSurrogate = void 0) : this.highSurrogate === void 0 && I >= 55296 && I < 56320 ? this.highSurrogate = I : (this.highSurrogate !== void 0 && (this.appendStringBuf(new Buffer(String.fromCharCode(this.highSurrogate))), this.highSurrogate = void 0), this.appendStringBuf(new Buffer(String.fromCharCode(I)))), this.tState = O;
}
} else return this.charError(e, n);
} else if (this.tState === E || this.tState === D) switch (t = e[n], t) {
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 46:
case 101:
case 69:
case 43:
case 45:
this.string += String.fromCharCode(t), this.tState = D;
break;
default:
this.tState = m;
var L = Number(this.string);
if (isNaN(L)) return this.charError(e, n);
this.string.match(/[0-9]+/) == this.string && L.toString() != this.string ? this.onToken(f, this.string) : this.onToken(p, L), this.offset += this.string.length - 1, this.string = void 0, n--;
}
else if (this.tState === g) {
if (e[n] === 114) this.tState = _;
else return this.charError(e, n);
} else if (this.tState === _) {
if (e[n] === 117) this.tState = v;
else return this.charError(e, n);
} else if (this.tState === v) {
if (e[n] === 101) this.tState = m, this.onToken(l, !0), this.offset += 3;
else return this.charError(e, n);
} else if (this.tState === y) {
if (e[n] === 97) this.tState = b;
else return this.charError(e, n);
} else if (this.tState === b) {
if (e[n] === 108) this.tState = x;
else return this.charError(e, n);
} else if (this.tState === x) {
if (e[n] === 115) this.tState = S;
else return this.charError(e, n);
} else if (this.tState === S) {
if (e[n] === 101) this.tState = m, this.onToken(u, !1), this.offset += 4;
else return this.charError(e, n);
} else if (this.tState === C) {
if (e[n] === 117) this.tState = w;
else return this.charError(e, n);
} else if (this.tState === w) {
if (e[n] === 108) this.tState = T;
else return this.charError(e, n);
} else if (this.tState === T) {
if (e[n] === 108) this.tState = m, this.onToken(d, null), this.offset += 3;
else return this.charError(e, n);
}
}, q.onToken = function(e, t) {}, q.parseError = function(e, t) {
this.tState = h, this.onError(/* @__PURE__ */ Error("Unexpected " + K.toknam(e) + (t ? "(" + JSON.stringify(t) + ")" : "") + " in state " + K.toknam(this.state)));
}, q.push = function() {
this.stack.push({
value: this.value,
key: this.key,
mode: this.mode
});
}, q.pop = function() {
var e = this.value, t = this.stack.pop();
this.value = t.value, this.key = t.key, this.mode = t.mode, this.emit(e), this.mode || (this.state = P);
}, q.emit = function(e) {
this.mode && (this.state = c), this.onValue(e);
}, q.onValue = function(e) {}, q.onToken = function(e, t) {
if (this.state === P) {
if (e === f || e === p || e === l || e === u || e === d) this.value && (this.value[this.key] = t), this.emit(t);
else if (e === r) this.push(), this.value = this.value ? this.value[this.key] = {} : {}, this.key = void 0, this.state = F, this.mode = I;
else if (e === a) this.push(), this.value = this.value ? this.value[this.key] = [] : [], this.key = 0, this.mode = L, this.state = P;
else if (e === i) {
if (this.mode === I) this.pop();
else return this.parseError(e, t);
} else if (e === o) {
if (this.mode === L) this.pop();
else return this.parseError(e, t);
} else return this.parseError(e, t);
} else if (this.state === F) {
if (e === f) this.key = t, this.state = s;
else if (e === i) this.pop();
else return this.parseError(e, t);
} else if (this.state === s) {
if (e === s) this.state = P;
else return this.parseError(e, t);
} else if (this.state === c) {
if (e === c) this.mode === L ? (this.key++, this.state = P) : this.mode === I && (this.state = F);
else if (e === o && this.mode === L || e === i && this.mode === I) this.pop();
else return this.parseError(e, t);
} else return this.parseError(e, t);
}, K.C = n, t.exports = K;
})), _r = /* @__PURE__ */ a(((e, t) => {
var n = gr(), { Minipass: r } = y(), i = class extends Error {
constructor(e, t) {
super(e.message), Error.captureStackTrace(this, t || this.constructor);
}
get name() {
return "JSONStreamError";
}
}, a = (e, t) => typeof e == "string" ? String(t) === e : e && typeof e.test == "function" ? e.test(t) : typeof e == "boolean" || typeof e == "object" ? e : typeof e == "function" && e(t);
t.exports = class e extends r {
#e = 0;
#t = !1;
#n = null;
#r = null;
#i = null;
#a;
#o;
#s = null;
#c = null;
constructor(e) {
super({
...e,
objectMode: !0
});
let t = this.#o = new n();
t.onValue = (e) => this.#f(e), this.#a = t.onToken, t.onToken = (e, t) => this.#d(e, t), t.onError = (e) => this.#u(e), this.#s = typeof e.path == "string" ? e.path.split(".").map((e) => e === "$*" ? { emitKey: !0 } : e === "*" ? !0 : e === "" ? { recurse: !0 } : e) : Array.isArray(e.path) && e.path.length ? e.path : null, typeof e.map == "function" && (this.#i = e.map);
}
#l(e, t) {
this.#r !== !1 && (this.#r = this.#r || {}, this.#r[e] = t), this.#n !== !1 && this.#r === !1 && (this.#n = this.#n || {}, this.#n[e] = t);
}
#u(e) {
let t = this.#t ? this.end : this.write;
return this.#t = !1, this.emit("error", new i(e, t));
}
#d(e, t) {
let n = this.#o;
if (this.#a.call(this.#o, e, t), n.stack.length === 0 && this.#c) {
let e = this.#c;
this.#s || super.write(e), this.#c = null, this.#e = 0;
}
}
#f(e) {
let t = this.#o;
if (this.#c = e, !this.#s) return;
let n = 0, r = 0, i = !1;
for (; n < this.#s.length;) {
let o = this.#s[n];
if (r++, o && !o.recurse) {
let s = r === t.stack.length ? t : t.stack[r];
if (!s) return;
if (!a(o, s.key)) {
this.#l(s.key, e);
return;
}
i = !!o.emitKey, n++;
} else {
if (n++, n >= this.#s.length) return;
let i = this.#s[n];
if (!i) return;
for (;;) {
let o = r === t.stack.length ? t : t.stack[r];
if (!o) return;
if (a(i, o.key)) {
n++, Object.isFrozen(t.stack[r]) || (t.stack[r].value = null);
break;
}
this.#l(o.key, e), r++;
}
}
}
if (this.#r) {
let e = this.#r;
this.#r = !1, this.emit("header", e);
}
if (r !== t.stack.length) return;
this.#e++;
let o = t.stack.slice(1).map((e) => e.key).concat([t.key]);
if (e != null) {
let n = this.#i ? this.#i(e, o) : e;
if (n != null) {
let e = i ? { value: n } : n;
i && (e.key = t.key), super.write(e);
}
}
t.value && delete t.value[t.key];
for (let e of t.stack) e.value = null;
}
write(e, t) {
if (typeof e == "string") e = Buffer.from(e, t);
else if (!Buffer.isBuffer(e)) return this.emit("error", /* @__PURE__ */ TypeError("Can only parse JSON from string or buffer input"));
return this.#o.write(e), this.flowing;
}
end(e, t) {
this.#t = !0, e && this.write(e, t);
let n = this.#r;
this.#r = null;
let r = this.#n;
return this.#n = null, n && this.emit("header", n), r && this.emit("footer", r), super.end();
}
static get JSONStreamError() {
return i;
}
static parse(t, n) {
return new e({
path: t,
map: n
});
}
};
})), vr = /* @__PURE__ */ a(((e, n) => {
var { HttpErrorAuthOTP: r } = v(), i = Se(), a = Oe(), o = hr(), s = _r(), c = De(), l = t("querystring"), u = t("url"), d = x(), { Minipass: f } = y(), p = _e(), m = (e) => {
try {
return !!new u.URL(e);
} catch {
return !1;
}
};
n.exports = h;
function h(e, t = {}) {
let n = {
...p,
...t
}, s = m(e), c = n.registry || p.registry;
s || (c = n.registry = n.spec && b(n.spec, n) || n.registry || c, e = `${c.trim().replace(/\/?$/g, "")}/${e.trim().replace(/^\//, "")}`, new u.URL(e));
let g = n.method || "GET", _ = Date.now(), v = a(e, n), y = C(e, v, n), x = n.body, w = f.isStream(x), T = x && typeof x == "object" && typeof x.then == "function";
if (x && !w && !T && typeof x != "string" && !Buffer.isBuffer(x) ? (y["content-type"] = y["content-type"] || "application/json", x = JSON.stringify(x)) : x && !y["content-type"] && (y["content-type"] = "application/octet-stream"), n.gzip) {
if (y["content-encoding"] = "gzip", w) {
let e = new d.Gzip();
x.on("error", (t) => e.emit("error", t)), x = x.pipe(e);
} else T || (x = new d.Gzip().end(x).concat());
}
let E = new u.URL(e);
if (n.query) {
let t = typeof n.query == "string" ? l.parse(n.query) : n.query;
Object.keys(t).forEach((e) => {
t[e] !== void 0 && E.searchParams.set(e, t[e]);
}), e = u.format(E);
}
return E.searchParams.get("write") === "true" && g === "GET" && (n.offline = !1, n.preferOffline = !1, n.preferOnline = !0), Promise.resolve(x).then(async (t) => {
let a = o(e, {
agent: n.agent,
algorithms: n.algorithms,
body: t,
cache: S(n),
cachePath: n.cache,
ca: n.ca,
cert: v.cert || n.cert,
headers: y,
integrity: n.integrity,
key: v.key || n.key,
localAddress: n.localAddress,
maxSockets: n.maxSockets,
memoize: n.memoize,
method: g,
noProxy: n.noProxy,
proxy: n.httpsProxy || n.proxy,
retry: n.retry ? n.retry : {
retries: n.fetchRetries,
factor: n.fetchRetryFactor,
minTimeout: n.fetchRetryMintimeout,
maxTimeout: n.fetchRetryMaxtimeout
},
strictSSL: n.strictSSL,
timeout: n.timeout || 3e4,
signal: n.signal
}).then((t) => i({
method: g,
uri: e,
res: t,
registry: c,
startTime: _,
auth: v,
opts: n
}));
return typeof n.otpPrompt == "function" ? a.catch(async (t) => {
if (t instanceof r) {
let r;
try {
r = await n.otpPrompt();
} catch {}
if (!r) throw t;
return h(e, {
...n,
otp: r
});
}
throw t;
}) : a;
});
}
n.exports.getAuth = a, n.exports.json = g;
function g(e, t) {
return h(e, t).then((e) => e.json());
}
n.exports.json.stream = _;
function _(e, t, n = {}) {
let r = {
...p,
...n
}, i = s.parse(t, r.mapJSON);
return h(e, r).then((e) => e.body.on(
"error",
/* istanbul ignore next: unlikely and difficult to test */
(e) => i.emit("error", e)
).pipe(i)).catch((e) => i.emit("error", e)), i;
}
n.exports.pickRegistry = b;
function b(e, t = {}) {
e = c(e);
let n = e.scope && t[e.scope.replace(/^@?/, "@") + ":registry"];
return !n && t.scope && (n = t[t.scope.replace(/^@?/, "@") + ":registry"]), n ||= t.registry || p.registry, n;
}
function S(e) {
return e.offline ? "only-if-cached" : e.preferOffline ? "force-cache" : e.preferOnline ? "no-cache" : "default";
}
function C(e, t, n) {
let r = Object.assign({ "user-agent": n.userAgent }, n.headers || {});
return n.authType && (r["npm-auth-type"] = n.authType), n.scope && (r["npm-scope"] = n.scope), n.npmSession && (r["npm-session"] = n.npmSession), n.npmCommand && (r["npm-command"] = n.npmCommand), t.token ? r.authorization = `Bearer ${t.token}` : t.auth && (r.authorization = `Basic ${t.auth}`), n.otp && (r["npm-otp"] = n.otp), r;
}
}));
//#endregion
export default vr();
export {};
//# sourceMappingURL=lib-ClO25DK1.js.map