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,KAAK,KAAK,OAAO,GAE9E,CAKA,qBAAA,GACI,OAAO,uBAAuB,KAAM,6BAA8B,KAAK,MAC3E,CAQA,IAAA,GACI,OAA+E,IAA3E,uBAAuB,KAAM,6BAA8B,KAAK,QAAgB,uBAAuB,KAAM,uBAAwB,OAAS,UAAU,KACjJ,IAAI,SAAS,IAChB,GAAS,IAIN,IAAI,SAAS,IAChB,uBAAuB,KAAM,uBAAwB,KAAK,KAAK,QAAQ,KACnE,GAAS,GACX,GAGd,EAEJ,6BAA+B,IAAI,QAAW,uBAAyB,IAAI,QAAW,sBAAwB,IAAI,QAAW,wBAA0B,IAAI,QAAW,0BAA4B,IAAI,QAAW,2BAA6B,IAAI,QAAW,kCAAoC,IAAI,QAAW,uBAAyB,IAAI,QAE7U,QAAQ,eAAiB,eACzB,QAAQ,WAAa,WACrB,QAAQ,SAAW,SACnB,QAAQ,aAAe,aACvB,QAAQ,QAAU","file":"/npm/http-connection-pool@1.0.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/http-connection-pool@1.0.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar node_events = require('node:events');\nvar http = require('node:http');\nvar https = require('node:https');\nvar stream = require('node:stream');\n\n/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\n\r\nfunction __classPrivateFieldGet(receiver, state, kind, f) {\r\n    if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n    if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n    return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nfunction __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n    if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n    if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n    if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n    return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\ntypeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n    var e = new Error(message);\r\n    return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\n\nfunction sleep(ms) {\n    return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Checks if the `number` is positive integer.\n * @param number number\n * @returns\n */\nfunction isPositiveInteger(number) {\n    return Number.isInteger(number) && number > 0;\n}\n\n/**\n * Checks if the retryObject is valid.\n * * If valid, return true.\n * * If invalid, throw {@link HcpError}\n */\nfunction isValidRetry(retry) {\n    if (typeof retry === \"undefined\") ;\n    else if (typeof retry === \"number\") {\n        if (!isPositiveInteger(retry)) {\n            throw new HcpError(`The value of \"retry\" expected positive number, not ${retry}`, HcpErrorCode.INVALID_ARGS);\n        }\n    }\n    else {\n        if (!(typeof retry.hooks?.afterRetryHook === \"function\") && !(typeof retry.hooks?.afterRetryHook === \"undefined\")) {\n            throw new HcpError(`The value of \"afterRetryHook\" expected function, not ${typeof retry.hooks.afterRetryHook}`, HcpErrorCode.TYPE_ERROR);\n        }\n        if (!(typeof retry.hooks?.beforeRetryHook === \"function\") && !(typeof retry.hooks?.beforeRetryHook === \"undefined\")) {\n            throw new HcpError(`The value of \"beforeRetryHook\" expected function, not ${typeof retry.hooks.beforeRetryHook}`, HcpErrorCode.TYPE_ERROR);\n        }\n        if (!(typeof retry.hooks?.retryErrorHandler === \"function\") && !(typeof retry.hooks?.retryErrorHandler === \"undefined\")) {\n            throw new HcpError(`The value of \"retryErrorHandler\" expected function, not ${typeof retry.hooks.retryErrorHandler}`, HcpErrorCode.TYPE_ERROR);\n        }\n        if (!isPositiveInteger(retry.retry)) {\n            throw new HcpError(`The value of \"retry\" expected positive number, not ${retry.retry}`, HcpErrorCode.INVALID_ARGS);\n        }\n        if (!isPositiveInteger(retry.retryDelay ?? 1)) {\n            throw new HcpError(`The value of \"retryDelay\" expected positive number, not ${retry.retryDelay}`, HcpErrorCode.INVALID_ARGS);\n        }\n    }\n    return true;\n}\n/**\n * ```typescript\n * const defaultConfig = {\n    maxRetryCount: 0,\n    retryDelay: 0\n  }\n * ```\n  Return {@link RetryConfig RetryConfig}\n\n * If the param is\n * * undefined => {@link defaultConfig}\n * * number => {@link defaultConfig defaultConfig (replace maxRetryCount)}\n * * Retry Object => as it is\n * @param retry\n * @returns\n */\nfunction createRetry(retry) {\n    isValidRetry(retry);\n    const defaultConfig = {\n        retry: 0,\n        retryDelay: 0\n    };\n    if (typeof retry === \"undefined\") {\n        return defaultConfig;\n    }\n    else if (typeof retry === \"number\") {\n        return { ...defaultConfig, retry };\n    }\n    else {\n        return { ...defaultConfig, ...retry };\n    }\n}\n\n/**\n * Return URL object.\n *\n * Receive url string or {@link UrlInfo Url Info Object}\n * @param urlInfo {@link UrlInfo}\n * @returns\n */\nfunction createUrl(urlInfo) {\n    if (typeof urlInfo === \"string\") {\n        return new URL(urlInfo);\n    }\n    else {\n        let url = urlInfo.protocol + \"://\";\n        url += urlInfo.host;\n        url += urlInfo.port ? `:${urlInfo.port}` : \"\";\n        url += urlInfo.path ? (urlInfo.path[0] === \"/\" ? urlInfo.path : `/${urlInfo.path}`) : \"\";\n        if (urlInfo.urlQuery) {\n            url += \"?\";\n            for (const [key, value] of Object.entries(urlInfo.urlQuery)) {\n                url += `${key}=${value}&`;\n            }\n            url = url.substring(0, url.length - 1);\n        }\n        return new URL(url);\n    }\n}\n\nconst HcpErrorCode = {\n    INVALID_ARGS: \"ERR_INVALID_ARGS\",\n    TIMEOUT: 'ERR_TIMEOUT',\n    BAD_REQUEST: \"ERR_BAD_REQUEST\",\n    BAD_RESPONSE: 'ERR_BAD_RESPONSE',\n    VALUE_ERROR: \"ERR_VALUE\",\n    TYPE_ERROR: \"ERR_TYPE\",\n    UNKNOWN_ERROR: 'ERR_UNKNOWN',\n};\n\nclass HcpError extends Error {\n    constructor(message, code, options) {\n        super(message);\n        this.code = code;\n        this.name = \"HCP_ERROR\";\n        if (options?.config) {\n            this.config = options.config;\n        }\n        if (options?.req) {\n            this.req = options.req;\n        }\n        if (options?.res) {\n            this.res = options.res;\n        }\n        if (options?.origin && !(options.origin instanceof HcpError)) {\n            this.origin = options.origin;\n        }\n        if (options?.retryCount) {\n            this.retryCount = options.retryCount;\n        }\n    }\n}\n\n/**\n * Checks if the retryObject is valid.\n * * If valid, return true.\n * * If invalid, throw {@link HcpError}\n */\nfunction isValidTimeout(timeout) {\n    if (typeof timeout === \"undefined\") ;\n    else if (typeof timeout === \"number\") {\n        if (!isPositiveInteger(timeout)) {\n            throw new HcpError(`The value of \"timeout\" expected positive number, not ${timeout}`, HcpErrorCode.INVALID_ARGS);\n        }\n    }\n    else {\n        if (!isPositiveInteger(timeout.timeout)) {\n            throw new HcpError(`The value of \"timeout\" expected positive number, not ${timeout.timeout}`, HcpErrorCode.INVALID_ARGS);\n        }\n    }\n    return true;\n}\nfunction createTimeout(timeout) {\n    isValidTimeout(timeout);\n    const defaultConfig = {\n        timeout: 0\n    };\n    if (typeof timeout === \"undefined\") {\n        return defaultConfig;\n    }\n    else if (typeof timeout === \"number\") {\n        return { ...defaultConfig, timeout };\n    }\n    else {\n        return { ...defaultConfig, ...timeout };\n    }\n}\n\nconst HTTPMethod = {\n    get: \"get\",\n    GET: \"GET\",\n    post: \"post\",\n    POST: \"POST\",\n    patch: \"patch\",\n    PATCH: \"PATCH\",\n    put: \"put\",\n    PUT: \"PUT\",\n    delete: \"delete\",\n    DELETE: \"DELETE\",\n    options: \"options\",\n    OPTIONS: \"OPTIONS\",\n    head: \"head\",\n    HEAD: \"HEAD\"\n};\n\nclass HttpClient {\n}\n\nvar _HcpHttpClient_instances, _HcpHttpClient_validateStatusCode;\n/**\n * Class that performs HTTP requests.\n */\nclass HcpHttpClient extends HttpClient {\n    constructor(config) {\n        super();\n        _HcpHttpClient_instances.add(this);\n        this.config = config;\n        this.retryCount = 0;\n        this.maxRetryCount = config.retry?.retry ?? 0;\n        this.retryDelay = config.retry?.retryDelay ?? 0;\n        this.timeout = config.timeout?.timeout ?? 0;\n        this.beforeRetryHook = config.retry?.hooks?.beforeRetryHook;\n        this.afterRetryHook = config.retry?.hooks?.afterRetryHook;\n        this.retryErrorHandler = config.retry?.hooks?.retryErrorHandler;\n        this.url = config.url;\n        this.method = config.method ?? HTTPMethod.GET;\n        this.headers = config.requestHeaders;\n        this.isHttps = this.url.protocol === \"https:\";\n        this.body = config.requestBody;\n        this.transport = this.isHttps ? https : http;\n        this.agent = this.isHttps ? (config.httpsAgent ?? new https.Agent({ keepAlive: true })) : (config.httpAgent ?? new http.Agent({ keepAlive: true }));\n        this.ignoreStatusCodes = config.ignoreStatusCodes;\n    }\n    /**\n     * Performs an HTTP request according to the configuration information.\n     *\n     * Only send and receive\n     * @returns\n     */\n    dispatch() {\n        return new Promise((resolve, reject) => {\n            const req = this.transport.request(this.url, {\n                method: this.method,\n                agent: this.agent,\n                headers: this.headers\n            }, (res) => {\n                if (!__classPrivateFieldGet(this, _HcpHttpClient_instances, \"m\", _HcpHttpClient_validateStatusCode).call(this, res.statusCode)) {\n                    reject(new HcpError(`${res.statusMessage} with status code ${res.statusCode}`, HcpErrorCode.BAD_RESPONSE, { config: this.config, req, res, retryCount: this.retryCount }));\n                }\n                else {\n                    let body = '';\n                    res.on('data', (chunk) => {\n                        body += chunk;\n                    });\n                    res.on('end', () => {\n                        resolve({\n                            statusCode: res.statusCode,\n                            statusMessage: res.statusMessage,\n                            headers: res.headers,\n                            body: body,\n                            config: this.config,\n                        });\n                    });\n                    res.on('error', (error) => {\n                        reject(new HcpError(error?.message ?? \"Response Error\", error?.code ?? HcpErrorCode.BAD_RESPONSE, { config: this.config, req, origin: error, retryCount: this.retryCount }));\n                    });\n                }\n            });\n            if (this.body) {\n                if (this.body instanceof stream) {\n                    if (typeof req.getHeader(\"content-type\") === \"undefined\") {\n                        console.warn(`[HCP_WARNNING]: Request header \"Content-Type\" is empty.`);\n                    }\n                    this.body.pipe(req);\n                }\n                else if (typeof this.body == \"string\") {\n                    if (typeof req.getHeader(\"content-type\") === \"undefined\") {\n                        req.setHeader('Content-Type', 'text/plain');\n                    }\n                    if (typeof req.getHeader(\"Content-Length\") === \"undefined\") {\n                        req.setHeader(\"Content-Length\", Buffer.byteLength(this.body));\n                    }\n                    req.write(this.body);\n                }\n                else {\n                    if (typeof req.getHeader(\"Content-Type\") === \"undefined\") {\n                        req.setHeader('Content-Type', 'application/json');\n                    }\n                    if (typeof req.getHeader(\"Content-Length\") === \"undefined\") {\n                        req.setHeader(\"Content-Length\", Buffer.byteLength(JSON.stringify(this.body)));\n                    }\n                    req.write(JSON.stringify(this.body));\n                }\n            }\n            req.on('error', (error) => {\n                reject(new HcpError(error?.message ?? 'Unknwon Error', error?.code ?? HcpErrorCode.UNKNOWN_ERROR, { config: this.config, req, origin: error, retryCount: this.retryCount }));\n            });\n            if (this.timeout > 0) {\n                req.setTimeout(this.timeout, () => {\n                    this.afterTimeoutHook?.(req);\n                    req.destroy(new HcpError(`Request Timeout ${this.timeout}ms`, HcpErrorCode.TIMEOUT));\n                });\n            }\n            if (this.body instanceof stream) {\n                this.body.on('end', () => {\n                    req.end();\n                });\n            }\n            else {\n                req.end();\n            }\n        });\n    }\n    /**\n     * Wrapper for dispatch function\n     *\n     * Perform add-on functions such as retry and timeout\n     * @returns\n     */\n    call() {\n        return new Promise(async (resolve, reject) => {\n            let lastError;\n            while (this.retryCount <= this.maxRetryCount) {\n                try {\n                    if (this.retryCount >= 1) {\n                        this.beforeRetryHook?.(this.retryCount);\n                        await sleep(this.retryDelay);\n                    }\n                    const res = await this.dispatch();\n                    resolve(res);\n                    break;\n                }\n                catch (error) {\n                    this.retryErrorHandler?.(error);\n                    lastError = error;\n                }\n                finally {\n                    if (this.retryCount >= 1) {\n                        this.afterRetryHook?.(this.retryCount);\n                    }\n                    this.retryCount++;\n                }\n            }\n            reject(lastError);\n        });\n    }\n}\n_HcpHttpClient_instances = new WeakSet(), _HcpHttpClient_validateStatusCode = function _HcpHttpClient_validateStatusCode(statusCode) {\n    if (typeof statusCode === \"undefined\") {\n        return true;\n    }\n    else {\n        if (this.ignoreStatusCodes?.includes(statusCode)) {\n            return true;\n        }\n        if (statusCode < 400) {\n            return true;\n        }\n    }\n    return false;\n};\n\nclass ExternalHttpClient extends HttpClient {\n    constructor(fn, ...args) {\n        super();\n        this.fn = fn;\n        this.args = args;\n    }\n    call() {\n        return this.fn(...this.args);\n    }\n}\n\nvar _ConnectionPool_requestQueue, _ConnectionPool_events, _ConnectionPool_retry, _ConnectionPool_timeout, _ConnectionPool_httpAgent, _ConnectionPool_httpsAgent, _ConnectionPool_ignoreStatusCodes, _ConnectionPool_status;\nconst HcpStatus = {\n    IDLE: 'IDLE',\n    BUSY: 'BUSY'\n};\n/**\n * Class for performing multiple HTTP requests\n *\n * Requests are stored in an internal queue, and are pulled out and executed one by one.\n *\n * All requests are performed as many times as possible simultaneously. (default 10)\n *\n * If the size is 10, no more than 10 requests can be performed simultaneously.\n */\nclass ConnectionPool {\n    constructor(config) {\n        /**\n         * Queue where requests are stored\n         *\n         * Additional requests are added to this queue, and requests are performed on a first-in-first-out basis.\n         */\n        _ConnectionPool_requestQueue.set(this, void 0);\n        /**\n         * EventEmitter for internal operations\n         */\n        _ConnectionPool_events.set(this, void 0);\n        _ConnectionPool_retry.set(this, void 0);\n        _ConnectionPool_timeout.set(this, void 0);\n        /**\n         * To use the same httpAgent in many Request instances\n         */\n        _ConnectionPool_httpAgent.set(this, void 0);\n        /**\n         * To use the same httpsAgent in many Request instances\n         */\n        _ConnectionPool_httpsAgent.set(this, void 0);\n        _ConnectionPool_ignoreStatusCodes.set(this, void 0);\n        _ConnectionPool_status.set(this, void 0);\n        __classPrivateFieldSet(this, _ConnectionPool_httpAgent, new http.Agent({ keepAlive: true }), \"f\");\n        __classPrivateFieldSet(this, _ConnectionPool_httpsAgent, new https.Agent({ keepAlive: true }), \"f\");\n        if (typeof config === \"undefined\") {\n            this.size = 10;\n        }\n        else if (typeof config === \"number\") {\n            if (isPositiveInteger(config)) {\n                this.size = config;\n            }\n            else {\n                throw new HcpError(`The value of \"size\" expected positive number, not ${config}`, HcpErrorCode.INVALID_ARGS);\n            }\n        }\n        else {\n            if (isPositiveInteger(config.size)) {\n                this.size = config.size;\n            }\n            else {\n                throw new HcpError(`The value of \"size\" expected positive number, not ${config.size}`, HcpErrorCode.INVALID_ARGS);\n            }\n            if (isValidRetry(config.retry)) {\n                __classPrivateFieldSet(this, _ConnectionPool_retry, config.retry, \"f\");\n            }\n            if (isValidTimeout(config.timeout)) {\n                __classPrivateFieldSet(this, _ConnectionPool_timeout, config.timeout, \"f\");\n            }\n            if (config.httpAgent) {\n                __classPrivateFieldSet(this, _ConnectionPool_httpAgent, config.httpAgent, \"f\");\n            }\n            if (config.httpsAgent) {\n                __classPrivateFieldSet(this, _ConnectionPool_httpsAgent, config.httpsAgent, \"f\");\n            }\n            __classPrivateFieldSet(this, _ConnectionPool_ignoreStatusCodes, config.ignoreStatuCodes, \"f\");\n        }\n        __classPrivateFieldSet(this, _ConnectionPool_requestQueue, [], \"f\");\n        __classPrivateFieldSet(this, _ConnectionPool_events, new node_events.EventEmitter(), \"f\");\n        this.currentSize = 0;\n        __classPrivateFieldSet(this, _ConnectionPool_status, HcpStatus.IDLE, \"f\");\n        /**\n         * The 'next' event performs the queued request and calls the 'next' event.\n         *\n         * When an HTTP response comes, reduce the currentSize and call the 'next' event.\n         */\n        __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").on('next', () => {\n            if (this.currentSize < this.size && __classPrivateFieldGet(this, _ConnectionPool_requestQueue, \"f\").length > 0) {\n                const requestItem = __classPrivateFieldGet(this, _ConnectionPool_requestQueue, \"f\").shift();\n                if (requestItem !== undefined) {\n                    const { request, resolve, reject } = requestItem;\n                    this.currentSize++;\n                    __classPrivateFieldSet(this, _ConnectionPool_status, HcpStatus.BUSY, \"f\");\n                    request.call()\n                        .then(resolve)\n                        .catch(reject)\n                        .finally(() => {\n                        this.currentSize--;\n                        __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").emit('next');\n                        if (this.currentSize === 0) {\n                            __classPrivateFieldSet(this, _ConnectionPool_status, HcpStatus.IDLE, \"f\");\n                            __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").emit(\"done\");\n                        }\n                    });\n                    __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").emit('next');\n                }\n            }\n        });\n    }\n    /**\n     * When a new request comes in, it adds the request to the internal queue and calls the 'next' event.\n     * @param requestConfig\n     * @returns\n     */\n    add(requestConfig) {\n        return new Promise((resolve, reject) => {\n            try {\n                const request = new HcpHttpClient({\n                    url: createUrl(requestConfig.url),\n                    requestHeaders: requestConfig.headers,\n                    requestBody: requestConfig.body,\n                    httpAgent: __classPrivateFieldGet(this, _ConnectionPool_httpAgent, \"f\"),\n                    httpsAgent: __classPrivateFieldGet(this, _ConnectionPool_httpsAgent, \"f\"),\n                    method: requestConfig.method,\n                    retry: typeof requestConfig.retry === \"undefined\" ? createRetry(__classPrivateFieldGet(this, _ConnectionPool_retry, \"f\")) : createRetry(requestConfig.retry),\n                    timeout: typeof requestConfig.timeout === \"undefined\" ? createTimeout(__classPrivateFieldGet(this, _ConnectionPool_timeout, \"f\")) : createTimeout(requestConfig.timeout),\n                    ignoreStatusCodes: __classPrivateFieldGet(this, _ConnectionPool_ignoreStatusCodes, \"f\")\n                });\n                __classPrivateFieldGet(this, _ConnectionPool_requestQueue, \"f\").push({\n                    request,\n                    resolve,\n                    reject\n                });\n                __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").emit('next');\n            }\n            catch (error) {\n                reject(new HcpError(error?.message ?? \"Add Request Error\", error?.code ?? HcpErrorCode.BAD_REQUEST, { origin: error }));\n            }\n        });\n    }\n    addExternalHttpClient(fn, ...args) {\n        return new Promise((resolve, reject) => {\n            __classPrivateFieldGet(this, _ConnectionPool_requestQueue, \"f\").push({\n                request: new ExternalHttpClient(fn, ...args),\n                resolve,\n                reject\n            });\n            __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").emit('next');\n        });\n    }\n    /**\n     * Return remaining queue size\n     * @returns\n     */\n    getPendingRequestSize() {\n        return __classPrivateFieldGet(this, _ConnectionPool_requestQueue, \"f\").length;\n    }\n    /**\n     * Return Promise.\n     *\n     * After calling this method, the promise is fulfilled the first time the queue size becomes 0.\n     *\n     * If the queue size is 0, Promise is fulfilled immediately.\n     */\n    done() {\n        if (__classPrivateFieldGet(this, _ConnectionPool_requestQueue, \"f\").length === 0 && __classPrivateFieldGet(this, _ConnectionPool_status, \"f\") === HcpStatus.IDLE) {\n            return new Promise((resolve) => {\n                resolve();\n            });\n        }\n        else {\n            return new Promise((resolve) => {\n                __classPrivateFieldGet(this, _ConnectionPool_events, \"f\").once('done', () => {\n                    resolve();\n                });\n            });\n        }\n    }\n}\n_ConnectionPool_requestQueue = new WeakMap(), _ConnectionPool_events = new WeakMap(), _ConnectionPool_retry = new WeakMap(), _ConnectionPool_timeout = new WeakMap(), _ConnectionPool_httpAgent = new WeakMap(), _ConnectionPool_httpsAgent = new WeakMap(), _ConnectionPool_ignoreStatusCodes = new WeakMap(), _ConnectionPool_status = new WeakMap();\n\nexports.ConnectionPool = ConnectionPool;\nexports.HTTPMethod = HTTPMethod;\nexports.HcpError = HcpError;\nexports.HcpErrorCode = HcpErrorCode;\nexports.default = ConnectionPool;\n"]}