UNPKG

pncat

Version:

A unified cli tool that enhances package managers catalogs feature.

1,495 lines (1,484 loc) 825 kB
import { r as __require, t as __commonJSMin } from "./chunk-6qLfnLNH.mjs"; import { t as require_semver } from "./semver-Df1PSY8l.mjs"; import { i as require_lib$13, r as require_commonjs$1, t as require_npa } from "./npa-fnjp9MqV.mjs"; import { a as require_lib$14, n as require_commonjs$3, r as require_commonjs$2, t as require_promise_retry } from "./promise-retry-BEdb5rpr.mjs"; //#region node_modules/.pnpm/npm-registry-fetch@19.1.1/node_modules/npm-registry-fetch/lib/errors.js var require_errors$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => { const { URL: URL$7 } = __require("node:url"); function packageName(href) { try { let basePath = new URL$7(href).pathname.slice(1); if (!basePath.match(/^-/)) { basePath = basePath.split("/"); var index$5 = basePath.indexOf("_rewrite"); if (index$5 === -1) index$5 = basePath.length - 1; else index$5++; return decodeURIComponent(basePath[index$5]); } } catch {} } var HttpErrorBase = class extends Error { constructor(method, res, body, spec) { super(); this.name = this.constructor.name; this.headers = typeof res.headers?.raw === "function" ? res.headers.raw() : res.headers; this.statusCode = res.status; this.code = `E${res.status}`; this.method = method; this.uri = res.url; this.body = body; this.pkgid = spec ? spec.toString() : packageName(res.url); Error.captureStackTrace(this, this.constructor); } }; var HttpErrorGeneral = class extends HttpErrorBase { constructor(method, res, body, spec) { super(method, res, body, spec); this.message = `${res.status} ${res.statusText} - ${this.method.toUpperCase()} ${this.spec || this.uri}${body && body.error ? " - " + body.error : ""}`; } }; var HttpErrorAuthOTP$1 = class extends HttpErrorBase { constructor(method, res, body, spec) { super(method, res, body, spec); this.message = "OTP required for authentication"; this.code = "EOTP"; } }; var HttpErrorAuthIPAddress = class extends HttpErrorBase { constructor(method, res, body, spec) { super(method, res, body, spec); this.message = "Login is not allowed from your IP address"; this.code = "EAUTHIP"; } }; var HttpErrorAuthUnknown = class extends HttpErrorBase { constructor(method, res, body, spec) { super(method, res, body, spec); this.message = "Unable to authenticate, need: " + res.headers.get("www-authenticate"); } }; module.exports = { HttpErrorBase, HttpErrorGeneral, HttpErrorAuthOTP: HttpErrorAuthOTP$1, HttpErrorAuthIPAddress, HttpErrorAuthUnknown }; })); //#endregion //#region node_modules/.pnpm/minizlib@3.1.0/node_modules/minizlib/dist/commonjs/constants.js var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports) => { var __importDefault$5 = exports && exports.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.constants = void 0; /* c8 ignore start */ const realZlibConstants = __importDefault$5(__require("zlib")).default.constants || { ZLIB_VERNUM: 4736 }; /* c8 ignore stop */ exports.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 }, realZlibConstants)); })); //#endregion //#region node_modules/.pnpm/minizlib@3.1.0/node_modules/minizlib/dist/commonjs/index.js var require_commonjs = /* @__PURE__ */ __commonJSMin(((exports) => { var __createBinding$10 = exports && exports.__createBinding || (Object.create ? (function(o, m$1, k, k2) { if (k2 === void 0) k2 = k; var desc$1 = Object.getOwnPropertyDescriptor(m$1, k); if (!desc$1 || ("get" in desc$1 ? !m$1.__esModule : desc$1.writable || desc$1.configurable)) desc$1 = { enumerable: true, get: function() { return m$1[k]; } }; Object.defineProperty(o, k2, desc$1); }) : (function(o, m$1, k, k2) { if (k2 === void 0) k2 = k; o[k2] = m$1[k]; })); var __setModuleDefault$9 = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar$9 = exports && exports.__importStar || (function() { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function(o$1) { var ar = []; for (var k in o$1) if (Object.prototype.hasOwnProperty.call(o$1, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k = ownKeys(mod), i$3 = 0; i$3 < k.length; i$3++) if (k[i$3] !== "default") __createBinding$10(result, mod, k[i$3]); } __setModuleDefault$9(result, mod); return result; }; })(); var __importDefault$4 = exports && exports.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ZstdDecompress = exports.ZstdCompress = exports.BrotliDecompress = exports.BrotliCompress = exports.Unzip = exports.InflateRaw = exports.DeflateRaw = exports.Gunzip = exports.Gzip = exports.Inflate = exports.Deflate = exports.Zlib = exports.ZlibError = exports.constants = void 0; const assert_1$1 = __importDefault$4(__require("assert")); const buffer_1$1 = __require("buffer"); const minipass_1 = require_commonjs$2(); const realZlib = __importStar$9(__require("zlib")); const constants_js_1 = require_constants$3(); var constants_js_2 = require_constants$3(); Object.defineProperty(exports, "constants", { enumerable: true, get: function() { return constants_js_2.constants; } }); const OriginalBufferConcat = buffer_1$1.Buffer.concat; const desc = Object.getOwnPropertyDescriptor(buffer_1$1.Buffer, "concat"); const noop = (args) => args; const passthroughBufferConcat = desc?.writable === true || desc?.set !== void 0 ? (makeNoOp) => { buffer_1$1.Buffer.concat = makeNoOp ? noop : OriginalBufferConcat; } : (_) => {}; const _superWrite = Symbol("_superWrite"); var ZlibError = class extends Error { code; errno; constructor(err, origin) { super("zlib: " + err.message, { cause: err }); this.code = err.code; this.errno = err.errno; /* c8 ignore next */ if (!this.code) this.code = "ZLIB_ERROR"; this.message = "zlib: " + err.message; Error.captureStackTrace(this, origin ?? this.constructor); } get name() { return "ZlibError"; } }; exports.ZlibError = ZlibError; const _flushFlag = Symbol("flushFlag"); var ZlibBase = class extends minipass_1.Minipass { #sawError = false; #ended = false; #flushFlag; #finishFlushFlag; #fullFlushFlag; #handle; #onError; get sawError() { return this.#sawError; } get handle() { return this.#handle; } /* c8 ignore start */ get flushFlag() { return this.#flushFlag; } /* c8 ignore stop */ constructor(opts, mode) { if (!opts || typeof opts !== "object") throw new TypeError("invalid options for ZlibBase constructor"); super(opts); /* c8 ignore start */ this.#flushFlag = opts.flush ?? 0; this.#finishFlushFlag = opts.finishFlush ?? 0; this.#fullFlushFlag = opts.fullFlushFlag ?? 0; /* c8 ignore stop */ if (typeof realZlib[mode] !== "function") throw new TypeError("Compression method not supported: " + mode); try { this.#handle = new realZlib[mode](opts); } catch (er) { throw new ZlibError(er, this.constructor); } this.#onError = (err) => { if (this.#sawError) return; this.#sawError = true; this.close(); this.emit("error", err); }; this.#handle?.on("error", (er) => this.#onError(new ZlibError(er))); this.once("end", () => this.close); } close() { if (this.#handle) { this.#handle.close(); this.#handle = void 0; this.emit("close"); } } reset() { if (!this.#sawError) { (0, assert_1$1.default)(this.#handle, "zlib binding closed"); return this.#handle.reset?.(); } } flush(flushFlag) { if (this.ended) return; if (typeof flushFlag !== "number") flushFlag = this.#fullFlushFlag; this.write(Object.assign(buffer_1$1.Buffer.alloc(0), { [_flushFlag]: flushFlag })); } end(chunk, encoding, cb) { /* c8 ignore start */ if (typeof chunk === "function") { cb = chunk; encoding = void 0; chunk = void 0; } if (typeof encoding === "function") { cb = encoding; encoding = void 0; } /* c8 ignore stop */ if (chunk) if (encoding) this.write(chunk, encoding); else this.write(chunk); this.flush(this.#finishFlushFlag); this.#ended = true; return super.end(cb); } get ended() { return this.#ended; } [_superWrite](data) { return super.write(data); } write(chunk, encoding, cb) { if (typeof encoding === "function") cb = encoding, encoding = "utf8"; if (typeof chunk === "string") chunk = buffer_1$1.Buffer.from(chunk, encoding); if (this.#sawError) return; (0, assert_1$1.default)(this.#handle, "zlib binding closed"); const nativeHandle = this.#handle._handle; const originalNativeClose = nativeHandle.close; nativeHandle.close = () => {}; const originalClose = this.#handle.close; this.#handle.close = () => {}; passthroughBufferConcat(true); let result = void 0; try { const flushFlag = typeof chunk[_flushFlag] === "number" ? chunk[_flushFlag] : this.#flushFlag; result = this.#handle._processChunk(chunk, flushFlag); passthroughBufferConcat(false); } catch (err) { passthroughBufferConcat(false); this.#onError(new ZlibError(err, this.write)); } finally { if (this.#handle) { this.#handle._handle = nativeHandle; nativeHandle.close = originalNativeClose; this.#handle.close = originalClose; this.#handle.removeAllListeners("error"); } } if (this.#handle) this.#handle.on("error", (er) => this.#onError(new ZlibError(er, this.write))); let writeReturn; if (result) if (Array.isArray(result) && result.length > 0) { const r = result[0]; writeReturn = this[_superWrite](buffer_1$1.Buffer.from(r)); for (let i$3 = 1; i$3 < result.length; i$3++) writeReturn = this[_superWrite](result[i$3]); } else writeReturn = this[_superWrite](buffer_1$1.Buffer.from(result)); if (cb) cb(); return writeReturn; } }; var Zlib = class extends ZlibBase { #level; #strategy; constructor(opts, mode) { opts = opts || {}; opts.flush = opts.flush || constants_js_1.constants.Z_NO_FLUSH; opts.finishFlush = opts.finishFlush || constants_js_1.constants.Z_FINISH; opts.fullFlushFlag = constants_js_1.constants.Z_FULL_FLUSH; super(opts, mode); this.#level = opts.level; this.#strategy = opts.strategy; } params(level, strategy) { if (this.sawError) return; if (!this.handle) throw new Error("cannot switch params when binding is closed"); /* c8 ignore start */ if (!this.handle.params) throw new Error("not supported in this implementation"); /* c8 ignore stop */ if (this.#level !== level || this.#strategy !== strategy) { this.flush(constants_js_1.constants.Z_SYNC_FLUSH); (0, assert_1$1.default)(this.handle, "zlib binding closed"); const origFlush = this.handle.flush; this.handle.flush = (flushFlag, cb) => { /* c8 ignore start */ if (typeof flushFlag === "function") { cb = flushFlag; flushFlag = this.flushFlag; } /* c8 ignore stop */ this.flush(flushFlag); cb?.(); }; try { this.handle.params(level, strategy); } finally { this.handle.flush = origFlush; } /* c8 ignore start */ if (this.handle) { this.#level = level; this.#strategy = strategy; } } } }; exports.Zlib = Zlib; var Deflate = class extends Zlib { constructor(opts) { super(opts, "Deflate"); } }; exports.Deflate = Deflate; var Inflate = class extends Zlib { constructor(opts) { super(opts, "Inflate"); } }; exports.Inflate = Inflate; var Gzip = class extends Zlib { #portable; constructor(opts) { super(opts, "Gzip"); this.#portable = opts && !!opts.portable; } [_superWrite](data) { if (!this.#portable) return super[_superWrite](data); this.#portable = false; data[9] = 255; return super[_superWrite](data); } }; exports.Gzip = Gzip; var Gunzip = class extends Zlib { constructor(opts) { super(opts, "Gunzip"); } }; exports.Gunzip = Gunzip; var DeflateRaw = class extends Zlib { constructor(opts) { super(opts, "DeflateRaw"); } }; exports.DeflateRaw = DeflateRaw; var InflateRaw = class extends Zlib { constructor(opts) { super(opts, "InflateRaw"); } }; exports.InflateRaw = InflateRaw; var Unzip = class extends Zlib { constructor(opts) { super(opts, "Unzip"); } }; exports.Unzip = Unzip; var Brotli = class extends ZlibBase { constructor(opts, mode) { opts = opts || {}; opts.flush = opts.flush || constants_js_1.constants.BROTLI_OPERATION_PROCESS; opts.finishFlush = opts.finishFlush || constants_js_1.constants.BROTLI_OPERATION_FINISH; opts.fullFlushFlag = constants_js_1.constants.BROTLI_OPERATION_FLUSH; super(opts, mode); } }; var BrotliCompress = class extends Brotli { constructor(opts) { super(opts, "BrotliCompress"); } }; exports.BrotliCompress = BrotliCompress; var BrotliDecompress = class extends Brotli { constructor(opts) { super(opts, "BrotliDecompress"); } }; exports.BrotliDecompress = BrotliDecompress; var Zstd = class extends ZlibBase { constructor(opts, mode) { opts = opts || {}; opts.flush = opts.flush || constants_js_1.constants.ZSTD_e_continue; opts.finishFlush = opts.finishFlush || constants_js_1.constants.ZSTD_e_end; opts.fullFlushFlag = constants_js_1.constants.ZSTD_e_flush; super(opts, mode); } }; var ZstdCompress = class extends Zstd { constructor(opts) { super(opts, "ZstdCompress"); } }; exports.ZstdCompress = ZstdCompress; var ZstdDecompress = class extends Zstd { constructor(opts) { super(opts, "ZstdDecompress"); } }; exports.ZstdDecompress = ZstdDecompress; })); //#endregion //#region node_modules/.pnpm/minipass@3.3.6/node_modules/minipass/index.js var require_minipass = /* @__PURE__ */ __commonJSMin(((exports, module) => { const proc = typeof process === "object" && process ? process : { stdout: null, stderr: null }; const EE$2 = __require("events"); const Stream = __require("stream"); const SD = __require("string_decoder").StringDecoder; const EOF = Symbol("EOF"); const MAYBE_EMIT_END = Symbol("maybeEmitEnd"); const EMITTED_END = Symbol("emittedEnd"); const EMITTING_END = Symbol("emittingEnd"); const EMITTED_ERROR = Symbol("emittedError"); const CLOSED = Symbol("closed"); const READ = Symbol("read"); const FLUSH = Symbol("flush"); const FLUSHCHUNK = Symbol("flushChunk"); const ENCODING = Symbol("encoding"); const DECODER = Symbol("decoder"); const FLOWING = Symbol("flowing"); const PAUSED = Symbol("paused"); const RESUME = Symbol("resume"); const BUFFERLENGTH = Symbol("bufferLength"); const BUFFERPUSH = Symbol("bufferPush"); const BUFFERSHIFT = Symbol("bufferShift"); const OBJECTMODE = Symbol("objectMode"); const DESTROYED = Symbol("destroyed"); const EMITDATA = Symbol("emitData"); const EMITEND = Symbol("emitEnd"); const EMITEND2 = Symbol("emitEnd2"); const ASYNC = Symbol("async"); const defer = (fn) => Promise.resolve().then(fn); const doIter = global._MP_NO_ITERATOR_SYMBOLS_ !== "1"; const ASYNCITERATOR = doIter && Symbol.asyncIterator || Symbol("asyncIterator not implemented"); const ITERATOR = doIter && Symbol.iterator || Symbol("iterator not implemented"); const isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish"; const isArrayBuffer = (b) => b instanceof ArrayBuffer || typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0; const isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b); var Pipe = class { constructor(src, dest, opts) { this.src = src; this.dest = dest; this.opts = opts; this.ondrain = () => src[RESUME](); dest.on("drain", this.ondrain); } unpipe() { this.dest.removeListener("drain", this.ondrain); } // istanbul ignore next - only here for the prototype proxyErrors() {} end() { this.unpipe(); if (this.opts.end) this.dest.end(); } }; var PipeProxyErrors = class extends Pipe { unpipe() { this.src.removeListener("error", this.proxyErrors); super.unpipe(); } constructor(src, dest, opts) { super(src, dest, opts); this.proxyErrors = (er) => dest.emit("error", er); src.on("error", this.proxyErrors); } }; module.exports = class Minipass$21 extends Stream { constructor(options) { super(); this[FLOWING] = false; this[PAUSED] = false; this.pipes = []; this.buffer = []; this[OBJECTMODE] = options && options.objectMode || false; if (this[OBJECTMODE]) this[ENCODING] = null; else this[ENCODING] = options && options.encoding || null; if (this[ENCODING] === "buffer") this[ENCODING] = null; this[ASYNC] = options && !!options.async || false; this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null; this[EOF] = false; this[EMITTED_END] = false; this[EMITTING_END] = false; this[CLOSED] = false; this[EMITTED_ERROR] = null; this.writable = true; this.readable = true; this[BUFFERLENGTH] = 0; this[DESTROYED] = false; } get bufferLength() { return this[BUFFERLENGTH]; } get encoding() { return this[ENCODING]; } set encoding(enc$1) { if (this[OBJECTMODE]) throw new Error("cannot set encoding in objectMode"); if (this[ENCODING] && enc$1 !== this[ENCODING] && (this[DECODER] && this[DECODER].lastNeed || this[BUFFERLENGTH])) throw new Error("cannot change encoding"); if (this[ENCODING] !== enc$1) { this[DECODER] = enc$1 ? new SD(enc$1) : null; if (this.buffer.length) this.buffer = this.buffer.map((chunk) => this[DECODER].write(chunk)); } this[ENCODING] = enc$1; } setEncoding(enc$1) { this.encoding = enc$1; } get objectMode() { return this[OBJECTMODE]; } set objectMode(om) { this[OBJECTMODE] = this[OBJECTMODE] || !!om; } get ["async"]() { return this[ASYNC]; } set ["async"](a) { this[ASYNC] = this[ASYNC] || !!a; } write(chunk, encoding, cb) { if (this[EOF]) throw new Error("write after end"); if (this[DESTROYED]) { this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })); return true; } if (typeof encoding === "function") cb = encoding, encoding = "utf8"; if (!encoding) encoding = "utf8"; const fn = this[ASYNC] ? defer : (f) => f(); if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) { if (isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength); else if (isArrayBuffer(chunk)) chunk = Buffer.from(chunk); else if (typeof chunk !== "string") this.objectMode = true; } if (this[OBJECTMODE]) { /* istanbul ignore if - maybe impossible? */ if (this.flowing && this[BUFFERLENGTH] !== 0) this[FLUSH](true); if (this.flowing) this.emit("data", chunk); else this[BUFFERPUSH](chunk); if (this[BUFFERLENGTH] !== 0) this.emit("readable"); if (cb) fn(cb); return this.flowing; } if (!chunk.length) { if (this[BUFFERLENGTH] !== 0) this.emit("readable"); if (cb) fn(cb); return this.flowing; } if (typeof chunk === "string" && !(encoding === this[ENCODING] && !this[DECODER].lastNeed)) chunk = Buffer.from(chunk, encoding); if (Buffer.isBuffer(chunk) && this[ENCODING]) chunk = this[DECODER].write(chunk); if (this.flowing && this[BUFFERLENGTH] !== 0) this[FLUSH](true); if (this.flowing) this.emit("data", chunk); else this[BUFFERPUSH](chunk); if (this[BUFFERLENGTH] !== 0) this.emit("readable"); if (cb) fn(cb); return this.flowing; } read(n) { if (this[DESTROYED]) return null; if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH]) { this[MAYBE_EMIT_END](); return null; } if (this[OBJECTMODE]) n = null; if (this.buffer.length > 1 && !this[OBJECTMODE]) if (this.encoding) this.buffer = [this.buffer.join("")]; else this.buffer = [Buffer.concat(this.buffer, this[BUFFERLENGTH])]; const ret = this[READ](n || null, this.buffer[0]); this[MAYBE_EMIT_END](); return ret; } [READ](n, chunk) { if (n === chunk.length || n === null) this[BUFFERSHIFT](); else { this.buffer[0] = chunk.slice(n); chunk = chunk.slice(0, n); this[BUFFERLENGTH] -= n; } this.emit("data", chunk); if (!this.buffer.length && !this[EOF]) this.emit("drain"); return chunk; } end(chunk, encoding, cb) { if (typeof chunk === "function") cb = chunk, chunk = null; if (typeof encoding === "function") cb = encoding, encoding = "utf8"; if (chunk) this.write(chunk, encoding); if (cb) this.once("end", cb); this[EOF] = true; this.writable = false; if (this.flowing || !this[PAUSED]) this[MAYBE_EMIT_END](); return this; } [RESUME]() { if (this[DESTROYED]) return; this[PAUSED] = false; this[FLOWING] = true; this.emit("resume"); if (this.buffer.length) this[FLUSH](); else if (this[EOF]) this[MAYBE_EMIT_END](); else this.emit("drain"); } resume() { return this[RESUME](); } pause() { this[FLOWING] = false; this[PAUSED] = true; } get destroyed() { return this[DESTROYED]; } get flowing() { return this[FLOWING]; } get paused() { return this[PAUSED]; } [BUFFERPUSH](chunk) { if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1; else this[BUFFERLENGTH] += chunk.length; this.buffer.push(chunk); } [BUFFERSHIFT]() { if (this.buffer.length) if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1; else this[BUFFERLENGTH] -= this.buffer[0].length; return this.buffer.shift(); } [FLUSH](noDrain) { do ; while (this[FLUSHCHUNK](this[BUFFERSHIFT]())); if (!noDrain && !this.buffer.length && !this[EOF]) this.emit("drain"); } [FLUSHCHUNK](chunk) { return chunk ? (this.emit("data", chunk), this.flowing) : false; } pipe(dest, opts) { if (this[DESTROYED]) return; const ended = this[EMITTED_END]; opts = opts || {}; if (dest === proc.stdout || dest === proc.stderr) opts.end = false; else opts.end = opts.end !== false; opts.proxyErrors = !!opts.proxyErrors; if (ended) { if (opts.end) dest.end(); } else { this.pipes.push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts)); if (this[ASYNC]) defer(() => this[RESUME]()); else this[RESUME](); } return dest; } unpipe(dest) { const p = this.pipes.find((p$1) => p$1.dest === dest); if (p) { this.pipes.splice(this.pipes.indexOf(p), 1); p.unpipe(); } } addListener(ev, fn) { return this.on(ev, fn); } on(ev, fn) { const ret = super.on(ev, fn); if (ev === "data" && !this.pipes.length && !this.flowing) this[RESUME](); else if (ev === "readable" && this[BUFFERLENGTH] !== 0) super.emit("readable"); else if (isEndish(ev) && this[EMITTED_END]) { super.emit(ev); this.removeAllListeners(ev); } else if (ev === "error" && this[EMITTED_ERROR]) if (this[ASYNC]) defer(() => fn.call(this, this[EMITTED_ERROR])); else fn.call(this, this[EMITTED_ERROR]); return ret; } get emittedEnd() { return this[EMITTED_END]; } [MAYBE_EMIT_END]() { if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this.buffer.length === 0 && this[EOF]) { this[EMITTING_END] = true; this.emit("end"); this.emit("prefinish"); this.emit("finish"); if (this[CLOSED]) this.emit("close"); this[EMITTING_END] = false; } } emit(ev, data, ...extra) { if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) return; else if (ev === "data") return !data ? false : this[ASYNC] ? defer(() => this[EMITDATA](data)) : this[EMITDATA](data); else if (ev === "end") return this[EMITEND](); else if (ev === "close") { this[CLOSED] = true; if (!this[EMITTED_END] && !this[DESTROYED]) return; const ret$1 = super.emit("close"); this.removeAllListeners("close"); return ret$1; } else if (ev === "error") { this[EMITTED_ERROR] = data; const ret$1 = super.emit("error", data); this[MAYBE_EMIT_END](); return ret$1; } else if (ev === "resume") { const ret$1 = super.emit("resume"); this[MAYBE_EMIT_END](); return ret$1; } else if (ev === "finish" || ev === "prefinish") { const ret$1 = super.emit(ev); this.removeAllListeners(ev); return ret$1; } const ret = super.emit(ev, data, ...extra); this[MAYBE_EMIT_END](); return ret; } [EMITDATA](data) { for (const p of this.pipes) if (p.dest.write(data) === false) this.pause(); const ret = super.emit("data", data); this[MAYBE_EMIT_END](); return ret; } [EMITEND]() { if (this[EMITTED_END]) return; this[EMITTED_END] = true; this.readable = false; if (this[ASYNC]) defer(() => this[EMITEND2]()); else this[EMITEND2](); } [EMITEND2]() { if (this[DECODER]) { const data = this[DECODER].end(); if (data) { for (const p of this.pipes) p.dest.write(data); super.emit("data", data); } } for (const p of this.pipes) p.end(); const ret = super.emit("end"); this.removeAllListeners("end"); return ret; } collect() { const buf = []; if (!this[OBJECTMODE]) buf.dataLength = 0; const p = this.promise(); this.on("data", (c) => { buf.push(c); if (!this[OBJECTMODE]) buf.dataLength += c.length; }); return p.then(() => buf); } concat() { return this[OBJECTMODE] ? Promise.reject(/* @__PURE__ */ new Error("cannot concat in objectMode")) : this.collect().then((buf) => this[OBJECTMODE] ? Promise.reject(/* @__PURE__ */ new Error("cannot concat in objectMode")) : this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength)); } promise() { return new Promise((resolve$2, reject) => { this.on(DESTROYED, () => reject(/* @__PURE__ */ new Error("stream destroyed"))); this.on("error", (er) => reject(er)); this.on("end", () => resolve$2()); }); } [ASYNCITERATOR]() { const next = () => { const res = this.read(); if (res !== null) return Promise.resolve({ done: false, value: res }); if (this[EOF]) return Promise.resolve({ done: true }); let resolve$2 = null; let reject = null; const onerr = (er) => { this.removeListener("data", ondata); this.removeListener("end", onend); reject(er); }; const ondata = (value) => { this.removeListener("error", onerr); this.removeListener("end", onend); this.pause(); resolve$2({ value, done: !!this[EOF] }); }; const onend = () => { this.removeListener("error", onerr); this.removeListener("data", ondata); resolve$2({ done: true }); }; const ondestroy = () => onerr(/* @__PURE__ */ new Error("stream destroyed")); return new Promise((res$1, rej) => { reject = rej; resolve$2 = res$1; this.once(DESTROYED, ondestroy); this.once("error", onerr); this.once("end", onend); this.once("data", ondata); }); }; return { next }; } [ITERATOR]() { const next = () => { const value = this.read(); return { value, done: value === null }; }; return { next }; } destroy(er) { if (this[DESTROYED]) { if (er) this.emit("error", er); else this.emit(DESTROYED); return this; } this[DESTROYED] = true; this.buffer.length = 0; this[BUFFERLENGTH] = 0; if (typeof this.close === "function" && !this[CLOSED]) this.close(); if (er) this.emit("error", er); else this.emit(DESTROYED); return this; } static isStream(s$1) { return !!s$1 && (s$1 instanceof Minipass$21 || s$1 instanceof Stream || s$1 instanceof EE$2 && (typeof s$1.pipe === "function" || typeof s$1.write === "function" && typeof s$1.end === "function")); } }; })); //#endregion //#region node_modules/.pnpm/minipass-sized@1.0.3/node_modules/minipass-sized/index.js var require_minipass_sized = /* @__PURE__ */ __commonJSMin(((exports, module) => { const Minipass$20 = require_minipass(); var SizeError = class extends Error { constructor(found, expect) { super(`Bad data size: expected ${expect} bytes, but got ${found}`); this.expect = expect; this.found = found; this.code = "EBADSIZE"; Error.captureStackTrace(this, this.constructor); } get name() { return "SizeError"; } }; var MinipassSized$2 = class extends Minipass$20 { constructor(options = {}) { super(options); if (options.objectMode) throw new TypeError(`${this.constructor.name} streams only work with string and buffer data`); this.found = 0; this.expect = options.size; if (typeof this.expect !== "number" || this.expect > Number.MAX_SAFE_INTEGER || isNaN(this.expect) || this.expect < 0 || !isFinite(this.expect) || this.expect !== Math.floor(this.expect)) throw new Error("invalid expected size: " + this.expect); } write(chunk, encoding, cb) { const buffer$1 = Buffer.isBuffer(chunk) ? chunk : typeof chunk === "string" ? Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8") : chunk; if (!Buffer.isBuffer(buffer$1)) { this.emit("error", /* @__PURE__ */ new TypeError(`${this.constructor.name} streams only work with string and buffer data`)); return false; } this.found += buffer$1.length; if (this.found > this.expect) this.emit("error", new SizeError(this.found, this.expect)); return super.write(chunk, encoding, cb); } emit(ev, ...data) { if (ev === "end") { if (this.found !== this.expect) this.emit("error", new SizeError(this.found, this.expect)); } return super.emit(ev, ...data); } }; MinipassSized$2.SizeError = SizeError; module.exports = MinipassSized$2; })); //#endregion //#region node_modules/.pnpm/minipass-fetch@5.0.0/node_modules/minipass-fetch/lib/blob.js var require_blob$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => { const { Minipass: Minipass$19 } = require_commonjs$2(); const TYPE$1 = Symbol("type"); const BUFFER$3 = Symbol("buffer"); var Blob$3 = class Blob$3 { constructor(blobParts, options) { this[TYPE$1] = ""; const buffers = []; let size = 0; if (blobParts) { const a = blobParts; const length = Number(a.length); for (let i$3 = 0; i$3 < length; i$3++) { const element = a[i$3]; const buffer$1 = element instanceof Buffer ? element : ArrayBuffer.isView(element) ? Buffer.from(element.buffer, element.byteOffset, element.byteLength) : element instanceof ArrayBuffer ? Buffer.from(element) : element instanceof Blob$3 ? element[BUFFER$3] : typeof element === "string" ? Buffer.from(element) : Buffer.from(String(element)); size += buffer$1.length; buffers.push(buffer$1); } } this[BUFFER$3] = Buffer.concat(buffers, size); const type = options && options.type !== void 0 && String(options.type).toLowerCase(); if (type && !/[^\u0020-\u007E]/.test(type)) this[TYPE$1] = type; } get size() { return this[BUFFER$3].length; } get type() { return this[TYPE$1]; } text() { return Promise.resolve(this[BUFFER$3].toString()); } arrayBuffer() { const buf = this[BUFFER$3]; const off = buf.byteOffset; const len = buf.byteLength; const ab = buf.buffer.slice(off, off + len); return Promise.resolve(ab); } stream() { return new Minipass$19().end(this[BUFFER$3]); } slice(start, end, type) { const size = this.size; const relativeStart = start === void 0 ? 0 : start < 0 ? Math.max(size + start, 0) : Math.min(start, size); const relativeEnd = end === void 0 ? size : end < 0 ? Math.max(size + end, 0) : Math.min(end, size); const span = Math.max(relativeEnd - relativeStart, 0); const slicedBuffer = this[BUFFER$3].slice(relativeStart, relativeStart + span); const blob = new Blob$3([], { type }); blob[BUFFER$3] = slicedBuffer; return blob; } get [Symbol.toStringTag]() { return "Blob"; } static get BUFFER() { return BUFFER$3; } }; Object.defineProperties(Blob$3.prototype, { size: { enumerable: true }, type: { enumerable: true } }); module.exports = Blob$3; })); //#endregion //#region node_modules/.pnpm/minipass-fetch@5.0.0/node_modules/minipass-fetch/lib/fetch-error.js var require_fetch_error$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => { var FetchError$7 = class extends Error { constructor(message, type, systemError) { super(message); this.code = "FETCH_ERROR"; if (systemError) Object.assign(this, systemError); this.errno = this.code; this.type = this.code === "EBADSIZE" && this.found > this.expect ? "max-size" : type; this.message = message; Error.captureStackTrace(this, this.constructor); } get name() { return "FetchError"; } set name(n) {} get [Symbol.toStringTag]() { return "FetchError"; } }; module.exports = FetchError$7; })); //#endregion //#region node_modules/.pnpm/safer-buffer@2.1.2/node_modules/safer-buffer/safer.js var require_safer = /* @__PURE__ */ __commonJSMin(((exports, module) => { var buffer = __require("buffer"); var Buffer$9 = buffer.Buffer; var safer = {}; var key; for (key in buffer) { if (!buffer.hasOwnProperty(key)) continue; if (key === "SlowBuffer" || key === "Buffer") continue; safer[key] = buffer[key]; } var Safer = safer.Buffer = {}; for (key in Buffer$9) { if (!Buffer$9.hasOwnProperty(key)) continue; if (key === "allocUnsafe" || key === "allocUnsafeSlow") continue; Safer[key] = Buffer$9[key]; } safer.Buffer.prototype = Buffer$9.prototype; if (!Safer.from || Safer.from === Uint8Array.from) Safer.from = function(value, encodingOrOffset, length) { if (typeof value === "number") throw new TypeError("The \"value\" argument must not be of type number. Received type " + typeof value); if (value && typeof value.length === "undefined") throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); return Buffer$9(value, encodingOrOffset, length); }; if (!Safer.alloc) Safer.alloc = function(size, fill, encoding) { if (typeof size !== "number") throw new TypeError("The \"size\" argument must be of type number. Received type " + typeof size); if (size < 0 || size >= 2 * (1 << 30)) throw new RangeError("The value \"" + size + "\" is invalid for option \"size\""); var buf = Buffer$9(size); if (!fill || fill.length === 0) buf.fill(0); else if (typeof encoding === "string") buf.fill(fill, encoding); else buf.fill(fill); return buf; }; if (!safer.kStringMaxLength) try { safer.kStringMaxLength = process.binding("buffer").kStringMaxLength; } catch (e) {} if (!safer.constants) { safer.constants = { MAX_LENGTH: safer.kMaxLength }; if (safer.kStringMaxLength) safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength; } module.exports = safer; })); //#endregion //#region node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/bom-handling.js var require_bom_handling = /* @__PURE__ */ __commonJSMin(((exports) => { var BOMChar = ""; exports.PrependBOM = PrependBOMWrapper; function PrependBOMWrapper(encoder, options) { this.encoder = encoder; this.addBOM = true; } PrependBOMWrapper.prototype.write = function(str) { if (this.addBOM) { str = BOMChar + str; this.addBOM = false; } return this.encoder.write(str); }; PrependBOMWrapper.prototype.end = function() { return this.encoder.end(); }; exports.StripBOM = StripBOMWrapper; function StripBOMWrapper(decoder, options) { this.decoder = decoder; this.pass = false; this.options = options || {}; } StripBOMWrapper.prototype.write = function(buf) { var res = this.decoder.write(buf); if (this.pass || !res) return res; if (res[0] === BOMChar) { res = res.slice(1); if (typeof this.options.stripBOM === "function") this.options.stripBOM(); } this.pass = true; return res; }; StripBOMWrapper.prototype.end = function() { return this.decoder.end(); }; })); //#endregion //#region node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/internal.js var require_internal = /* @__PURE__ */ __commonJSMin(((exports, module) => { var Buffer$8 = require_safer().Buffer; module.exports = { utf8: { type: "_internal", bomAware: true }, cesu8: { type: "_internal", bomAware: true }, unicode11utf8: "utf8", ucs2: { type: "_internal", bomAware: true }, utf16le: "ucs2", binary: { type: "_internal" }, base64: { type: "_internal" }, hex: { type: "_internal" }, _internal: InternalCodec }; function InternalCodec(codecOptions, iconv$1) { this.enc = codecOptions.encodingName; this.bomAware = codecOptions.bomAware; if (this.enc === "base64") this.encoder = InternalEncoderBase64; else if (this.enc === "cesu8") { this.enc = "utf8"; this.encoder = InternalEncoderCesu8; if (Buffer$8.from("eda0bdedb2a9", "hex").toString() !== "💩") { this.decoder = InternalDecoderCesu8; this.defaultCharUnicode = iconv$1.defaultCharUnicode; } } } InternalCodec.prototype.encoder = InternalEncoder; InternalCodec.prototype.decoder = InternalDecoder; var StringDecoder = __require("string_decoder").StringDecoder; if (!StringDecoder.prototype.end) StringDecoder.prototype.end = function() {}; function InternalDecoder(options, codec) { this.decoder = new StringDecoder(codec.enc); } InternalDecoder.prototype.write = function(buf) { if (!Buffer$8.isBuffer(buf)) buf = Buffer$8.from(buf); return this.decoder.write(buf); }; InternalDecoder.prototype.end = function() { return this.decoder.end(); }; function InternalEncoder(options, codec) { this.enc = codec.enc; } InternalEncoder.prototype.write = function(str) { return Buffer$8.from(str, this.enc); }; InternalEncoder.prototype.end = function() {}; function InternalEncoderBase64(options, codec) { this.prevStr = ""; } InternalEncoderBase64.prototype.write = function(str) { str = this.prevStr + str; var completeQuads = str.length - str.length % 4; this.prevStr = str.slice(completeQuads); str = str.slice(0, completeQuads); return Buffer$8.from(str, "base64"); }; InternalEncoderBase64.prototype.end = function() { return Buffer$8.from(this.prevStr, "base64"); }; function InternalEncoderCesu8(options, codec) {} InternalEncoderCesu8.prototype.write = function(str) { var buf = Buffer$8.alloc(str.length * 3), bufIdx = 0; for (var i$3 = 0; i$3 < str.length; i$3++) { var charCode = str.charCodeAt(i$3); if (charCode < 128) buf[bufIdx++] = charCode; else if (charCode < 2048) { buf[bufIdx++] = 192 + (charCode >>> 6); buf[bufIdx++] = 128 + (charCode & 63); } else { buf[bufIdx++] = 224 + (charCode >>> 12); buf[bufIdx++] = 128 + (charCode >>> 6 & 63); buf[bufIdx++] = 128 + (charCode & 63); } } return buf.slice(0, bufIdx); }; InternalEncoderCesu8.prototype.end = function() {}; function InternalDecoderCesu8(options, codec) { this.acc = 0; this.contBytes = 0; this.accBytes = 0; this.defaultCharUnicode = codec.defaultCharUnicode; } InternalDecoderCesu8.prototype.write = function(buf) { var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, res = ""; for (var i$3 = 0; i$3 < buf.length; i$3++) { var curByte = buf[i$3]; if ((curByte & 192) !== 128) { if (contBytes > 0) { res += this.defaultCharUnicode; contBytes = 0; } if (curByte < 128) res += String.fromCharCode(curByte); else if (curByte < 224) { acc = curByte & 31; contBytes = 1; accBytes = 1; } else if (curByte < 240) { acc = curByte & 15; contBytes = 2; accBytes = 1; } else res += this.defaultCharUnicode; } else if (contBytes > 0) { acc = acc << 6 | curByte & 63; contBytes--; accBytes++; if (contBytes === 0) if (accBytes === 2 && acc < 128 && acc > 0) res += this.defaultCharUnicode; else if (accBytes === 3 && acc < 2048) res += this.defaultCharUnicode; else res += String.fromCharCode(acc); } else res += this.defaultCharUnicode; } this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes; return res; }; InternalDecoderCesu8.prototype.end = function() { var res = 0; if (this.contBytes > 0) res += this.defaultCharUnicode; return res; }; })); //#endregion //#region node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf32.js var require_utf32 = /* @__PURE__ */ __commonJSMin(((exports) => { var Buffer$7 = require_safer().Buffer; exports._utf32 = Utf32Codec; function Utf32Codec(codecOptions, iconv$1) { this.iconv = iconv$1; this.bomAware = true; this.isLE = codecOptions.isLE; } exports.utf32le = { type: "_utf32", isLE: true }; exports.utf32be = { type: "_utf32", isLE: false }; exports.ucs4le = "utf32le"; exports.ucs4be = "utf32be"; Utf32Codec.prototype.encoder = Utf32Encoder; Utf32Codec.prototype.decoder = Utf32Decoder; function Utf32Encoder(options, codec) { this.isLE = codec.isLE; this.highSurrogate = 0; } Utf32Encoder.prototype.write = function(str) { var src = Buffer$7.from(str, "ucs2"); var dst = Buffer$7.alloc(src.length * 2); var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE; var offset = 0; for (var i$3 = 0; i$3 < src.length; i$3 += 2) { var code = src.readUInt16LE(i$3); var isHighSurrogate = 55296 <= code && code < 56320; var isLowSurrogate = 56320 <= code && code < 57344; if (this.highSurrogate) if (isHighSurrogate || !isLowSurrogate) { write32.call(dst, this.highSurrogate, offset); offset += 4; } else { var codepoint = (this.highSurrogate - 55296 << 10 | code - 56320) + 65536; write32.call(dst, codepoint, offset); offset += 4; this.highSurrogate = 0; continue; } if (isHighSurrogate) this.highSurrogate = code; else { write32.call(dst, code, offset); offset += 4; this.highSurrogate = 0; } } if (offset < dst.length) dst = dst.slice(0, offset); return dst; }; Utf32Encoder.prototype.end = function() { if (!this.highSurrogate) return; var buf = Buffer$7.alloc(4); if (this.isLE) buf.writeUInt32LE(this.highSurrogate, 0); else buf.writeUInt32BE(this.highSurrogate, 0); this.highSurrogate = 0; return buf; }; function Utf32Decoder(options, codec) { this.isLE = codec.isLE; this.badChar = codec.iconv.defaultCharUnicode.charCodeAt(0); this.overflow = []; } Utf32Decoder.prototype.write = function(src) { if (src.length === 0) return ""; var i$3 = 0; var codepoint = 0; var dst = Buffer$7.alloc(src.length + 4); var offset = 0; var isLE = this.isLE; var overflow = this.overflow; var badChar = this.badChar; if (overflow.length > 0) { for (; i$3 < src.length && overflow.length < 4; i$3++) overflow.push(src[i$3]); if (overflow.length === 4) { if (isLE) codepoint = overflow[i$3] | overflow[i$3 + 1] << 8 | overflow[i$3 + 2] << 16 | overflow[i$3 + 3] << 24; else codepoint = overflow[i$3 + 3] | overflow[i$3 + 2] << 8 | overflow[i$3 + 1] << 16 | overflow[i$3] << 24; overflow.length = 0; offset = _writeCodepoint(dst, offset, codepoint, badChar); } } for (; i$3 < src.length - 3; i$3 += 4) { if (isLE) codepoint = src[i$3] | src[i$3 + 1] << 8 | src[i$3 + 2] << 16 | src[i$3 + 3] << 24; else codepoint = src[i$3 + 3] | src[i$3 + 2] << 8 | src[i$3 + 1] << 16 | src[i$3] << 24; offset = _writeCodepoint(dst, offset, codepoint, badChar); } for (; i$3 < src.length; i$3++) overflow.push(src[i$3]); return dst.slice(0, offset).toString("ucs2"); }; function _writeCodepoint(dst, offset, codepoint, badChar) { if (codepoint < 0 || codepoint > 1114111) codepoint = badChar; if (codepoint >= 65536) { codepoint -= 65536; var high = 55296 | codepoint >> 10; dst[offset++] = high & 255; dst[offset++] = high >> 8; var codepoint = 56320 | codepoint & 1023; } dst[offset++] = codepoint & 255; dst[offset++] = codepoint >> 8; return offset; } Utf32Decoder.prototype.end = function() { this.overflow.length = 0; }; exports.utf32 = Utf32AutoCodec; exports.ucs4 = "utf32"; function Utf32AutoCodec(options, iconv$1) { this.iconv = iconv$1; } Utf32AutoCodec.prototype.encoder = Utf32AutoEncoder; Utf32AutoCodec.prototype.decoder = Utf32AutoDecoder; function Utf32AutoEncoder(options, codec) { options = options || {}; if (options.addBOM === void 0) options.addBOM = true; this.encoder = codec.iconv.getEncoder(options.defaultEncoding || "utf-32le", options); } Utf32AutoEncoder.prototype.write = function(str) { return this.encoder.write(str); }; Utf32AutoEncoder.prototype.end = function() { return this.encoder.end(); }; function Utf32AutoDecoder(options, codec) { this.decoder = null; this.initialBufs = []; this.initialBufsLen = 0; this.options = options || {}; this.iconv = codec.iconv; } Utf32AutoDecoder.prototype.write = function(buf) { if (!this.decoder) { this.initialBufs.push(buf); this.initialBufsLen += buf.length; if (this.initialBufsLen < 32) return ""; var encoding = detectEncoding$1(this.initialBufs, this.options.defaultEncoding); this.decoder = this.iconv.getDecoder(encoding, this.options); var resStr = ""; for (var i$3 = 0; i$3 < this.initialBufs.length; i$3++) resStr += this.decoder.write(this.initialBufs[i$3]); this.initialBufs.length = this.initialBufsLen = 0; return resStr; } return this.decoder.write(buf); }; Utf32AutoDecoder.prototype.end = function() { if (!this.decoder) { var encoding = detectEncoding$1(this.initialBufs, this.options.defaultEncoding); this.decoder = this.iconv.getDecoder(encoding, this.options); var resStr = ""; for (var i$3 = 0; i$3 < this.initialBufs.length; i$3++) resStr += this.decoder.write(this.initialBufs[i$3]); var trail = this.decoder.end(); if (trail) resStr += trail; this.initialBufs.length = this.initialBufsLen = 0; return resStr; } return this.decoder.end(); }; function detectEncoding$1(bufs, defaultEncoding) { var b = []; var charsProcessed = 0; var invalidLE = 0, invalidBE = 0; var bmpCharsLE = 0, bmpCharsBE = 0; outer_loop: for (var i$3 = 0; i$3 < bufs.length; i$3++) { var buf = bufs[i$3]; for (var j = 0; j < buf.length; j++) { b