{"version":3,"sources":["jsdelivr-header.js","/npm/ky@1.14.2/source/errors/HTTPError.ts","/npm/ky@1.14.2/source/errors/NonError.ts","/npm/ky@1.14.2/source/errors/ForceRetryError.ts","/npm/ky@1.14.2/source/core/constants.ts","/npm/ky@1.14.2/source/utils/body.ts","/npm/ky@1.14.2/source/utils/is.ts","/npm/ky@1.14.2/source/utils/merge.ts","/npm/ky@1.14.2/source/utils/normalize.ts","/npm/ky@1.14.2/source/errors/TimeoutError.ts","/npm/ky@1.14.2/source/utils/type-guards.ts","/npm/ky@1.14.2/source/core/Ky.ts","/npm/ky@1.14.2/source/utils/options.ts","/npm/ky@1.14.2/source/utils/delay.ts","/npm/ky@1.14.2/source/utils/timeout.ts","/npm/ky@1.14.2/source/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACFM,MAAO,UAA+B,MACpC,SACA,QACA,QAEP,WAAA,CAAY,EAAoB,EAAkB,GACjD,MAEM,EAAS,GAFD,EAAS,QAA8B,IAApB,EAAS,OAAgB,EAAS,OAAS,MAC9D,EAAS,YAAc,KACH,OAGlC,MAAM,uBAFS,EAAS,eAAe,IAAW,uBAEV,EAAQ,UAAU,EAAQ,OAElE,KAAK,KAAO,YACZ,KAAK,SAAW,EAChB,KAAK,QAAU,EACf,KAAK,QAAU,C,ECfX,MAAO,UAAiB,MACpB,KAAO,WACP,MAET,WAAA,CAAY,GACX,IAAI,EAAU,6BAGd,IACsB,iBAAV,EACV,EAAU,EACA,GAA0B,iBAAV,GAAsB,YAAa,GAAkC,iBAAlB,EAAM,UACnF,EAAU,EAAM,Q,CAEhB,M,CAIF,MAAM,GAEN,KAAK,MAAQ,C,EClBT,MAAO,UAAwB,MAC3B,KAAO,kBAChB,YACA,KACA,cAEA,WAAA,CAAY,GAGX,MAAM,EAAQ,GAAS,MACnB,EAAQ,iBAAiB,MAAQ,EAAQ,MAAQ,IAAI,EAAS,EAAQ,YACvE,EAEH,MACC,GAAS,KAAO,iBAAiB,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,OAAU,IACe,mBAAhB,IACV,EAAc,EAAY,GAAY,KAGhC,EAAe,EAAiB,EAAU,KAGlD,EAAG,KAAO,EACV,EAAG,MAAQ,EAEJ,CAAgB,EAGlB,EAAK,W","file":"/npm/ky@1.14.2/distribution/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/ky@1.14.2/distribution/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 type {NormalizedOptions} from '../types/options.js';\nimport type {KyRequest} from '../types/request.js';\nimport type {KyResponse} from '../types/response.js';\n\nexport class HTTPError<T = unknown> extends Error {\n\tpublic response: KyResponse<T>;\n\tpublic request: KyRequest;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText ?? '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}: ${request.method} ${request.url}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","/**\nWrapper for non-Error values that were thrown.\n\nIn JavaScript, any value can be thrown (not just Error instances). This class wraps such values to ensure consistent error handling.\n*/\nexport class NonError extends Error {\n\toverride name = 'NonError';\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tlet message = 'Non-error value was thrown';\n\n\t\t// Intentionally minimal as this error is just an edge-case.\n\t\ttry {\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tmessage = value;\n\t\t\t} else if (value && typeof value === 'object' && 'message' in value && typeof value.message === 'string') {\n\t\t\t\tmessage = value.message;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Use default message if accessing properties throws\n\t\t}\n\n\t\tsuper(message);\n\n\t\tthis.value = value;\n\t}\n}\n","import type {ForceRetryOptions} from '../core/constants.js';\nimport {NonError} from './NonError.js';\n\n/**\nInternal error used to signal a forced retry from afterResponse hooks.\nThis is thrown when a user returns ky.retry() from an afterResponse hook.\n*/\nexport class ForceRetryError extends Error {\n\toverride name = 'ForceRetryError' as const;\n\tcustomDelay: number | undefined;\n\tcode: string | undefined;\n\tcustomRequest: Request | undefined;\n\n\tconstructor(options?: ForceRetryOptions) {\n\t\t// Runtime protection: wrap non-Error causes in NonError\n\t\t// TypeScript type is Error for guidance, but JS users can pass anything\n\t\tconst cause = options?.cause\n\t\t\t? (options.cause instanceof Error ? options.cause : new NonError(options.cause))\n\t\t\t: undefined;\n\n\t\tsuper(\n\t\t\toptions?.code ? `Forced retry: ${options.code}` : 'Forced retry',\n\t\t\tcause ? {cause} : undefined,\n\t\t);\n\n\t\tthis.customDelay = options?.delay;\n\t\tthis.code = options?.code;\n\t\tthis.customRequest = options?.request;\n\t}\n}\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type KyOptionsRegistry, type RequestHttpMethod} from '../types/options.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\ttry {\n\t\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\t\tmethod: 'POST',\n\t\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\t\tget duplex() {\n\t\t\t\t\tduplexAccessed = true;\n\t\t\t\t\treturn 'half';\n\t\t\t\t},\n\t\t\t}).headers.has('Content-Type');\n\t\t} catch (error) {\n\t\t\t// QQBrowser on iOS throws \"unsupported BodyInit type\" error (see issue #581)\n\t\t\tif (error instanceof Error && error.message === 'unsupported BodyInit type') {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsAbortSignal = typeof globalThis.AbortSignal === 'function' && typeof globalThis.AbortSignal.any === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], RequestHttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n\t// Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).\n\t// We still feature-check at runtime before exposing the shortcut.\n\tbytes: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\n// Size in bytes of a typical form boundary, used to help estimate upload size\nexport const usualFormBoundarySize = new TextEncoder().encode('------WebKitFormBoundaryaxpyiPgbbPti10Rw').length;\n\nexport const stop = Symbol('stop');\n\n/**\nOptions for forcing a retry via `ky.retry()`.\n*/\nexport type ForceRetryOptions = {\n\t/**\n\tCustom delay in milliseconds before retrying.\n\n\tIf not provided, uses the default retry delay calculation based on `retry.delay` configuration.\n\n\t**Note:** Custom delays bypass jitter and `backoffLimit`. This is intentional, as custom delays often come from server responses (e.g., `Retry-After` headers) and should be respected exactly as specified.\n\t*/\n\tdelay?: number;\n\n\t/**\n\tError code for the retry.\n\n\tThis machine-readable identifier will be included in the error message passed to `beforeRetry` hooks, allowing you to distinguish between different types of forced retries.\n\n\t@example\n\t```\n\treturn ky.retry({code: 'RATE_LIMIT'});\n\t// Resulting error message: 'Forced retry: RATE_LIMIT'\n\t```\n\t*/\n\tcode?: string;\n\n\t/**\n\tOriginal error that caused the retry.\n\n\tThis allows you to preserve the error chain when forcing a retry based on caught exceptions. The error will be set as the `cause` of the `ForceRetryError`, enabling proper error chain traversal.\n\n\t@example\n\t```\n\ttry {\n\t\tconst data = await response.clone().json();\n\t\tvalidateBusinessLogic(data);\n\t} catch (error) {\n\t\treturn ky.retry({\n\t\t\tcode: 'VALIDATION_FAILED',\n\t\t\tcause: error  // Preserves original error in chain\n\t\t});\n\t}\n\t```\n\t*/\n\tcause?: Error;\n\n\t/**\n\tCustom request to use for the retry.\n\n\tThis allows you to modify or completely replace the request during a forced retry. The custom request becomes the starting point for the retry - `beforeRetry` hooks can still further modify it if needed.\n\n\t**Note:** The custom request's `signal` will be replaced with Ky's managed signal to handle timeouts and user-provided abort signals correctly. If the original request body has been consumed, you must provide a new body or clone the request before consuming.\n\n\t@example\n\t```\n\t// Fallback to a different endpoint\n\treturn ky.retry({\n\t\trequest: new Request('https://backup-api.com/endpoint', {\n\t\t\tmethod: request.method,\n\t\t\theaders: request.headers,\n\t\t}),\n\t\tcode: 'BACKUP_ENDPOINT'\n\t});\n\n\t// Retry with refreshed authentication token\n\tconst data = await response.clone().json();\n\treturn ky.retry({\n\t\trequest: new Request(request, {\n\t\t\theaders: {\n\t\t\t\t...Object.fromEntries(request.headers),\n\t\t\t\t'Authorization': `Bearer ${data.newToken}`\n\t\t\t}\n\t\t}),\n\t\tcode: 'TOKEN_REFRESHED'\n\t});\n\t```\n\t*/\n\trequest?: Request;\n};\n\n/**\nMarker returned by ky.retry() to signal a forced retry from afterResponse hooks.\n*/\nexport class RetryMarker {\n\tconstructor(public options?: ForceRetryOptions) {}\n}\n\n/**\nForce a retry from an `afterResponse` hook.\n\nThis allows you to retry a request based on the response content, even if the response has a successful status code. The retry will respect the `retry.limit` option and skip the `shouldRetry` check. The forced retry is observable in `beforeRetry` hooks, where the error will be a `ForceRetryError`.\n\n@param options - Optional configuration for the retry.\n\n@example\n```\nimport ky, {isForceRetryError} from 'ky';\n\nconst api = ky.extend({\n\thooks: {\n\t\tafterResponse: [\n\t\t\tasync (request, options, response) => {\n\t\t\t\t// Retry based on response body content\n\t\t\t\tif (response.status === 200) {\n\t\t\t\t\tconst data = await response.clone().json();\n\n\t\t\t\t\t// Simple retry with default delay\n\t\t\t\t\tif (data.error?.code === 'TEMPORARY_ERROR') {\n\t\t\t\t\t\treturn ky.retry();\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with custom delay from API response\n\t\t\t\t\tif (data.error?.code === 'RATE_LIMIT') {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\tdelay: data.error.retryAfter * 1000,\n\t\t\t\t\t\t\tcode: 'RATE_LIMIT'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with a modified request (e.g., fallback endpoint)\n\t\t\t\t\tif (data.error?.code === 'FALLBACK_TO_BACKUP') {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\trequest: new Request('https://backup-api.com/endpoint', {\n\t\t\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcode: 'BACKUP_ENDPOINT'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with refreshed authentication\n\t\t\t\t\tif (data.error?.code === 'TOKEN_REFRESH' && data.newToken) {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\trequest: new Request(request, {\n\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\t...Object.fromEntries(request.headers),\n\t\t\t\t\t\t\t\t\t'Authorization': `Bearer ${data.newToken}`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcode: 'TOKEN_REFRESHED'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with cause to preserve error chain\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidateResponse(data);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\tcode: 'VALIDATION_FAILED',\n\t\t\t\t\t\t\tcause: error\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\tbeforeRetry: [\n\t\t\t({error, retryCount}) => {\n\t\t\t\t// Observable in beforeRetry hooks\n\t\t\t\tif (isForceRetryError(error)) {\n\t\t\t\t\tconsole.log(`Forced retry #${retryCount}: ${error.message}`);\n\t\t\t\t\t// Example output: \"Forced retry #1: Forced retry: RATE_LIMIT\"\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n\nconst response = await api.get('https://example.com/api');\n```\n*/\nexport const retry = (options?: ForceRetryOptions) => new RetryMarker(options);\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tstringifyJson: true,\n\tsearchParams: true,\n\tprefixUrl: true,\n\tretry: true,\n\ttimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tonUploadProgress: true,\n\tfetch: true,\n\tcontext: true,\n};\n\n// Vendor-specific fetch options that should always be passed to fetch()\n// even if they appear on the Request object due to vendor patching.\n// See: https://github.com/sindresorhus/ky/issues/541\nexport const vendorSpecificOptions = {\n\tnext: true, // Next.js cache revalidation (revalidate, tags)\n} as const;\n\n// Standard RequestInit options that should NOT be passed separately to fetch()\n// because they're already applied to the Request object.\n// Note: `dispatcher` and `priority` are NOT included here - they're fetch-only\n// options that the Request constructor doesn't accept, so they need to be passed\n// separately to fetch().\nexport const requestOptionsRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tduplex: true,\n} as const;\n","import type {Options} from '../types/options.js';\nimport {usualFormBoundarySize} from '../core/constants.js';\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const getBodySize = (body?: BodyInit | null): number => {\n\tif (!body) {\n\t\treturn 0;\n\t}\n\n\tif (body instanceof FormData) {\n\t\t// This is an approximation, as FormData size calculation is not straightforward\n\t\tlet size = 0;\n\n\t\tfor (const [key, value] of body) {\n\t\t\tsize += usualFormBoundarySize;\n\t\t\tsize += new TextEncoder().encode(`Content-Disposition: form-data; name=\"${key}\"`).length;\n\t\t\tsize += typeof value === 'string'\n\t\t\t\t? new TextEncoder().encode(value).length\n\t\t\t\t: value.size;\n\t\t}\n\n\t\treturn size;\n\t}\n\n\tif (body instanceof Blob) {\n\t\treturn body.size;\n\t}\n\n\tif (body instanceof ArrayBuffer) {\n\t\treturn body.byteLength;\n\t}\n\n\tif (typeof body === 'string') {\n\t\treturn new TextEncoder().encode(body).length;\n\t}\n\n\tif (body instanceof URLSearchParams) {\n\t\treturn new TextEncoder().encode(body.toString()).length;\n\t}\n\n\tif ('byteLength' in body) {\n\t\treturn (body).byteLength;\n\t}\n\n\tif (typeof body === 'object' && body !== null) {\n\t\ttry {\n\t\t\tconst jsonString = JSON.stringify(body);\n\t\t\treturn new TextEncoder().encode(jsonString).length;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn 0; // Default case, unable to determine size\n};\n\nconst withProgress = (stream: ReadableStream<Uint8Array>, totalBytes: number, onProgress: Options['onDownloadProgress'] | Options['onUploadProgress']): ReadableStream<Uint8Array> => {\n\tlet previousChunk: Uint8Array | undefined;\n\tlet transferredBytes = 0;\n\n\treturn stream.pipeThrough(new TransformStream<Uint8Array, Uint8Array>({\n\t\ttransform(currentChunk, controller) {\n\t\t\tcontroller.enqueue(currentChunk);\n\n\t\t\tif (previousChunk) {\n\t\t\t\ttransferredBytes += previousChunk.byteLength;\n\n\t\t\t\tlet percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t// Avoid reporting 100% progress before the stream is actually finished (in case totalBytes is inaccurate)\n\t\t\t\tif (percent >= 1) {\n\t\t\t\t\t// Epsilon is used here to get as close as possible to 100% without reaching it.\n\t\t\t\t\t// If we were to use 0.99 here, percent could potentially go backwards.\n\t\t\t\t\tpercent = 1 - Number.EPSILON;\n\t\t\t\t}\n\n\t\t\t\tonProgress?.({percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes}, previousChunk);\n\t\t\t}\n\n\t\t\tpreviousChunk = currentChunk;\n\t\t},\n\t\tflush() {\n\t\t\tif (previousChunk) {\n\t\t\t\ttransferredBytes += previousChunk.byteLength;\n\t\t\t\tonProgress?.({percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes}, previousChunk);\n\t\t\t}\n\t\t},\n\t}));\n};\n\nexport const streamResponse = (response: Response, onDownloadProgress: Options['onDownloadProgress']) => {\n\tif (!response.body) {\n\t\treturn response;\n\t}\n\n\tif (response.status === 204) {\n\t\treturn new Response(\n\t\t\tnull,\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n\n\tconst totalBytes = Math.max(0, Number(response.headers.get('content-length')) || 0);\n\n\treturn new Response(\n\t\twithProgress(response.body, totalBytes, onDownloadProgress),\n\t\t{\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\theaders: response.headers,\n\t\t},\n\t);\n};\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const streamRequest = (request: Request, onUploadProgress: Options['onUploadProgress'], originalBody?: BodyInit | null) => {\n\tif (!request.body) {\n\t\treturn request;\n\t}\n\n\t// Use original body for size calculation since request.body is already a stream\n\tconst totalBytes = getBodySize(originalBody ?? request.body);\n\n\treturn new Request(request, {\n\t\t// @ts-expect-error - Types are outdated.\n\t\tduplex: 'half',\n\t\tbody: withProgress(request.body, totalBytes, onUploadProgress),\n\t});\n};\n","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport type {Hooks} from '../types/hooks.js';\nimport {supportsAbortSignal} from '../core/constants.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as RequestInit['headers']);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as RequestInit['headers']);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\nfunction newHookValue<K extends keyof Hooks>(original: Hooks, incoming: Hooks, property: K): Required<Hooks>[K] {\n\treturn (Object.hasOwn(incoming, property) && incoming[property] === undefined)\n\t\t? []\n\t\t: deepMerge<Required<Hooks>[K]>(original[property] ?? [], incoming[property] ?? []);\n}\n\nexport const mergeHooks = (original: Hooks = {}, incoming: Hooks = {}): Required<Hooks> => (\n\t{\n\t\tbeforeRequest: newHookValue(original, incoming, 'beforeRequest'),\n\t\tbeforeRetry: newHookValue(original, incoming, 'beforeRetry'),\n\t\tafterResponse: newHookValue(original, incoming, 'afterResponse'),\n\t\tbeforeError: newHookValue(original, incoming, 'beforeError'),\n\t}\n);\n\nconst appendSearchParameters = (target: any, source: any): URLSearchParams => {\n\tconst result = new URLSearchParams();\n\n\tfor (const input of [target, source]) {\n\t\tif (input === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (input instanceof URLSearchParams) {\n\t\t\tfor (const [key, value] of input.entries()) {\n\t\t\t\tresult.append(key, value);\n\t\t\t}\n\t\t} else if (Array.isArray(input)) {\n\t\t\tfor (const pair of input) {\n\t\t\t\tif (!Array.isArray(pair) || pair.length !== 2) {\n\t\t\t\t\tthrow new TypeError('Array search parameters must be provided in [[key, value], ...] format');\n\t\t\t\t}\n\n\t\t\t\tresult.append(String(pair[0]), String(pair[1]));\n\t\t\t}\n\t\t} else if (isObject(input)) {\n\t\t\tfor (const [key, value] of Object.entries(input)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tresult.append(key, String(value));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// String\n\t\t\tconst parameters = new URLSearchParams(input);\n\t\t\tfor (const [key, value] of parameters.entries()) {\n\t\t\t\tresult.append(key, value);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\tlet hooks = {};\n\tlet searchParameters: any;\n\tconst signals: AbortSignal[] = [];\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\t// Special handling for AbortSignal instances\n\t\t\t\tif (key === 'signal' && value instanceof globalThis.AbortSignal) {\n\t\t\t\t\tsignals.push(value);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Special handling for context - shallow merge only\n\t\t\t\tif (key === 'context') {\n\t\t\t\t\tif (value !== undefined && value !== null && (!isObject(value) || Array.isArray(value))) {\n\t\t\t\t\t\tthrow new TypeError('The `context` option must be an object');\n\t\t\t\t\t}\n\n\t\t\t\t\t// Shallow merge: always create a new object to prevent mutation bugs\n\t\t\t\t\treturnValue = {\n\t\t\t\t\t\t...returnValue,\n\t\t\t\t\t\tcontext: (value === undefined || value === null)\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {...returnValue.context, ...value},\n\t\t\t\t\t};\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Special handling for searchParams\n\t\t\t\tif (key === 'searchParams') {\n\t\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\t\t// Explicit undefined or null removes searchParams\n\t\t\t\t\t\tsearchParameters = undefined;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// First source: keep as-is to preserve type (string/object/URLSearchParams)\n\t\t\t\t\t\t// Subsequent sources: merge and convert to URLSearchParams\n\t\t\t\t\t\tsearchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).hooks)) {\n\t\t\t\thooks = mergeHooks(hooks, (source as any).hooks);\n\t\t\t\treturnValue.hooks = hooks;\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (searchParameters !== undefined) {\n\t\treturnValue.searchParams = searchParameters;\n\t}\n\n\tif (signals.length > 0) {\n\t\tif (signals.length === 1) {\n\t\t\treturnValue.signal = signals[0];\n\t\t} else if (supportsAbortSignal) {\n\t\t\treturnValue.signal = AbortSignal.any(signals);\n\t\t} else {\n\t\t\t// When AbortSignal.any is not available, use the last signal\n\t\t\t// This maintains the previous behavior before signal merging was added\n\t\t\t// This can be remove when the `supportsAbortSignal` check is removed.`\n\t\t\treturnValue.signal = signals.at(-1);\n\t\t}\n\t}\n\n\tif (returnValue.context === undefined) {\n\t\treturnValue.context = {};\n\t}\n\n\treturn returnValue;\n};\n","import {requestMethods} from '../core/constants.js';\nimport type {RetryOptions} from '../types/retry.js';\nimport type {HttpMethod, RequestHttpMethod} from '../types/options.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as RequestHttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods: HttpMethod[] = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\ntype InternalRetryOptions = Required<Omit<RetryOptions, 'shouldRetry'>> & Pick<RetryOptions, 'shouldRetry'>;\n\nconst defaultRetryOptions: InternalRetryOptions = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n\tjitter: undefined,\n\tretryOnTimeout: false,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): InternalRetryOptions => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tretry.methods &&= retry.methods.map(method => method.toLowerCase());\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\tconst normalizedRetry = Object.fromEntries(\n\t\tObject.entries(retry).filter(([, value]) => value !== undefined),\n\t) as RetryOptions;\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...normalizedRetry,\n\t};\n};\n","import type {KyRequest} from '../types/request.js';\n\nexport class TimeoutError extends Error {\n\tpublic request: KyRequest;\n\n\tconstructor(request: Request) {\n\t\tsuper(`Request timed out: ${request.method} ${request.url}`);\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport {ForceRetryError} from '../errors/ForceRetryError.js';\n\n/**\nType guard to check if an error is a Ky error.\n\n@param error - The error to check\n@returns `true` if the error is a Ky error, `false` otherwise\n\n@example\n```\nimport ky, {isKyError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data');\n} catch (error) {\n\tif (isKyError(error)) {\n\t\t// Handle Ky-specific errors\n\t\tconsole.log('Ky error occurred:', error.message);\n\t} else {\n\t\t// Handle other errors\n\t\tconsole.log('Unknown error:', error);\n\t}\n}\n```\n*/\nexport function isKyError(error: unknown): error is HTTPError | TimeoutError | ForceRetryError {\n\treturn isHTTPError(error) || isTimeoutError(error) || isForceRetryError(error);\n}\n\n/**\nType guard to check if an error is an HTTPError.\n\n@param error - The error to check\n@returns `true` if the error is an HTTPError, `false` otherwise\n\n@example\n```\nimport ky, {isHTTPError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data');\n} catch (error) {\n\tif (isHTTPError(error)) {\n\t\tconsole.log('HTTP error status:', error.response.status);\n\t}\n}\n```\n*/\nexport function isHTTPError<T = unknown>(error: unknown): error is HTTPError<T> {\n\treturn error instanceof HTTPError || ((error as any)?.name === HTTPError.name);\n}\n\n/**\nType guard to check if an error is a TimeoutError.\n\n@param error - The error to check\n@returns `true` if the error is a TimeoutError, `false` otherwise\n\n@example\n```\nimport ky, {isTimeoutError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data', { timeout: 1000 });\n} catch (error) {\n\tif (isTimeoutError(error)) {\n\t\tconsole.log('Request timed out:', error.request.url);\n\t}\n}\n```\n*/\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n\treturn error instanceof TimeoutError || ((error as any)?.name === TimeoutError.name);\n}\n\n/**\nType guard to check if an error is a ForceRetryError.\n\n@param error - The error to check\n@returns `true` if the error is a ForceRetryError, `false` otherwise\n\n@example\n```\nimport ky, {isForceRetryError} from 'ky';\n\nconst api = ky.extend({\n\thooks: {\n\t\tbeforeRetry: [\n\t\t\t({error, retryCount}) => {\n\t\t\t\tif (isForceRetryError(error)) {\n\t\t\t\t\tconsole.log(`Forced retry #${retryCount}: ${error.code}`);\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n```\n*/\nexport function isForceRetryError(error: unknown): error is ForceRetryError {\n\treturn error instanceof ForceRetryError || ((error as any)?.name === ForceRetryError.name);\n}\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {NonError} from '../errors/NonError.js';\nimport {ForceRetryError} from '../errors/ForceRetryError.js';\nimport type {\n\tInput,\n\tInternalOptions,\n\tNormalizedOptions,\n\tOptions,\n\tSearchParamsInit,\n\tSearchParamsOption,\n} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport {streamRequest, streamResponse} from '../utils/body.js';\nimport {mergeHeaders, mergeHooks} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {type TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions, hasSearchParameters} from '../utils/options.js';\nimport {isHTTPError, isTimeoutError} from '../utils/type-guards.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tRetryMarker,\n\tsupportsAbortController,\n\tsupportsAbortSignal,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst function_ = async (): Promise<Response> => {\n\t\t\tif (typeof ky.#options.timeout === 'number' && ky.#options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\t// Before using ky.request, _fetch clones it and saves the clone for future retries to use.\n\t\t\t// If retry is not needed, close the cloned request's ReadableStream for memory safety.\n\t\t\tlet response = await ky.#fetch();\n\n\t\t\tfor (const hook of ky.#options.hooks.afterResponse) {\n\t\t\t\t// Clone the response before passing to hook so we can cancel it if needed\n\t\t\t\tconst clonedResponse = ky.#decorateResponse(response.clone());\n\n\t\t\t\tlet modifiedResponse;\n\t\t\t\ttry {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tmodifiedResponse = await hook(\n\t\t\t\t\t\tky.request,\n\t\t\t\t\t\tky.#getNormalizedOptions(),\n\t\t\t\t\t\tclonedResponse,\n\t\t\t\t\t\t{retryCount: ky.#retryCount},\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Cancel both responses to prevent memory leaks when hook throws\n\t\t\t\t\tky.#cancelResponseBody(clonedResponse);\n\t\t\t\t\tky.#cancelResponseBody(response);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\tif (modifiedResponse instanceof RetryMarker) {\n\t\t\t\t\t// Cancel both the cloned response passed to the hook and the current response to prevent resource leaks (especially important in Deno/Bun).\n\t\t\t\t\t// Do not await cancellation since hooks can clone the response, leaving extra tee branches that keep cancel promises pending per the Streams spec.\n\t\t\t\t\tky.#cancelResponseBody(clonedResponse);\n\t\t\t\t\tky.#cancelResponseBody(response);\n\t\t\t\t\tthrow new ForceRetryError(modifiedResponse.options);\n\t\t\t\t}\n\n\t\t\t\t// Determine which response to use going forward\n\t\t\t\tconst nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;\n\n\t\t\t\t// Cancel any response bodies we won't use to prevent memory leaks.\n\t\t\t\t// Uses fire-and-forget since hooks may have cloned the response, creating tee branches that block cancellation.\n\t\t\t\tif (clonedResponse !== nextResponse) {\n\t\t\t\t\tky.#cancelResponseBody(clonedResponse);\n\t\t\t\t}\n\n\t\t\t\tif (response !== nextResponse) {\n\t\t\t\t\tky.#cancelResponseBody(response);\n\t\t\t\t}\n\n\t\t\t\tresponse = nextResponse;\n\t\t\t}\n\n\t\t\tky.#decorateResponse(response);\n\n\t\t\tif (!response.ok && (\n\t\t\t\ttypeof ky.#options.throwHttpErrors === 'function'\n\t\t\t\t\t? ky.#options.throwHttpErrors(response.status)\n\t\t\t\t\t: ky.#options.throwHttpErrors\n\t\t\t)) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, ky.#getNormalizedOptions());\n\n\t\t\t\tfor (const hook of ky.#options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error, {retryCount: ky.#retryCount});\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\tif (ky.#options.onDownloadProgress) {\n\t\t\t\tif (typeof ky.#options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\tconst progressResponse = response.clone();\n\t\t\t\tky.#cancelResponseBody(response);\n\t\t\t\treturn streamResponse(progressResponse, ky.#options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\t// Always wrap in #retry to catch forced retries from afterResponse hooks\n\t\t// Method retriability is checked in #calculateRetryDelay for non-forced retries\n\t\tconst result = ky.#retry(function_)\n\t\t\t.finally(() => {\n\t\t\t\tconst originalRequest = ky.#originalRequest;\n\n\t\t\t\t// Ignore cancellation errors from already-locked or already-consumed streams.\n\t\t\t\tky.#cancelBody(originalRequest?.body ?? undefined);\n\t\t\t\tky.#cancelBody(ky.request.body ?? undefined);\n\t\t\t}) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\t// Only expose `.bytes()` when the environment implements it.\n\t\t\tif (\n\t\t\t\ttype === 'bytes'\n\t\t\t\t&& typeof (globalThis.Response?.prototype as unknown as {bytes?: unknown})?.bytes !== 'function'\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst response = await result;\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\tif (text === '') {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(text);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn JSON.parse(text);\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\tstatic #normalizeSearchParams(searchParams: SearchParamsOption): SearchParamsOption {\n\t\t// Filter out undefined values from plain objects\n\t\tif (searchParams && typeof searchParams === 'object' && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries(searchParams).filter(([, value]) => value !== undefined),\n\t\t\t);\n\t\t}\n\n\t\treturn searchParams;\n\t}\n\n\tpublic request: Request;\n\t#abortController?: AbortController;\n\t#retryCount = 0;\n\t// eslint-disable-next-line @typescript-eslint/prefer-readonly -- False positive: #input is reassigned on line 202\n\t#input: Input;\n\treadonly #options: InternalOptions;\n\t#originalRequest?: Request;\n\treadonly #userProvidedAbortSignal?: AbortSignal;\n\t#cachedNormalizedOptions: NormalizedOptions | undefined;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis.#input = input;\n\n\t\tthis.#options = {\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this.#input as Request).headers, options.headers),\n\t\t\thooks: mergeHooks(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this.#input as Request).method ?? 'GET'),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors ?? true,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t\tcontext: options.context ?? {},\n\t\t};\n\n\t\tif (typeof this.#input !== 'string' && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this.#options.prefixUrl && typeof this.#input === 'string') {\n\t\t\tif (this.#input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this.#options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis.#options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis.#input = this.#options.prefixUrl + this.#input;\n\t\t}\n\n\t\tif (supportsAbortController && supportsAbortSignal) {\n\t\t\tthis.#userProvidedAbortSignal = this.#options.signal ?? (this.#input as Request).signal;\n\t\t\tthis.#abortController = new globalThis.AbortController();\n\t\t\tthis.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis.#options.duplex = 'half';\n\t\t}\n\n\t\tif (this.#options.json !== undefined) {\n\t\t\tthis.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);\n\t\t\tthis.#options.headers.set('content-type', this.#options.headers.get('content-type') ?? 'application/json');\n\t\t}\n\n\t\t// To provide correct form boundary, Content-Type header should be deleted when creating Request from another Request with FormData/URLSearchParams body\n\t\t// Only delete if user didn't explicitly provide a custom content-type\n\t\tconst userProvidedContentType = options.headers && new globalThis.Headers(options.headers as HeadersInit).has('content-type');\n\t\tif (\n\t\t\tthis.#input instanceof globalThis.Request\n\t\t\t&& ((supportsFormData && this.#options.body instanceof globalThis.FormData) || this.#options.body instanceof URLSearchParams)\n\t\t\t&& !userProvidedContentType\n\t\t) {\n\t\t\tthis.#options.headers.delete('content-type');\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this.#input, this.#options);\n\n\t\tif (hasSearchParameters(this.#options.searchParams)) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this.#options.searchParams === 'string'\n\t\t\t\t? this.#options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams) as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// Recreate request with the updated URL. We already have all options in this.#options, including duplex.\n\t\t\tthis.request = new globalThis.Request(url, this.#options as RequestInit);\n\t\t}\n\n\t\t// If `onUploadProgress` is passed, it uses the stream API internally\n\t\tif (this.#options.onUploadProgress) {\n\t\t\tif (typeof this.#options.onUploadProgress !== 'function') {\n\t\t\t\tthrow new TypeError('The `onUploadProgress` option must be a function');\n\t\t\t}\n\n\t\t\tif (!supportsRequestStreams) {\n\t\t\t\tthrow new Error('Request streams are not supported in your environment. The `duplex` option for `Request` is not available.');\n\t\t\t}\n\n\t\t\tthis.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);\n\t\t}\n\t}\n\n\t#calculateDelay(): number {\n\t\tconst retryDelay = this.#options.retry.delay(this.#retryCount);\n\n\t\tlet jitteredDelay = retryDelay;\n\t\tif (this.#options.retry.jitter === true) {\n\t\t\tjitteredDelay = Math.random() * retryDelay;\n\t\t} else if (typeof this.#options.retry.jitter === 'function') {\n\t\t\tjitteredDelay = this.#options.retry.jitter(retryDelay);\n\n\t\t\tif (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {\n\t\t\t\tjitteredDelay = retryDelay;\n\t\t\t}\n\t\t}\n\n\t\t// Handle undefined backoffLimit by treating it as no limit (Infinity)\n\t\tconst backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;\n\t\treturn Math.min(backoffLimit, jitteredDelay);\n\t}\n\n\tasync #calculateRetryDelay(error: unknown) {\n\t\tthis.#retryCount++;\n\n\t\tif (this.#retryCount > this.#options.retry.limit) {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Wrap non-Error throws to ensure consistent error handling\n\t\tconst errorObject = error instanceof Error ? error : new NonError(error);\n\n\t\t// Handle forced retry from afterResponse hook - skip method check and shouldRetry\n\t\tif (errorObject instanceof ForceRetryError) {\n\t\t\treturn errorObject.customDelay ?? this.#calculateDelay();\n\t\t}\n\n\t\t// Check if method is retriable for non-forced retries\n\t\tif (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// User-provided shouldRetry function takes precedence over all other checks\n\t\tif (this.#options.retry.shouldRetry !== undefined) {\n\t\t\tconst result = await this.#options.retry.shouldRetry({error: errorObject, retryCount: this.#retryCount});\n\n\t\t\t// Strict boolean checking - only exact true/false are handled specially\n\t\t\tif (result === false) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (result === true) {\n\t\t\t\t// Force retry - skip all other validation and return delay\n\t\t\t\treturn this.#calculateDelay();\n\t\t\t}\n\n\t\t\t// If undefined or any other value, fall through to default behavior\n\t\t}\n\n\t\t// Default timeout behavior\n\t\tif (isTimeoutError(error) && !this.#options.retry.retryOnTimeout) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (isHTTPError(error)) {\n\t\t\tif (!this.#options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tconst retryAfter = error.response.headers.get('Retry-After')\n\t\t\t\t?? error.response.headers.get('RateLimit-Reset')\n\t\t\t\t?? error.response.headers.get('X-RateLimit-Retry-After') // Symfony-based services\n\t\t\t\t?? error.response.headers.get('X-RateLimit-Reset') // GitHub\n\t\t\t\t?? error.response.headers.get('X-Rate-Limit-Reset'); // Twitter\n\t\t\tif (retryAfter && this.#options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\tlet after = Number(retryAfter) * 1000;\n\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t} else if (after >= Date.parse('2024-01-01')) {\n\t\t\t\t\t// A large number is treated as a timestamp (fixed threshold protects against clock skew)\n\t\t\t\t\tafter -= Date.now();\n\t\t\t\t}\n\n\t\t\t\tconst max = this.#options.retry.maxRetryAfter ?? after;\n\t\t\t\t// Don't apply jitter when server provides explicit retry timing\n\t\t\t\treturn after < max ? after : max;\n\t\t\t}\n\n\t\t\tif (error.response.status === 413) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn this.#calculateDelay();\n\t}\n\n\t#decorateResponse(response: Response): Response {\n\t\tif (this.#options.parseJson) {\n\t\t\tresponse.json = async () => this.#options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\t#cancelBody(body: ReadableStream | undefined): void {\n\t\tif (!body) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore cancellation failures from already-locked or already-consumed streams.\n\t\tvoid body.cancel().catch(() => undefined);\n\t}\n\n\t#cancelResponseBody(response: Response): void {\n\t\t// Ignore cancellation failures from already-locked or already-consumed streams.\n\t\tthis.#cancelBody(response.body ?? undefined);\n\t}\n\n\tasync #retry<T extends (...arguments_: any) => Promise<any>>(function_: T): Promise<ReturnType<T> | Response | void> {\n\t\ttry {\n\t\t\treturn await function_();\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (this.#retryCount < 1) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// Only use user-provided signal for delay, not our internal abortController\n\t\t\tawait delay(ms, this.#userProvidedAbortSignal ? {signal: this.#userProvidedAbortSignal} : {});\n\n\t\t\t// Apply custom request from forced retry before beforeRetry hooks\n\t\t\t// Ensure the custom request has the correct managed signal for timeouts and user aborts\n\t\t\tif (error instanceof ForceRetryError && error.customRequest) {\n\t\t\t\tconst managedRequest = this.#options.signal\n\t\t\t\t\t? new globalThis.Request(error.customRequest, {signal: this.#options.signal})\n\t\t\t\t\t: new globalThis.Request(error.customRequest);\n\n\t\t\t\tthis.#assignRequest(managedRequest);\n\t\t\t}\n\n\t\t\tfor (const hook of this.#options.hooks.beforeRetry) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\trequest: this.request,\n\t\t\t\t\toptions: this.#getNormalizedOptions(),\n\t\t\t\t\terror: error as Error,\n\t\t\t\t\tretryCount: this.#retryCount,\n\t\t\t\t});\n\n\t\t\t\tif (hookResult instanceof globalThis.Request) {\n\t\t\t\t\tthis.#assignRequest(hookResult);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// If a Response is returned, use it and skip the retry\n\t\t\t\tif (hookResult instanceof globalThis.Response) {\n\t\t\t\t\treturn hookResult;\n\t\t\t\t}\n\n\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this.#retry(function_);\n\t\t}\n\t}\n\n\tasync #fetch(): Promise<Response> {\n\t\t// Reset abortController if it was aborted (happens on timeout retry)\n\t\tif (this.#abortController?.signal.aborted) {\n\t\t\tthis.#abortController = new globalThis.AbortController();\n\t\t\tthis.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;\n\t\t\t// Recreate request with new signal\n\t\t\tthis.request = new globalThis.Request(this.request, {signal: this.#options.signal});\n\t\t}\n\n\t\tfor (const hook of this.#options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(\n\t\t\t\tthis.request,\n\t\t\t\tthis.#getNormalizedOptions(),\n\t\t\t\t{retryCount: this.#retryCount},\n\t\t\t);\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tif (result instanceof globalThis.Request) {\n\t\t\t\tthis.#assignRequest(result);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.request, this.#options);\n\n\t\t// Cloning is done here to prepare in advance for retries\n\t\tthis.#originalRequest = this.request;\n\t\tthis.request = this.#originalRequest.clone();\n\n\t\tif (this.#options.timeout === false) {\n\t\t\treturn this.#options.fetch(this.#originalRequest, nonRequestOptions);\n\t\t}\n\n\t\treturn timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options as TimeoutOptions);\n\t}\n\n\t#getNormalizedOptions(): NormalizedOptions {\n\t\tif (!this.#cachedNormalizedOptions) {\n\t\t\tconst {hooks, ...normalizedOptions} = this.#options;\n\t\t\tthis.#cachedNormalizedOptions = Object.freeze(normalizedOptions) as NormalizedOptions;\n\t\t}\n\n\t\treturn this.#cachedNormalizedOptions;\n\t}\n\n\t#assignRequest(request: Request): void {\n\t\tthis.#cachedNormalizedOptions = undefined;\n\t\tthis.request = this.#wrapRequestWithUploadProgress(request);\n\t}\n\n\t#wrapRequestWithUploadProgress(request: Request, originalBody?: BodyInit): Request {\n\t\tif (!this.#options.onUploadProgress || !request.body) {\n\t\t\treturn request;\n\t\t}\n\n\t\treturn streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);\n\t}\n}\n","import {kyOptionKeys, requestOptionsRegistry, vendorSpecificOptions} from '../core/constants.js';\nimport type {SearchParamsOption} from '../types/options.js';\n\nexport const findUnknownOptions = (\n\trequest: Request,\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\t// Skip inherited properties\n\t\tif (!Object.hasOwn(options, key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// An option is passed to fetch() if:\n\t\t// 1. It's not a standard RequestInit option (not in requestOptionsRegistry)\n\t\t// 2. It's not a ky-specific option (not in kyOptionKeys)\n\t\t// 3. Either:\n\t\t//    a. It's not on the Request object, OR\n\t\t//    b. It's a vendor-specific option that should always be passed (in vendorSpecificOptions)\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || key in vendorSpecificOptions)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n\nexport const hasSearchParameters = (search: SearchParamsOption): boolean => {\n\tif (search === undefined) {\n\t\treturn false;\n\t}\n\n\t// The `typeof array` still gives \"object\", so we need different checking for array.\n\tif (Array.isArray(search)) {\n\t\treturn search.length > 0;\n\t}\n\n\tif (search instanceof URLSearchParams) {\n\t\treturn search.size > 0;\n\t}\n\n\t// Record\n\tif (typeof search === 'object') {\n\t\treturn Object.keys(search).length > 0;\n\t}\n\n\tif (typeof search === 'string') {\n\t\treturn search.trim().length > 0;\n\t}\n\n\treturn Boolean(search);\n};\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason as Error);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop, retry} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options> | ((parentDefaults: Partial<Options>) => Partial<Options>)) => {\n\t\tif (typeof newDefaults === 'function') {\n\t\t\tnewDefaults = newDefaults(defaults ?? {});\n\t\t}\n\n\t\treturn createInstance(validateAndMerge(defaults, newDefaults));\n\t};\n\n\tky.stop = stop;\n\tky.retry = retry;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tInput,\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tShouldRetryState,\n\tSearchParamsOption,\n\tProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRequestState,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tBeforeErrorState,\n\tAfterResponseHook,\n\tAfterResponseState,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {KyRequest} from './types/request.js';\nexport type {KyResponse} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\nexport {ForceRetryError} from './errors/ForceRetryError.js';\nexport {\n\tisKyError,\n\tisHTTPError,\n\tisTimeoutError,\n\tisForceRetryError,\n} from './utils/type-guards.js';\n\n// Intentionally not exporting this for now as it's just an implementation detail and we don't want to commit to a certain API yet at least.\n// export {NonError} from './errors/NonError.js';\n"]}