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IAAK,EAAW,MAAO,IAExE,IAAK,EAAU,MAAQ,SAAS,EAE5C,CAIA,OAHI,GACF,EAAW,IAAI,EAAe,GAEzB,CACT,CACA,MAAM,EAAQ,CAAC,GAAO,UAAS,eAAc,GAAS,CAAC,IAC9C,IAAI,SAAQ,MAAO,EAAS,KACjC,GAAK,GAAY,UAAW,GAGrB,GAAI,KAAY,eAAgB,GAAO,CAC5C,MAAM,QAAc,EAAS,EAAK,IAAK,oBAAqB,IACxD,IAAO,EAAK,WAAa,EAC/B,MANmC,CACjC,MAAM,QAAc,EAAS,EAAK,IAAK,oBAAqB,IACxD,IAAO,EAAK,MAAQ,EAC1B,CAIA,IAAI,EACA,EACA,MACI,WAAY,IAAS,WAAW,kBACpC,EAAa,IAAI,gBACjB,EAAK,OAAS,EAAW,QAE3B,EAAY,YAAW,KACrB,GAAY,UACZ,MAAM,EAAM,IAAI,aAAa,GAAG,EAAK,QAAU,SAAS,WAAW,sBAAwB,OAC3F,EAAO,EAAI,GACV,GACH,GAAW,WAEb,EAAoB,EAAK,GAAM,MAAM,IAC/B,GAAW,aAAa,GAC5B,EAAQ,EAAI,IACX,OAAO,IAER,GADI,GAAW,aAAa,GACX,eAAb,EAAI,KAAuB,OAAO,EAAQ,IAAI,UAClD,EAAO,EAAI,GACX,IASN,OANA,EAAM,WAAa,KACjB,IAAK,MAAM,KAAS,EAAW,SACzB,YAAa,GAAO,EAAM,UAEhC,EAAW,OAAO,EAEb,CACT,QAEE,aACA","file":"/npm/fetch-enhanced@12.3.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/fetch-enhanced@12.3.2/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","import require$$0 from \"https\";\nimport require$$1 from \"http\";\nimport require$$2 from \"url\";\nimport { Agent as Agent$1 } from \"node:http\";\nimport { Agent } from \"node:https\";\nfunction getDefaultExportFromCjs(x) {\n  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, \"default\") ? x[\"default\"] : x;\n}\nvar hpagent;\nvar hasRequiredHpagent;\nfunction requireHpagent() {\n  if (hasRequiredHpagent) return hpagent;\n  hasRequiredHpagent = 1;\n  const https = require$$0;\n  const http = require$$1;\n  const { URL: URL2 } = require$$2;\n  class HttpProxyAgent2 extends http.Agent {\n    constructor(options) {\n      const { proxy, proxyRequestOptions, ...opts } = options;\n      super(opts);\n      this.proxy = typeof proxy === \"string\" ? new URL2(proxy) : proxy;\n      this.proxyRequestOptions = proxyRequestOptions || {};\n    }\n    createConnection(options, callback) {\n      const requestOptions = {\n        ...this.proxyRequestOptions,\n        method: \"CONNECT\",\n        host: this.proxy.hostname,\n        port: this.proxy.port,\n        path: `${options.host}:${options.port}`,\n        setHost: false,\n        headers: { ...this.proxyRequestOptions.headers, connection: this.keepAlive ? \"keep-alive\" : \"close\", host: `${options.host}:${options.port}` },\n        agent: false,\n        timeout: options.timeout || 0\n      };\n      if (this.proxy.username || this.proxy.password) {\n        const base64 = Buffer.from(`${decodeURIComponent(this.proxy.username || \"\")}:${decodeURIComponent(this.proxy.password || \"\")}`).toString(\"base64\");\n        requestOptions.headers[\"proxy-authorization\"] = `Basic ${base64}`;\n      }\n      if (this.proxy.protocol === \"https:\") {\n        requestOptions.servername = this.proxy.hostname;\n      }\n      const request = (this.proxy.protocol === \"http:\" ? http : https).request(requestOptions);\n      request.once(\"connect\", (response, socket, head) => {\n        request.removeAllListeners();\n        socket.removeAllListeners();\n        if (response.statusCode === 200) {\n          callback(null, socket);\n        } else {\n          socket.destroy();\n          callback(new Error(`Bad response: ${response.statusCode}`), null);\n        }\n      });\n      request.once(\"timeout\", () => {\n        request.destroy(new Error(\"Proxy timeout\"));\n      });\n      request.once(\"error\", (err) => {\n        request.removeAllListeners();\n        callback(err, null);\n      });\n      request.end();\n    }\n  }\n  class HttpsProxyAgent2 extends https.Agent {\n    constructor(options) {\n      const { proxy, proxyRequestOptions, ...opts } = options;\n      super(opts);\n      this.proxy = typeof proxy === \"string\" ? new URL2(proxy) : proxy;\n      this.proxyRequestOptions = proxyRequestOptions || {};\n    }\n    createConnection(options, callback) {\n      const requestOptions = {\n        ...this.proxyRequestOptions,\n        method: \"CONNECT\",\n        host: this.proxy.hostname,\n        port: this.proxy.port,\n        path: `${options.host}:${options.port}`,\n        setHost: false,\n        headers: { ...this.proxyRequestOptions.headers, connection: this.keepAlive ? \"keep-alive\" : \"close\", host: `${options.host}:${options.port}` },\n        agent: false,\n        timeout: options.timeout || 0\n      };\n      if (this.proxy.username || this.proxy.password) {\n        const base64 = Buffer.from(`${decodeURIComponent(this.proxy.username || \"\")}:${decodeURIComponent(this.proxy.password || \"\")}`).toString(\"base64\");\n        requestOptions.headers[\"proxy-authorization\"] = `Basic ${base64}`;\n      }\n      if (this.proxy.protocol === \"https:\") {\n        requestOptions.servername = this.proxy.hostname;\n      }\n      const request = (this.proxy.protocol === \"http:\" ? http : https).request(requestOptions);\n      request.once(\"connect\", (response, socket, head) => {\n        request.removeAllListeners();\n        socket.removeAllListeners();\n        if (response.statusCode === 200) {\n          const secureSocket = super.createConnection({ ...options, socket });\n          callback(null, secureSocket);\n        } else {\n          socket.destroy();\n          callback(new Error(`Bad response: ${response.statusCode}`), null);\n        }\n      });\n      request.once(\"timeout\", () => {\n        request.destroy(new Error(\"Proxy timeout\"));\n      });\n      request.once(\"error\", (err) => {\n        request.removeAllListeners();\n        callback(err, null);\n      });\n      request.end();\n    }\n  }\n  hpagent = {\n    HttpProxyAgent: HttpProxyAgent2,\n    HttpsProxyAgent: HttpsProxyAgent2\n  };\n  return hpagent;\n}\nvar hpagentExports = requireHpagent();\nconst mod = /* @__PURE__ */ getDefaultExportFromCjs(hpagentExports);\nconst HttpProxyAgent = mod.HttpProxyAgent;\nconst HttpsProxyAgent = mod.HttpsProxyAgent;\nclass QuickLRU extends Map {\n  #size = 0;\n  #cache = /* @__PURE__ */ new Map();\n  #oldCache = /* @__PURE__ */ new Map();\n  #maxSize;\n  #maxAge;\n  #onEviction;\n  constructor(options = {}) {\n    super();\n    if (!(options.maxSize && options.maxSize > 0)) {\n      throw new TypeError(\"`maxSize` must be a number greater than 0\");\n    }\n    if (typeof options.maxAge === \"number\" && options.maxAge === 0) {\n      throw new TypeError(\"`maxAge` must be a number greater than 0\");\n    }\n    this.#maxSize = options.maxSize;\n    this.#maxAge = options.maxAge || Number.POSITIVE_INFINITY;\n    this.#onEviction = options.onEviction;\n  }\n  // For tests.\n  get __oldCache() {\n    return this.#oldCache;\n  }\n  #emitEvictions(cache) {\n    if (typeof this.#onEviction !== \"function\") {\n      return;\n    }\n    for (const [key, item] of cache) {\n      this.#onEviction(key, item.value);\n    }\n  }\n  #deleteIfExpired(key, item) {\n    if (typeof item.expiry === \"number\" && item.expiry <= Date.now()) {\n      if (typeof this.#onEviction === \"function\") {\n        this.#onEviction(key, item.value);\n      }\n      return this.delete(key);\n    }\n    return false;\n  }\n  #getOrDeleteIfExpired(key, item) {\n    const deleted = this.#deleteIfExpired(key, item);\n    if (deleted === false) {\n      return item.value;\n    }\n  }\n  #getItemValue(key, item) {\n    return item.expiry ? this.#getOrDeleteIfExpired(key, item) : item.value;\n  }\n  #peek(key, cache) {\n    const item = cache.get(key);\n    return this.#getItemValue(key, item);\n  }\n  #set(key, value) {\n    this.#cache.set(key, value);\n    this.#size++;\n    if (this.#size >= this.#maxSize) {\n      this.#size = 0;\n      this.#emitEvictions(this.#oldCache);\n      this.#oldCache = this.#cache;\n      this.#cache = /* @__PURE__ */ new Map();\n    }\n  }\n  #moveToRecent(key, item) {\n    this.#oldCache.delete(key);\n    this.#set(key, item);\n  }\n  *#entriesAscending() {\n    for (const item of this.#oldCache) {\n      const [key, value] = item;\n      if (!this.#cache.has(key)) {\n        const deleted = this.#deleteIfExpired(key, value);\n        if (deleted === false) {\n          yield item;\n        }\n      }\n    }\n    for (const item of this.#cache) {\n      const [key, value] = item;\n      const deleted = this.#deleteIfExpired(key, value);\n      if (deleted === false) {\n        yield item;\n      }\n    }\n  }\n  get(key) {\n    if (this.#cache.has(key)) {\n      const item = this.#cache.get(key);\n      return this.#getItemValue(key, item);\n    }\n    if (this.#oldCache.has(key)) {\n      const item = this.#oldCache.get(key);\n      if (this.#deleteIfExpired(key, item) === false) {\n        this.#moveToRecent(key, item);\n        return item.value;\n      }\n    }\n  }\n  set(key, value, { maxAge = this.#maxAge } = {}) {\n    const expiry = typeof maxAge === \"number\" && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : void 0;\n    if (this.#cache.has(key)) {\n      this.#cache.set(key, {\n        value,\n        expiry\n      });\n    } else {\n      this.#set(key, { value, expiry });\n    }\n    return this;\n  }\n  has(key) {\n    if (this.#cache.has(key)) {\n      return !this.#deleteIfExpired(key, this.#cache.get(key));\n    }\n    if (this.#oldCache.has(key)) {\n      return !this.#deleteIfExpired(key, this.#oldCache.get(key));\n    }\n    return false;\n  }\n  peek(key) {\n    if (this.#cache.has(key)) {\n      return this.#peek(key, this.#cache);\n    }\n    if (this.#oldCache.has(key)) {\n      return this.#peek(key, this.#oldCache);\n    }\n  }\n  expiresIn(key) {\n    const item = this.#cache.get(key) ?? this.#oldCache.get(key);\n    if (item) {\n      return item.expiry ? item.expiry - Date.now() : Number.POSITIVE_INFINITY;\n    }\n  }\n  delete(key) {\n    const deleted = this.#cache.delete(key);\n    if (deleted) {\n      this.#size--;\n    }\n    return this.#oldCache.delete(key) || deleted;\n  }\n  clear() {\n    this.#cache.clear();\n    this.#oldCache.clear();\n    this.#size = 0;\n  }\n  resize(newSize) {\n    if (!(newSize && newSize > 0)) {\n      throw new TypeError(\"`maxSize` must be a number greater than 0\");\n    }\n    const items = [...this.#entriesAscending()];\n    const removeCount = items.length - newSize;\n    if (removeCount < 0) {\n      this.#cache = new Map(items);\n      this.#oldCache = /* @__PURE__ */ new Map();\n      this.#size = items.length;\n    } else {\n      if (removeCount > 0) {\n        this.#emitEvictions(items.slice(0, removeCount));\n      }\n      this.#oldCache = new Map(items.slice(removeCount));\n      this.#cache = /* @__PURE__ */ new Map();\n      this.#size = 0;\n    }\n    this.#maxSize = newSize;\n  }\n  evict(count = 1) {\n    const requested = Number(count);\n    if (!requested || requested <= 0) {\n      return;\n    }\n    const items = [...this.#entriesAscending()];\n    const evictCount = Math.trunc(Math.min(requested, Math.max(items.length - 1, 0)));\n    if (evictCount <= 0) {\n      return;\n    }\n    this.#emitEvictions(items.slice(0, evictCount));\n    this.#oldCache = new Map(items.slice(evictCount));\n    this.#cache = /* @__PURE__ */ new Map();\n    this.#size = 0;\n  }\n  *keys() {\n    for (const [key] of this) {\n      yield key;\n    }\n  }\n  *values() {\n    for (const [, value] of this) {\n      yield value;\n    }\n  }\n  *[Symbol.iterator]() {\n    for (const item of this.#cache) {\n      const [key, value] = item;\n      const deleted = this.#deleteIfExpired(key, value);\n      if (deleted === false) {\n        yield [key, value.value];\n      }\n    }\n    for (const item of this.#oldCache) {\n      const [key, value] = item;\n      if (!this.#cache.has(key)) {\n        const deleted = this.#deleteIfExpired(key, value);\n        if (deleted === false) {\n          yield [key, value.value];\n        }\n      }\n    }\n  }\n  *entriesDescending() {\n    let items = [...this.#cache];\n    for (let i = items.length - 1; i >= 0; --i) {\n      const item = items[i];\n      const [key, value] = item;\n      const deleted = this.#deleteIfExpired(key, value);\n      if (deleted === false) {\n        yield [key, value.value];\n      }\n    }\n    items = [...this.#oldCache];\n    for (let i = items.length - 1; i >= 0; --i) {\n      const item = items[i];\n      const [key, value] = item;\n      if (!this.#cache.has(key)) {\n        const deleted = this.#deleteIfExpired(key, value);\n        if (deleted === false) {\n          yield [key, value.value];\n        }\n      }\n    }\n  }\n  *entriesAscending() {\n    for (const [key, value] of this.#entriesAscending()) {\n      yield [key, value.value];\n    }\n  }\n  get size() {\n    if (!this.#size) {\n      return this.#oldCache.size;\n    }\n    let oldCacheSize = 0;\n    for (const key of this.#oldCache.keys()) {\n      if (!this.#cache.has(key)) {\n        oldCacheSize++;\n      }\n    }\n    return Math.min(this.#size + oldCacheSize, this.#maxSize);\n  }\n  get maxSize() {\n    return this.#maxSize;\n  }\n  get maxAge() {\n    return this.#maxAge;\n  }\n  entries() {\n    return this.entriesAscending();\n  }\n  forEach(callbackFunction, thisArgument = this) {\n    for (const [key, value] of this.entriesAscending()) {\n      callbackFunction.call(thisArgument, value, key, this);\n    }\n  }\n  get [Symbol.toStringTag]() {\n    return \"QuickLRU\";\n  }\n  toString() {\n    return `QuickLRU(${this.size}/${this.maxSize})`;\n  }\n  [/* @__PURE__ */ Symbol.for(\"nodejs.util.inspect.custom\")]() {\n    return this.toString();\n  }\n}\nvar DEFAULT_PORTS = {\n  ftp: 21,\n  gopher: 70,\n  http: 80,\n  https: 443,\n  ws: 80,\n  wss: 443\n};\nfunction parseUrl(urlString) {\n  try {\n    return new URL(urlString);\n  } catch {\n    return null;\n  }\n}\nfunction getProxyForUrl(url) {\n  var parsedUrl = (typeof url === \"string\" ? parseUrl(url) : url) || {};\n  var proto = parsedUrl.protocol;\n  var hostname = parsedUrl.host;\n  var port = parsedUrl.port;\n  if (typeof hostname !== \"string\" || !hostname || typeof proto !== \"string\") {\n    return \"\";\n  }\n  proto = proto.split(\":\", 1)[0];\n  hostname = hostname.replace(/:\\d*$/, \"\");\n  port = parseInt(port) || DEFAULT_PORTS[proto] || 0;\n  if (!shouldProxy(hostname, port)) {\n    return \"\";\n  }\n  var proxy = getEnv(proto + \"_proxy\") || getEnv(\"all_proxy\");\n  if (proxy && proxy.indexOf(\"://\") === -1) {\n    proxy = proto + \"://\" + proxy;\n  }\n  return proxy;\n}\nfunction shouldProxy(hostname, port) {\n  var NO_PROXY = getEnv(\"no_proxy\").toLowerCase();\n  if (!NO_PROXY) {\n    return true;\n  }\n  if (NO_PROXY === \"*\") {\n    return false;\n  }\n  return NO_PROXY.split(/[,\\s]/).every(function(proxy) {\n    if (!proxy) {\n      return true;\n    }\n    var parsedProxy = proxy.match(/^(.+):(\\d+)$/);\n    var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;\n    var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;\n    if (parsedProxyPort && parsedProxyPort !== port) {\n      return true;\n    }\n    if (!/^[.*]/.test(parsedProxyHostname)) {\n      return hostname !== parsedProxyHostname;\n    }\n    if (parsedProxyHostname.charAt(0) === \"*\") {\n      parsedProxyHostname = parsedProxyHostname.slice(1);\n    }\n    return !hostname.endsWith(parsedProxyHostname);\n  });\n}\nfunction getEnv(key) {\n  return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || \"\";\n}\nconst defaultAgentOpts = {\n  maxSockets: 64,\n  keepAlive: false\n};\nclass TimeoutError extends Error {\n  constructor(message) {\n    super(message);\n    this.name = \"TimeoutError\";\n  }\n}\nconst inputToUrl = (url) => url instanceof URL ? url : new URL(url);\nconst inputToStr = (url) => url instanceof URL ? String(url) : url;\nfunction fetchEnhanced(fetchImplementation, { undici, agentCacheSize } = { undici: false }) {\n  const agentCache = new QuickLRU({ maxSize: agentCacheSize ?? 512 });\n  async function getAgent(url, agentOpts = {}) {\n    const { origin, protocol } = inputToUrl(url);\n    const proxyUrl = agentOpts?.noProxy ? null : getProxyForUrl(url instanceof URL ? String(url) : url);\n    const agentCacheKey = JSON.stringify({ proxyUrl, origin, ...agentOpts });\n    if (agentCache.has(agentCacheKey)) return agentCache.get(agentCacheKey);\n    let agent;\n    if (\"noProxy\" in agentOpts) delete agentOpts.noProxy;\n    if (undici) {\n      const undiciOpts = { ...agentOpts };\n      if (\"keepAlive\" in undiciOpts && !(\"pipelining\" in undiciOpts)) {\n        undiciOpts.pipelining = undiciOpts.keepAlive ? 1 : 0;\n      }\n      if (\"keepAlive\" in undiciOpts) {\n        delete undiciOpts.keepAlive;\n      }\n      if (\"maxSockets\" in undiciOpts && typeof undiciOpts.maxSockets === \"number\") {\n        undiciOpts.connections = undiciOpts.maxSockets;\n        delete undiciOpts.maxSockets;\n      }\n      let UndiciProxyAgent;\n      let UndiciAgent;\n      let hadError = false;\n      try {\n        ({ ProxyAgent: UndiciProxyAgent, Agent: UndiciAgent } = await import(\"undici\"));\n      } catch {\n        hadError = true;\n      }\n      if (proxyUrl && hadError) {\n        throw new Error(`Please install the \"undici\" package to enable proxy support`);\n      }\n      if (proxyUrl && UndiciProxyAgent) {\n        agent = new UndiciProxyAgent({ ...undiciOpts, uri: proxyUrl });\n      } else if (UndiciAgent) {\n        agent = new UndiciAgent(undiciOpts);\n      }\n    } else {\n      const isHttps = protocol === \"https:\";\n      if (proxyUrl) {\n        agent = new (isHttps ? HttpsProxyAgent : HttpProxyAgent)({ ...agentOpts, proxy: proxyUrl });\n      } else {\n        agent = new (isHttps ? Agent : Agent$1)(agentOpts);\n      }\n    }\n    if (agent) {\n      agentCache.set(agentCacheKey, agent);\n    }\n    return agent;\n  }\n  const fetch = (url, { timeout, agentOpts, ...opts } = {}) => {\n    return new Promise(async (resolve, reject) => {\n      if (!undici && !(\"agent\" in opts)) {\n        const agent = await getAgent(url, { ...defaultAgentOpts, ...agentOpts });\n        if (agent) opts.agent = agent;\n      } else if (undici && !(\"dispatcher\" in opts)) {\n        const agent = await getAgent(url, { ...defaultAgentOpts, ...agentOpts });\n        if (agent) opts.dispatcher = agent;\n      }\n      let timeoutId;\n      let controller;\n      if (timeout) {\n        if (!(\"signal\" in opts) && globalThis.AbortController) {\n          controller = new AbortController();\n          opts.signal = controller.signal;\n        }\n        timeoutId = setTimeout(() => {\n          controller?.abort?.();\n          const err = new TimeoutError(`${opts.method || \"GET\"} ${inputToStr(url)} timed out after ${timeout}ms`);\n          reject(err);\n        }, timeout);\n        timeoutId?.unref?.();\n      }\n      fetchImplementation(url, opts).then((res) => {\n        if (timeoutId) clearTimeout(timeoutId);\n        resolve(res);\n      }).catch((err) => {\n        if (timeoutId) clearTimeout(timeoutId);\n        if (err.name === \"AbortError\") return resolve(new Response());\n        reject(err);\n      });\n    });\n  };\n  fetch.clearCache = () => {\n    for (const agent of agentCache.values()) {\n      if (\"destroy\" in agent) agent.destroy();\n    }\n    agentCache.clear();\n  };\n  return fetch;\n}\nexport {\n  TimeoutError,\n  fetchEnhanced as default\n};\n"]}