@volter/tabnode 0.5.17 → 0.5.19

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
  };
@@ -29978,7 +30028,7 @@ function createTimersModule(owned) {
29978
30028
  }
29979
30029
  const NODE_LTS_VERSION = "22.12.0";
29980
30030
  function nodeVersions(node = NODE_LTS_VERSION) {
29981
- return { node, v8: "11.3.244.8", uv: "1.44.2", webcontainer: "1", openssl: "3.0.15" };
30031
+ return { node, v8: "11.3.244.8", uv: "1.44.2", webcontainer: "1", openssl: "3.0.15", amaro: "1.1.0" };
29982
30032
  }
29983
30033
  var StdinClasses;
29984
30034
  function processStdinClass(ReadableClass) {
@@ -35003,7 +35053,7 @@ const fill_window = (s10) => {
35003
35053
  }
35004
35054
  } while (s10.lookahead < MIN_LOOKAHEAD && s10.strm.avail_in !== 0);
35005
35055
  };
35006
- const deflate_stored = (s10, flush) => {
35056
+ const deflate_stored = (s10, flush2) => {
35007
35057
  let min_block = s10.pending_buf_size - 5 > s10.w_size ? s10.w_size : s10.pending_buf_size - 5;
35008
35058
  let len2, left, have, last = 0;
35009
35059
  let used = s10.strm.avail_in;
@@ -35021,10 +35071,10 @@ const deflate_stored = (s10, flush) => {
35021
35071
  if (len2 > have) {
35022
35072
  len2 = have;
35023
35073
  }
35024
- if (len2 < min_block && (len2 === 0 && flush !== Z_FINISH$3 || flush === Z_NO_FLUSH$2 || len2 !== left + s10.strm.avail_in)) {
35074
+ if (len2 < min_block && (len2 === 0 && flush2 !== Z_FINISH$3 || flush2 === Z_NO_FLUSH$2 || len2 !== left + s10.strm.avail_in)) {
35025
35075
  break;
35026
35076
  }
35027
- last = flush === Z_FINISH$3 && len2 === left + s10.strm.avail_in ? 1 : 0;
35077
+ last = flush2 === Z_FINISH$3 && len2 === left + s10.strm.avail_in ? 1 : 0;
35028
35078
  _tr_stored_block(s10, 0, 0, last);
35029
35079
  s10.pending_buf[s10.pending - 4] = len2;
35030
35080
  s10.pending_buf[s10.pending - 3] = len2 >> 8;
@@ -35079,7 +35129,7 @@ const deflate_stored = (s10, flush) => {
35079
35129
  if (last) {
35080
35130
  return BS_FINISH_DONE;
35081
35131
  }
35082
- if (flush !== Z_NO_FLUSH$2 && flush !== Z_FINISH$3 && s10.strm.avail_in === 0 && s10.strstart === s10.block_start) {
35132
+ if (flush2 !== Z_NO_FLUSH$2 && flush2 !== Z_FINISH$3 && s10.strm.avail_in === 0 && s10.strstart === s10.block_start) {
35083
35133
  return BS_BLOCK_DONE;
35084
35134
  }
35085
35135
  have = s10.window_size - s10.strstart;
@@ -35110,22 +35160,22 @@ const deflate_stored = (s10, flush) => {
35110
35160
  have = s10.pending_buf_size - have > 65535 ? 65535 : s10.pending_buf_size - have;
35111
35161
  min_block = have > s10.w_size ? s10.w_size : have;
35112
35162
  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) {
35163
+ if (left >= min_block || (left || flush2 === Z_FINISH$3) && flush2 !== Z_NO_FLUSH$2 && s10.strm.avail_in === 0 && left <= have) {
35114
35164
  len2 = left > have ? have : left;
35115
- last = flush === Z_FINISH$3 && s10.strm.avail_in === 0 && len2 === left ? 1 : 0;
35165
+ last = flush2 === Z_FINISH$3 && s10.strm.avail_in === 0 && len2 === left ? 1 : 0;
35116
35166
  _tr_stored_block(s10, s10.block_start, len2, last);
35117
35167
  s10.block_start += len2;
35118
35168
  flush_pending(s10.strm);
35119
35169
  }
35120
35170
  return last ? BS_FINISH_STARTED : BS_NEED_MORE;
35121
35171
  };
35122
- const deflate_fast = (s10, flush) => {
35172
+ const deflate_fast = (s10, flush2) => {
35123
35173
  let hash_head;
35124
35174
  let bflush;
35125
35175
  for (; ; ) {
35126
35176
  if (s10.lookahead < MIN_LOOKAHEAD) {
35127
35177
  fill_window(s10);
35128
- if (s10.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$2) {
35178
+ if (s10.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH$2) {
35129
35179
  return BS_NEED_MORE;
35130
35180
  }
35131
35181
  if (s10.lookahead === 0) {
@@ -35172,7 +35222,7 @@ const deflate_fast = (s10, flush) => {
35172
35222
  }
35173
35223
  }
35174
35224
  s10.insert = s10.strstart < MIN_MATCH - 1 ? s10.strstart : MIN_MATCH - 1;
35175
- if (flush === Z_FINISH$3) {
35225
+ if (flush2 === Z_FINISH$3) {
35176
35226
  flush_block_only(s10, true);
35177
35227
  if (s10.strm.avail_out === 0) {
35178
35228
  return BS_FINISH_STARTED;
@@ -35187,14 +35237,14 @@ const deflate_fast = (s10, flush) => {
35187
35237
  }
35188
35238
  return BS_BLOCK_DONE;
35189
35239
  };
35190
- const deflate_slow = (s10, flush) => {
35240
+ const deflate_slow = (s10, flush2) => {
35191
35241
  let hash_head;
35192
35242
  let bflush;
35193
35243
  let max_insert;
35194
35244
  for (; ; ) {
35195
35245
  if (s10.lookahead < MIN_LOOKAHEAD) {
35196
35246
  fill_window(s10);
35197
- if (s10.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$2) {
35247
+ if (s10.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH$2) {
35198
35248
  return BS_NEED_MORE;
35199
35249
  }
35200
35250
  if (s10.lookahead === 0) {
@@ -35258,7 +35308,7 @@ const deflate_slow = (s10, flush) => {
35258
35308
  s10.match_available = 0;
35259
35309
  }
35260
35310
  s10.insert = s10.strstart < MIN_MATCH - 1 ? s10.strstart : MIN_MATCH - 1;
35261
- if (flush === Z_FINISH$3) {
35311
+ if (flush2 === Z_FINISH$3) {
35262
35312
  flush_block_only(s10, true);
35263
35313
  if (s10.strm.avail_out === 0) {
35264
35314
  return BS_FINISH_STARTED;
@@ -35273,7 +35323,7 @@ const deflate_slow = (s10, flush) => {
35273
35323
  }
35274
35324
  return BS_BLOCK_DONE;
35275
35325
  };
35276
- const deflate_rle = (s10, flush) => {
35326
+ const deflate_rle = (s10, flush2) => {
35277
35327
  let bflush;
35278
35328
  let prev;
35279
35329
  let scan, strend;
@@ -35281,7 +35331,7 @@ const deflate_rle = (s10, flush) => {
35281
35331
  for (; ; ) {
35282
35332
  if (s10.lookahead <= MAX_MATCH) {
35283
35333
  fill_window(s10);
35284
- if (s10.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH$2) {
35334
+ if (s10.lookahead <= MAX_MATCH && flush2 === Z_NO_FLUSH$2) {
35285
35335
  return BS_NEED_MORE;
35286
35336
  }
35287
35337
  if (s10.lookahead === 0) {
@@ -35320,7 +35370,7 @@ const deflate_rle = (s10, flush) => {
35320
35370
  }
35321
35371
  }
35322
35372
  s10.insert = 0;
35323
- if (flush === Z_FINISH$3) {
35373
+ if (flush2 === Z_FINISH$3) {
35324
35374
  flush_block_only(s10, true);
35325
35375
  if (s10.strm.avail_out === 0) {
35326
35376
  return BS_FINISH_STARTED;
@@ -35335,13 +35385,13 @@ const deflate_rle = (s10, flush) => {
35335
35385
  }
35336
35386
  return BS_BLOCK_DONE;
35337
35387
  };
35338
- const deflate_huff = (s10, flush) => {
35388
+ const deflate_huff = (s10, flush2) => {
35339
35389
  let bflush;
35340
35390
  for (; ; ) {
35341
35391
  if (s10.lookahead === 0) {
35342
35392
  fill_window(s10);
35343
35393
  if (s10.lookahead === 0) {
35344
- if (flush === Z_NO_FLUSH$2) {
35394
+ if (flush2 === Z_NO_FLUSH$2) {
35345
35395
  return BS_NEED_MORE;
35346
35396
  }
35347
35397
  break;
@@ -35359,7 +35409,7 @@ const deflate_huff = (s10, flush) => {
35359
35409
  }
35360
35410
  }
35361
35411
  s10.insert = 0;
35362
- if (flush === Z_FINISH$3) {
35412
+ if (flush2 === Z_FINISH$3) {
35363
35413
  flush_block_only(s10, true);
35364
35414
  if (s10.strm.avail_out === 0) {
35365
35415
  return BS_FINISH_STARTED;
@@ -35582,23 +35632,23 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
35582
35632
  const deflateInit = (strm, level) => {
35583
35633
  return deflateInit2(strm, level, Z_DEFLATED$2, MAX_WBITS$1, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY$1);
35584
35634
  };
35585
- const deflate$2 = (strm, flush) => {
35586
- if (deflateStateCheck(strm) || flush > Z_BLOCK$1 || flush < 0) {
35635
+ const deflate$2 = (strm, flush2) => {
35636
+ if (deflateStateCheck(strm) || flush2 > Z_BLOCK$1 || flush2 < 0) {
35587
35637
  return strm ? err(strm, Z_STREAM_ERROR$2) : Z_STREAM_ERROR$2;
35588
35638
  }
35589
35639
  const s10 = strm.state;
35590
- if (!strm.output || strm.avail_in !== 0 && !strm.input || s10.status === FINISH_STATE && flush !== Z_FINISH$3) {
35640
+ if (!strm.output || strm.avail_in !== 0 && !strm.input || s10.status === FINISH_STATE && flush2 !== Z_FINISH$3) {
35591
35641
  return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR$1 : Z_STREAM_ERROR$2);
35592
35642
  }
35593
35643
  const old_flush = s10.last_flush;
35594
- s10.last_flush = flush;
35644
+ s10.last_flush = flush2;
35595
35645
  if (s10.pending !== 0) {
35596
35646
  flush_pending(strm);
35597
35647
  if (strm.avail_out === 0) {
35598
35648
  s10.last_flush = -1;
35599
35649
  return Z_OK$3;
35600
35650
  }
35601
- } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH$3) {
35651
+ } else if (strm.avail_in === 0 && rank(flush2) <= rank(old_flush) && flush2 !== Z_FINISH$3) {
35602
35652
  return err(strm, Z_BUF_ERROR$1);
35603
35653
  }
35604
35654
  if (s10.status === FINISH_STATE && strm.avail_in !== 0) {
@@ -35787,8 +35837,8 @@ const deflate$2 = (strm, flush) => {
35787
35837
  return Z_OK$3;
35788
35838
  }
35789
35839
  }
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);
35840
+ if (strm.avail_in !== 0 || s10.lookahead !== 0 || flush2 !== Z_NO_FLUSH$2 && s10.status !== FINISH_STATE) {
35841
+ 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
35842
  if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
35793
35843
  s10.status = FINISH_STATE;
35794
35844
  }
@@ -35799,11 +35849,11 @@ const deflate$2 = (strm, flush) => {
35799
35849
  return Z_OK$3;
35800
35850
  }
35801
35851
  if (bstate === BS_BLOCK_DONE) {
35802
- if (flush === Z_PARTIAL_FLUSH) {
35852
+ if (flush2 === Z_PARTIAL_FLUSH) {
35803
35853
  _tr_align(s10);
35804
- } else if (flush !== Z_BLOCK$1) {
35854
+ } else if (flush2 !== Z_BLOCK$1) {
35805
35855
  _tr_stored_block(s10, 0, 0, false);
35806
- if (flush === Z_FULL_FLUSH$1) {
35856
+ if (flush2 === Z_FULL_FLUSH$1) {
35807
35857
  zero(s10.head);
35808
35858
  if (s10.lookahead === 0) {
35809
35859
  s10.strstart = 0;
@@ -35819,7 +35869,7 @@ const deflate$2 = (strm, flush) => {
35819
35869
  }
35820
35870
  }
35821
35871
  }
35822
- if (flush !== Z_FINISH$3) {
35872
+ if (flush2 !== Z_FINISH$3) {
35823
35873
  return Z_OK$3;
35824
35874
  }
35825
35875
  if (s10.wrap <= 0) {
@@ -37038,7 +37088,7 @@ const updatewindow = (strm, src, end, copy2) => {
37038
37088
  }
37039
37089
  return 0;
37040
37090
  };
37041
- const inflate$2 = (strm, flush) => {
37091
+ const inflate$2 = (strm, flush2) => {
37042
37092
  let state;
37043
37093
  let input, output;
37044
37094
  let next2;
@@ -37376,7 +37426,7 @@ const inflate$2 = (strm, flush) => {
37376
37426
  strm.adler = state.check = 1;
37377
37427
  state.mode = TYPE;
37378
37428
  case TYPE:
37379
- if (flush === Z_BLOCK || flush === Z_TREES) {
37429
+ if (flush2 === Z_BLOCK || flush2 === Z_TREES) {
37380
37430
  break inf_leave;
37381
37431
  }
37382
37432
  case TYPEDO:
@@ -37404,7 +37454,7 @@ const inflate$2 = (strm, flush) => {
37404
37454
  case 1:
37405
37455
  fixedtables(state);
37406
37456
  state.mode = LEN_;
37407
- if (flush === Z_TREES) {
37457
+ if (flush2 === Z_TREES) {
37408
37458
  hold2 >>>= 2;
37409
37459
  bits -= 2;
37410
37460
  break inf_leave;
@@ -37440,7 +37490,7 @@ const inflate$2 = (strm, flush) => {
37440
37490
  hold2 = 0;
37441
37491
  bits = 0;
37442
37492
  state.mode = COPY_;
37443
- if (flush === Z_TREES) {
37493
+ if (flush2 === Z_TREES) {
37444
37494
  break inf_leave;
37445
37495
  }
37446
37496
  case COPY_:
@@ -37635,7 +37685,7 @@ const inflate$2 = (strm, flush) => {
37635
37685
  break;
37636
37686
  }
37637
37687
  state.mode = LEN_;
37638
- if (flush === Z_TREES) {
37688
+ if (flush2 === Z_TREES) {
37639
37689
  break inf_leave;
37640
37690
  }
37641
37691
  case LEN_:
@@ -37925,7 +37975,7 @@ const inflate$2 = (strm, flush) => {
37925
37975
  strm.avail_in = have;
37926
37976
  state.hold = hold2;
37927
37977
  state.bits = bits;
37928
- if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {
37978
+ if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH$1)) {
37929
37979
  if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;
37930
37980
  }
37931
37981
  _in -= strm.avail_in;
@@ -37938,7 +37988,7 @@ const inflate$2 = (strm, flush) => {
37938
37988
  state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out);
37939
37989
  }
37940
37990
  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) {
37991
+ if ((_in === 0 && _out === 0 || flush2 === Z_FINISH$1) && ret === Z_OK$1) {
37942
37992
  ret = Z_BUF_ERROR;
37943
37993
  }
37944
37994
  return ret;
@@ -73243,6 +73293,418 @@ function __nodeResolverFor(fs2, profile, extensions) {
73243
73293
  byProfile.set(key, resolver);
73244
73294
  return resolver;
73245
73295
  }
73296
+ function unstreamedOutput(total, streamed) {
73297
+ let rest = total;
73298
+ let cursor = 0;
73299
+ for (const piece of streamed) {
73300
+ if (!piece) continue;
73301
+ const at3 = rest.indexOf(piece, cursor);
73302
+ if (at3 < 0) continue;
73303
+ rest = rest.slice(0, at3) + rest.slice(at3 + piece.length);
73304
+ cursor = at3;
73305
+ }
73306
+ return rest;
73307
+ }
73308
+ const LAST_JOB_VAR = "__TABNODE_LAST_JOB_PID";
73309
+ const SHELL_VAR = "__TABNODE_SHELL";
73310
+ const BG_COMMAND = "__tabnode_bg";
73311
+ const WAIT_COMMAND = "__tabnode_wait";
73312
+ const JOB_PLACEHOLDER = "__tabnode_job";
73313
+ const PENDING_LIMIT = 1 << 20;
73314
+ const IGNORED_BY_DEFAULT = /* @__PURE__ */ new Set(["SIGCHLD", "SIGCONT", "SIGURG", "SIGWINCH"]);
73315
+ const shells$1 = /* @__PURE__ */ new Map();
73316
+ const handoff = /* @__PURE__ */ new Map();
73317
+ let nextShell = 1;
73318
+ let nextJob = 1;
73319
+ function isNode(value) {
73320
+ return typeof value === "object" && value !== null;
73321
+ }
73322
+ function literalWord(value) {
73323
+ return { type: "Word", parts: [{ type: "Literal", value }] };
73324
+ }
73325
+ function wordLiteral(word) {
73326
+ if (!isNode(word) || !Array.isArray(word.parts) || word.parts.length !== 1) return null;
73327
+ const part = word.parts[0];
73328
+ return isNode(part) && part.type === "Literal" && typeof part.value === "string" ? part.value : null;
73329
+ }
73330
+ function definesFunction(statement) {
73331
+ const pipelines = statement.pipelines;
73332
+ return Array.isArray(pipelines) && pipelines.some((pipeline) => isNode(pipeline) && Array.isArray(pipeline.commands) && pipeline.commands.some((command) => isNode(command) && command.type === "FunctionDef"));
73333
+ }
73334
+ function functionDefinitions(node, found = []) {
73335
+ if (Array.isArray(node)) {
73336
+ for (const child of node) functionDefinitions(child, found);
73337
+ return found;
73338
+ }
73339
+ if (!isNode(node)) return found;
73340
+ if (node.type === "Statement" && node.background === true) return found;
73341
+ if (node.type === "Statement" && definesFunction(node)) found.push(node);
73342
+ for (const key of Object.keys(node)) functionDefinitions(node[key], found);
73343
+ return found;
73344
+ }
73345
+ function rewrite(node, functions) {
73346
+ if (Array.isArray(node)) {
73347
+ for (let index2 = 0; index2 < node.length; index2 += 1) {
73348
+ const child = node[index2];
73349
+ if (isNode(child) && child.type === "Statement" && child.background === true) {
73350
+ node[index2] = backgroundCall(child, functions);
73351
+ } else rewrite(child, functions);
73352
+ }
73353
+ return;
73354
+ }
73355
+ if (!isNode(node)) return;
73356
+ if (node.type === "ParameterExpansion" && node.parameter === "!") node.parameter = LAST_JOB_VAR;
73357
+ if (node.type === "SimpleCommand" && wordLiteral(node.name) === "wait") node.name = literalWord(WAIT_COMMAND);
73358
+ for (const key of Object.keys(node)) {
73359
+ const child = node[key];
73360
+ if (isNode(child) && child.type === "Statement" && child.background === true) node[key] = backgroundCall(child, functions);
73361
+ else rewrite(child, functions);
73362
+ }
73363
+ }
73364
+ function backgroundCall(statement, functions) {
73365
+ const job = JSON.stringify({ ...statement, background: false });
73366
+ return {
73367
+ type: "Statement",
73368
+ pipelines: [{
73369
+ type: "Pipeline",
73370
+ commands: [{
73371
+ type: "SimpleCommand",
73372
+ name: literalWord(BG_COMMAND),
73373
+ args: [{ type: "Word", parts: [{ type: "SingleQuoted", value: job }] }, { type: "Word", parts: [{ type: "SingleQuoted", value: functions }] }],
73374
+ assignments: [],
73375
+ redirections: []
73376
+ }],
73377
+ negated: false,
73378
+ timed: false,
73379
+ timePosix: false
73380
+ }],
73381
+ operators: [],
73382
+ background: false,
73383
+ ...typeof statement.sourceText === "string" ? { sourceText: statement.sourceText } : {}
73384
+ };
73385
+ }
73386
+ function transform$1({ ast }) {
73387
+ let script = ast;
73388
+ const statements = Array.isArray(ast.statements) ? ast.statements : [];
73389
+ if (statements.length === 1 && isNode(statements[0])) {
73390
+ const pipelines = statements[0].pipelines;
73391
+ const command = Array.isArray(pipelines) && isNode(pipelines[0]) && Array.isArray(pipelines[0].commands) ? pipelines[0].commands[0] : void 0;
73392
+ if (isNode(command) && command.type === "SimpleCommand" && wordLiteral(command.name) === ":" && Array.isArray(command.args) && command.args.length === 2 && wordLiteral(command.args[0]) === JOB_PLACEHOLDER) {
73393
+ const token = wordLiteral(command.args[1]);
73394
+ const own = token === null ? void 0 : handoff.get(token);
73395
+ if (own && token !== null) {
73396
+ handoff.delete(token);
73397
+ script = own;
73398
+ }
73399
+ }
73400
+ }
73401
+ if (!Array.isArray(script.statements) || !JSON.stringify(script).match(/"background":true|"parameter":"!"|"value":"wait"/u)) return { ast: script };
73402
+ const functions = JSON.stringify(functionDefinitions(script.statements));
73403
+ rewrite(script.statements, functions);
73404
+ return { ast: script };
73405
+ }
73406
+ function shellOf$1(ctx) {
73407
+ let id2 = ctx.env.get(SHELL_VAR);
73408
+ if (!id2) {
73409
+ id2 = `shell-${nextShell++}`;
73410
+ ctx.env.set(SHELL_VAR, id2);
73411
+ }
73412
+ let shell = shells$1.get(id2);
73413
+ if (!shell) {
73414
+ shell = { jobs: /* @__PURE__ */ new Map(), order: [], pendingOut: "", pendingErr: "" };
73415
+ shells$1.set(id2, shell);
73416
+ }
73417
+ return { id: id2, shell };
73418
+ }
73419
+ function signalNumber(name) {
73420
+ return __substrateSignals[name] ?? 15;
73421
+ }
73422
+ function signalName(spec) {
73423
+ const bare = spec.startsWith("-") ? spec.slice(1) : spec;
73424
+ if (/^\d+$/u.test(bare)) {
73425
+ const number = Number(bare);
73426
+ if (number === 0) return "0";
73427
+ return __substrateSignalNames[number > 128 ? number - 128 : number] ?? null;
73428
+ }
73429
+ const upper = bare.toUpperCase();
73430
+ const name = upper.startsWith("SIG") ? upper : `SIG${upper}`;
73431
+ return __substrateSignals[name] !== void 0 ? name : null;
73432
+ }
73433
+ function startJob(host, ctx, shell, script, sourceText) {
73434
+ var _a3;
73435
+ const token = `job-${nextJob++}`;
73436
+ const parent = host.runTokenOf(ctx);
73437
+ const parentPid = (_a3 = runPid(parent)) == null ? void 0 : _a3.pid;
73438
+ const pid = mintPid();
73439
+ setRunPid(token, pid, parentPid !== void 0 && pidIsLive(parentPid) ? parentPid : 0, { argv: ["sh", "-c", sourceText], cwd: ctx.cwd });
73440
+ const controller = new AbortController();
73441
+ let streamedOut = [];
73442
+ let streamedErr = [];
73443
+ const live = () => parent === null ? void 0 : host.runStreamsFor(parent);
73444
+ host.registerRunStreams(token, {
73445
+ onStdout: (data2) => {
73446
+ var _a4, _b3;
73447
+ streamedOut.push(data2);
73448
+ (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStdout) == null ? void 0 : _b3.call(_a4, data2);
73449
+ },
73450
+ onStderr: (data2) => {
73451
+ var _a4, _b3;
73452
+ streamedErr.push(data2);
73453
+ (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStderr) == null ? void 0 : _b3.call(_a4, data2);
73454
+ },
73455
+ signal: controller.signal,
73456
+ held: false
73457
+ });
73458
+ let settle = () => {
73459
+ };
73460
+ const job = {
73461
+ pid,
73462
+ token,
73463
+ status: null,
73464
+ done: new Promise((resolve2) => {
73465
+ settle = resolve2;
73466
+ }),
73467
+ kill(signal) {
73468
+ if (job.status !== null) return false;
73469
+ if (__signalOwnedProcess(token, signal) || signalPid(pid, signal)) return true;
73470
+ if (IGNORED_BY_DEFAULT.has(signal)) return true;
73471
+ controller.abort(signal);
73472
+ __releaseOwnedServers(token, false);
73473
+ __releaseOwnedHandles(token);
73474
+ __stopOwnedProcess(token);
73475
+ end(128 + signalNumber(signal));
73476
+ return true;
73477
+ }
73478
+ };
73479
+ const end = (status) => {
73480
+ if (job.status !== null) return;
73481
+ job.status = status;
73482
+ host.releaseRunStreams(token);
73483
+ forgetRunPid(token);
73484
+ __substrateChildren.delete(pid);
73485
+ settle(status);
73486
+ };
73487
+ const hold2 = (text, key) => {
73488
+ if (!text) return;
73489
+ const room = PENDING_LIMIT - shell[key].length;
73490
+ if (room > 0) shell[key] += text.slice(0, room);
73491
+ };
73492
+ const env = Object.fromEntries(ctx.env);
73493
+ delete env[SHELL_VAR];
73494
+ env[PROCESS_TOKEN_ENV] = token;
73495
+ handoff.set(token, script);
73496
+ __substrateChildren.set(pid, {
73497
+ get exitCode() {
73498
+ return job.status;
73499
+ },
73500
+ signalCode: null,
73501
+ kill: (signal = "SIGTERM") => job.kill(signal)
73502
+ });
73503
+ 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 });
73504
+ void Promise.resolve(run).then(
73505
+ (result) => {
73506
+ var _a4, _b3, _c3, _d3;
73507
+ handoff.delete(token);
73508
+ const stdout = result.stdout ?? "";
73509
+ const stderr = result.stderr ?? "";
73510
+ const restOut = unstreamedOutput(stdout, streamedOut);
73511
+ const restErr = unstreamedOutput(stderr, streamedErr);
73512
+ if (restOut) (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStdout) == null ? void 0 : _b3.call(_a4, restOut);
73513
+ if (restErr) (_d3 = (_c3 = live()) == null ? void 0 : _c3.onStderr) == null ? void 0 : _d3.call(_c3, restErr);
73514
+ hold2(stdout, "pendingOut");
73515
+ hold2(stderr, "pendingErr");
73516
+ streamedOut = [];
73517
+ streamedErr = [];
73518
+ end(result.exitCode ?? 0);
73519
+ },
73520
+ (error) => {
73521
+ var _a4, _b3;
73522
+ handoff.delete(token);
73523
+ const text = `${error instanceof Error ? error.message : String(error)}
73524
+ `;
73525
+ (_b3 = (_a4 = live()) == null ? void 0 : _a4.onStderr) == null ? void 0 : _b3.call(_a4, text);
73526
+ hold2(text, "pendingErr");
73527
+ end(1);
73528
+ }
73529
+ );
73530
+ return job;
73531
+ }
73532
+ function flush(shell) {
73533
+ const taken = { stdout: shell.pendingOut, stderr: shell.pendingErr };
73534
+ shell.pendingOut = "";
73535
+ shell.pendingErr = "";
73536
+ return taken;
73537
+ }
73538
+ function installShellJobs(bash, host) {
73539
+ bash.registerTransformPlugin({ name: "tabnode-background-jobs", transform: transform$1 });
73540
+ bash.registerCommand(uA(BG_COMMAND, async (args, ctx) => {
73541
+ let statement;
73542
+ let functions;
73543
+ try {
73544
+ statement = JSON.parse(args[0] ?? "");
73545
+ functions = JSON.parse(args[1] ?? "[]");
73546
+ } catch {
73547
+ return { stdout: "", stderr: `bash: ${BG_COMMAND}: not a job
73548
+ `, exitCode: 2 };
73549
+ }
73550
+ const { shell } = shellOf$1(ctx);
73551
+ const script = { type: "Script", statements: [...functions, statement] };
73552
+ const job = startJob(host, ctx, shell, script, typeof statement.sourceText === "string" ? statement.sourceText : "");
73553
+ shell.jobs.set(job.pid, job);
73554
+ shell.order.push(job.pid);
73555
+ ctx.env.set(LAST_JOB_VAR, String(job.pid));
73556
+ return { stdout: "", stderr: "", exitCode: 0 };
73557
+ }));
73558
+ bash.registerCommand(uA(WAIT_COMMAND, async (args, ctx) => {
73559
+ const { id: id2, shell } = shellOf$1(ctx);
73560
+ let stderr = "";
73561
+ let status = 0;
73562
+ let next2 = false;
73563
+ const targets = [];
73564
+ for (const arg of args) {
73565
+ if (arg === "-n") next2 = true;
73566
+ else if (arg === "-f" || arg === "--") continue;
73567
+ else targets.push(arg);
73568
+ }
73569
+ const aborted = new Promise((resolve2) => {
73570
+ var _a3, _b3;
73571
+ if ((_a3 = ctx.signal) == null ? void 0 : _a3.aborted) resolve2("aborted");
73572
+ (_b3 = ctx.signal) == null ? void 0 : _b3.addEventListener("abort", () => resolve2("aborted"), { once: true });
73573
+ });
73574
+ const running = () => shell.order.map((pid) => shell.jobs.get(pid)).filter((job) => job !== void 0 && job.status === null);
73575
+ const reap = (job) => {
73576
+ shell.jobs.delete(job.pid);
73577
+ shell.order = shell.order.filter((pid) => pid !== job.pid);
73578
+ };
73579
+ if (next2) {
73580
+ 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);
73581
+ if (pending.length === 0) status = 127;
73582
+ else {
73583
+ const first = await Promise.race([...pending.map((job) => job.done.then(() => job)), aborted]);
73584
+ if (first === "aborted") status = 130;
73585
+ else {
73586
+ status = first.status ?? 0;
73587
+ reap(first);
73588
+ }
73589
+ }
73590
+ } else if (targets.length === 0) {
73591
+ for (let jobs = running(); jobs.length > 0; jobs = running()) {
73592
+ if (await Promise.race([Promise.all(jobs.map((job) => job.done)), aborted]) === "aborted") {
73593
+ status = 130;
73594
+ break;
73595
+ }
73596
+ }
73597
+ for (const pid of [...shell.order]) {
73598
+ const job = shell.jobs.get(pid);
73599
+ if (job && job.status !== null) reap(job);
73600
+ }
73601
+ } else {
73602
+ for (const target of targets) {
73603
+ if (target.startsWith("%")) {
73604
+ stderr += `bash: wait: ${target}: no such job
73605
+ `;
73606
+ status = 127;
73607
+ continue;
73608
+ }
73609
+ const pid = Number(target);
73610
+ const job = Number.isInteger(pid) ? shell.jobs.get(pid) : void 0;
73611
+ if (!job) {
73612
+ stderr += Number.isInteger(pid) ? `bash: wait: pid ${target} is not a child of this shell
73613
+ ` : `bash: wait: \`${target}': not a pid or valid job spec
73614
+ `;
73615
+ status = 127;
73616
+ continue;
73617
+ }
73618
+ const outcome = await Promise.race([job.done, aborted]);
73619
+ if (outcome === "aborted") {
73620
+ status = 130;
73621
+ break;
73622
+ }
73623
+ status = outcome;
73624
+ reap(job);
73625
+ }
73626
+ }
73627
+ const held = flush(shell);
73628
+ if (shell.jobs.size === 0) shells$1.delete(id2);
73629
+ return { stdout: held.stdout, stderr: held.stderr + stderr, exitCode: status };
73630
+ }));
73631
+ bash.registerCommand(uA("kill", async (args) => {
73632
+ let signal = "SIGTERM";
73633
+ let index2 = 0;
73634
+ if (args[0] === "-l" || args[0] === "-L") {
73635
+ const names2 = Object.entries(__substrateSignals).sort((a, b) => a[1] - b[1]).map(([name]) => name.slice(3));
73636
+ if (args[1] !== void 0) {
73637
+ const number = Number(args[1]);
73638
+ const name = Number.isInteger(number) ? __substrateSignalNames[number > 128 ? number - 128 : number] : signalName(args[1]);
73639
+ if (!name) return { stdout: "", stderr: `bash: kill: ${args[1]}: invalid signal specification
73640
+ `, exitCode: 1 };
73641
+ return { stdout: `${Number.isInteger(number) ? name.slice(3) : __substrateSignals[name]}
73642
+ `, stderr: "", exitCode: 0 };
73643
+ }
73644
+ return { stdout: `${names2.join(" ")}
73645
+ `, stderr: "", exitCode: 0 };
73646
+ }
73647
+ if (args[0] === "-s" || args[0] === "-n") {
73648
+ const name = args[1] === void 0 ? null : signalName(args[1]);
73649
+ if (!name) return { stdout: "", stderr: `bash: kill: ${args[1] ?? ""}: invalid signal specification
73650
+ `, exitCode: 1 };
73651
+ signal = name;
73652
+ index2 = 2;
73653
+ } else if (args[0] !== void 0 && args[0].startsWith("-") && args[0] !== "--") {
73654
+ const name = signalName(args[0]);
73655
+ if (!name) return { stdout: "", stderr: `bash: kill: ${args[0].slice(1)}: invalid signal specification
73656
+ `, exitCode: 1 };
73657
+ signal = name;
73658
+ index2 = 1;
73659
+ }
73660
+ if (args[index2] === "--") index2 += 1;
73661
+ const targets = args.slice(index2);
73662
+ 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 };
73663
+ let stderr = "";
73664
+ let status = 0;
73665
+ for (const target of targets) {
73666
+ if (target.startsWith("%")) {
73667
+ stderr += `bash: kill: ${target}: no such job
73668
+ `;
73669
+ status = 1;
73670
+ continue;
73671
+ }
73672
+ if (!/^-?\d+$/u.test(target)) {
73673
+ stderr += `bash: kill: ${target}: arguments must be process or job IDs
73674
+ `;
73675
+ status = 1;
73676
+ continue;
73677
+ }
73678
+ const pid = Math.abs(Number(target));
73679
+ if (!deliver(pid, signal)) {
73680
+ stderr += `bash: kill: (${target}) - No such process
73681
+ `;
73682
+ status = 1;
73683
+ }
73684
+ }
73685
+ return { stdout: "", stderr, exitCode: status };
73686
+ }));
73687
+ bash.registerCommand(uA("disown", async (args, ctx) => {
73688
+ const { shell } = shellOf$1(ctx);
73689
+ const pids = args.filter((arg) => !arg.startsWith("-")).map(Number);
73690
+ const all = args.includes("-a");
73691
+ const chosen = all ? [...shell.order] : pids.length > 0 ? pids : shell.order.slice(-1);
73692
+ for (const pid of chosen) {
73693
+ shell.jobs.delete(pid);
73694
+ shell.order = shell.order.filter((own) => own !== pid);
73695
+ }
73696
+ return { stdout: "", stderr: "", exitCode: 0 };
73697
+ }));
73698
+ }
73699
+ function deliver(pid, signal) {
73700
+ const child = __substrateChildren.get(pid);
73701
+ const childLive = child !== void 0 && child.exitCode === null && child.signalCode === null;
73702
+ if (signal === "0") return childLive || pidIsLive(pid);
73703
+ if (childLive) return child.kill(signal);
73704
+ const token = tokenOfPid(pid);
73705
+ if (token !== null && __signalOwnedProcess(token, signal)) return true;
73706
+ return signalPid(pid, signal);
73707
+ }
73246
73708
  if (typeof globalThis.process === "undefined") {
73247
73709
  globalThis.process = {
73248
73710
  env: {
@@ -73857,6 +74319,7 @@ ${error.stack || ""}` : String(error);
73857
74319
  },
73858
74320
  customCommands: [nodeCommand, npmCommand]
73859
74321
  });
74322
+ installShellJobs(bashInstance, { runTokenOf, runStreamsFor, registerRunStreams, releaseRunStreams });
73860
74323
  shells.set(tree2, { bash: bashInstance, adapter: vfsAdapter });
73861
74324
  if (processRunnerInstalled) return;
73862
74325
  processRunnerInstalled = true;
@@ -74375,17 +74838,17 @@ function startChildRun(request) {
74375
74838
  stdinSink.push(chunk);
74376
74839
  }
74377
74840
  };
74378
- let streamedOut = 0;
74379
- let streamedErr = 0;
74841
+ const streamedOut = [];
74842
+ const streamedErr = [];
74380
74843
  const streams2 = {
74381
74844
  onStdout: (data2) => {
74382
74845
  var _a4;
74383
- streamedOut += data2.length;
74846
+ streamedOut.push(data2);
74384
74847
  (_a4 = request.stdout) == null ? void 0 : _a4.call(request, data2);
74385
74848
  },
74386
74849
  onStderr: (data2) => {
74387
74850
  var _a4;
74388
- streamedErr += data2.length;
74851
+ streamedErr.push(data2);
74389
74852
  (_a4 = request.stderr) == null ? void 0 : _a4.call(request, data2);
74390
74853
  },
74391
74854
  signal: controller.signal,
@@ -74467,8 +74930,10 @@ function startChildRun(request) {
74467
74930
  outcome = { stdout: "", stderr: `${error instanceof Error ? error.message : String(error)}
74468
74931
  `, exitCode: 1 };
74469
74932
  }
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));
74933
+ const restOut = unstreamedOutput(outcome.stdout, streamedOut);
74934
+ const restErr = unstreamedOutput(outcome.stderr, streamedErr);
74935
+ if (restOut) (_a4 = request.stdout) == null ? void 0 : _a4.call(request, restOut);
74936
+ if (restErr) (_b3 = request.stderr) == null ? void 0 : _b3.call(request, restErr);
74472
74937
  end(outcome.exitCode, outcome.signal ?? null);
74473
74938
  })();
74474
74939
  };
@@ -77424,6 +77889,26 @@ function transformEsmToCjsRegex(code2) {
77424
77889
  );
77425
77890
  return transformed;
77426
77891
  }
77892
+ function canStripTypes() {
77893
+ return hostAmaro() !== null;
77894
+ }
77895
+ function startedWith(process2, option) {
77896
+ var _a3;
77897
+ if (Array.isArray(process2.execArgv) && process2.execArgv.includes(option)) return true;
77898
+ const nodeOptions = (_a3 = process2.env) == null ? void 0 : _a3.NODE_OPTIONS;
77899
+ return typeof nodeOptions === "string" && nodeOptions.split(/\s+/u).includes(option);
77900
+ }
77901
+ function transformsTypes(process2) {
77902
+ return startedWith(process2, "--experimental-transform-types");
77903
+ }
77904
+ function stripModuleTypes(source, filename, process2) {
77905
+ const typescript = loadNodeLibFor(process2, "internal/modules/typescript");
77906
+ const transform2 = transformsTypes(process2);
77907
+ return withOptionValues({
77908
+ "--experimental-transform-types": transform2,
77909
+ "--enable-source-maps": transform2 || startedWith(process2, "--enable-source-maps")
77910
+ }, () => typescript.stripTypeScriptModuleTypes(source, filename));
77911
+ }
77427
77912
  function walkAst(node, callback) {
77428
77913
  if (!node || typeof node !== "object") return;
77429
77914
  if (typeof node.type === "string") {
@@ -77457,6 +77942,14 @@ function __substrateGuestConstructor(Constructor, process2) {
77457
77942
  return __substrateFunctionScope(__substrateGuestGlobal(process2), String(compiled));
77458
77943
  } });
77459
77944
  }
77945
+ function __substrateModuleTypes(code2, resolvedPath, format2, process2) {
77946
+ const typescript = format2 === void 0 ? /[.](?:ts|mts|cts)$/u.test(resolvedPath) && !resolvedPath.endsWith(".d.ts") : format2 === "typescript" || format2 === "commonjs-typescript" || format2 === "module-typescript";
77947
+ if (!typescript) return code2;
77948
+ const registered = globalThis.__substrateStripTypes;
77949
+ if (typeof registered === "function") return registered(code2, resolvedPath);
77950
+ if (!canStripTypes()) return code2;
77951
+ return stripModuleTypes(code2, resolvedPath, process2);
77952
+ }
77460
77953
  function __substrateSourceURL(resolvedPath) {
77461
77954
  let name = resolvedPath;
77462
77955
  if (name.startsWith("file://")) {
@@ -77799,11 +78292,11 @@ async function __substrateImportChain(hooks, id2, parentURL, moduleRequire) {
77799
78292
  const doors = moduleRequire;
77800
78293
  const resolved = hooks.hasAsyncResolve ? await hooks.resolve(id2, parentURL, void 0, (specifier) => ({ url: doors.__resolveToURL(specifier) })) : { url: doors.__resolveToURL(id2), format: void 0 };
77801
78294
  if (!hooks.hasAsyncLoad) return doors.__loadFromURL(resolved.url, resolved.format);
77802
- const loaded = await hooks.load(resolved.url, resolved.format, void 0, (url2, context2) => ({
78295
+ const loaded2 = await hooks.load(resolved.url, resolved.format, void 0, (url2, context2) => ({
77803
78296
  source: doors.__readFromURL(url2),
77804
78297
  format: context2.format
77805
78298
  }));
77806
- return doors.__loadFromURL(resolved.url, loaded.format ?? resolved.format, loaded.source ?? void 0);
78299
+ return doors.__loadFromURL(resolved.url, loaded2.format ?? resolved.format, loaded2.source ?? void 0);
77807
78300
  }
77808
78301
  function createDynamicImport(moduleRequire, process2, parentURL) {
77809
78302
  return async (specifier) => {
@@ -77895,7 +78388,8 @@ function __substratePackageIdentity(vfs2, file) {
77895
78388
  function __webStreamsModule() {
77896
78389
  const module = {};
77897
78390
  for (const name of ["ReadableStream", "ReadableStreamDefaultReader", "ReadableStreamBYOBReader", "ReadableStreamBYOBRequest", "ReadableByteStreamController", "ReadableStreamDefaultController", "TransformStream", "TransformStreamDefaultController", "WritableStream", "WritableStreamDefaultWriter", "WritableStreamDefaultController", "ByteLengthQueuingStrategy", "CountQueuingStrategy", "TextEncoderStream", "TextDecoderStream", "CompressionStream", "DecompressionStream"]) {
77898
- if (typeof globalThis[name] !== "undefined") module[name] = globalThis[name];
78391
+ if (typeof globalThis[name] === "undefined") continue;
78392
+ Object.defineProperty(module, name, { enumerable: true, configurable: true, get: () => globalThis[name] });
77899
78393
  }
77900
78394
  return module;
77901
78395
  }
@@ -78692,14 +79186,14 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
78692
79186
  let source = resolvedAs == null ? void 0 : resolvedAs.source;
78693
79187
  if (__hooks && __hooks.hasSyncLoad && source === void 0) {
78694
79188
  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) => ({
79189
+ const loaded2 = __hooks.sync.loadWithHooks(url2, format2, void 0, CJS_CONDITIONS, (urlFromHook, context2) => ({
78696
79190
  // Node's `getDefaultLoad`: a URL the chain changed is read from the
78697
79191
  // file it names, not from the one the loader started with.
78698
79192
  source: urlFromHook === url2 ? defaultSource() : vfs2.readFileSync(__hooks.sync.convertURLToCJSFilename(urlFromHook), "utf8"),
78699
79193
  format: context2.format
78700
79194
  }));
78701
- format2 = loaded.format;
78702
- source = loaded.source;
79195
+ format2 = loaded2.format;
79196
+ source = loaded2.source;
78703
79197
  }
78704
79198
  if (format2 === "json" || format2 === void 0 && resolvedPath.endsWith(".json")) {
78705
79199
  module.exports = JSON.parse(source === void 0 || source === null ? vfs2.readFileSync(resolvedPath, "utf8") : String(source));
@@ -78712,22 +79206,18 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
78712
79206
  return module;
78713
79207
  };
78714
79208
  const prepareModuleCode = (rawCode, resolvedPath, format2) => {
78715
- const codeCacheKey = `${resolvedPath}|${format2 ?? ""}|${simpleHash(rawCode)}`;
79209
+ const codeCacheKey = `${resolvedPath}|${format2 ?? ""}|${transformsTypes(process2) ? "transform-types|" : ""}${simpleHash(rawCode)}`;
78716
79210
  let code2 = processedCodeCache == null ? void 0 : processedCodeCache.get(codeCacheKey);
78717
79211
  if (!code2) {
78718
79212
  code2 = rawCode;
78719
79213
  if (code2.startsWith("#!")) {
78720
79214
  code2 = code2.slice(code2.indexOf("\n") + 1);
78721
79215
  }
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");
79216
+ code2 = __substrateModuleTypes(code2, resolvedPath, format2, process2);
79217
+ const __commonjs = format2 === "commonjs" || format2 === "commonjs-typescript" ? true : format2 === "module" || format2 === "module-typescript" ? false : resolvedPath.endsWith(".cjs") || resolvedPath.endsWith(".cts");
78727
79218
  if (!__commonjs) {
78728
79219
  const lowered = transformEsmToCjs(code2, resolvedPath);
78729
- code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";
78730
- ${lowered}`;
79220
+ code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
78731
79221
  } else {
78732
79222
  code2 = transformDynamicImportsRegex(code2);
78733
79223
  }
@@ -78840,9 +79330,9 @@ ${lowered}`;
78840
79330
  const filename = url2 === defaultURL ? defaultFilename : hooks.sync.convertURLToCJSFilename(url2);
78841
79331
  if (isBuiltin(filename)) {
78842
79332
  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;
79333
+ const loaded2 = hooks.sync.loadWithHooks(url2, format2 || "builtin", void 0, CJS_CONDITIONS, (_urlFromHook, context2) => ({ source: null, format: context2.format }));
79334
+ if (loaded2.format && loaded2.format !== "builtin") {
79335
+ return loadModule(filename, { url: url2, format: loaded2.format, source: loaded2.source }).exports;
78846
79336
  }
78847
79337
  }
78848
79338
  return requirePlain(filename);
@@ -79099,10 +79589,10 @@ class Runtime {
79099
79589
  if (code2.startsWith("#!")) {
79100
79590
  code2 = code2.slice(code2.indexOf("\n") + 1);
79101
79591
  }
79102
- if (!filename.endsWith(".cjs")) {
79592
+ code2 = __substrateModuleTypes(code2, filename, void 0, this.process);
79593
+ if (!filename.endsWith(".cjs") && !filename.endsWith(".cts")) {
79103
79594
  const lowered = transformEsmToCjs(code2, filename);
79104
- code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";
79105
- ${lowered}`;
79595
+ code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
79106
79596
  } else {
79107
79597
  code2 = transformDynamicImportsRegex(code2);
79108
79598
  }