@volter/tabnode 0.5.17 → 0.5.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -828,6 +828,7 @@ var INTERNAL_VALIDATORS = "/* eslint jsdoc/require-jsdoc: \"error\" */\n\n'use s
828
828
  var INTERNAL_ABORT_LISTENER = "'use strict';\n\nconst {\n SymbolDispose,\n} = require('internal/util');\nconst {\n validateAbortSignal,\n validateFunction,\n} = require('internal/validators');\nconst {\n codes: {\n ERR_INVALID_ARG_TYPE,\n },\n} = require('internal/errors');\n\nlet queueMicrotask;\nlet kResistStopPropagation;\n\n/**\n * @param {AbortSignal} signal\n * @param {EventListener} listener\n * @returns {Disposable}\n */\nfunction addAbortListener(signal, listener) {\n if (signal === undefined) {\n throw new ERR_INVALID_ARG_TYPE('signal', 'AbortSignal', signal);\n }\n validateAbortSignal(signal, 'signal');\n validateFunction(listener, 'listener');\n\n let removeEventListener;\n if (signal.aborted) {\n queueMicrotask ??= require('internal/process/task_queues').queueMicrotask;\n queueMicrotask(() => listener());\n } else {\n kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation;\n // TODO(atlowChemi) add { subscription: true } and return directly\n signal.addEventListener('abort', listener, { __proto__: null, once: true, [kResistStopPropagation]: true });\n removeEventListener = () => {\n signal.removeEventListener('abort', listener);\n };\n }\n return {\n __proto__: null,\n [SymbolDispose]() {\n removeEventListener?.();\n },\n };\n}\n\nmodule.exports = {\n __proto__: null,\n addAbortListener,\n};\n";
829
829
  var INTERNAL_CHILD_PROCESS_SERIALIZATION = "'use strict';\n\nconst {\n ArrayPrototypePush,\n JSONParse,\n JSONStringify,\n StringPrototypeSplit,\n Symbol,\n TypedArrayPrototypeSubarray,\n} = primordials;\nconst { Buffer } = require('buffer');\nconst { StringDecoder } = require('string_decoder');\nconst v8 = require('v8');\nconst { isArrayBufferView } = require('internal/util/types');\nconst assert = require('internal/assert');\nconst { streamBaseState, kLastWriteWasAsync } = internalBinding('stream_wrap');\n\nconst kMessageBuffer = Symbol('kMessageBuffer');\nconst kMessageBufferSize = Symbol('kMessageBufferSize');\nconst kJSONBuffer = Symbol('kJSONBuffer');\nconst kStringDecoder = Symbol('kStringDecoder');\n\n// Extend V8's serializer APIs to give more JSON-like behaviour in\n// some cases; in particular, for native objects this serializes them the same\n// way that JSON does rather than throwing an exception.\nconst kArrayBufferViewTag = 0;\nconst kNotArrayBufferViewTag = 1;\nclass ChildProcessSerializer extends v8.DefaultSerializer {\n _writeHostObject(object) {\n if (isArrayBufferView(object)) {\n this.writeUint32(kArrayBufferViewTag);\n return super._writeHostObject(object);\n }\n this.writeUint32(kNotArrayBufferViewTag);\n this.writeValue({ ...object });\n }\n}\n\nclass ChildProcessDeserializer extends v8.DefaultDeserializer {\n _readHostObject() {\n const tag = this.readUint32();\n if (tag === kArrayBufferViewTag)\n return super._readHostObject();\n\n assert(tag === kNotArrayBufferViewTag);\n return this.readValue();\n }\n}\n\n// Messages are parsed in either of the following formats:\n// - Newline-delimited JSON, or\n// - V8-serialized buffers, prefixed with their length as a big endian uint32\n// (aka 'advanced')\nconst advanced = {\n initMessageChannel(channel) {\n channel[kMessageBuffer] = [];\n channel[kMessageBufferSize] = 0;\n channel.buffering = false;\n },\n\n *parseChannelMessages(channel, readData) {\n if (readData.length === 0) return;\n\n if (channel[kMessageBufferSize] && channel[kMessageBuffer][0].length < 4) {\n // Message length split into two buffers, so let's concatenate it.\n channel[kMessageBuffer][0] = Buffer.concat([channel[kMessageBuffer][0], readData]);\n } else {\n ArrayPrototypePush(channel[kMessageBuffer], readData);\n }\n channel[kMessageBufferSize] += readData.length;\n\n // Index 0 should always be present because we just pushed data into it.\n let messageBufferHead = channel[kMessageBuffer][0];\n while (messageBufferHead.length >= 4) {\n // We call `readUInt32BE` manually here, because this is faster than first converting\n // it to a buffer and using `readUInt32BE` on that.\n const fullMessageSize = (\n messageBufferHead[0] << 24 |\n messageBufferHead[1] << 16 |\n messageBufferHead[2] << 8 |\n messageBufferHead[3]\n ) + 4;\n\n if (channel[kMessageBufferSize] < fullMessageSize) break;\n\n const concatenatedBuffer = channel[kMessageBuffer].length === 1 ?\n channel[kMessageBuffer][0] :\n Buffer.concat(\n channel[kMessageBuffer],\n channel[kMessageBufferSize],\n );\n\n const deserializer = new ChildProcessDeserializer(\n TypedArrayPrototypeSubarray(concatenatedBuffer, 4, fullMessageSize),\n );\n\n messageBufferHead = TypedArrayPrototypeSubarray(concatenatedBuffer, fullMessageSize);\n channel[kMessageBufferSize] = messageBufferHead.length;\n channel[kMessageBuffer] =\n channel[kMessageBufferSize] !== 0 ? [messageBufferHead] : [];\n\n deserializer.readHeader();\n yield deserializer.readValue();\n }\n\n channel.buffering = channel[kMessageBufferSize] > 0;\n },\n\n writeChannelMessage(channel, req, message, handle) {\n const ser = new ChildProcessSerializer();\n // Add 4 bytes, to later populate with message length\n ser.writeRawBytes(Buffer.allocUnsafe(4));\n ser.writeHeader();\n ser.writeValue(message);\n\n const serializedMessage = ser.releaseBuffer();\n const serializedMessageLength = serializedMessage.length - 4;\n\n serializedMessage.set([\n serializedMessageLength >> 24 & 0xFF,\n serializedMessageLength >> 16 & 0xFF,\n serializedMessageLength >> 8 & 0xFF,\n serializedMessageLength & 0xFF,\n ], 0);\n\n const result = channel.writeBuffer(req, serializedMessage, handle);\n\n // Mirror what stream_base_commons.js does for Buffer retention.\n if (streamBaseState[kLastWriteWasAsync])\n req.buffer = serializedMessage;\n\n return result;\n },\n};\n\nconst json = {\n initMessageChannel(channel) {\n channel[kJSONBuffer] = '';\n channel[kStringDecoder] = undefined;\n },\n\n *parseChannelMessages(channel, readData) {\n if (readData.length === 0) return;\n\n if (channel[kStringDecoder] === undefined)\n channel[kStringDecoder] = new StringDecoder('utf8');\n const chunks =\n StringPrototypeSplit(channel[kStringDecoder].write(readData), '\\n');\n const numCompleteChunks = chunks.length - 1;\n // Last line does not have trailing linebreak\n const incompleteChunk = chunks[numCompleteChunks];\n if (numCompleteChunks === 0) {\n channel[kJSONBuffer] += incompleteChunk;\n } else {\n chunks[0] = channel[kJSONBuffer] + chunks[0];\n for (let i = 0; i < numCompleteChunks; i++)\n yield JSONParse(chunks[i]);\n channel[kJSONBuffer] = incompleteChunk;\n }\n channel.buffering = channel[kJSONBuffer].length !== 0;\n },\n\n writeChannelMessage(channel, req, message, handle) {\n const string = JSONStringify(message) + '\\n';\n return channel.writeUtf8String(req, string, handle);\n },\n};\n\nmodule.exports = { advanced, json };\n";
830
830
  var INTERNAL_MODULES_CUSTOMIZATION_HOOKS = "'use strict';\n\nconst {\n ArrayPrototypeFindIndex,\n ArrayPrototypePush,\n ArrayPrototypeSplice,\n ObjectAssign,\n ObjectFreeze,\n StringPrototypeSlice,\n StringPrototypeStartsWith,\n Symbol,\n} = primordials;\nconst {\n isAnyArrayBuffer,\n isArrayBufferView,\n} = require('internal/util/types');\n\nconst { BuiltinModule } = require('internal/bootstrap/realm');\nconst {\n ERR_INVALID_RETURN_PROPERTY_VALUE,\n} = require('internal/errors').codes;\nconst { validateFunction } = require('internal/validators');\nconst { isAbsolute } = require('path');\nconst { pathToFileURL, fileURLToPath } = require('internal/url');\n\nlet debug = require('internal/util/debuglog').debuglog('module_hooks', (fn) => {\n debug = fn;\n});\n\n/**\n * @typedef {import('internal/modules/cjs/loader.js').Module} Module\n */\n/**\n * @typedef {(\n * specifier: string,\n * context: Partial<ModuleResolveContext>,\n * ) => ModuleResolveResult\n * } NextResolve\n * @typedef {(\n * specifier: string,\n * context: ModuleResolveContext,\n * nextResolve: NextResolve,\n * ) => ModuleResolveResult\n * } ResolveHook\n * @typedef {(\n * url: string,\n * context: Partial<ModuleLoadContext>,\n * ) => ModuleLoadResult\n * } NextLoad\n * @typedef {(\n * url: string,\n * context: ModuleLoadContext,\n * nextLoad: NextLoad,\n * ) => ModuleLoadResult\n * } LoadHook\n */\n\n// Use arrays for better insertion and iteration performance, we don't care\n// about deletion performance as much.\n\n/** @type {ResolveHook[]} */\nconst resolveHooks = [];\n/** @type {LoadHook[]} */\nconst loadHooks = [];\nconst hookId = Symbol('kModuleHooksIdKey');\nlet nextHookId = 0;\n\nclass ModuleHooks {\n /**\n * @param {ResolveHook|undefined} resolve User-provided hook.\n * @param {LoadHook|undefined} load User-provided hook.\n */\n constructor(resolve, load) {\n this[hookId] = Symbol(`module-hook-${nextHookId++}`);\n // Always initialize all hooks, if it's unspecified it'll be an owned undefined.\n this.resolve = resolve;\n this.load = load;\n\n if (resolve) {\n ArrayPrototypePush(resolveHooks, this);\n }\n if (load) {\n ArrayPrototypePush(loadHooks, this);\n }\n\n ObjectFreeze(this);\n }\n // TODO(joyeecheung): we may want methods that allow disabling/enabling temporarily\n // which just sets the item in the array to undefined temporarily.\n // TODO(joyeecheung): this can be the [Symbol.dispose] implementation to pair with\n // `using` when the explicit resource management proposal is shipped by V8.\n /**\n * Deregister the hook instance.\n */\n deregister() {\n const id = this[hookId];\n let index = ArrayPrototypeFindIndex(resolveHooks, (hook) => hook[hookId] === id);\n if (index !== -1) {\n ArrayPrototypeSplice(resolveHooks, index, 1);\n }\n index = ArrayPrototypeFindIndex(loadHooks, (hook) => hook[hookId] === id);\n if (index !== -1) {\n ArrayPrototypeSplice(loadHooks, index, 1);\n }\n }\n};\n\n/**\n * TODO(joyeecheung): taken an optional description?\n * @param {{ resolve?: ResolveHook, load?: LoadHook }} hooks User-provided hooks\n * @returns {ModuleHooks}\n */\nfunction registerHooks(hooks) {\n const { resolve, load } = hooks;\n if (resolve) {\n validateFunction(resolve, 'hooks.resolve');\n }\n if (load) {\n validateFunction(load, 'hooks.load');\n }\n return new ModuleHooks(resolve, load);\n}\n\n/**\n * @param {string} filename\n * @returns {string}\n */\nfunction convertCJSFilenameToURL(filename) {\n if (!filename) { return filename; }\n let normalizedId = filename;\n if (StringPrototypeStartsWith(filename, 'node:')) {\n normalizedId = StringPrototypeSlice(filename, 5);\n }\n if (BuiltinModule.canBeRequiredByUsers(normalizedId)) {\n return `node:${normalizedId}`;\n }\n // Handle the case where filename is neither a path, nor a built-in id,\n // which is possible via monkey-patching.\n if (isAbsolute(filename)) {\n return pathToFileURL(filename).href;\n }\n return filename;\n}\n\n/**\n * @param {string} url\n * @returns {string}\n */\nfunction convertURLToCJSFilename(url) {\n if (!url) { return url; }\n const builtinId = BuiltinModule.normalizeRequirableId(url);\n if (builtinId) {\n return builtinId;\n }\n if (StringPrototypeStartsWith(url, 'file://')) {\n return fileURLToPath(url);\n }\n return url;\n}\n\n/**\n * Convert a list of hooks into a function that can be used to do an operation through\n * a chain of hooks. If any of the hook returns without calling the next hook, it\n * must return shortCircuit: true to stop the chain from continuing to avoid\n * forgetting to invoke the next hook by mistake.\n * @param {ModuleHooks[]} hooks A list of hooks whose last argument is `nextHook`.\n * @param {'load'|'resolve'} name Name of the hook in ModuleHooks.\n * @param {Function} defaultStep The default step in the chain.\n * @param {Function} validate A function that validates and sanitize the result returned by the chain.\n */\nfunction buildHooks(hooks, name, defaultStep, validate, mergedContext) {\n let lastRunIndex = hooks.length;\n /**\n * Helper function to wrap around invocation of user hook or the default step\n * in order to fill in missing arguments or check returned results.\n * Due to the merging of the context, this must be a closure.\n * @param {number} index Index in the chain. Default step is 0, last added hook is 1,\n * and so on.\n * @param {Function} userHookOrDefault Either the user hook or the default step to invoke.\n * @param {Function|undefined} next The next wrapped step. If this is the default step, it's undefined.\n * @returns {Function} Wrapped hook or default step.\n */\n function wrapHook(index, userHookOrDefault, next) {\n return function nextStep(arg0, context) {\n lastRunIndex = index;\n if (context && context !== mergedContext) {\n ObjectAssign(mergedContext, context);\n }\n const hookResult = userHookOrDefault(arg0, mergedContext, next);\n if (lastRunIndex > 0 && lastRunIndex === index && !hookResult.shortCircuit) {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE('true', name, 'shortCircuit',\n hookResult.shortCircuit);\n }\n return validate(arg0, mergedContext, hookResult);\n };\n }\n const chain = [wrapHook(0, defaultStep)];\n for (let i = 0; i < hooks.length; ++i) {\n const wrappedHook = wrapHook(i + 1, hooks[i][name], chain[i]);\n ArrayPrototypePush(chain, wrappedHook);\n }\n return chain[chain.length - 1];\n}\n\n/**\n * @typedef {object} ModuleResolveResult\n * @property {string} url Resolved URL of the module.\n * @property {string|undefined} format Format of the module.\n * @property {ImportAttributes|undefined} importAttributes Import attributes for the request.\n * @property {boolean|undefined} shortCircuit Whether the next hook has been skipped.\n */\n\n/**\n * Validate the result returned by a chain of resolve hook.\n * @param {string} specifier Specifier passed into the hooks.\n * @param {ModuleResolveContext} context Context passed into the hooks.\n * @param {ModuleResolveResult} result Result produced by resolve hooks.\n * @returns {ModuleResolveResult}\n */\nfunction validateResolve(specifier, context, result) {\n const { url, format, importAttributes } = result;\n if (typeof url !== 'string') {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a URL string',\n 'resolve',\n 'url',\n url,\n );\n }\n\n if (format && typeof format !== 'string') {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a string',\n 'resolve',\n 'format',\n format,\n );\n }\n\n if (importAttributes && typeof importAttributes !== 'object') {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'an object',\n 'resolve',\n 'importAttributes',\n importAttributes,\n );\n }\n\n return {\n __proto__: null,\n url,\n format,\n importAttributes,\n };\n}\n\n/**\n * @typedef {object} ModuleLoadResult\n * @property {string|undefined} format Format of the loaded module.\n * @property {string|ArrayBuffer|TypedArray} source Source code of the module.\n * @property {boolean|undefined} shortCircuit Whether the next hook has been skipped.\n */\n\n/**\n * Validate the result returned by a chain of resolve hook.\n * @param {string} url URL passed into the hooks.\n * @param {ModuleLoadContext} context Context passed into the hooks.\n * @param {ModuleLoadResult} result Result produced by load hooks.\n * @returns {ModuleLoadResult}\n */\nfunction validateLoad(url, context, result) {\n const { source, format } = result;\n // To align with module.register(), the load hooks are still invoked for\n // the builtins even though the default load step only provides null as source,\n // and any source content for builtins provided by the user hooks are ignored.\n if (!StringPrototypeStartsWith(url, 'node:') &&\n typeof result.source !== 'string' &&\n !isAnyArrayBuffer(source) &&\n !isArrayBufferView(source)) {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a string, an ArrayBuffer, or a TypedArray',\n 'load',\n 'source',\n source,\n );\n }\n\n if (typeof format !== 'string' && format !== undefined) {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a string',\n 'load',\n 'format',\n format,\n );\n }\n\n return {\n __proto__: null,\n format,\n source,\n };\n}\n\nclass ModuleResolveContext {\n /**\n * Context for the resolve hook.\n * @param {string|undefined} parentURL Parent URL.\n * @param {ImportAttributes|undefined} importAttributes Import attributes.\n * @param {string[]} conditions Conditions.\n */\n constructor(parentURL, importAttributes, conditions) {\n this.parentURL = parentURL;\n this.importAttributes = importAttributes;\n this.conditions = conditions;\n // TODO(joyeecheung): a field to differentiate between require and import?\n }\n};\n\nclass ModuleLoadContext {\n /**\n * Context for the load hook.\n * @param {string|undefined} format URL.\n * @param {ImportAttributes|undefined} importAttributes Import attributes.\n * @param {string[]} conditions Conditions.\n */\n constructor(format, importAttributes, conditions) {\n this.format = format;\n this.importAttributes = importAttributes;\n this.conditions = conditions;\n }\n};\n\nlet decoder;\n/**\n * Load module source for a url, through a hooks chain if it exists.\n * @param {string} url\n * @param {string|undefined} originalFormat\n * @param {ImportAttributes|undefined} importAttributes\n * @param {string[]} conditions\n * @param {(url: string, context: ModuleLoadContext) => ModuleLoadResult} defaultLoad\n * @returns {ModuleLoadResult}\n */\nfunction loadWithHooks(url, originalFormat, importAttributes, conditions, defaultLoad) {\n debug('loadWithHooks', url, originalFormat);\n const context = new ModuleLoadContext(originalFormat, importAttributes, conditions);\n if (loadHooks.length === 0) {\n return defaultLoad(url, context);\n }\n\n const runner = buildHooks(loadHooks, 'load', defaultLoad, validateLoad, context);\n\n const result = runner(url, context);\n const { source, format } = result;\n if (!isAnyArrayBuffer(source) && !isArrayBufferView(source)) {\n return result;\n }\n\n switch (format) {\n // Text formats:\n case undefined:\n case 'module':\n case 'commonjs':\n case 'json':\n case 'module-typescript':\n case 'commonjs-typescript':\n case 'typescript': {\n decoder ??= new (require('internal/encoding').TextDecoder)();\n result.source = decoder.decode(source);\n break;\n }\n default:\n break;\n }\n return result;\n}\n\n/**\n * Resolve module request to a url, through a hooks chain if it exists.\n * @param {string} specifier\n * @param {string|undefined} parentURL\n * @param {ImportAttributes|undefined} importAttributes\n * @param {string[]} conditions\n * @param {(specifier: string, context: ModuleResolveContext) => ModuleResolveResult} defaultResolve\n * @returns {ModuleResolveResult}\n */\nfunction resolveWithHooks(specifier, parentURL, importAttributes, conditions, defaultResolve) {\n debug('resolveWithHooks', specifier, parentURL, importAttributes);\n const context = new ModuleResolveContext(parentURL, importAttributes, conditions);\n if (resolveHooks.length === 0) {\n return defaultResolve(specifier, context);\n }\n\n const runner = buildHooks(resolveHooks, 'resolve', defaultResolve, validateResolve, context);\n\n return runner(specifier, context);\n}\n\nmodule.exports = {\n convertCJSFilenameToURL,\n convertURLToCJSFilename,\n loadHooks,\n loadWithHooks,\n registerHooks,\n resolveHooks,\n resolveWithHooks,\n};\n";
831
+ var INTERNAL_MODULES_TYPESCRIPT = "'use strict';\n\nconst {\n ObjectPrototypeHasOwnProperty,\n} = primordials;\nconst {\n validateBoolean,\n validateOneOf,\n validateObject,\n validateString,\n} = require('internal/validators');\nconst { assertTypeScript,\n emitExperimentalWarning,\n getLazy,\n isUnderNodeModules,\n kEmptyObject } = require('internal/util');\nconst {\n ERR_INVALID_TYPESCRIPT_SYNTAX,\n ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING,\n ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX,\n} = require('internal/errors').codes;\nconst { getOptionValue } = require('internal/options');\nconst assert = require('internal/assert');\nconst { Buffer } = require('buffer');\n\n/**\n * The TypeScript parsing mode, either 'strip-only' or 'transform'.\n * @type {function(): TypeScriptMode}\n */\nconst getTypeScriptParsingMode = getLazy(() =>\n (getOptionValue('--experimental-transform-types') ?\n (emitExperimentalWarning('Transform Types'), 'transform') : 'strip-only'),\n);\n\n/**\n * Load the TypeScript parser.\n * and returns an object with a `code` property.\n * @returns {Function} The TypeScript parser function.\n */\nconst loadTypeScriptParser = getLazy(() => {\n assertTypeScript();\n const amaro = require('internal/deps/amaro/dist/index');\n return amaro.transformSync;\n});\n\n/**\n *\n * @param {string} source the source code\n * @param {object} options the options to pass to the parser\n * @returns {TransformOutput} an object with a `code` property.\n */\nfunction parseTypeScript(source, options) {\n const parse = loadTypeScriptParser();\n try {\n return parse(source, options);\n } catch (error) {\n /**\n * Amaro v0.3.0 (from SWC v1.10.7) throws an object with `message` and `code` properties.\n * It allows us to distinguish between invalid syntax and unsupported syntax.\n */\n switch (error?.code) {\n case 'UnsupportedSyntax': {\n const unsupportedSyntaxError = new ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX(error.message);\n throw decorateErrorWithSnippet(unsupportedSyntaxError, error); /* node-do-not-add-exception-line */\n }\n case 'InvalidSyntax': {\n const invalidSyntaxError = new ERR_INVALID_TYPESCRIPT_SYNTAX(error.message);\n throw decorateErrorWithSnippet(invalidSyntaxError, error); /* node-do-not-add-exception-line */\n }\n default:\n // SWC may throw strings when something goes wrong.\n if (typeof error === 'string') { assert.fail(error); }\n assert(error != null && ObjectPrototypeHasOwnProperty(error, 'message'));\n assert.fail(error.message);\n }\n }\n}\n\n/**\n *\n * @param {Error} error the error to decorate: ERR_INVALID_TYPESCRIPT_SYNTAX, ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX\n * @param {object} amaroError the error object from amaro\n * @returns {Error} the decorated error\n */\nfunction decorateErrorWithSnippet(error, amaroError) {\n const errorHints = `${amaroError.filename}:${amaroError.startLine}\\n${amaroError.snippet}`;\n error.stack = `${errorHints}\\n${error.stack}`;\n return error;\n}\n\n/**\n * Performs type-stripping to TypeScript source code.\n * @param {string} code TypeScript code to parse.\n * @param {TransformOptions} options The configuration for type stripping.\n * @returns {string} The stripped TypeScript code.\n */\nfunction stripTypeScriptTypes(code, options = kEmptyObject) {\n emitExperimentalWarning('stripTypeScriptTypes');\n validateString(code, 'code');\n validateObject(options, 'options');\n\n const {\n sourceMap = false,\n sourceUrl = '',\n } = options;\n let { mode = 'strip' } = options;\n validateOneOf(mode, 'options.mode', ['strip', 'transform']);\n validateBoolean(sourceMap, 'options.sourceMap');\n validateString(sourceUrl, 'options.sourceUrl');\n if (mode === 'strip') {\n validateOneOf(sourceMap, 'options.sourceMap', [false, undefined]);\n // Rename mode from 'strip' to 'strip-only'.\n // The reason is to match `process.features.typescript` which returns `strip`,\n // but the parser expects `strip-only`.\n mode = 'strip-only';\n }\n\n return processTypeScriptCode(code, {\n mode,\n sourceMap,\n filename: sourceUrl,\n });\n}\n\n/**\n * Processes TypeScript code by stripping types or transforming.\n * Handles source maps if needed.\n * @param {string} code TypeScript code to process.\n * @param {object} options The configuration object.\n * @returns {string} The processed code.\n */\nfunction processTypeScriptCode(code, options) {\n const { code: transformedCode, map } = parseTypeScript(code, options);\n\n if (map) {\n return addSourceMap(transformedCode, map);\n }\n\n if (options.filename) {\n return `${transformedCode}\\n\\n//# sourceURL=${options.filename}`;\n }\n\n return transformedCode;\n}\n\n/**\n * Performs type-stripping to TypeScript source code internally.\n * It is used by internal loaders.\n * @param {string} source TypeScript code to parse.\n * @param {string} filename The filename of the source code.\n * @returns {TransformOutput} The stripped TypeScript code.\n */\nfunction stripTypeScriptModuleTypes(source, filename) {\n assert(typeof source === 'string');\n if (isUnderNodeModules(filename)) {\n throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING(filename);\n }\n const options = {\n mode: getTypeScriptParsingMode(),\n sourceMap: getOptionValue('--enable-source-maps'),\n filename,\n };\n return processTypeScriptCode(source, options);\n}\n\n/**\n *\n * @param {string} code The compiled code.\n * @param {string} sourceMap The source map.\n * @returns {string} The code with the source map attached.\n */\nfunction addSourceMap(code, sourceMap) {\n // The base64 encoding should be https://datatracker.ietf.org/doc/html/rfc4648#section-4,\n // not base64url https://datatracker.ietf.org/doc/html/rfc4648#section-5. See data url\n // spec https://tools.ietf.org/html/rfc2397#section-2.\n const base64SourceMap = Buffer.from(sourceMap).toString('base64');\n return `${code}\\n\\n//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`;\n}\n\nmodule.exports = {\n stripTypeScriptModuleTypes,\n stripTypeScriptTypes,\n};\n";
831
832
  var EVENTS = "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nconst {\n ArrayPrototypeJoin,\n ArrayPrototypePop,\n ArrayPrototypePush,\n ArrayPrototypeSlice,\n ArrayPrototypeSplice,\n ArrayPrototypeUnshift,\n Boolean,\n Error,\n ErrorCaptureStackTrace,\n FunctionPrototypeBind,\n FunctionPrototypeCall,\n NumberMAX_SAFE_INTEGER,\n ObjectDefineProperties,\n ObjectDefineProperty,\n ObjectGetPrototypeOf,\n ObjectSetPrototypeOf,\n Promise,\n PromiseReject,\n PromiseResolve,\n ReflectApply,\n ReflectOwnKeys,\n String,\n StringPrototypeSplit,\n Symbol,\n SymbolAsyncIterator,\n SymbolFor,\n} = primordials;\nconst kRejection = SymbolFor('nodejs.rejection');\n\nconst { SymbolDispose, kEmptyObject, spliceOne } = require('internal/util');\n\nconst {\n inspect,\n identicalSequenceRange,\n} = require('internal/util/inspect');\n\nlet FixedQueue;\nlet kFirstEventParam;\nlet kResistStopPropagation;\n\nconst {\n AbortError,\n codes: {\n ERR_INVALID_ARG_TYPE,\n ERR_INVALID_THIS,\n ERR_UNHANDLED_ERROR,\n },\n genericNodeError,\n kEnhanceStackBeforeInspector,\n} = require('internal/errors');\n\nconst {\n validateInteger,\n validateAbortSignal,\n validateBoolean,\n validateFunction,\n validateNumber,\n validateObject,\n validateString,\n} = require('internal/validators');\nconst { addAbortListener } = require('internal/events/abort_listener');\n\nconst kCapture = Symbol('kCapture');\nconst kErrorMonitor = Symbol('events.errorMonitor');\nconst kShapeMode = Symbol('shapeMode');\nconst kMaxEventTargetListeners = Symbol('events.maxEventTargetListeners');\nconst kMaxEventTargetListenersWarned =\n Symbol('events.maxEventTargetListenersWarned');\nconst kWatermarkData = SymbolFor('nodejs.watermarkData');\n\nlet EventEmitterAsyncResource;\n// The EventEmitterAsyncResource has to be initialized lazily because event.js\n// is loaded so early in the bootstrap process, before async_hooks is available.\n//\n// This implementation was adapted straight from addaleax's\n// eventemitter-asyncresource MIT-licensed userland module.\n// https://github.com/addaleax/eventemitter-asyncresource\nfunction lazyEventEmitterAsyncResource() {\n if (EventEmitterAsyncResource === undefined) {\n const {\n AsyncResource,\n } = require('async_hooks');\n\n const kEventEmitter = Symbol('kEventEmitter');\n const kAsyncResource = Symbol('kAsyncResource');\n class EventEmitterReferencingAsyncResource extends AsyncResource {\n /**\n * @param {EventEmitter} ee\n * @param {string} [type]\n * @param {{\n * triggerAsyncId?: number,\n * requireManualDestroy?: boolean,\n * }} [options]\n */\n constructor(ee, type, options) {\n super(type, options);\n this[kEventEmitter] = ee;\n }\n\n /**\n * @type {EventEmitter}\n */\n get eventEmitter() {\n if (this[kEventEmitter] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterReferencingAsyncResource');\n return this[kEventEmitter];\n }\n }\n\n EventEmitterAsyncResource =\n class EventEmitterAsyncResource extends EventEmitter {\n /**\n * @param {{\n * name?: string,\n * triggerAsyncId?: number,\n * requireManualDestroy?: boolean,\n * }} [options]\n */\n constructor(options = undefined) {\n let name;\n if (typeof options === 'string') {\n name = options;\n options = undefined;\n } else {\n if (new.target === EventEmitterAsyncResource) {\n validateString(options?.name, 'options.name');\n }\n name = options?.name || new.target.name;\n }\n super(options);\n\n this[kAsyncResource] =\n new EventEmitterReferencingAsyncResource(this, name, options);\n }\n\n /**\n * @param {symbol,string} event\n * @param {...any} args\n * @returns {boolean}\n */\n emit(event, ...args) {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n const { asyncResource } = this;\n ArrayPrototypeUnshift(args, super.emit, this, event);\n return ReflectApply(asyncResource.runInAsyncScope, asyncResource,\n args);\n }\n\n /**\n * @returns {void}\n */\n emitDestroy() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n this.asyncResource.emitDestroy();\n }\n\n /**\n * @type {number}\n */\n get asyncId() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n return this.asyncResource.asyncId();\n }\n\n /**\n * @type {number}\n */\n get triggerAsyncId() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n return this.asyncResource.triggerAsyncId();\n }\n\n /**\n * @type {EventEmitterReferencingAsyncResource}\n */\n get asyncResource() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n return this[kAsyncResource];\n }\n };\n }\n return EventEmitterAsyncResource;\n}\n\n/**\n * Creates a new `EventEmitter` instance.\n * @param {{ captureRejections?: boolean; }} [opts]\n * @constructs {EventEmitter}\n */\nfunction EventEmitter(opts) {\n EventEmitter.init.call(this, opts);\n}\nmodule.exports = EventEmitter;\nmodule.exports.addAbortListener = addAbortListener;\nmodule.exports.once = once;\nmodule.exports.on = on;\nmodule.exports.getEventListeners = getEventListeners;\nmodule.exports.getMaxListeners = getMaxListeners;\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.usingDomains = false;\n\nEventEmitter.captureRejectionSymbol = kRejection;\nObjectDefineProperty(EventEmitter, 'captureRejections', {\n __proto__: null,\n get() {\n return EventEmitter.prototype[kCapture];\n },\n set(value) {\n validateBoolean(value, 'EventEmitter.captureRejections');\n\n EventEmitter.prototype[kCapture] = value;\n },\n enumerable: true,\n});\n\nObjectDefineProperty(EventEmitter, 'EventEmitterAsyncResource', {\n __proto__: null,\n enumerable: true,\n get: lazyEventEmitterAsyncResource,\n set: undefined,\n configurable: true,\n});\n\nEventEmitter.errorMonitor = kErrorMonitor;\n\n// The default for captureRejections is false\nObjectDefineProperty(EventEmitter.prototype, kCapture, {\n __proto__: null,\n value: false,\n writable: true,\n enumerable: false,\n});\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nlet defaultMaxListeners = 10;\nlet isEventTarget;\n\nfunction checkListener(listener) {\n validateFunction(listener, 'listener');\n}\n\nObjectDefineProperty(EventEmitter, 'defaultMaxListeners', {\n __proto__: null,\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n validateNumber(arg, 'defaultMaxListeners', 0);\n defaultMaxListeners = arg;\n },\n});\n\nObjectDefineProperties(EventEmitter, {\n kMaxEventTargetListeners: {\n __proto__: null,\n value: kMaxEventTargetListeners,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n kMaxEventTargetListenersWarned: {\n __proto__: null,\n value: kMaxEventTargetListenersWarned,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n});\n\n/**\n * Sets the max listeners.\n * @param {number} n\n * @param {EventTarget[] | EventEmitter[]} [eventTargets]\n * @returns {void}\n */\nEventEmitter.setMaxListeners =\n function(n = defaultMaxListeners, ...eventTargets) {\n validateNumber(n, 'setMaxListeners', 0);\n if (eventTargets.length === 0) {\n defaultMaxListeners = n;\n } else {\n if (isEventTarget === undefined)\n isEventTarget = require('internal/event_target').isEventTarget;\n\n for (let i = 0; i < eventTargets.length; i++) {\n const target = eventTargets[i];\n if (isEventTarget(target)) {\n target[kMaxEventTargetListeners] = n;\n target[kMaxEventTargetListenersWarned] = false;\n } else if (typeof target.setMaxListeners === 'function') {\n target.setMaxListeners(n);\n } else {\n throw new ERR_INVALID_ARG_TYPE(\n 'eventTargets',\n ['EventEmitter', 'EventTarget'],\n target);\n }\n }\n }\n };\n\n// If you're updating this function definition, please also update any\n// re-definitions, such as the one in the Domain module (lib/domain.js).\nEventEmitter.init = function(opts) {\n\n if (this._events === undefined ||\n this._events === ObjectGetPrototypeOf(this)._events) {\n this._events = { __proto__: null };\n this._eventsCount = 0;\n this[kShapeMode] = false;\n } else {\n this[kShapeMode] = true;\n }\n\n this._maxListeners ||= undefined;\n\n\n if (opts?.captureRejections) {\n validateBoolean(opts.captureRejections, 'options.captureRejections');\n this[kCapture] = Boolean(opts.captureRejections);\n } else {\n // Assigning the kCapture property directly saves an expensive\n // prototype lookup in a very sensitive hot path.\n this[kCapture] = EventEmitter.prototype[kCapture];\n }\n};\n\nfunction addCatch(that, promise, type, args) {\n if (!that[kCapture]) {\n return;\n }\n\n // Handle Promises/A+ spec, then could be a getter\n // that throws on second use.\n try {\n const then = promise.then;\n\n if (typeof then === 'function') {\n then.call(promise, undefined, function(err) {\n // The callback is called with nextTick to avoid a follow-up\n // rejection from this promise.\n process.nextTick(emitUnhandledRejectionOrErr, that, err, type, args);\n });\n }\n } catch (err) {\n that.emit('error', err);\n }\n}\n\nfunction emitUnhandledRejectionOrErr(ee, err, type, args) {\n if (typeof ee[kRejection] === 'function') {\n ee[kRejection](err, type, ...args);\n } else {\n // We have to disable the capture rejections mechanism, otherwise\n // we might end up in an infinite loop.\n const prev = ee[kCapture];\n\n // If the error handler throws, it is not catchable and it\n // will end up in 'uncaughtException'. We restore the previous\n // value of kCapture in case the uncaughtException is present\n // and the exception is handled.\n try {\n ee[kCapture] = false;\n ee.emit('error', err);\n } finally {\n ee[kCapture] = prev;\n }\n }\n}\n\n/**\n * Increases the max listeners of the event emitter.\n * @param {number} n\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n validateNumber(n, 'setMaxListeners', 0);\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\n/**\n * Returns the current max listener value for the event emitter.\n * @returns {number}\n */\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nfunction enhanceStackTrace(err, own) {\n let ctorInfo = '';\n try {\n const { name } = this.constructor;\n if (name !== 'EventEmitter')\n ctorInfo = ` on ${name} instance`;\n } catch {\n // Continue regardless of error.\n }\n const sep = `\\nEmitted 'error' event${ctorInfo} at:\\n`;\n\n const errStack = ArrayPrototypeSlice(\n StringPrototypeSplit(err.stack, '\\n'), 1);\n const ownStack = ArrayPrototypeSlice(\n StringPrototypeSplit(own.stack, '\\n'), 1);\n\n const { len, offset } = identicalSequenceRange(ownStack, errStack);\n if (len > 0) {\n ArrayPrototypeSplice(ownStack, offset + 1, len - 2,\n ' [... lines matching original stack trace ...]');\n }\n\n return err.stack + sep + ArrayPrototypeJoin(ownStack, '\\n');\n}\n\n/**\n * Synchronously calls each of the listeners registered\n * for the event.\n * @param {string | symbol} type\n * @param {...any} [args]\n * @returns {boolean}\n */\nEventEmitter.prototype.emit = function emit(type, ...args) {\n let doError = (type === 'error');\n\n const events = this._events;\n if (events !== undefined) {\n if (doError && events[kErrorMonitor] !== undefined)\n this.emit(kErrorMonitor, ...args);\n doError &&= events.error === undefined;\n } else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n let er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n try {\n const capture = {};\n ErrorCaptureStackTrace(capture, EventEmitter.prototype.emit);\n ObjectDefineProperty(er, kEnhanceStackBeforeInspector, {\n __proto__: null,\n value: FunctionPrototypeBind(enhanceStackTrace, this, er, capture),\n configurable: true,\n });\n } catch {\n // Continue regardless of error.\n }\n\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n\n let stringifiedEr;\n try {\n stringifiedEr = inspect(er);\n } catch {\n stringifiedEr = er;\n }\n\n // At least give some kind of context to the user\n const err = new ERR_UNHANDLED_ERROR(stringifiedEr);\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n const handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n const result = handler.apply(this, args);\n\n // We check if result is undefined first because that\n // is the most common case so we do not pay any perf\n // penalty\n if (result !== undefined && result !== null) {\n addCatch(this, result, type, args);\n }\n } else {\n const len = handler.length;\n const listeners = arrayClone(handler);\n for (let i = 0; i < len; ++i) {\n const result = listeners[i].apply(this, args);\n\n // We check if result is undefined first because that\n // is the most common case so we do not pay any perf\n // penalty.\n // This code is duplicated because extracting it away\n // would make it non-inlineable.\n if (result !== undefined && result !== null) {\n addCatch(this, result, type, args);\n }\n }\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n let m;\n let events;\n let existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = { __proto__: null };\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ?? listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n const w = genericNodeError(\n `Possible EventEmitter memory leak detected. ${existing.length} ${String(type)} listeners ` +\n `added to ${inspect(target, { depth: -1 })}. MaxListeners is ${m}. Use emitter.setMaxListeners() to increase limit`,\n { name: 'MaxListenersExceededWarning', emitter: target, type: type, count: existing.length });\n process.emitWarning(w);\n }\n }\n\n return target;\n}\n\n/**\n * Adds a listener to the event emitter.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\n/**\n * Adds the `listener` function to the beginning of\n * the listeners array.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n const state = { fired: false, wrapFn: undefined, target, type, listener };\n const wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\n/**\n * Adds a one-time `listener` function to the event emitter.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\n/**\n * Adds a one-time `listener` function to the beginning of\n * the listeners array.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n/**\n * Removes the specified `listener` from the listeners array.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n checkListener(listener);\n\n const events = this._events;\n if (events === undefined)\n return this;\n\n const list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n this._eventsCount -= 1;\n\n if (this[kShapeMode]) {\n events[type] = undefined;\n } else if (this._eventsCount === 0) {\n this._events = { __proto__: null };\n } else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n let position = -1;\n\n for (let i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\n/**\n * Removes all listeners from the event emitter. (Only\n * removes listeners for a specific event name if specified\n * as `type`).\n * @param {string | symbol} [type]\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n const events = this._events;\n if (events === undefined)\n return this;\n\n // Not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = { __proto__: null };\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = { __proto__: null };\n else\n delete events[type];\n }\n this[kShapeMode] = false;\n return this;\n }\n\n // Emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (const key of ReflectOwnKeys(events)) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = { __proto__: null };\n this._eventsCount = 0;\n this[kShapeMode] = false;\n return this;\n }\n\n const listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (let i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n const events = target._events;\n\n if (events === undefined)\n return [];\n\n const evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener);\n}\n\n/**\n * Returns a copy of the array of listeners for the event name\n * specified as `type`.\n * @param {string | symbol} type\n * @returns {Function[]}\n */\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\n/**\n * Returns a copy of the array of listeners and wrappers for\n * the event name specified as `type`.\n * @param {string | symbol} type\n * @returns {Function[]}\n */\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\n/**\n * Returns the number of listeners listening to the event name\n * specified as `type`.\n * @deprecated since v3.2.0\n * @param {EventEmitter} emitter\n * @param {string | symbol} type\n * @returns {number}\n */\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n }\n return FunctionPrototypeCall(listenerCount, emitter, type);\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\n\n/**\n * Returns the number of listeners listening to event name\n * specified as `type`.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {number}\n */\nfunction listenerCount(type, listener) {\n const events = this._events;\n\n if (events !== undefined) {\n const evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n if (listener != null) {\n return listener === evlistener || listener === evlistener.listener ? 1 : 0;\n }\n\n return 1;\n } else if (evlistener !== undefined) {\n if (listener != null) {\n let matching = 0;\n\n for (let i = 0, l = evlistener.length; i < l; i++) {\n if (evlistener[i] === listener || evlistener[i].listener === listener) {\n matching++;\n }\n }\n\n return matching;\n }\n\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\n/**\n * Returns an array listing the events for which\n * the emitter has registered listeners.\n * @returns {(string | symbol)[]}\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr) {\n // At least since V8 8.3, this implementation is faster than the previous\n // which always used a simple for-loop\n switch (arr.length) {\n case 2: return [arr[0], arr[1]];\n case 3: return [arr[0], arr[1], arr[2]];\n case 4: return [arr[0], arr[1], arr[2], arr[3]];\n case 5: return [arr[0], arr[1], arr[2], arr[3], arr[4]];\n case 6: return [arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]];\n }\n return ArrayPrototypeSlice(arr);\n}\n\nfunction unwrapListeners(arr) {\n const ret = arrayClone(arr);\n for (let i = 0; i < ret.length; ++i) {\n const orig = ret[i].listener;\n if (typeof orig === 'function')\n ret[i] = orig;\n }\n return ret;\n}\n\n/**\n * Returns a copy of the array of listeners for the event name\n * specified as `type`.\n * @param {EventEmitter | EventTarget} emitterOrTarget\n * @param {string | symbol} type\n * @returns {Function[]}\n */\nfunction getEventListeners(emitterOrTarget, type) {\n // First check if EventEmitter\n if (typeof emitterOrTarget.listeners === 'function') {\n return emitterOrTarget.listeners(type);\n }\n // Require event target lazily to avoid always loading it\n const { isEventTarget, kEvents } = require('internal/event_target');\n if (isEventTarget(emitterOrTarget)) {\n const root = emitterOrTarget[kEvents].get(type);\n const listeners = [];\n let handler = root?.next;\n while (handler?.listener !== undefined) {\n const listener = handler.listener?.deref ?\n handler.listener.deref() : handler.listener;\n listeners.push(listener);\n handler = handler.next;\n }\n return listeners;\n }\n throw new ERR_INVALID_ARG_TYPE('emitter',\n ['EventEmitter', 'EventTarget'],\n emitterOrTarget);\n}\n\n/**\n * Returns the max listeners set.\n * @param {EventEmitter | EventTarget} emitterOrTarget\n * @returns {number}\n */\nfunction getMaxListeners(emitterOrTarget) {\n if (typeof emitterOrTarget?.getMaxListeners === 'function') {\n return _getMaxListeners(emitterOrTarget);\n } else if (typeof emitterOrTarget?.[kMaxEventTargetListeners] === 'number') {\n return emitterOrTarget[kMaxEventTargetListeners];\n }\n\n throw new ERR_INVALID_ARG_TYPE('emitter',\n ['EventEmitter', 'EventTarget'],\n emitterOrTarget);\n}\n\n/**\n * Creates a `Promise` that is fulfilled when the emitter\n * emits the given event.\n * @param {EventEmitter} emitter\n * @param {string | symbol} name\n * @param {{ signal: AbortSignal; }} [options]\n * @returns {Promise}\n */\nasync function once(emitter, name, options = kEmptyObject) {\n validateObject(options, 'options');\n const { signal } = options;\n validateAbortSignal(signal, 'options.signal');\n if (signal?.aborted)\n throw new AbortError(undefined, { cause: signal.reason });\n return new Promise((resolve, reject) => {\n const errorListener = (err) => {\n emitter.removeListener(name, resolver);\n if (signal != null) {\n eventTargetAgnosticRemoveListener(signal, 'abort', abortListener);\n }\n reject(err);\n };\n const resolver = (...args) => {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n if (signal != null) {\n eventTargetAgnosticRemoveListener(signal, 'abort', abortListener);\n }\n resolve(args);\n };\n\n kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation;\n const opts = { __proto__: null, once: true, [kResistStopPropagation]: true };\n eventTargetAgnosticAddListener(emitter, name, resolver, opts);\n if (name !== 'error' && typeof emitter.once === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we listen to `error` events only on EventEmitters.\n emitter.once('error', errorListener);\n }\n function abortListener() {\n eventTargetAgnosticRemoveListener(emitter, name, resolver);\n eventTargetAgnosticRemoveListener(emitter, 'error', errorListener);\n reject(new AbortError(undefined, { cause: signal?.reason }));\n }\n if (signal != null) {\n eventTargetAgnosticAddListener(\n signal, 'abort', abortListener, { __proto__: null, once: true, [kResistStopPropagation]: true });\n }\n });\n}\n\nconst AsyncIteratorPrototype = ObjectGetPrototypeOf(\n ObjectGetPrototypeOf(async function* () {}).prototype);\n\nfunction createIterResult(value, done) {\n return { value, done };\n}\n\nfunction eventTargetAgnosticRemoveListener(emitter, name, listener, flags) {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener(name, listener);\n } else if (typeof emitter.removeEventListener === 'function') {\n emitter.removeEventListener(name, listener, flags);\n } else {\n throw new ERR_INVALID_ARG_TYPE('emitter', 'EventEmitter', emitter);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags?.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n emitter.addEventListener(name, listener, flags);\n } else {\n throw new ERR_INVALID_ARG_TYPE('emitter', 'EventEmitter', emitter);\n }\n}\n\n/**\n * Returns an `AsyncIterator` that iterates `event` events.\n * @param {EventEmitter} emitter\n * @param {string | symbol} event\n * @param {{\n * signal: AbortSignal;\n * close?: string[];\n * highWaterMark?: number,\n * lowWaterMark?: number\n * }} [options]\n * @returns {AsyncIterator}\n */\nfunction on(emitter, event, options = kEmptyObject) {\n // Parameters validation\n validateObject(options, 'options');\n const signal = options.signal;\n validateAbortSignal(signal, 'options.signal');\n if (signal?.aborted)\n throw new AbortError(undefined, { cause: signal.reason });\n // Support both highWaterMark and highWatermark for backward compatibility\n const highWatermark = options.highWaterMark ?? options.highWatermark ?? NumberMAX_SAFE_INTEGER;\n validateInteger(highWatermark, 'options.highWaterMark', 1);\n // Support both lowWaterMark and lowWatermark for backward compatibility\n const lowWatermark = options.lowWaterMark ?? options.lowWatermark ?? 1;\n validateInteger(lowWatermark, 'options.lowWaterMark', 1);\n\n // Preparing controlling queues and variables\n FixedQueue ??= require('internal/fixed_queue');\n const unconsumedEvents = new FixedQueue();\n const unconsumedPromises = new FixedQueue();\n let paused = false;\n let error = null;\n let finished = false;\n let size = 0;\n\n const iterator = ObjectSetPrototypeOf({\n next() {\n // First, we consume all unread events\n if (size) {\n const value = unconsumedEvents.shift();\n size--;\n if (paused && size < lowWatermark) {\n emitter.resume();\n paused = false;\n }\n return PromiseResolve(createIterResult(value, false));\n }\n\n // Then we error, if an error happened\n // This happens one time if at all, because after 'error'\n // we stop listening\n if (error) {\n const p = PromiseReject(error);\n // Only the first element errors\n error = null;\n return p;\n }\n\n // If the iterator is finished, resolve to done\n if (finished) return closeHandler();\n\n // Wait until an event happens\n return new Promise(function(resolve, reject) {\n unconsumedPromises.push({ resolve, reject });\n });\n },\n\n return() {\n return closeHandler();\n },\n\n throw(err) {\n if (!err || !(err instanceof Error)) {\n throw new ERR_INVALID_ARG_TYPE('EventEmitter.AsyncIterator',\n 'Error', err);\n }\n errorHandler(err);\n },\n [SymbolAsyncIterator]() {\n return this;\n },\n [kWatermarkData]: {\n /**\n * The current queue size\n */\n get size() {\n return size;\n },\n /**\n * The low watermark. The emitter is resumed every time size is lower than it\n */\n get low() {\n return lowWatermark;\n },\n /**\n * The high watermark. The emitter is paused every time size is higher than it\n */\n get high() {\n return highWatermark;\n },\n /**\n * It checks whether the emitter is paused by the watermark controller or not\n */\n get isPaused() {\n return paused;\n },\n },\n }, AsyncIteratorPrototype);\n\n // Adding event handlers\n const { addEventListener, removeAll } = listenersController();\n kFirstEventParam ??= require('internal/events/symbols').kFirstEventParam;\n addEventListener(emitter, event, options[kFirstEventParam] ? eventHandler : function(...args) {\n return eventHandler(args);\n });\n if (event !== 'error' && typeof emitter.on === 'function') {\n addEventListener(emitter, 'error', errorHandler);\n }\n const closeEvents = options?.close;\n if (closeEvents?.length) {\n for (let i = 0; i < closeEvents.length; i++) {\n addEventListener(emitter, closeEvents[i], closeHandler);\n }\n }\n\n const abortListenerDisposable = signal ? addAbortListener(signal, abortListener) : null;\n\n return iterator;\n\n function abortListener() {\n errorHandler(new AbortError(undefined, { cause: signal?.reason }));\n }\n\n function eventHandler(value) {\n if (unconsumedPromises.isEmpty()) {\n size++;\n if (!paused && size > highWatermark) {\n paused = true;\n emitter.pause();\n }\n unconsumedEvents.push(value);\n } else unconsumedPromises.shift().resolve(createIterResult(value, false));\n }\n\n function errorHandler(err) {\n if (unconsumedPromises.isEmpty()) error = err;\n else unconsumedPromises.shift().reject(err);\n\n closeHandler();\n }\n\n function closeHandler() {\n abortListenerDisposable?.[SymbolDispose]();\n removeAll();\n finished = true;\n const doneResult = createIterResult(undefined, true);\n while (!unconsumedPromises.isEmpty()) {\n unconsumedPromises.shift().resolve(doneResult);\n }\n\n return PromiseResolve(doneResult);\n }\n}\n\nfunction listenersController() {\n const listeners = [];\n\n return {\n addEventListener(emitter, event, handler, flags) {\n eventTargetAgnosticAddListener(emitter, event, handler, flags);\n ArrayPrototypePush(listeners, [emitter, event, handler, flags]);\n },\n removeAll() {\n while (listeners.length > 0) {\n ReflectApply(eventTargetAgnosticRemoveListener, undefined, ArrayPrototypePop(listeners));\n }\n },\n };\n}\n";
832
833
  var INTERNAL_CONSTANTS = "'use strict';\n\nconst isWindows = process.platform === 'win32';\n\nmodule.exports = {\n // Alphabet chars.\n CHAR_UPPERCASE_A: 65, /* A */\n CHAR_LOWERCASE_A: 97, /* a */\n CHAR_UPPERCASE_Z: 90, /* Z */\n CHAR_LOWERCASE_Z: 122, /* z */\n CHAR_UPPERCASE_C: 67, /* C */\n CHAR_LOWERCASE_B: 98, /* b */\n CHAR_LOWERCASE_E: 101, /* e */\n CHAR_LOWERCASE_N: 110, /* n */\n\n // Non-alphabetic chars.\n CHAR_DOT: 46, /* . */\n CHAR_FORWARD_SLASH: 47, /* / */\n CHAR_BACKWARD_SLASH: 92, /* \\ */\n CHAR_VERTICAL_LINE: 124, /* | */\n CHAR_COLON: 58, /* : */\n CHAR_QUESTION_MARK: 63, /* ? */\n CHAR_UNDERSCORE: 95, /* _ */\n CHAR_LINE_FEED: 10, /* \\n */\n CHAR_CARRIAGE_RETURN: 13, /* \\r */\n CHAR_TAB: 9, /* \\t */\n CHAR_FORM_FEED: 12, /* \\f */\n CHAR_EXCLAMATION_MARK: 33, /* ! */\n CHAR_HASH: 35, /* # */\n CHAR_SPACE: 32, /* */\n CHAR_NO_BREAK_SPACE: 160, /* \\u00A0 */\n CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \\uFEFF */\n CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */\n CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */\n CHAR_LEFT_ANGLE_BRACKET: 60, /* < */\n CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */\n CHAR_LEFT_CURLY_BRACKET: 123, /* { */\n CHAR_RIGHT_CURLY_BRACKET: 125, /* } */\n CHAR_HYPHEN_MINUS: 45, /* - */\n CHAR_PLUS: 43, /* + */\n CHAR_DOUBLE_QUOTE: 34, /* \" */\n CHAR_SINGLE_QUOTE: 39, /* ' */\n CHAR_PERCENT: 37, /* % */\n CHAR_SEMICOLON: 59, /* ; */\n CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */\n CHAR_GRAVE_ACCENT: 96, /* ` */\n CHAR_AT: 64, /* @ */\n CHAR_AMPERSAND: 38, /* & */\n CHAR_EQUAL: 61, /* = */\n\n // Digits\n CHAR_0: 48, /* 0 */\n CHAR_9: 57, /* 9 */\n\n EOL: isWindows ? '\\r\\n' : '\\n',\n};\n";
833
834
  var INTERNAL_MIME = "'use strict';\n\nconst {\n FunctionPrototypeCall,\n ObjectDefineProperty,\n RegExpPrototypeExec,\n SafeMap,\n SafeStringPrototypeSearch,\n StringPrototypeCharAt,\n StringPrototypeIndexOf,\n StringPrototypeSlice,\n StringPrototypeToLowerCase,\n SymbolIterator,\n} = primordials;\nconst {\n ERR_INVALID_MIME_SYNTAX,\n} = require('internal/errors').codes;\n\nconst NOT_HTTP_TOKEN_CODE_POINT = /[^!#$%&'*+\\-.^_`|~A-Za-z0-9]/g;\nconst NOT_HTTP_QUOTED_STRING_CODE_POINT = /[^\\t\\u0020-~\\u0080-\\u00FF]/g;\n\nconst END_BEGINNING_WHITESPACE = /[^\\r\\n\\t ]|$/;\nconst START_ENDING_WHITESPACE = /[\\r\\n\\t ]*$/;\n\nfunction toASCIILower(str) {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n result += char >= 'A' && char <= 'Z' ?\n StringPrototypeToLowerCase(char) :\n char;\n }\n return result;\n}\n\nconst SOLIDUS = '/';\nconst SEMICOLON = ';';\n\nfunction parseTypeAndSubtype(str) {\n // Skip only HTTP whitespace from start\n let position = SafeStringPrototypeSearch(str, END_BEGINNING_WHITESPACE);\n // read until '/'\n const typeEnd = StringPrototypeIndexOf(str, SOLIDUS, position);\n const trimmedType = typeEnd === -1 ?\n StringPrototypeSlice(str, position) :\n StringPrototypeSlice(str, position, typeEnd);\n const invalidTypeIndex = SafeStringPrototypeSearch(trimmedType,\n NOT_HTTP_TOKEN_CODE_POINT);\n if (trimmedType === '' || invalidTypeIndex !== -1 || typeEnd === -1) {\n throw new ERR_INVALID_MIME_SYNTAX('type', str, invalidTypeIndex);\n }\n // skip type and '/'\n position = typeEnd + 1;\n const type = toASCIILower(trimmedType);\n // read until ';'\n const subtypeEnd = StringPrototypeIndexOf(str, SEMICOLON, position);\n const rawSubtype = subtypeEnd === -1 ?\n StringPrototypeSlice(str, position) :\n StringPrototypeSlice(str, position, subtypeEnd);\n position += rawSubtype.length;\n if (subtypeEnd !== -1) {\n // skip ';'\n position += 1;\n }\n const trimmedSubtype = StringPrototypeSlice(\n rawSubtype,\n 0,\n SafeStringPrototypeSearch(rawSubtype, START_ENDING_WHITESPACE));\n const invalidSubtypeIndex = SafeStringPrototypeSearch(trimmedSubtype,\n NOT_HTTP_TOKEN_CODE_POINT);\n if (trimmedSubtype === '' || invalidSubtypeIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX('subtype', str, invalidSubtypeIndex);\n }\n const subtype = toASCIILower(trimmedSubtype);\n return [\n type,\n subtype,\n position,\n ];\n}\n\nconst EQUALS_SEMICOLON_OR_END = /[;=]|$/;\nconst QUOTED_VALUE_PATTERN = /^(?:([\\\\]$)|[\\\\][\\s\\S]|[^\"])*(?:(\")|$)/u;\n\nfunction removeBackslashes(str) {\n let ret = '';\n // We stop at str.length - 1 because we want to look ahead one character.\n let i;\n for (i = 0; i < str.length - 1; i++) {\n const c = str[i];\n if (c === '\\\\') {\n i++;\n ret += str[i];\n } else {\n ret += c;\n }\n }\n // We add the last character if we didn't skip to it.\n if (i === str.length - 1) {\n ret += str[i];\n }\n return ret;\n}\n\n\nfunction escapeQuoteOrSolidus(str) {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n result += (char === '\"' || char === '\\\\') ? `\\\\${char}` : char;\n }\n return result;\n}\n\nconst encode = (value) => {\n if (value.length === 0) return '\"\"';\n const encode = SafeStringPrototypeSearch(value, NOT_HTTP_TOKEN_CODE_POINT) !== -1;\n if (!encode) return value;\n const escaped = escapeQuoteOrSolidus(value);\n return `\"${escaped}\"`;\n};\n\nclass MIMEParams {\n #data = new SafeMap();\n // We set the flag the MIMEParams instance as processed on initialization\n // to defer the parsing of a potentially large string.\n #processed = true;\n #string = null;\n\n /**\n * Used to instantiate a MIMEParams object within the MIMEType class and\n * to allow it to be parsed lazily.\n */\n static instantiateMimeParams(str) {\n const instance = new MIMEParams();\n instance.#string = str;\n instance.#processed = false;\n return instance;\n }\n\n delete(name) {\n this.#parse();\n this.#data.delete(name);\n }\n\n get(name) {\n this.#parse();\n const data = this.#data;\n if (data.has(name)) {\n return data.get(name);\n }\n return null;\n }\n\n has(name) {\n this.#parse();\n return this.#data.has(name);\n }\n\n set(name, value) {\n this.#parse();\n const data = this.#data;\n name = `${name}`;\n value = `${value}`;\n const invalidNameIndex = SafeStringPrototypeSearch(name, NOT_HTTP_TOKEN_CODE_POINT);\n if (name.length === 0 || invalidNameIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX(\n 'parameter name',\n name,\n invalidNameIndex,\n );\n }\n const invalidValueIndex = SafeStringPrototypeSearch(\n value,\n NOT_HTTP_QUOTED_STRING_CODE_POINT);\n if (invalidValueIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX(\n 'parameter value',\n value,\n invalidValueIndex,\n );\n }\n data.set(name, value);\n }\n\n *entries() {\n this.#parse();\n yield* this.#data.entries();\n }\n\n *keys() {\n this.#parse();\n yield* this.#data.keys();\n }\n\n *values() {\n this.#parse();\n yield* this.#data.values();\n }\n\n toString() {\n this.#parse();\n let ret = '';\n for (const { 0: key, 1: value } of this.#data) {\n const encoded = encode(value);\n // Ensure they are separated\n if (ret.length) ret += ';';\n ret += `${key}=${encoded}`;\n }\n return ret;\n }\n\n // Used to act as a friendly class to stringifying stuff\n // not meant to be exposed to users, could inject invalid values\n #parse() {\n if (this.#processed) return; // already parsed\n const paramsMap = this.#data;\n let position = 0;\n const str = this.#string;\n const endOfSource = SafeStringPrototypeSearch(\n StringPrototypeSlice(str, position),\n START_ENDING_WHITESPACE,\n ) + position;\n while (position < endOfSource) {\n // Skip any whitespace before parameter\n position += SafeStringPrototypeSearch(\n StringPrototypeSlice(str, position),\n END_BEGINNING_WHITESPACE,\n );\n // Read until ';' or '='\n const afterParameterName = SafeStringPrototypeSearch(\n StringPrototypeSlice(str, position),\n EQUALS_SEMICOLON_OR_END,\n ) + position;\n const parameterString = toASCIILower(\n StringPrototypeSlice(str, position, afterParameterName),\n );\n position = afterParameterName;\n // If we found a terminating character\n if (position < endOfSource) {\n // Safe to use because we never do special actions for surrogate pairs\n const char = StringPrototypeCharAt(str, position);\n // Skip the terminating character\n position += 1;\n // Ignore parameters without values\n if (char === ';') {\n continue;\n }\n }\n // If we are at end of the string, it cannot have a value\n if (position >= endOfSource) break;\n // Safe to use because we never do special actions for surrogate pairs\n const char = StringPrototypeCharAt(str, position);\n let parameterValue = null;\n if (char === '\"') {\n // Handle quoted-string form of values\n // skip '\"'\n position += 1;\n // Find matching closing '\"' or end of string\n // use $1 to see if we terminated on unmatched '\\'\n // use $2 to see if we terminated on a matching '\"'\n // so we can skip the last char in either case\n const insideMatch = RegExpPrototypeExec(\n QUOTED_VALUE_PATTERN,\n StringPrototypeSlice(str, position));\n position += insideMatch[0].length;\n // Skip including last character if an unmatched '\\' or '\"' during\n // unescape\n const inside = insideMatch[1] || insideMatch[2] ?\n StringPrototypeSlice(insideMatch[0], 0, -1) :\n insideMatch[0];\n // Unescape '\\' quoted characters\n parameterValue = removeBackslashes(inside);\n // If we did have an unmatched '\\' add it back to the end\n if (insideMatch[1]) parameterValue += '\\\\';\n } else {\n // Handle the normal parameter value form\n const valueEnd = StringPrototypeIndexOf(str, SEMICOLON, position);\n const rawValue = valueEnd === -1 ?\n StringPrototypeSlice(str, position) :\n StringPrototypeSlice(str, position, valueEnd);\n position += rawValue.length;\n const trimmedValue = StringPrototypeSlice(\n rawValue,\n 0,\n SafeStringPrototypeSearch(rawValue, START_ENDING_WHITESPACE),\n );\n // Ignore parameters without values\n if (trimmedValue === '') continue;\n parameterValue = trimmedValue;\n }\n if (\n parameterString !== '' &&\n SafeStringPrototypeSearch(parameterString,\n NOT_HTTP_TOKEN_CODE_POINT) === -1 &&\n SafeStringPrototypeSearch(parameterValue,\n NOT_HTTP_QUOTED_STRING_CODE_POINT) === -1 &&\n paramsMap.has(parameterString) === false\n ) {\n paramsMap.set(parameterString, parameterValue);\n }\n position++;\n }\n this.#data = paramsMap;\n this.#processed = true;\n }\n}\nconst MIMEParamsStringify = MIMEParams.prototype.toString;\nObjectDefineProperty(MIMEParams.prototype, SymbolIterator, {\n __proto__: null,\n configurable: true,\n value: MIMEParams.prototype.entries,\n writable: true,\n});\nObjectDefineProperty(MIMEParams.prototype, 'toJSON', {\n __proto__: null,\n configurable: true,\n value: MIMEParamsStringify,\n writable: true,\n});\n\nconst { instantiateMimeParams } = MIMEParams;\ndelete MIMEParams.instantiateMimeParams;\n\nclass MIMEType {\n #type;\n #subtype;\n #parameters;\n constructor(string) {\n string = `${string}`;\n const data = parseTypeAndSubtype(string);\n this.#type = data[0];\n this.#subtype = data[1];\n this.#parameters = instantiateMimeParams(StringPrototypeSlice(string, data[2]));\n }\n\n get type() {\n return this.#type;\n }\n\n set type(v) {\n v = `${v}`;\n const invalidTypeIndex = SafeStringPrototypeSearch(v, NOT_HTTP_TOKEN_CODE_POINT);\n if (v.length === 0 || invalidTypeIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX('type', v, invalidTypeIndex);\n }\n this.#type = toASCIILower(v);\n }\n\n get subtype() {\n return this.#subtype;\n }\n\n set subtype(v) {\n v = `${v}`;\n const invalidSubtypeIndex = SafeStringPrototypeSearch(v, NOT_HTTP_TOKEN_CODE_POINT);\n if (v.length === 0 || invalidSubtypeIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX('subtype', v, invalidSubtypeIndex);\n }\n this.#subtype = toASCIILower(v);\n }\n\n get essence() {\n return `${this.#type}/${this.#subtype}`;\n }\n\n get params() {\n return this.#parameters;\n }\n\n toString() {\n let ret = `${this.#type}/${this.#subtype}`;\n const paramStr = FunctionPrototypeCall(MIMEParamsStringify, this.#parameters);\n if (paramStr.length) ret += `;${paramStr}`;\n return ret;\n }\n}\nObjectDefineProperty(MIMEType.prototype, 'toJSON', {\n __proto__: null,\n configurable: true,\n value: MIMEType.prototype.toString,\n writable: true,\n});\n\nmodule.exports = {\n MIMEParams,\n MIMEType,\n};\n";
@@ -4785,6 +4786,7 @@ const NODE_LIB_SOURCES = {
4785
4786
  "internal/events/abort_listener": INTERNAL_ABORT_LISTENER,
4786
4787
  "internal/child_process/serialization": INTERNAL_CHILD_PROCESS_SERIALIZATION,
4787
4788
  "internal/modules/customization_hooks": INTERNAL_MODULES_CUSTOMIZATION_HOOKS,
4789
+ "internal/modules/typescript": INTERNAL_MODULES_TYPESCRIPT,
4788
4790
  "events": EVENTS,
4789
4791
  "internal/constants": INTERNAL_CONSTANTS,
4790
4792
  "internal/mime": INTERNAL_MIME,
@@ -5171,10 +5173,21 @@ const optionValues = {
5171
5173
  "--experimental-print-required-tla": false,
5172
5174
  "--max-http-header-size": 16 * 1024,
5173
5175
  "--insecure-http-parser": false,
5174
- "--enable-source-maps": false
5176
+ "--enable-source-maps": false,
5177
+ "--experimental-transform-types": false
5175
5178
  };
5179
+ let optionOverrides = null;
5180
+ function withOptionValues(overrides, fn2) {
5181
+ const previous = optionOverrides;
5182
+ optionOverrides = { ...previous ?? {}, ...overrides };
5183
+ try {
5184
+ return fn2();
5185
+ } finally {
5186
+ optionOverrides = previous;
5187
+ }
5188
+ }
5176
5189
  const internalOptions = {
5177
- getOptionValue: (name) => optionValues[name],
5190
+ getOptionValue: (name) => optionOverrides !== null && name in optionOverrides ? optionOverrides[name] : optionValues[name],
5178
5191
  getEmbedderOptions: () => ({ shouldNotRegisterESMLoader: false, noGlobalSearchPaths: false, noBrowserGlobals: false })
5179
5192
  };
5180
5193
  const internalPerfObserve = {
@@ -5925,6 +5938,26 @@ const internalEncoding = {
5925
5938
  return globalThis.TextEncoder;
5926
5939
  }
5927
5940
  };
5941
+ const hostProcess$1 = typeof process !== "undefined" && process !== null ? process : null;
5942
+ let loaded;
5943
+ function hostAmaro() {
5944
+ if (loaded !== void 0) return loaded;
5945
+ loaded = null;
5946
+ try {
5947
+ const moduleBuiltin = typeof (hostProcess$1 == null ? void 0 : hostProcess$1.getBuiltinModule) === "function" ? hostProcess$1.getBuiltinModule("module") : void 0;
5948
+ if (moduleBuiltin && typeof moduleBuiltin.createRequire === "function") {
5949
+ const amaro = moduleBuiltin.createRequire(import.meta.url)("amaro");
5950
+ if (typeof (amaro == null ? void 0 : amaro.transformSync) === "function") loaded = amaro;
5951
+ }
5952
+ } catch {
5953
+ }
5954
+ return loaded;
5955
+ }
5956
+ function internalAmaro() {
5957
+ const amaro = hostAmaro();
5958
+ if (amaro) return amaro;
5959
+ throw Object.assign(new Error("Node.js is not compiled with TypeScript support"), { code: "ERR_NO_TYPESCRIPT" });
5960
+ }
5928
5961
  var __table$2;
5929
5962
  function nodeLibInternal(name, require2, process2) {
5930
5963
  if (require2 && name === "internal/webstreams/adapters") return () => createWebStreamsAdapters(require2);
@@ -5973,6 +6006,7 @@ function nodeLibInternal(name, require2, process2) {
5973
6006
  "internal/process/warning": () => internalProcessWarning,
5974
6007
  "internal/source_map/source_map_cache": () => internalSourceMapCache,
5975
6008
  "internal/deps/undici/undici": () => internalUndici,
6009
+ "internal/deps/amaro/dist/index": () => internalAmaro(),
5976
6010
  "internal/readline/interface": () => internalReadlineInterface,
5977
6011
  "internal/worker/js_transferable": () => internalJsTransferable
5978
6012
  });
@@ -6793,6 +6827,18 @@ function __stopOwnedProcess(token) {
6793
6827
  var _a3;
6794
6828
  (_a3 = runs.get(token)) == null ? void 0 : _a3.stopTimers();
6795
6829
  }
6830
+ function __signalOwnedProcess(token, signal) {
6831
+ const run = runs.get(token);
6832
+ if (!run) return false;
6833
+ const guest = run.process;
6834
+ try {
6835
+ enterRun(token, () => guest.kill(guest.pid, signal));
6836
+ } catch (error) {
6837
+ if (error instanceof Error && error.message.startsWith("Process exited with code")) return true;
6838
+ return false;
6839
+ }
6840
+ return true;
6841
+ }
6796
6842
  const processRegistryOwner = createProcessRegistryOwner();
6797
6843
  let processRegistry = processRegistryOwner.createScope();
6798
6844
  const pidsOfRuns = /* @__PURE__ */ new Map();
@@ -6810,6 +6856,10 @@ function forgetRunPid(token) {
6810
6856
  processRegistry.forget(token);
6811
6857
  pidsOfRuns.delete(token);
6812
6858
  }
6859
+ function tokenOfPid(pid) {
6860
+ for (const [token, numbers] of pidsOfRuns) if (numbers.pid === pid) return token;
6861
+ return null;
6862
+ }
6813
6863
  function pidIsLive(pid) {
6814
6864
  return processRegistry.lookup(pid) !== void 0;
6815
6865
  }
@@ -11388,7 +11438,7 @@ const updatewindow$1 = (strm, src, end, copy2) => {
11388
11438
  }
11389
11439
  return 0;
11390
11440
  };
11391
- const inflate$3 = (strm, flush) => {
11441
+ const inflate$3 = (strm, flush2) => {
11392
11442
  let state;
11393
11443
  let input, output;
11394
11444
  let next2;
@@ -11726,7 +11776,7 @@ const inflate$3 = (strm, flush) => {
11726
11776
  strm.adler = state.check = 1;
11727
11777
  state.mode = TYPE$2;
11728
11778
  case TYPE$2:
11729
- if (flush === Z_BLOCK$3 || flush === Z_TREES$1) {
11779
+ if (flush2 === Z_BLOCK$3 || flush2 === Z_TREES$1) {
11730
11780
  break inf_leave;
11731
11781
  }
11732
11782
  case TYPEDO$1:
@@ -11754,7 +11804,7 @@ const inflate$3 = (strm, flush) => {
11754
11804
  case 1:
11755
11805
  fixedtables$1(state);
11756
11806
  state.mode = LEN_$1;
11757
- if (flush === Z_TREES$1) {
11807
+ if (flush2 === Z_TREES$1) {
11758
11808
  hold2 >>>= 2;
11759
11809
  bits -= 2;
11760
11810
  break inf_leave;
@@ -11790,7 +11840,7 @@ const inflate$3 = (strm, flush) => {
11790
11840
  hold2 = 0;
11791
11841
  bits = 0;
11792
11842
  state.mode = COPY_$1;
11793
- if (flush === Z_TREES$1) {
11843
+ if (flush2 === Z_TREES$1) {
11794
11844
  break inf_leave;
11795
11845
  }
11796
11846
  case COPY_$1:
@@ -11985,7 +12035,7 @@ const inflate$3 = (strm, flush) => {
11985
12035
  break;
11986
12036
  }
11987
12037
  state.mode = LEN_$1;
11988
- if (flush === Z_TREES$1) {
12038
+ if (flush2 === Z_TREES$1) {
11989
12039
  break inf_leave;
11990
12040
  }
11991
12041
  case LEN_$1:
@@ -12275,7 +12325,7 @@ const inflate$3 = (strm, flush) => {
12275
12325
  strm.avail_in = have;
12276
12326
  state.hold = hold2;
12277
12327
  state.bits = bits;
12278
- if (state.wsize || _out !== strm.avail_out && state.mode < BAD$2 && (state.mode < CHECK$1 || flush !== Z_FINISH$5)) {
12328
+ if (state.wsize || _out !== strm.avail_out && state.mode < BAD$2 && (state.mode < CHECK$1 || flush2 !== Z_FINISH$5)) {
12279
12329
  if (updatewindow$1(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;
12280
12330
  }
12281
12331
  _in -= strm.avail_in;
@@ -12288,7 +12338,7 @@ const inflate$3 = (strm, flush) => {
12288
12338
  state.flags ? crc32$2(state.check, output, _out, strm.next_out - _out) : adler32$2(state.check, output, _out, strm.next_out - _out);
12289
12339
  }
12290
12340
  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE$2 ? 128 : 0) + (state.mode === LEN_$1 || state.mode === COPY_$1 ? 256 : 0);
12291
- if ((_in === 0 && _out === 0 || flush === Z_FINISH$5) && ret === Z_OK$5) {
12341
+ if ((_in === 0 && _out === 0 || flush2 === Z_FINISH$5) && ret === Z_OK$5) {
12292
12342
  ret = Z_BUF_ERROR$3;
12293
12343
  }
12294
12344
  return ret;
@@ -13238,7 +13288,7 @@ const fill_window$1 = (s10) => {
13238
13288
  }
13239
13289
  } while (s10.lookahead < MIN_LOOKAHEAD$1 && s10.strm.avail_in !== 0);
13240
13290
  };
13241
- const deflate_stored$1 = (s10, flush) => {
13291
+ const deflate_stored$1 = (s10, flush2) => {
13242
13292
  let min_block = s10.pending_buf_size - 5 > s10.w_size ? s10.w_size : s10.pending_buf_size - 5;
13243
13293
  let len2, left, have, last = 0;
13244
13294
  let used = s10.strm.avail_in;
@@ -13256,10 +13306,10 @@ const deflate_stored$1 = (s10, flush) => {
13256
13306
  if (len2 > have) {
13257
13307
  len2 = have;
13258
13308
  }
13259
- if (len2 < min_block && (len2 === 0 && flush !== Z_FINISH$4 || flush === Z_NO_FLUSH$3 || len2 !== left + s10.strm.avail_in)) {
13309
+ if (len2 < min_block && (len2 === 0 && flush2 !== Z_FINISH$4 || flush2 === Z_NO_FLUSH$3 || len2 !== left + s10.strm.avail_in)) {
13260
13310
  break;
13261
13311
  }
13262
- last = flush === Z_FINISH$4 && len2 === left + s10.strm.avail_in ? 1 : 0;
13312
+ last = flush2 === Z_FINISH$4 && len2 === left + s10.strm.avail_in ? 1 : 0;
13263
13313
  _tr_stored_block$2(s10, 0, 0, last);
13264
13314
  s10.pending_buf[s10.pending - 4] = len2;
13265
13315
  s10.pending_buf[s10.pending - 3] = len2 >> 8;
@@ -13314,7 +13364,7 @@ const deflate_stored$1 = (s10, flush) => {
13314
13364
  if (last) {
13315
13365
  return BS_FINISH_DONE$1;
13316
13366
  }
13317
- if (flush !== Z_NO_FLUSH$3 && flush !== Z_FINISH$4 && s10.strm.avail_in === 0 && s10.strstart === s10.block_start) {
13367
+ if (flush2 !== Z_NO_FLUSH$3 && flush2 !== Z_FINISH$4 && s10.strm.avail_in === 0 && s10.strstart === s10.block_start) {
13318
13368
  return BS_BLOCK_DONE$1;
13319
13369
  }
13320
13370
  have = s10.window_size - s10.strstart;
@@ -13345,22 +13395,22 @@ const deflate_stored$1 = (s10, flush) => {
13345
13395
  have = s10.pending_buf_size - have > 65535 ? 65535 : s10.pending_buf_size - have;
13346
13396
  min_block = have > s10.w_size ? s10.w_size : have;
13347
13397
  left = s10.strstart - s10.block_start;
13348
- if (left >= min_block || (left || flush === Z_FINISH$4) && flush !== Z_NO_FLUSH$3 && s10.strm.avail_in === 0 && left <= have) {
13398
+ if (left >= min_block || (left || flush2 === Z_FINISH$4) && flush2 !== Z_NO_FLUSH$3 && s10.strm.avail_in === 0 && left <= have) {
13349
13399
  len2 = left > have ? have : left;
13350
- last = flush === Z_FINISH$4 && s10.strm.avail_in === 0 && len2 === left ? 1 : 0;
13400
+ last = flush2 === Z_FINISH$4 && s10.strm.avail_in === 0 && len2 === left ? 1 : 0;
13351
13401
  _tr_stored_block$2(s10, s10.block_start, len2, last);
13352
13402
  s10.block_start += len2;
13353
13403
  flush_pending$1(s10.strm);
13354
13404
  }
13355
13405
  return last ? BS_FINISH_STARTED$1 : BS_NEED_MORE$1;
13356
13406
  };
13357
- const deflate_fast$1 = (s10, flush) => {
13407
+ const deflate_fast$1 = (s10, flush2) => {
13358
13408
  let hash_head;
13359
13409
  let bflush;
13360
13410
  for (; ; ) {
13361
13411
  if (s10.lookahead < MIN_LOOKAHEAD$1) {
13362
13412
  fill_window$1(s10);
13363
- if (s10.lookahead < MIN_LOOKAHEAD$1 && flush === Z_NO_FLUSH$3) {
13413
+ if (s10.lookahead < MIN_LOOKAHEAD$1 && flush2 === Z_NO_FLUSH$3) {
13364
13414
  return BS_NEED_MORE$1;
13365
13415
  }
13366
13416
  if (s10.lookahead === 0) {
@@ -13407,7 +13457,7 @@ const deflate_fast$1 = (s10, flush) => {
13407
13457
  }
13408
13458
  }
13409
13459
  s10.insert = s10.strstart < MIN_MATCH$2 - 1 ? s10.strstart : MIN_MATCH$2 - 1;
13410
- if (flush === Z_FINISH$4) {
13460
+ if (flush2 === Z_FINISH$4) {
13411
13461
  flush_block_only$1(s10, true);
13412
13462
  if (s10.strm.avail_out === 0) {
13413
13463
  return BS_FINISH_STARTED$1;
@@ -13422,14 +13472,14 @@ const deflate_fast$1 = (s10, flush) => {
13422
13472
  }
13423
13473
  return BS_BLOCK_DONE$1;
13424
13474
  };
13425
- const deflate_slow$1 = (s10, flush) => {
13475
+ const deflate_slow$1 = (s10, flush2) => {
13426
13476
  let hash_head;
13427
13477
  let bflush;
13428
13478
  let max_insert;
13429
13479
  for (; ; ) {
13430
13480
  if (s10.lookahead < MIN_LOOKAHEAD$1) {
13431
13481
  fill_window$1(s10);
13432
- if (s10.lookahead < MIN_LOOKAHEAD$1 && flush === Z_NO_FLUSH$3) {
13482
+ if (s10.lookahead < MIN_LOOKAHEAD$1 && flush2 === Z_NO_FLUSH$3) {
13433
13483
  return BS_NEED_MORE$1;
13434
13484
  }
13435
13485
  if (s10.lookahead === 0) {
@@ -13493,7 +13543,7 @@ const deflate_slow$1 = (s10, flush) => {
13493
13543
  s10.match_available = 0;
13494
13544
  }
13495
13545
  s10.insert = s10.strstart < MIN_MATCH$2 - 1 ? s10.strstart : MIN_MATCH$2 - 1;
13496
- if (flush === Z_FINISH$4) {
13546
+ if (flush2 === Z_FINISH$4) {
13497
13547
  flush_block_only$1(s10, true);
13498
13548
  if (s10.strm.avail_out === 0) {
13499
13549
  return BS_FINISH_STARTED$1;
@@ -13508,7 +13558,7 @@ const deflate_slow$1 = (s10, flush) => {
13508
13558
  }
13509
13559
  return BS_BLOCK_DONE$1;
13510
13560
  };
13511
- const deflate_rle$1 = (s10, flush) => {
13561
+ const deflate_rle$1 = (s10, flush2) => {
13512
13562
  let bflush;
13513
13563
  let prev;
13514
13564
  let scan, strend;
@@ -13516,7 +13566,7 @@ const deflate_rle$1 = (s10, flush) => {
13516
13566
  for (; ; ) {
13517
13567
  if (s10.lookahead <= MAX_MATCH$2) {
13518
13568
  fill_window$1(s10);
13519
- if (s10.lookahead <= MAX_MATCH$2 && flush === Z_NO_FLUSH$3) {
13569
+ if (s10.lookahead <= MAX_MATCH$2 && flush2 === Z_NO_FLUSH$3) {
13520
13570
  return BS_NEED_MORE$1;
13521
13571
  }
13522
13572
  if (s10.lookahead === 0) {
@@ -13555,7 +13605,7 @@ const deflate_rle$1 = (s10, flush) => {
13555
13605
  }
13556
13606
  }
13557
13607
  s10.insert = 0;
13558
- if (flush === Z_FINISH$4) {
13608
+ if (flush2 === Z_FINISH$4) {
13559
13609
  flush_block_only$1(s10, true);
13560
13610
  if (s10.strm.avail_out === 0) {
13561
13611
  return BS_FINISH_STARTED$1;
@@ -13570,13 +13620,13 @@ const deflate_rle$1 = (s10, flush) => {
13570
13620
  }
13571
13621
  return BS_BLOCK_DONE$1;
13572
13622
  };
13573
- const deflate_huff$1 = (s10, flush) => {
13623
+ const deflate_huff$1 = (s10, flush2) => {
13574
13624
  let bflush;
13575
13625
  for (; ; ) {
13576
13626
  if (s10.lookahead === 0) {
13577
13627
  fill_window$1(s10);
13578
13628
  if (s10.lookahead === 0) {
13579
- if (flush === Z_NO_FLUSH$3) {
13629
+ if (flush2 === Z_NO_FLUSH$3) {
13580
13630
  return BS_NEED_MORE$1;
13581
13631
  }
13582
13632
  break;
@@ -13594,7 +13644,7 @@ const deflate_huff$1 = (s10, flush) => {
13594
13644
  }
13595
13645
  }
13596
13646
  s10.insert = 0;
13597
- if (flush === Z_FINISH$4) {
13647
+ if (flush2 === Z_FINISH$4) {
13598
13648
  flush_block_only$1(s10, true);
13599
13649
  if (s10.strm.avail_out === 0) {
13600
13650
  return BS_FINISH_STARTED$1;
@@ -13817,23 +13867,23 @@ const deflateInit2$1 = (strm, level, method, windowBits, memLevel, strategy) =>
13817
13867
  const deflateInit$1 = (strm, level) => {
13818
13868
  return deflateInit2$1(strm, level, Z_DEFLATED$3, MAX_WBITS$2, DEF_MEM_LEVEL$1, Z_DEFAULT_STRATEGY$2);
13819
13869
  };
13820
- const deflate$3 = (strm, flush) => {
13821
- if (deflateStateCheck$1(strm) || flush > Z_BLOCK$2 || flush < 0) {
13870
+ const deflate$3 = (strm, flush2) => {
13871
+ if (deflateStateCheck$1(strm) || flush2 > Z_BLOCK$2 || flush2 < 0) {
13822
13872
  return strm ? err$1(strm, Z_STREAM_ERROR$3) : Z_STREAM_ERROR$3;
13823
13873
  }
13824
13874
  const s10 = strm.state;
13825
- if (!strm.output || strm.avail_in !== 0 && !strm.input || s10.status === FINISH_STATE$1 && flush !== Z_FINISH$4) {
13875
+ if (!strm.output || strm.avail_in !== 0 && !strm.input || s10.status === FINISH_STATE$1 && flush2 !== Z_FINISH$4) {
13826
13876
  return err$1(strm, strm.avail_out === 0 ? Z_BUF_ERROR$2 : Z_STREAM_ERROR$3);
13827
13877
  }
13828
13878
  const old_flush = s10.last_flush;
13829
- s10.last_flush = flush;
13879
+ s10.last_flush = flush2;
13830
13880
  if (s10.pending !== 0) {
13831
13881
  flush_pending$1(strm);
13832
13882
  if (strm.avail_out === 0) {
13833
13883
  s10.last_flush = -1;
13834
13884
  return Z_OK$4;
13835
13885
  }
13836
- } else if (strm.avail_in === 0 && rank$1(flush) <= rank$1(old_flush) && flush !== Z_FINISH$4) {
13886
+ } else if (strm.avail_in === 0 && rank$1(flush2) <= rank$1(old_flush) && flush2 !== Z_FINISH$4) {
13837
13887
  return err$1(strm, Z_BUF_ERROR$2);
13838
13888
  }
13839
13889
  if (s10.status === FINISH_STATE$1 && strm.avail_in !== 0) {
@@ -14022,8 +14072,8 @@ const deflate$3 = (strm, flush) => {
14022
14072
  return Z_OK$4;
14023
14073
  }
14024
14074
  }
14025
- if (strm.avail_in !== 0 || s10.lookahead !== 0 || flush !== Z_NO_FLUSH$3 && s10.status !== FINISH_STATE$1) {
14026
- let bstate = s10.level === 0 ? deflate_stored$1(s10, flush) : s10.strategy === Z_HUFFMAN_ONLY$1 ? deflate_huff$1(s10, flush) : s10.strategy === Z_RLE$1 ? deflate_rle$1(s10, flush) : configuration_table$1[s10.level].func(s10, flush);
14075
+ if (strm.avail_in !== 0 || s10.lookahead !== 0 || flush2 !== Z_NO_FLUSH$3 && s10.status !== FINISH_STATE$1) {
14076
+ let bstate = s10.level === 0 ? deflate_stored$1(s10, flush2) : s10.strategy === Z_HUFFMAN_ONLY$1 ? deflate_huff$1(s10, flush2) : s10.strategy === Z_RLE$1 ? deflate_rle$1(s10, flush2) : configuration_table$1[s10.level].func(s10, flush2);
14027
14077
  if (bstate === BS_FINISH_STARTED$1 || bstate === BS_FINISH_DONE$1) {
14028
14078
  s10.status = FINISH_STATE$1;
14029
14079
  }
@@ -14034,11 +14084,11 @@ const deflate$3 = (strm, flush) => {
14034
14084
  return Z_OK$4;
14035
14085
  }
14036
14086
  if (bstate === BS_BLOCK_DONE$1) {
14037
- if (flush === Z_PARTIAL_FLUSH$1) {
14087
+ if (flush2 === Z_PARTIAL_FLUSH$1) {
14038
14088
  _tr_align$2(s10);
14039
- } else if (flush !== Z_BLOCK$2) {
14089
+ } else if (flush2 !== Z_BLOCK$2) {
14040
14090
  _tr_stored_block$2(s10, 0, 0, false);
14041
- if (flush === Z_FULL_FLUSH$2) {
14091
+ if (flush2 === Z_FULL_FLUSH$2) {
14042
14092
  zero$2(s10.head);
14043
14093
  if (s10.lookahead === 0) {
14044
14094
  s10.strstart = 0;
@@ -14054,7 +14104,7 @@ const deflate$3 = (strm, flush) => {
14054
14104
  }
14055
14105
  }
14056
14106
  }
14057
- if (flush !== Z_FINISH$4) {
14107
+ if (flush2 !== Z_FINISH$4) {
14058
14108
  return Z_OK$4;
14059
14109
  }
14060
14110
  if (s10.wrap <= 0) {
@@ -16506,10 +16556,10 @@ prefix.kCopyRangeLut = [
16506
16556
  8,
16507
16557
  16
16508
16558
  ];
16509
- var transform$1 = {};
16559
+ var transform$2 = {};
16510
16560
  var hasRequiredTransform;
16511
16561
  function requireTransform() {
16512
- if (hasRequiredTransform) return transform$1;
16562
+ if (hasRequiredTransform) return transform$2;
16513
16563
  hasRequiredTransform = 1;
16514
16564
  var BrotliDictionary = requireDictionary();
16515
16565
  var kIdentity = 0;
@@ -16664,8 +16714,8 @@ function requireTransform() {
16664
16714
  new Transform(" ", kUppercaseAll, "='"),
16665
16715
  new Transform(" ", kUppercaseFirst, "='")
16666
16716
  ];
16667
- transform$1.kTransforms = kTransforms;
16668
- transform$1.kNumTransforms = kTransforms.length;
16717
+ transform$2.kTransforms = kTransforms;
16718
+ transform$2.kNumTransforms = kTransforms.length;
16669
16719
  function ToUpperCase(p, i10) {
16670
16720
  if (p[i10] < 192) {
16671
16721
  if (p[i10] >= 97 && p[i10] <= 122) {
@@ -16680,7 +16730,7 @@ function requireTransform() {
16680
16730
  p[i10 + 2] ^= 5;
16681
16731
  return 3;
16682
16732
  }
16683
- transform$1.transformDictionaryWord = function(dst, idx, word, len2, transform2) {
16733
+ transform$2.transformDictionaryWord = function(dst, idx, word, len2, transform2) {
16684
16734
  var prefix2 = kTransforms[transform2].prefix;
16685
16735
  var suffix = kTransforms[transform2].suffix;
16686
16736
  var t10 = kTransforms[transform2].transform;
@@ -16719,7 +16769,7 @@ function requireTransform() {
16719
16769
  }
16720
16770
  return idx - start_idx;
16721
16771
  };
16722
- return transform$1;
16772
+ return transform$2;
16723
16773
  }
16724
16774
  var hasRequiredDecode;
16725
16775
  function requireDecode() {
@@ -17607,20 +17657,20 @@ class Zlib {
17607
17657
  __privateSet(this, _dictionary, dictionary2);
17608
17658
  __privateMethod(this, _Zlib_instances, start_fn).call(this);
17609
17659
  }
17610
- write(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17660
+ write(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17611
17661
  var _a3;
17612
17662
  const tick = ((_a3 = globalThis.process) == null ? void 0 : _a3.nextTick) ?? ((fn2) => {
17613
17663
  queueMicrotask(fn2);
17614
17664
  });
17615
17665
  tick(() => {
17616
17666
  var _a4;
17617
- __privateMethod(this, _Zlib_instances, run_fn).call(this, flush, inBuf, inOff, inLen, outBuf, outOff, outLen);
17667
+ __privateMethod(this, _Zlib_instances, run_fn).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
17618
17668
  (_a4 = __privateGet(this, _callback)) == null ? void 0 : _a4.call(this);
17619
17669
  });
17620
17670
  return this;
17621
17671
  }
17622
- writeSync(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17623
- __privateMethod(this, _Zlib_instances, run_fn).call(this, flush, inBuf, inOff, inLen, outBuf, outOff, outLen);
17672
+ writeSync(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17673
+ __privateMethod(this, _Zlib_instances, run_fn).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
17624
17674
  return this;
17625
17675
  }
17626
17676
  /**
@@ -17708,7 +17758,7 @@ report_fn = function(strm) {
17708
17758
  state[0] = strm.avail_out;
17709
17759
  state[1] = strm.avail_in;
17710
17760
  };
17711
- run_fn = function(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17761
+ run_fn = function(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17712
17762
  var _a3;
17713
17763
  const strm = __privateGet(this, _strm);
17714
17764
  if (!strm) {
@@ -17721,11 +17771,11 @@ run_fn = function(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17721
17771
  strm.output = outBuf;
17722
17772
  strm.next_out = outOff;
17723
17773
  strm.avail_out = outLen;
17724
- const status = __privateGet(this, _Zlib_instances, inflating_get) ? inflateModule.inflate(strm, flush) : deflateModule.deflate(strm, flush);
17774
+ const status = __privateGet(this, _Zlib_instances, inflating_get) ? inflateModule.inflate(strm, flush2) : deflateModule.deflate(strm, flush2);
17725
17775
  if (status === zlibConstants$1.Z_NEED_DICT && __privateGet(this, _dictionary)) {
17726
17776
  const dictStatus = inflateModule.inflateSetDictionary(strm, __privateGet(this, _dictionary));
17727
17777
  if (dictStatus === zlibConstants$1.Z_OK) {
17728
- const again = inflateModule.inflate(strm, flush);
17778
+ const again = inflateModule.inflate(strm, flush2);
17729
17779
  if (again !== zlibConstants$1.Z_OK && again !== zlibConstants$1.Z_STREAM_END && again !== zlibConstants$1.Z_BUF_ERROR) {
17730
17780
  __privateMethod(this, _Zlib_instances, fail_fn).call(this, again, strm);
17731
17781
  return;
@@ -17780,20 +17830,20 @@ class BrotliDecoderHandle {
17780
17830
  __privateSet(this, _callback2, processCallback);
17781
17831
  return true;
17782
17832
  }
17783
- write(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17833
+ write(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17784
17834
  var _a3;
17785
17835
  const tick = ((_a3 = globalThis.process) == null ? void 0 : _a3.nextTick) ?? ((fn2) => {
17786
17836
  queueMicrotask(fn2);
17787
17837
  });
17788
17838
  tick(() => {
17789
17839
  var _a4;
17790
- __privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this, flush, inBuf, inOff, inLen, outBuf, outOff, outLen);
17840
+ __privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
17791
17841
  (_a4 = __privateGet(this, _callback2)) == null ? void 0 : _a4.call(this);
17792
17842
  });
17793
17843
  return this;
17794
17844
  }
17795
- writeSync(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17796
- __privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this, flush, inBuf, inOff, inLen, outBuf, outOff, outLen);
17845
+ writeSync(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17846
+ __privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
17797
17847
  return this;
17798
17848
  }
17799
17849
  params() {
@@ -17817,10 +17867,10 @@ _input = new WeakMap();
17817
17867
  _output = new WeakMap();
17818
17868
  _outputAt = new WeakMap();
17819
17869
  _BrotliDecoderHandle_instances = new WeakSet();
17820
- run_fn2 = function(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17870
+ run_fn2 = function(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
17821
17871
  var _a3;
17822
17872
  if (inBuf && inLen > 0) __privateGet(this, _input).push(inBuf.slice(inOff, inOff + inLen));
17823
- if (flush === BROTLI_OPERATION_FINISH && __privateGet(this, _output) === null) {
17873
+ if (flush2 === BROTLI_OPERATION_FINISH && __privateGet(this, _output) === null) {
17824
17874
  const total = __privateGet(this, _input).reduce((sum, part) => sum + part.byteLength, 0);
17825
17875
  const whole = new Uint8Array(total);
17826
17876
  let at3 = 0;
@@ -18904,11 +18954,11 @@ const isWindows = false;
18904
18954
  const isMacOS = false;
18905
18955
  function getLazy(fn2) {
18906
18956
  let value;
18907
- let loaded = false;
18957
+ let loaded2 = false;
18908
18958
  return () => {
18909
- if (!loaded) {
18959
+ if (!loaded2) {
18910
18960
  value = fn2();
18911
- loaded = true;
18961
+ loaded2 = true;
18912
18962
  }
18913
18963
  return value;
18914
18964
  };
@@ -21053,10 +21103,17 @@ var implementation$1 = function bind2(that) {
21053
21103
  var implementation = implementation$1;
21054
21104
  var functionBind = Function.prototype.bind || implementation;
21055
21105
  var functionCall = Function.prototype.call;
21056
- var functionApply = Function.prototype.apply;
21106
+ var functionApply;
21107
+ var hasRequiredFunctionApply;
21108
+ function requireFunctionApply() {
21109
+ if (hasRequiredFunctionApply) return functionApply;
21110
+ hasRequiredFunctionApply = 1;
21111
+ functionApply = Function.prototype.apply;
21112
+ return functionApply;
21113
+ }
21057
21114
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
21058
21115
  var bind$2 = functionBind;
21059
- var $apply$1 = functionApply;
21116
+ var $apply$1 = requireFunctionApply();
21060
21117
  var $call$2 = functionCall;
21061
21118
  var $reflectApply = reflectApply;
21062
21119
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
@@ -21176,7 +21233,7 @@ var hasSymbols = requireHasSymbols()();
21176
21233
  var getProto = requireGetProto();
21177
21234
  var $ObjectGPO = requireObject_getPrototypeOf();
21178
21235
  var $ReflectGPO = requireReflect_getPrototypeOf();
21179
- var $apply = functionApply;
21236
+ var $apply = requireFunctionApply();
21180
21237
  var $call = functionCall;
21181
21238
  var needsEval = {};
21182
21239
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
@@ -21817,7 +21874,7 @@ function requireApplyBind() {
21817
21874
  if (hasRequiredApplyBind) return applyBind;
21818
21875
  hasRequiredApplyBind = 1;
21819
21876
  var bind3 = functionBind;
21820
- var $apply2 = functionApply;
21877
+ var $apply2 = requireFunctionApply();
21821
21878
  var actualApply$1 = actualApply;
21822
21879
  applyBind = function applyBind2() {
21823
21880
  return actualApply$1(bind3, $apply2, arguments);
@@ -29978,7 +30035,7 @@ function createTimersModule(owned) {
29978
30035
  }
29979
30036
  const NODE_LTS_VERSION = "22.12.0";
29980
30037
  function nodeVersions(node = NODE_LTS_VERSION) {
29981
- return { node, v8: "11.3.244.8", uv: "1.44.2", webcontainer: "1", openssl: "3.0.15" };
30038
+ return { node, v8: "11.3.244.8", uv: "1.44.2", webcontainer: "1", openssl: "3.0.15", amaro: "1.1.0" };
29982
30039
  }
29983
30040
  var StdinClasses;
29984
30041
  function processStdinClass(ReadableClass) {
@@ -35003,7 +35060,7 @@ const fill_window = (s10) => {
35003
35060
  }
35004
35061
  } while (s10.lookahead < MIN_LOOKAHEAD && s10.strm.avail_in !== 0);
35005
35062
  };
35006
- const deflate_stored = (s10, flush) => {
35063
+ const deflate_stored = (s10, flush2) => {
35007
35064
  let min_block = s10.pending_buf_size - 5 > s10.w_size ? s10.w_size : s10.pending_buf_size - 5;
35008
35065
  let len2, left, have, last = 0;
35009
35066
  let used = s10.strm.avail_in;
@@ -35021,10 +35078,10 @@ const deflate_stored = (s10, flush) => {
35021
35078
  if (len2 > have) {
35022
35079
  len2 = have;
35023
35080
  }
35024
- if (len2 < min_block && (len2 === 0 && flush !== Z_FINISH$3 || flush === Z_NO_FLUSH$2 || len2 !== left + s10.strm.avail_in)) {
35081
+ if (len2 < min_block && (len2 === 0 && flush2 !== Z_FINISH$3 || flush2 === Z_NO_FLUSH$2 || len2 !== left + s10.strm.avail_in)) {
35025
35082
  break;
35026
35083
  }
35027
- last = flush === Z_FINISH$3 && len2 === left + s10.strm.avail_in ? 1 : 0;
35084
+ last = flush2 === Z_FINISH$3 && len2 === left + s10.strm.avail_in ? 1 : 0;
35028
35085
  _tr_stored_block(s10, 0, 0, last);
35029
35086
  s10.pending_buf[s10.pending - 4] = len2;
35030
35087
  s10.pending_buf[s10.pending - 3] = len2 >> 8;
@@ -35079,7 +35136,7 @@ const deflate_stored = (s10, flush) => {
35079
35136
  if (last) {
35080
35137
  return BS_FINISH_DONE;
35081
35138
  }
35082
- if (flush !== Z_NO_FLUSH$2 && flush !== Z_FINISH$3 && s10.strm.avail_in === 0 && s10.strstart === s10.block_start) {
35139
+ if (flush2 !== Z_NO_FLUSH$2 && flush2 !== Z_FINISH$3 && s10.strm.avail_in === 0 && s10.strstart === s10.block_start) {
35083
35140
  return BS_BLOCK_DONE;
35084
35141
  }
35085
35142
  have = s10.window_size - s10.strstart;
@@ -35110,22 +35167,22 @@ const deflate_stored = (s10, flush) => {
35110
35167
  have = s10.pending_buf_size - have > 65535 ? 65535 : s10.pending_buf_size - have;
35111
35168
  min_block = have > s10.w_size ? s10.w_size : have;
35112
35169
  left = s10.strstart - s10.block_start;
35113
- if (left >= min_block || (left || flush === Z_FINISH$3) && flush !== Z_NO_FLUSH$2 && s10.strm.avail_in === 0 && left <= have) {
35170
+ if (left >= min_block || (left || flush2 === Z_FINISH$3) && flush2 !== Z_NO_FLUSH$2 && s10.strm.avail_in === 0 && left <= have) {
35114
35171
  len2 = left > have ? have : left;
35115
- last = flush === Z_FINISH$3 && s10.strm.avail_in === 0 && len2 === left ? 1 : 0;
35172
+ last = flush2 === Z_FINISH$3 && s10.strm.avail_in === 0 && len2 === left ? 1 : 0;
35116
35173
  _tr_stored_block(s10, s10.block_start, len2, last);
35117
35174
  s10.block_start += len2;
35118
35175
  flush_pending(s10.strm);
35119
35176
  }
35120
35177
  return last ? BS_FINISH_STARTED : BS_NEED_MORE;
35121
35178
  };
35122
- const deflate_fast = (s10, flush) => {
35179
+ const deflate_fast = (s10, flush2) => {
35123
35180
  let hash_head;
35124
35181
  let bflush;
35125
35182
  for (; ; ) {
35126
35183
  if (s10.lookahead < MIN_LOOKAHEAD) {
35127
35184
  fill_window(s10);
35128
- if (s10.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$2) {
35185
+ if (s10.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH$2) {
35129
35186
  return BS_NEED_MORE;
35130
35187
  }
35131
35188
  if (s10.lookahead === 0) {
@@ -35172,7 +35229,7 @@ const deflate_fast = (s10, flush) => {
35172
35229
  }
35173
35230
  }
35174
35231
  s10.insert = s10.strstart < MIN_MATCH - 1 ? s10.strstart : MIN_MATCH - 1;
35175
- if (flush === Z_FINISH$3) {
35232
+ if (flush2 === Z_FINISH$3) {
35176
35233
  flush_block_only(s10, true);
35177
35234
  if (s10.strm.avail_out === 0) {
35178
35235
  return BS_FINISH_STARTED;
@@ -35187,14 +35244,14 @@ const deflate_fast = (s10, flush) => {
35187
35244
  }
35188
35245
  return BS_BLOCK_DONE;
35189
35246
  };
35190
- const deflate_slow = (s10, flush) => {
35247
+ const deflate_slow = (s10, flush2) => {
35191
35248
  let hash_head;
35192
35249
  let bflush;
35193
35250
  let max_insert;
35194
35251
  for (; ; ) {
35195
35252
  if (s10.lookahead < MIN_LOOKAHEAD) {
35196
35253
  fill_window(s10);
35197
- if (s10.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$2) {
35254
+ if (s10.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH$2) {
35198
35255
  return BS_NEED_MORE;
35199
35256
  }
35200
35257
  if (s10.lookahead === 0) {
@@ -35258,7 +35315,7 @@ const deflate_slow = (s10, flush) => {
35258
35315
  s10.match_available = 0;
35259
35316
  }
35260
35317
  s10.insert = s10.strstart < MIN_MATCH - 1 ? s10.strstart : MIN_MATCH - 1;
35261
- if (flush === Z_FINISH$3) {
35318
+ if (flush2 === Z_FINISH$3) {
35262
35319
  flush_block_only(s10, true);
35263
35320
  if (s10.strm.avail_out === 0) {
35264
35321
  return BS_FINISH_STARTED;
@@ -35273,7 +35330,7 @@ const deflate_slow = (s10, flush) => {
35273
35330
  }
35274
35331
  return BS_BLOCK_DONE;
35275
35332
  };
35276
- const deflate_rle = (s10, flush) => {
35333
+ const deflate_rle = (s10, flush2) => {
35277
35334
  let bflush;
35278
35335
  let prev;
35279
35336
  let scan, strend;
@@ -35281,7 +35338,7 @@ const deflate_rle = (s10, flush) => {
35281
35338
  for (; ; ) {
35282
35339
  if (s10.lookahead <= MAX_MATCH) {
35283
35340
  fill_window(s10);
35284
- if (s10.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH$2) {
35341
+ if (s10.lookahead <= MAX_MATCH && flush2 === Z_NO_FLUSH$2) {
35285
35342
  return BS_NEED_MORE;
35286
35343
  }
35287
35344
  if (s10.lookahead === 0) {
@@ -35320,7 +35377,7 @@ const deflate_rle = (s10, flush) => {
35320
35377
  }
35321
35378
  }
35322
35379
  s10.insert = 0;
35323
- if (flush === Z_FINISH$3) {
35380
+ if (flush2 === Z_FINISH$3) {
35324
35381
  flush_block_only(s10, true);
35325
35382
  if (s10.strm.avail_out === 0) {
35326
35383
  return BS_FINISH_STARTED;
@@ -35335,13 +35392,13 @@ const deflate_rle = (s10, flush) => {
35335
35392
  }
35336
35393
  return BS_BLOCK_DONE;
35337
35394
  };
35338
- const deflate_huff = (s10, flush) => {
35395
+ const deflate_huff = (s10, flush2) => {
35339
35396
  let bflush;
35340
35397
  for (; ; ) {
35341
35398
  if (s10.lookahead === 0) {
35342
35399
  fill_window(s10);
35343
35400
  if (s10.lookahead === 0) {
35344
- if (flush === Z_NO_FLUSH$2) {
35401
+ if (flush2 === Z_NO_FLUSH$2) {
35345
35402
  return BS_NEED_MORE;
35346
35403
  }
35347
35404
  break;
@@ -35359,7 +35416,7 @@ const deflate_huff = (s10, flush) => {
35359
35416
  }
35360
35417
  }
35361
35418
  s10.insert = 0;
35362
- if (flush === Z_FINISH$3) {
35419
+ if (flush2 === Z_FINISH$3) {
35363
35420
  flush_block_only(s10, true);
35364
35421
  if (s10.strm.avail_out === 0) {
35365
35422
  return BS_FINISH_STARTED;
@@ -35582,23 +35639,23 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
35582
35639
  const deflateInit = (strm, level) => {
35583
35640
  return deflateInit2(strm, level, Z_DEFLATED$2, MAX_WBITS$1, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY$1);
35584
35641
  };
35585
- const deflate$2 = (strm, flush) => {
35586
- if (deflateStateCheck(strm) || flush > Z_BLOCK$1 || flush < 0) {
35642
+ const deflate$2 = (strm, flush2) => {
35643
+ if (deflateStateCheck(strm) || flush2 > Z_BLOCK$1 || flush2 < 0) {
35587
35644
  return strm ? err(strm, Z_STREAM_ERROR$2) : Z_STREAM_ERROR$2;
35588
35645
  }
35589
35646
  const s10 = strm.state;
35590
- if (!strm.output || strm.avail_in !== 0 && !strm.input || s10.status === FINISH_STATE && flush !== Z_FINISH$3) {
35647
+ if (!strm.output || strm.avail_in !== 0 && !strm.input || s10.status === FINISH_STATE && flush2 !== Z_FINISH$3) {
35591
35648
  return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR$1 : Z_STREAM_ERROR$2);
35592
35649
  }
35593
35650
  const old_flush = s10.last_flush;
35594
- s10.last_flush = flush;
35651
+ s10.last_flush = flush2;
35595
35652
  if (s10.pending !== 0) {
35596
35653
  flush_pending(strm);
35597
35654
  if (strm.avail_out === 0) {
35598
35655
  s10.last_flush = -1;
35599
35656
  return Z_OK$3;
35600
35657
  }
35601
- } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH$3) {
35658
+ } else if (strm.avail_in === 0 && rank(flush2) <= rank(old_flush) && flush2 !== Z_FINISH$3) {
35602
35659
  return err(strm, Z_BUF_ERROR$1);
35603
35660
  }
35604
35661
  if (s10.status === FINISH_STATE && strm.avail_in !== 0) {
@@ -35787,8 +35844,8 @@ const deflate$2 = (strm, flush) => {
35787
35844
  return Z_OK$3;
35788
35845
  }
35789
35846
  }
35790
- if (strm.avail_in !== 0 || s10.lookahead !== 0 || flush !== Z_NO_FLUSH$2 && s10.status !== FINISH_STATE) {
35791
- let bstate = s10.level === 0 ? deflate_stored(s10, flush) : s10.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s10, flush) : s10.strategy === Z_RLE ? deflate_rle(s10, flush) : configuration_table[s10.level].func(s10, flush);
35847
+ if (strm.avail_in !== 0 || s10.lookahead !== 0 || flush2 !== Z_NO_FLUSH$2 && s10.status !== FINISH_STATE) {
35848
+ let bstate = s10.level === 0 ? deflate_stored(s10, flush2) : s10.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s10, flush2) : s10.strategy === Z_RLE ? deflate_rle(s10, flush2) : configuration_table[s10.level].func(s10, flush2);
35792
35849
  if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
35793
35850
  s10.status = FINISH_STATE;
35794
35851
  }
@@ -35799,11 +35856,11 @@ const deflate$2 = (strm, flush) => {
35799
35856
  return Z_OK$3;
35800
35857
  }
35801
35858
  if (bstate === BS_BLOCK_DONE) {
35802
- if (flush === Z_PARTIAL_FLUSH) {
35859
+ if (flush2 === Z_PARTIAL_FLUSH) {
35803
35860
  _tr_align(s10);
35804
- } else if (flush !== Z_BLOCK$1) {
35861
+ } else if (flush2 !== Z_BLOCK$1) {
35805
35862
  _tr_stored_block(s10, 0, 0, false);
35806
- if (flush === Z_FULL_FLUSH$1) {
35863
+ if (flush2 === Z_FULL_FLUSH$1) {
35807
35864
  zero(s10.head);
35808
35865
  if (s10.lookahead === 0) {
35809
35866
  s10.strstart = 0;
@@ -35819,7 +35876,7 @@ const deflate$2 = (strm, flush) => {
35819
35876
  }
35820
35877
  }
35821
35878
  }
35822
- if (flush !== Z_FINISH$3) {
35879
+ if (flush2 !== Z_FINISH$3) {
35823
35880
  return Z_OK$3;
35824
35881
  }
35825
35882
  if (s10.wrap <= 0) {
@@ -37038,7 +37095,7 @@ const updatewindow = (strm, src, end, copy2) => {
37038
37095
  }
37039
37096
  return 0;
37040
37097
  };
37041
- const inflate$2 = (strm, flush) => {
37098
+ const inflate$2 = (strm, flush2) => {
37042
37099
  let state;
37043
37100
  let input, output;
37044
37101
  let next2;
@@ -37376,7 +37433,7 @@ const inflate$2 = (strm, flush) => {
37376
37433
  strm.adler = state.check = 1;
37377
37434
  state.mode = TYPE;
37378
37435
  case TYPE:
37379
- if (flush === Z_BLOCK || flush === Z_TREES) {
37436
+ if (flush2 === Z_BLOCK || flush2 === Z_TREES) {
37380
37437
  break inf_leave;
37381
37438
  }
37382
37439
  case TYPEDO:
@@ -37404,7 +37461,7 @@ const inflate$2 = (strm, flush) => {
37404
37461
  case 1:
37405
37462
  fixedtables(state);
37406
37463
  state.mode = LEN_;
37407
- if (flush === Z_TREES) {
37464
+ if (flush2 === Z_TREES) {
37408
37465
  hold2 >>>= 2;
37409
37466
  bits -= 2;
37410
37467
  break inf_leave;
@@ -37440,7 +37497,7 @@ const inflate$2 = (strm, flush) => {
37440
37497
  hold2 = 0;
37441
37498
  bits = 0;
37442
37499
  state.mode = COPY_;
37443
- if (flush === Z_TREES) {
37500
+ if (flush2 === Z_TREES) {
37444
37501
  break inf_leave;
37445
37502
  }
37446
37503
  case COPY_:
@@ -37635,7 +37692,7 @@ const inflate$2 = (strm, flush) => {
37635
37692
  break;
37636
37693
  }
37637
37694
  state.mode = LEN_;
37638
- if (flush === Z_TREES) {
37695
+ if (flush2 === Z_TREES) {
37639
37696
  break inf_leave;
37640
37697
  }
37641
37698
  case LEN_:
@@ -37925,7 +37982,7 @@ const inflate$2 = (strm, flush) => {
37925
37982
  strm.avail_in = have;
37926
37983
  state.hold = hold2;
37927
37984
  state.bits = bits;
37928
- if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {
37985
+ if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH$1)) {
37929
37986
  if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;
37930
37987
  }
37931
37988
  _in -= strm.avail_in;
@@ -37938,7 +37995,7 @@ const inflate$2 = (strm, flush) => {
37938
37995
  state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out);
37939
37996
  }
37940
37997
  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
37941
- if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {
37998
+ if ((_in === 0 && _out === 0 || flush2 === Z_FINISH$1) && ret === Z_OK$1) {
37942
37999
  ret = Z_BUF_ERROR;
37943
38000
  }
37944
38001
  return ret;
@@ -73243,6 +73300,418 @@ function __nodeResolverFor(fs2, profile, extensions) {
73243
73300
  byProfile.set(key, resolver);
73244
73301
  return resolver;
73245
73302
  }
73303
+ function unstreamedOutput(total, streamed) {
73304
+ let rest = total;
73305
+ let cursor = 0;
73306
+ for (const piece of streamed) {
73307
+ if (!piece) continue;
73308
+ const at3 = rest.indexOf(piece, cursor);
73309
+ if (at3 < 0) continue;
73310
+ rest = rest.slice(0, at3) + rest.slice(at3 + piece.length);
73311
+ cursor = at3;
73312
+ }
73313
+ return rest;
73314
+ }
73315
+ const LAST_JOB_VAR = "__TABNODE_LAST_JOB_PID";
73316
+ const SHELL_VAR = "__TABNODE_SHELL";
73317
+ const BG_COMMAND = "__tabnode_bg";
73318
+ const WAIT_COMMAND = "__tabnode_wait";
73319
+ const JOB_PLACEHOLDER = "__tabnode_job";
73320
+ const PENDING_LIMIT = 1 << 20;
73321
+ const IGNORED_BY_DEFAULT = /* @__PURE__ */ new Set(["SIGCHLD", "SIGCONT", "SIGURG", "SIGWINCH"]);
73322
+ const shells$1 = /* @__PURE__ */ new Map();
73323
+ const handoff = /* @__PURE__ */ new Map();
73324
+ let nextShell = 1;
73325
+ let nextJob = 1;
73326
+ function isNode(value) {
73327
+ return typeof value === "object" && value !== null;
73328
+ }
73329
+ function literalWord(value) {
73330
+ return { type: "Word", parts: [{ type: "Literal", value }] };
73331
+ }
73332
+ function wordLiteral(word) {
73333
+ if (!isNode(word) || !Array.isArray(word.parts) || word.parts.length !== 1) return null;
73334
+ const part = word.parts[0];
73335
+ return isNode(part) && part.type === "Literal" && typeof part.value === "string" ? part.value : null;
73336
+ }
73337
+ function definesFunction(statement) {
73338
+ const pipelines = statement.pipelines;
73339
+ return Array.isArray(pipelines) && pipelines.some((pipeline) => isNode(pipeline) && Array.isArray(pipeline.commands) && pipeline.commands.some((command) => isNode(command) && command.type === "FunctionDef"));
73340
+ }
73341
+ function functionDefinitions(node, found = []) {
73342
+ if (Array.isArray(node)) {
73343
+ for (const child of node) functionDefinitions(child, found);
73344
+ return found;
73345
+ }
73346
+ if (!isNode(node)) return found;
73347
+ if (node.type === "Statement" && node.background === true) return found;
73348
+ if (node.type === "Statement" && definesFunction(node)) found.push(node);
73349
+ for (const key of Object.keys(node)) functionDefinitions(node[key], found);
73350
+ return found;
73351
+ }
73352
+ function rewrite(node, functions) {
73353
+ if (Array.isArray(node)) {
73354
+ for (let index2 = 0; index2 < node.length; index2 += 1) {
73355
+ const child = node[index2];
73356
+ if (isNode(child) && child.type === "Statement" && child.background === true) {
73357
+ node[index2] = backgroundCall(child, functions);
73358
+ } else rewrite(child, functions);
73359
+ }
73360
+ return;
73361
+ }
73362
+ if (!isNode(node)) return;
73363
+ if (node.type === "ParameterExpansion" && node.parameter === "!") node.parameter = LAST_JOB_VAR;
73364
+ if (node.type === "SimpleCommand" && wordLiteral(node.name) === "wait") node.name = literalWord(WAIT_COMMAND);
73365
+ for (const key of Object.keys(node)) {
73366
+ const child = node[key];
73367
+ if (isNode(child) && child.type === "Statement" && child.background === true) node[key] = backgroundCall(child, functions);
73368
+ else rewrite(child, functions);
73369
+ }
73370
+ }
73371
+ function backgroundCall(statement, functions) {
73372
+ const job = JSON.stringify({ ...statement, background: false });
73373
+ return {
73374
+ type: "Statement",
73375
+ pipelines: [{
73376
+ type: "Pipeline",
73377
+ commands: [{
73378
+ type: "SimpleCommand",
73379
+ name: literalWord(BG_COMMAND),
73380
+ args: [{ type: "Word", parts: [{ type: "SingleQuoted", value: job }] }, { type: "Word", parts: [{ type: "SingleQuoted", value: functions }] }],
73381
+ assignments: [],
73382
+ redirections: []
73383
+ }],
73384
+ negated: false,
73385
+ timed: false,
73386
+ timePosix: false
73387
+ }],
73388
+ operators: [],
73389
+ background: false,
73390
+ ...typeof statement.sourceText === "string" ? { sourceText: statement.sourceText } : {}
73391
+ };
73392
+ }
73393
+ function transform$1({ ast }) {
73394
+ let script = ast;
73395
+ const statements = Array.isArray(ast.statements) ? ast.statements : [];
73396
+ if (statements.length === 1 && isNode(statements[0])) {
73397
+ const pipelines = statements[0].pipelines;
73398
+ const command = Array.isArray(pipelines) && isNode(pipelines[0]) && Array.isArray(pipelines[0].commands) ? pipelines[0].commands[0] : void 0;
73399
+ if (isNode(command) && command.type === "SimpleCommand" && wordLiteral(command.name) === ":" && Array.isArray(command.args) && command.args.length === 2 && wordLiteral(command.args[0]) === JOB_PLACEHOLDER) {
73400
+ const token = wordLiteral(command.args[1]);
73401
+ const own = token === null ? void 0 : handoff.get(token);
73402
+ if (own && token !== null) {
73403
+ handoff.delete(token);
73404
+ script = own;
73405
+ }
73406
+ }
73407
+ }
73408
+ if (!Array.isArray(script.statements) || !JSON.stringify(script).match(/"background":true|"parameter":"!"|"value":"wait"/u)) return { ast: script };
73409
+ const functions = JSON.stringify(functionDefinitions(script.statements));
73410
+ rewrite(script.statements, functions);
73411
+ return { ast: script };
73412
+ }
73413
+ function shellOf$1(ctx) {
73414
+ let id2 = ctx.env.get(SHELL_VAR);
73415
+ if (!id2) {
73416
+ id2 = `shell-${nextShell++}`;
73417
+ ctx.env.set(SHELL_VAR, id2);
73418
+ }
73419
+ let shell = shells$1.get(id2);
73420
+ if (!shell) {
73421
+ shell = { jobs: /* @__PURE__ */ new Map(), order: [], pendingOut: "", pendingErr: "" };
73422
+ shells$1.set(id2, shell);
73423
+ }
73424
+ return { id: id2, shell };
73425
+ }
73426
+ function signalNumber(name) {
73427
+ return __substrateSignals[name] ?? 15;
73428
+ }
73429
+ function signalName(spec) {
73430
+ const bare = spec.startsWith("-") ? spec.slice(1) : spec;
73431
+ if (/^\d+$/u.test(bare)) {
73432
+ const number = Number(bare);
73433
+ if (number === 0) return "0";
73434
+ return __substrateSignalNames[number > 128 ? number - 128 : number] ?? null;
73435
+ }
73436
+ const upper = bare.toUpperCase();
73437
+ const name = upper.startsWith("SIG") ? upper : `SIG${upper}`;
73438
+ return __substrateSignals[name] !== void 0 ? name : null;
73439
+ }
73440
+ function startJob(host, ctx, shell, script, sourceText) {
73441
+ var _a3;
73442
+ const token = `job-${nextJob++}`;
73443
+ const parent = host.runTokenOf(ctx);
73444
+ const parentPid = (_a3 = runPid(parent)) == null ? void 0 : _a3.pid;
73445
+ const pid = mintPid();
73446
+ setRunPid(token, pid, parentPid !== void 0 && pidIsLive(parentPid) ? parentPid : 0, { argv: ["sh", "-c", sourceText], cwd: ctx.cwd });
73447
+ const controller = new AbortController();
73448
+ let streamedOut = [];
73449
+ let streamedErr = [];
73450
+ const live = () => parent === null ? void 0 : host.runStreamsFor(parent);
73451
+ host.registerRunStreams(token, {
73452
+ onStdout: (data2) => {
73453
+ var _a4, _b3;
73454
+ streamedOut.push(data2);
73455
+ (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStdout) == null ? void 0 : _b3.call(_a4, data2);
73456
+ },
73457
+ onStderr: (data2) => {
73458
+ var _a4, _b3;
73459
+ streamedErr.push(data2);
73460
+ (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStderr) == null ? void 0 : _b3.call(_a4, data2);
73461
+ },
73462
+ signal: controller.signal,
73463
+ held: false
73464
+ });
73465
+ let settle = () => {
73466
+ };
73467
+ const job = {
73468
+ pid,
73469
+ token,
73470
+ status: null,
73471
+ done: new Promise((resolve2) => {
73472
+ settle = resolve2;
73473
+ }),
73474
+ kill(signal) {
73475
+ if (job.status !== null) return false;
73476
+ if (__signalOwnedProcess(token, signal) || signalPid(pid, signal)) return true;
73477
+ if (IGNORED_BY_DEFAULT.has(signal)) return true;
73478
+ controller.abort(signal);
73479
+ __releaseOwnedServers(token, false);
73480
+ __releaseOwnedHandles(token);
73481
+ __stopOwnedProcess(token);
73482
+ end(128 + signalNumber(signal));
73483
+ return true;
73484
+ }
73485
+ };
73486
+ const end = (status) => {
73487
+ if (job.status !== null) return;
73488
+ job.status = status;
73489
+ host.releaseRunStreams(token);
73490
+ forgetRunPid(token);
73491
+ __substrateChildren.delete(pid);
73492
+ settle(status);
73493
+ };
73494
+ const hold2 = (text, key) => {
73495
+ if (!text) return;
73496
+ const room = PENDING_LIMIT - shell[key].length;
73497
+ if (room > 0) shell[key] += text.slice(0, room);
73498
+ };
73499
+ const env = Object.fromEntries(ctx.env);
73500
+ delete env[SHELL_VAR];
73501
+ env[PROCESS_TOKEN_ENV] = token;
73502
+ handoff.set(token, script);
73503
+ __substrateChildren.set(pid, {
73504
+ get exitCode() {
73505
+ return job.status;
73506
+ },
73507
+ signalCode: null,
73508
+ kill: (signal = "SIGTERM") => job.kill(signal)
73509
+ });
73510
+ const run = ctx.exec ? enterRun(token, () => ctx.exec(`: ${JOB_PLACEHOLDER} ${token}`, { env, cwd: ctx.cwd, replaceEnv: true, signal: controller.signal })) : Promise.resolve({ stdout: "", stderr: "bash: background jobs need a shell that can run a script\n", exitCode: 1 });
73511
+ void Promise.resolve(run).then(
73512
+ (result) => {
73513
+ var _a4, _b3, _c3, _d3;
73514
+ handoff.delete(token);
73515
+ const stdout = result.stdout ?? "";
73516
+ const stderr = result.stderr ?? "";
73517
+ const restOut = unstreamedOutput(stdout, streamedOut);
73518
+ const restErr = unstreamedOutput(stderr, streamedErr);
73519
+ if (restOut) (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStdout) == null ? void 0 : _b3.call(_a4, restOut);
73520
+ if (restErr) (_d3 = (_c3 = live()) == null ? void 0 : _c3.onStderr) == null ? void 0 : _d3.call(_c3, restErr);
73521
+ hold2(stdout, "pendingOut");
73522
+ hold2(stderr, "pendingErr");
73523
+ streamedOut = [];
73524
+ streamedErr = [];
73525
+ end(result.exitCode ?? 0);
73526
+ },
73527
+ (error) => {
73528
+ var _a4, _b3;
73529
+ handoff.delete(token);
73530
+ const text = `${error instanceof Error ? error.message : String(error)}
73531
+ `;
73532
+ (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStderr) == null ? void 0 : _b3.call(_a4, text);
73533
+ hold2(text, "pendingErr");
73534
+ end(1);
73535
+ }
73536
+ );
73537
+ return job;
73538
+ }
73539
+ function flush(shell) {
73540
+ const taken = { stdout: shell.pendingOut, stderr: shell.pendingErr };
73541
+ shell.pendingOut = "";
73542
+ shell.pendingErr = "";
73543
+ return taken;
73544
+ }
73545
+ function installShellJobs(bash, host) {
73546
+ bash.registerTransformPlugin({ name: "tabnode-background-jobs", transform: transform$1 });
73547
+ bash.registerCommand(uA(BG_COMMAND, async (args, ctx) => {
73548
+ let statement;
73549
+ let functions;
73550
+ try {
73551
+ statement = JSON.parse(args[0] ?? "");
73552
+ functions = JSON.parse(args[1] ?? "[]");
73553
+ } catch {
73554
+ return { stdout: "", stderr: `bash: ${BG_COMMAND}: not a job
73555
+ `, exitCode: 2 };
73556
+ }
73557
+ const { shell } = shellOf$1(ctx);
73558
+ const script = { type: "Script", statements: [...functions, statement] };
73559
+ const job = startJob(host, ctx, shell, script, typeof statement.sourceText === "string" ? statement.sourceText : "");
73560
+ shell.jobs.set(job.pid, job);
73561
+ shell.order.push(job.pid);
73562
+ ctx.env.set(LAST_JOB_VAR, String(job.pid));
73563
+ return { stdout: "", stderr: "", exitCode: 0 };
73564
+ }));
73565
+ bash.registerCommand(uA(WAIT_COMMAND, async (args, ctx) => {
73566
+ const { id: id2, shell } = shellOf$1(ctx);
73567
+ let stderr = "";
73568
+ let status = 0;
73569
+ let next2 = false;
73570
+ const targets = [];
73571
+ for (const arg of args) {
73572
+ if (arg === "-n") next2 = true;
73573
+ else if (arg === "-f" || arg === "--") continue;
73574
+ else targets.push(arg);
73575
+ }
73576
+ const aborted = new Promise((resolve2) => {
73577
+ var _a3, _b3;
73578
+ if ((_a3 = ctx.signal) == null ? void 0 : _a3.aborted) resolve2("aborted");
73579
+ (_b3 = ctx.signal) == null ? void 0 : _b3.addEventListener("abort", () => resolve2("aborted"), { once: true });
73580
+ });
73581
+ const running = () => shell.order.map((pid) => shell.jobs.get(pid)).filter((job) => job !== void 0 && job.status === null);
73582
+ const reap = (job) => {
73583
+ shell.jobs.delete(job.pid);
73584
+ shell.order = shell.order.filter((pid) => pid !== job.pid);
73585
+ };
73586
+ if (next2) {
73587
+ const pending = targets.length > 0 ? targets.map((target) => shell.jobs.get(Number(target))).filter((job) => job !== void 0) : shell.order.map((pid) => shell.jobs.get(pid)).filter((job) => job !== void 0);
73588
+ if (pending.length === 0) status = 127;
73589
+ else {
73590
+ const first = await Promise.race([...pending.map((job) => job.done.then(() => job)), aborted]);
73591
+ if (first === "aborted") status = 130;
73592
+ else {
73593
+ status = first.status ?? 0;
73594
+ reap(first);
73595
+ }
73596
+ }
73597
+ } else if (targets.length === 0) {
73598
+ for (let jobs = running(); jobs.length > 0; jobs = running()) {
73599
+ if (await Promise.race([Promise.all(jobs.map((job) => job.done)), aborted]) === "aborted") {
73600
+ status = 130;
73601
+ break;
73602
+ }
73603
+ }
73604
+ for (const pid of [...shell.order]) {
73605
+ const job = shell.jobs.get(pid);
73606
+ if (job && job.status !== null) reap(job);
73607
+ }
73608
+ } else {
73609
+ for (const target of targets) {
73610
+ if (target.startsWith("%")) {
73611
+ stderr += `bash: wait: ${target}: no such job
73612
+ `;
73613
+ status = 127;
73614
+ continue;
73615
+ }
73616
+ const pid = Number(target);
73617
+ const job = Number.isInteger(pid) ? shell.jobs.get(pid) : void 0;
73618
+ if (!job) {
73619
+ stderr += Number.isInteger(pid) ? `bash: wait: pid ${target} is not a child of this shell
73620
+ ` : `bash: wait: \`${target}': not a pid or valid job spec
73621
+ `;
73622
+ status = 127;
73623
+ continue;
73624
+ }
73625
+ const outcome = await Promise.race([job.done, aborted]);
73626
+ if (outcome === "aborted") {
73627
+ status = 130;
73628
+ break;
73629
+ }
73630
+ status = outcome;
73631
+ reap(job);
73632
+ }
73633
+ }
73634
+ const held = flush(shell);
73635
+ if (shell.jobs.size === 0) shells$1.delete(id2);
73636
+ return { stdout: held.stdout, stderr: held.stderr + stderr, exitCode: status };
73637
+ }));
73638
+ bash.registerCommand(uA("kill", async (args) => {
73639
+ let signal = "SIGTERM";
73640
+ let index2 = 0;
73641
+ if (args[0] === "-l" || args[0] === "-L") {
73642
+ const names2 = Object.entries(__substrateSignals).sort((a, b) => a[1] - b[1]).map(([name]) => name.slice(3));
73643
+ if (args[1] !== void 0) {
73644
+ const number = Number(args[1]);
73645
+ const name = Number.isInteger(number) ? __substrateSignalNames[number > 128 ? number - 128 : number] : signalName(args[1]);
73646
+ if (!name) return { stdout: "", stderr: `bash: kill: ${args[1]}: invalid signal specification
73647
+ `, exitCode: 1 };
73648
+ return { stdout: `${Number.isInteger(number) ? name.slice(3) : __substrateSignals[name]}
73649
+ `, stderr: "", exitCode: 0 };
73650
+ }
73651
+ return { stdout: `${names2.join(" ")}
73652
+ `, stderr: "", exitCode: 0 };
73653
+ }
73654
+ if (args[0] === "-s" || args[0] === "-n") {
73655
+ const name = args[1] === void 0 ? null : signalName(args[1]);
73656
+ if (!name) return { stdout: "", stderr: `bash: kill: ${args[1] ?? ""}: invalid signal specification
73657
+ `, exitCode: 1 };
73658
+ signal = name;
73659
+ index2 = 2;
73660
+ } else if (args[0] !== void 0 && args[0].startsWith("-") && args[0] !== "--") {
73661
+ const name = signalName(args[0]);
73662
+ if (!name) return { stdout: "", stderr: `bash: kill: ${args[0].slice(1)}: invalid signal specification
73663
+ `, exitCode: 1 };
73664
+ signal = name;
73665
+ index2 = 1;
73666
+ }
73667
+ if (args[index2] === "--") index2 += 1;
73668
+ const targets = args.slice(index2);
73669
+ if (targets.length === 0) return { stdout: "", stderr: "bash: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]\n", exitCode: 2 };
73670
+ let stderr = "";
73671
+ let status = 0;
73672
+ for (const target of targets) {
73673
+ if (target.startsWith("%")) {
73674
+ stderr += `bash: kill: ${target}: no such job
73675
+ `;
73676
+ status = 1;
73677
+ continue;
73678
+ }
73679
+ if (!/^-?\d+$/u.test(target)) {
73680
+ stderr += `bash: kill: ${target}: arguments must be process or job IDs
73681
+ `;
73682
+ status = 1;
73683
+ continue;
73684
+ }
73685
+ const pid = Math.abs(Number(target));
73686
+ if (!deliver(pid, signal)) {
73687
+ stderr += `bash: kill: (${target}) - No such process
73688
+ `;
73689
+ status = 1;
73690
+ }
73691
+ }
73692
+ return { stdout: "", stderr, exitCode: status };
73693
+ }));
73694
+ bash.registerCommand(uA("disown", async (args, ctx) => {
73695
+ const { shell } = shellOf$1(ctx);
73696
+ const pids = args.filter((arg) => !arg.startsWith("-")).map(Number);
73697
+ const all = args.includes("-a");
73698
+ const chosen = all ? [...shell.order] : pids.length > 0 ? pids : shell.order.slice(-1);
73699
+ for (const pid of chosen) {
73700
+ shell.jobs.delete(pid);
73701
+ shell.order = shell.order.filter((own) => own !== pid);
73702
+ }
73703
+ return { stdout: "", stderr: "", exitCode: 0 };
73704
+ }));
73705
+ }
73706
+ function deliver(pid, signal) {
73707
+ const child = __substrateChildren.get(pid);
73708
+ const childLive = child !== void 0 && child.exitCode === null && child.signalCode === null;
73709
+ if (signal === "0") return childLive || pidIsLive(pid);
73710
+ if (childLive) return child.kill(signal);
73711
+ const token = tokenOfPid(pid);
73712
+ if (token !== null && __signalOwnedProcess(token, signal)) return true;
73713
+ return signalPid(pid, signal);
73714
+ }
73246
73715
  if (typeof globalThis.process === "undefined") {
73247
73716
  globalThis.process = {
73248
73717
  env: {
@@ -73857,6 +74326,7 @@ ${error.stack || ""}` : String(error);
73857
74326
  },
73858
74327
  customCommands: [nodeCommand, npmCommand]
73859
74328
  });
74329
+ installShellJobs(bashInstance, { runTokenOf, runStreamsFor, registerRunStreams, releaseRunStreams });
73860
74330
  shells.set(tree2, { bash: bashInstance, adapter: vfsAdapter });
73861
74331
  if (processRunnerInstalled) return;
73862
74332
  processRunnerInstalled = true;
@@ -74375,17 +74845,17 @@ function startChildRun(request) {
74375
74845
  stdinSink.push(chunk);
74376
74846
  }
74377
74847
  };
74378
- let streamedOut = 0;
74379
- let streamedErr = 0;
74848
+ const streamedOut = [];
74849
+ const streamedErr = [];
74380
74850
  const streams2 = {
74381
74851
  onStdout: (data2) => {
74382
74852
  var _a4;
74383
- streamedOut += data2.length;
74853
+ streamedOut.push(data2);
74384
74854
  (_a4 = request.stdout) == null ? void 0 : _a4.call(request, data2);
74385
74855
  },
74386
74856
  onStderr: (data2) => {
74387
74857
  var _a4;
74388
- streamedErr += data2.length;
74858
+ streamedErr.push(data2);
74389
74859
  (_a4 = request.stderr) == null ? void 0 : _a4.call(request, data2);
74390
74860
  },
74391
74861
  signal: controller.signal,
@@ -74467,8 +74937,10 @@ function startChildRun(request) {
74467
74937
  outcome = { stdout: "", stderr: `${error instanceof Error ? error.message : String(error)}
74468
74938
  `, exitCode: 1 };
74469
74939
  }
74470
- if (outcome.stdout.length > streamedOut) (_a4 = request.stdout) == null ? void 0 : _a4.call(request, outcome.stdout.slice(streamedOut));
74471
- if (outcome.stderr.length > streamedErr) (_b3 = request.stderr) == null ? void 0 : _b3.call(request, outcome.stderr.slice(streamedErr));
74940
+ const restOut = unstreamedOutput(outcome.stdout, streamedOut);
74941
+ const restErr = unstreamedOutput(outcome.stderr, streamedErr);
74942
+ if (restOut) (_a4 = request.stdout) == null ? void 0 : _a4.call(request, restOut);
74943
+ if (restErr) (_b3 = request.stderr) == null ? void 0 : _b3.call(request, restErr);
74472
74944
  end(outcome.exitCode, outcome.signal ?? null);
74473
74945
  })();
74474
74946
  };
@@ -77424,6 +77896,26 @@ function transformEsmToCjsRegex(code2) {
77424
77896
  );
77425
77897
  return transformed;
77426
77898
  }
77899
+ function canStripTypes() {
77900
+ return hostAmaro() !== null;
77901
+ }
77902
+ function startedWith(process2, option) {
77903
+ var _a3;
77904
+ if (Array.isArray(process2.execArgv) && process2.execArgv.includes(option)) return true;
77905
+ const nodeOptions = (_a3 = process2.env) == null ? void 0 : _a3.NODE_OPTIONS;
77906
+ return typeof nodeOptions === "string" && nodeOptions.split(/\s+/u).includes(option);
77907
+ }
77908
+ function transformsTypes(process2) {
77909
+ return startedWith(process2, "--experimental-transform-types");
77910
+ }
77911
+ function stripModuleTypes(source, filename, process2) {
77912
+ const typescript = loadNodeLibFor(process2, "internal/modules/typescript");
77913
+ const transform2 = transformsTypes(process2);
77914
+ return withOptionValues({
77915
+ "--experimental-transform-types": transform2,
77916
+ "--enable-source-maps": transform2 || startedWith(process2, "--enable-source-maps")
77917
+ }, () => typescript.stripTypeScriptModuleTypes(source, filename));
77918
+ }
77427
77919
  function walkAst(node, callback) {
77428
77920
  if (!node || typeof node !== "object") return;
77429
77921
  if (typeof node.type === "string") {
@@ -77457,6 +77949,14 @@ function __substrateGuestConstructor(Constructor, process2) {
77457
77949
  return __substrateFunctionScope(__substrateGuestGlobal(process2), String(compiled));
77458
77950
  } });
77459
77951
  }
77952
+ function __substrateModuleTypes(code2, resolvedPath, format2, process2) {
77953
+ const typescript = format2 === void 0 ? /[.](?:ts|mts|cts)$/u.test(resolvedPath) && !resolvedPath.endsWith(".d.ts") : format2 === "typescript" || format2 === "commonjs-typescript" || format2 === "module-typescript";
77954
+ if (!typescript) return code2;
77955
+ const registered = globalThis.__substrateStripTypes;
77956
+ if (typeof registered === "function") return registered(code2, resolvedPath);
77957
+ if (!canStripTypes()) return code2;
77958
+ return stripModuleTypes(code2, resolvedPath, process2);
77959
+ }
77460
77960
  function __substrateSourceURL(resolvedPath) {
77461
77961
  let name = resolvedPath;
77462
77962
  if (name.startsWith("file://")) {
@@ -77799,11 +78299,11 @@ async function __substrateImportChain(hooks, id2, parentURL, moduleRequire) {
77799
78299
  const doors = moduleRequire;
77800
78300
  const resolved = hooks.hasAsyncResolve ? await hooks.resolve(id2, parentURL, void 0, (specifier) => ({ url: doors.__resolveToURL(specifier) })) : { url: doors.__resolveToURL(id2), format: void 0 };
77801
78301
  if (!hooks.hasAsyncLoad) return doors.__loadFromURL(resolved.url, resolved.format);
77802
- const loaded = await hooks.load(resolved.url, resolved.format, void 0, (url2, context2) => ({
78302
+ const loaded2 = await hooks.load(resolved.url, resolved.format, void 0, (url2, context2) => ({
77803
78303
  source: doors.__readFromURL(url2),
77804
78304
  format: context2.format
77805
78305
  }));
77806
- return doors.__loadFromURL(resolved.url, loaded.format ?? resolved.format, loaded.source ?? void 0);
78306
+ return doors.__loadFromURL(resolved.url, loaded2.format ?? resolved.format, loaded2.source ?? void 0);
77807
78307
  }
77808
78308
  function createDynamicImport(moduleRequire, process2, parentURL) {
77809
78309
  return async (specifier) => {
@@ -78692,14 +79192,14 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
78692
79192
  let source = resolvedAs == null ? void 0 : resolvedAs.source;
78693
79193
  if (__hooks && __hooks.hasSyncLoad && source === void 0) {
78694
79194
  const url2 = (resolvedAs == null ? void 0 : resolvedAs.url) ?? __hooks.sync.convertCJSFilenameToURL(resolvedPath);
78695
- const loaded = __hooks.sync.loadWithHooks(url2, format2, void 0, CJS_CONDITIONS, (urlFromHook, context2) => ({
79195
+ const loaded2 = __hooks.sync.loadWithHooks(url2, format2, void 0, CJS_CONDITIONS, (urlFromHook, context2) => ({
78696
79196
  // Node's `getDefaultLoad`: a URL the chain changed is read from the
78697
79197
  // file it names, not from the one the loader started with.
78698
79198
  source: urlFromHook === url2 ? defaultSource() : vfs2.readFileSync(__hooks.sync.convertURLToCJSFilename(urlFromHook), "utf8"),
78699
79199
  format: context2.format
78700
79200
  }));
78701
- format2 = loaded.format;
78702
- source = loaded.source;
79201
+ format2 = loaded2.format;
79202
+ source = loaded2.source;
78703
79203
  }
78704
79204
  if (format2 === "json" || format2 === void 0 && resolvedPath.endsWith(".json")) {
78705
79205
  module.exports = JSON.parse(source === void 0 || source === null ? vfs2.readFileSync(resolvedPath, "utf8") : String(source));
@@ -78712,22 +79212,18 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
78712
79212
  return module;
78713
79213
  };
78714
79214
  const prepareModuleCode = (rawCode, resolvedPath, format2) => {
78715
- const codeCacheKey = `${resolvedPath}|${format2 ?? ""}|${simpleHash(rawCode)}`;
79215
+ const codeCacheKey = `${resolvedPath}|${format2 ?? ""}|${transformsTypes(process2) ? "transform-types|" : ""}${simpleHash(rawCode)}`;
78716
79216
  let code2 = processedCodeCache == null ? void 0 : processedCodeCache.get(codeCacheKey);
78717
79217
  if (!code2) {
78718
79218
  code2 = rawCode;
78719
79219
  if (code2.startsWith("#!")) {
78720
79220
  code2 = code2.slice(code2.indexOf("\n") + 1);
78721
79221
  }
78722
- const __typescript = format2 === void 0 ? /[.](?:ts|mts|cts)$/u.test(resolvedPath) && !resolvedPath.endsWith(".d.ts") : format2 === "typescript" || format2 === "commonjs-typescript" || format2 === "module-typescript";
78723
- if (__typescript && typeof globalThis.__substrateStripTypes === "function") {
78724
- code2 = globalThis.__substrateStripTypes(code2, resolvedPath);
78725
- }
78726
- const __commonjs = format2 === "commonjs" || format2 === "commonjs-typescript" ? true : format2 === "module" || format2 === "module-typescript" ? false : resolvedPath.endsWith(".cjs");
79222
+ code2 = __substrateModuleTypes(code2, resolvedPath, format2, process2);
79223
+ const __commonjs = format2 === "commonjs" || format2 === "commonjs-typescript" ? true : format2 === "module" || format2 === "module-typescript" ? false : resolvedPath.endsWith(".cjs") || resolvedPath.endsWith(".cts");
78727
79224
  if (!__commonjs) {
78728
79225
  const lowered = transformEsmToCjs(code2, resolvedPath);
78729
- code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";
78730
- ${lowered}`;
79226
+ code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
78731
79227
  } else {
78732
79228
  code2 = transformDynamicImportsRegex(code2);
78733
79229
  }
@@ -78840,9 +79336,9 @@ ${lowered}`;
78840
79336
  const filename = url2 === defaultURL ? defaultFilename : hooks.sync.convertURLToCJSFilename(url2);
78841
79337
  if (isBuiltin(filename)) {
78842
79338
  if (hooks.hasSyncLoad) {
78843
- const loaded = hooks.sync.loadWithHooks(url2, format2 || "builtin", void 0, CJS_CONDITIONS, (_urlFromHook, context2) => ({ source: null, format: context2.format }));
78844
- if (loaded.format && loaded.format !== "builtin") {
78845
- return loadModule(filename, { url: url2, format: loaded.format, source: loaded.source }).exports;
79339
+ const loaded2 = hooks.sync.loadWithHooks(url2, format2 || "builtin", void 0, CJS_CONDITIONS, (_urlFromHook, context2) => ({ source: null, format: context2.format }));
79340
+ if (loaded2.format && loaded2.format !== "builtin") {
79341
+ return loadModule(filename, { url: url2, format: loaded2.format, source: loaded2.source }).exports;
78846
79342
  }
78847
79343
  }
78848
79344
  return requirePlain(filename);
@@ -79099,10 +79595,10 @@ class Runtime {
79099
79595
  if (code2.startsWith("#!")) {
79100
79596
  code2 = code2.slice(code2.indexOf("\n") + 1);
79101
79597
  }
79102
- if (!filename.endsWith(".cjs")) {
79598
+ code2 = __substrateModuleTypes(code2, filename, void 0, this.process);
79599
+ if (!filename.endsWith(".cjs") && !filename.endsWith(".cts")) {
79103
79600
  const lowered = transformEsmToCjs(code2, filename);
79104
- code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";
79105
- ${lowered}`;
79601
+ code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
79106
79602
  } else {
79107
79603
  code2 = transformDynamicImportsRegex(code2);
79108
79604
  }