{"version":3,"file":"index.cjs","names":["getURL","getURL"],"sources":["../src/error.ts","../src/plugins.ts","../src/retry.ts","../src/create-fetch/schema.ts","../src/method.ts","../src/url.ts","../src/auth.ts","../src/utils.ts","../src/fetch.ts","../src/create-fetch/index.ts"],"sourcesContent":["export class BetterFetchError extends Error {\n\tconstructor(\n\t\tpublic status: number,\n\t\tpublic statusText: string,\n\t\tpublic error: any,\n\t) {\n\t\tsuper(statusText || status.toString(), {\n\t\t\tcause: error,\n\t\t});\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n}\n","import type { Schema } from \"./create-fetch\";\nimport type { BetterFetchError } from \"./error\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\nimport type { BetterFetchOption } from \"./types\";\n\nexport type RequestContext<T extends Record<string, any> = any> = {\n\turl: URL | string;\n\theaders: Headers;\n\tbody: any;\n\tmethod: string;\n\tsignal: AbortSignal;\n} & BetterFetchOption<any, any, any, T>;\nexport type ResponseContext = {\n\tresponse: Response;\n\trequest: RequestContext;\n};\nexport type SuccessContext<Res = any> = {\n\tdata: Res;\n\tresponse: Response;\n\trequest: RequestContext;\n};\nexport type ErrorContext = {\n\tresponse: Response;\n\trequest: RequestContext;\n\terror: BetterFetchError & Record<string, any>;\n};\nexport interface FetchHooks<Res = any> {\n\t/**\n\t * a callback function that will be called when a\n\t * request is made.\n\t *\n\t * The returned context object will be reassigned to\n\t * the original request context.\n\t */\n\tonRequest?: <T extends Record<string, any>>(\n\t\tcontext: RequestContext<T>,\n\t) => Promise<RequestContext | void> | RequestContext | void;\n\t/**\n\t * a callback function that will be called when\n\t * response is received. This will be called before\n\t * the response is parsed and returned.\n\t *\n\t * The returned response will be reassigned to the\n\t * original response if it's changed.\n\t */\n\tonResponse?: (\n\t\tcontext: ResponseContext,\n\t) =>\n\t\t| Promise<Response | void | ResponseContext>\n\t\t| Response\n\t\t| ResponseContext\n\t\t| void;\n\t/**\n\t * a callback function that will be called when a\n\t * response is successful.\n\t */\n\tonSuccess?: (context: SuccessContext<Res>) => Promise<void> | void;\n\t/**\n\t * a callback function that will be called when an\n\t * error occurs.\n\t */\n\tonError?: (context: ErrorContext) => Promise<void> | void;\n\t/**\n\t * a callback function that will be called when a\n\t * request is retried.\n\t */\n\tonRetry?: (response: ResponseContext) => Promise<void> | void;\n\t/**\n\t * Options for the hooks\n\t */\n\thookOptions?: {\n\t\t/**\n\t\t * Clone the response\n\t\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Response/clone\n\t\t */\n\t\tcloneResponse?: boolean;\n\t};\n}\n\n/**\n * A plugin that returns an id and hooks\n */\nexport type BetterFetchPlugin<\n\tExtraOptions extends Record<string, any> = Record<string, any>,\n> = {\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n\t/**\n\t * Hooks for the plugin\n\t */\n\thooks?: FetchHooks;\n\t/**\n\t * A function that will be called when the plugin is\n\t * initialized. This will be called before the any\n\t * of the other internal functions.\n\t *\n\t * The returned options will be merged with the\n\t * original options.\n\t */\n\tinit?: (\n\t\turl: string,\n\t\toptions?: BetterFetchOption & ExtraOptions,\n\t) =>\n\t\t| Promise<{\n\t\t\t\turl: string;\n\t\t\t\toptions?: BetterFetchOption;\n\t\t  }>\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\toptions?: BetterFetchOption;\n\t\t  };\n\t/**\n\t * A schema for the plugin\n\t */\n\tschema?: Schema;\n\t/**\n\t * Additional options that can be passed to the plugin\n\t *\n\t * @deprecated Use type inference through direct typescript instead\n\t * ```ts\n\t * const plugin = {\n\t *\n\t * } satisfies BetterFetchPlugin<{\n\t *  myCustomOptions: string;\n\t * }>\n\t * ```\n\t */\n\tgetOptions?: () => StandardSchemaV1;\n};\n\nexport const initializePlugins = async (\n\turl: string,\n\toptions?: BetterFetchOption,\n) => {\n\tlet opts = options || {};\n\tconst hooks: {\n\t\tonRequest: Array<FetchHooks[\"onRequest\"]>;\n\t\tonResponse: Array<FetchHooks[\"onResponse\"]>;\n\t\tonSuccess: Array<FetchHooks[\"onSuccess\"]>;\n\t\tonError: Array<FetchHooks[\"onError\"]>;\n\t\tonRetry: Array<FetchHooks[\"onRetry\"]>;\n\t} = {\n\t\tonRequest: [options?.onRequest],\n\t\tonResponse: [options?.onResponse],\n\t\tonSuccess: [options?.onSuccess],\n\t\tonError: [options?.onError],\n\t\tonRetry: [options?.onRetry],\n\t};\n\tif (!options || !options?.plugins) {\n\t\treturn {\n\t\t\turl,\n\t\t\toptions: opts,\n\t\t\thooks,\n\t\t};\n\t}\n\tfor (const plugin of options?.plugins || []) {\n\t\tif (plugin.init) {\n\t\t\tconst pluginRes = await plugin.init?.(url.toString(), opts);\n\t\t\topts = pluginRes.options || opts;\n\t\t\turl = pluginRes.url;\n\t\t}\n\t\thooks.onRequest.push(plugin.hooks?.onRequest);\n\t\thooks.onResponse.push(plugin.hooks?.onResponse);\n\t\thooks.onSuccess.push(plugin.hooks?.onSuccess);\n\t\thooks.onError.push(plugin.hooks?.onError);\n\t\thooks.onRetry.push(plugin.hooks?.onRetry);\n\t}\n\n\treturn {\n\t\turl,\n\t\toptions: opts,\n\t\thooks,\n\t};\n};\n","export type RetryCondition = (\n\tresponse: Response | null,\n) => boolean | Promise<boolean>;\n\nexport type LinearRetry = {\n\ttype: \"linear\";\n\tattempts: number;\n\tdelay: number;\n\tshouldRetry?: RetryCondition;\n};\n\nexport type ExponentialRetry = {\n\ttype: \"exponential\";\n\tattempts: number;\n\tbaseDelay: number;\n\tmaxDelay: number;\n\tshouldRetry?: RetryCondition;\n};\n\nexport type RetryOptions = LinearRetry | ExponentialRetry | number;\n\nexport interface RetryStrategy {\n\tshouldAttemptRetry(\n\t\tattempt: number,\n\t\tresponse: Response | null,\n\t): Promise<boolean>;\n\tgetDelay(attempt: number): number;\n}\n\nclass LinearRetryStrategy implements RetryStrategy {\n\tconstructor(private options: LinearRetry) {}\n\n\tshouldAttemptRetry(\n\t\tattempt: number,\n\t\tresponse: Response | null,\n\t): Promise<boolean> {\n\t\tif (this.options.shouldRetry) {\n\t\t\treturn Promise.resolve(\n\t\t\t\tattempt < this.options.attempts && this.options.shouldRetry(response),\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(attempt < this.options.attempts);\n\t}\n\n\tgetDelay(): number {\n\t\treturn this.options.delay;\n\t}\n}\n\nclass ExponentialRetryStrategy implements RetryStrategy {\n\tconstructor(private options: ExponentialRetry) {}\n\n\tshouldAttemptRetry(\n\t\tattempt: number,\n\t\tresponse: Response | null,\n\t): Promise<boolean> {\n\t\tif (this.options.shouldRetry) {\n\t\t\treturn Promise.resolve(\n\t\t\t\tattempt < this.options.attempts && this.options.shouldRetry(response),\n\t\t\t);\n\t\t}\n\t\treturn Promise.resolve(attempt < this.options.attempts);\n\t}\n\n\tgetDelay(attempt: number): number {\n\t\tconst delay = Math.min(\n\t\t\tthis.options.maxDelay,\n\t\t\tthis.options.baseDelay * 2 ** attempt,\n\t\t);\n\t\treturn delay;\n\t}\n}\n\nexport function createRetryStrategy(options: RetryOptions): RetryStrategy {\n\tif (typeof options === \"number\") {\n\t\treturn new LinearRetryStrategy({\n\t\t\ttype: \"linear\",\n\t\t\tattempts: options,\n\t\t\tdelay: 1000,\n\t\t});\n\t}\n\n\tswitch (options.type) {\n\t\tcase \"linear\":\n\t\t\treturn new LinearRetryStrategy(options);\n\t\tcase \"exponential\":\n\t\t\treturn new ExponentialRetryStrategy(options);\n\t\tdefault:\n\t\t\tthrow new Error(\"Invalid retry strategy\");\n\t}\n}\n","import type { StandardSchemaV1 } from \"../standard-schema\";\nimport type { StringLiteralUnion } from \"../type-utils\";\n\nexport type FetchSchema = {\n\tinput?: StandardSchemaV1;\n\toutput?: StandardSchemaV1;\n\tquery?: StandardSchemaV1;\n\tparams?: StandardSchemaV1<Record<string, unknown>> | undefined;\n\tmethod?: Methods;\n\theaders?: StandardSchemaV1<Record<string, unknown>>;\n};\n\nexport type Methods = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\";\n\nexport const methods = [\"get\", \"post\", \"put\", \"patch\", \"delete\"];\n\ntype RouteKey = StringLiteralUnion<`@${Methods}/`>;\n\nexport type FetchSchemaRoutes = {\n\t[key in RouteKey]?: FetchSchema;\n};\n\nexport const createSchema = <\n\tF extends FetchSchemaRoutes,\n\tS extends SchemaConfig,\n>(\n\tschema: F,\n\tconfig?: S,\n) => {\n\treturn {\n\t\tschema: schema as F,\n\t\tconfig: config as S,\n\t};\n};\n\nexport type SchemaConfig = {\n\tstrict?: boolean;\n\t/**\n\t * A prefix that will be prepended when it's\n\t * calling the schema.\n\t *\n\t * NOTE: Make sure to handle converting\n\t * the prefix to the baseURL in the init\n\t * function if you you are defining for a\n\t * plugin.\n\t */\n\tprefix?: \"\" | (string & Record<never, never>);\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the fetch instance.\n\t */\n\tbaseURL?: \"\" | (string & Record<never, never>);\n};\n\nexport type Schema = {\n\tschema: FetchSchemaRoutes;\n\tconfig: SchemaConfig;\n};\n","import { methods } from \"./create-fetch/schema\";\n\nexport function parseMethodModifier(path: string) {\n\tif (!path.startsWith(\"@\")) {\n\t\treturn { method: undefined, path };\n\t}\n\n\tconst separator = path.indexOf(\"/\");\n\tconst method = path.slice(1, separator === -1 ? undefined : separator);\n\tif (!methods.includes(method)) {\n\t\treturn { method: undefined, path };\n\t}\n\n\treturn {\n\t\tmethod,\n\t\tpath: separator === -1 ? path : path.slice(separator + 1),\n\t};\n}\n","import { parseMethodModifier } from \"./method\";\nimport type { BetterFetchOption } from \"./types\";\n\n/**\n * Matches the scheme, `//` and host at the start of a URL that names its own\n * host, such as `https://example.com` in `https://example.com/users`.\n *\n * @see https://www.rfc-editor.org/rfc/rfc3986#section-3\n */\nconst ORIGIN_RE = /^[a-z][a-z\\d+.-]*:\\/\\/[^/?#]+/i;\n\n/**\n * Matches the slashes at the start of a path, such as `///` in `///users`.\n */\nconst LEADING_SLASHES_RE = /^\\/+/;\n\n/**\n * Removes every slash at the end, so `\"a//\"` becomes `\"a\"`. A loop rather than\n * a regex, as a pattern anchored at the end backtracks over a long run of\n * slashes.\n */\nfunction withoutTrailingSlashes(value: string) {\n\tlet end = value.length;\n\twhile (end > 0 && value[end - 1] === \"/\") {\n\t\tend--;\n\t}\n\treturn value.slice(0, end);\n}\n\n/**\n * Splits at the first occurrence of the separator, so a separator inside the\n * remainder is kept. `\"a?b?c\"` splits into `\"a\"` and `\"b?c\"`.\n */\nfunction splitOnce(value: string, separator: string) {\n\tconst index = value.indexOf(separator);\n\tif (index === -1) {\n\t\treturn [value, undefined] as const;\n\t}\n\treturn [value.slice(0, index), value.slice(index + 1)] as const;\n}\n\nconst isReservedPathSegment = (value: string) =>\n\tvalue === \".\" || value === \"..\";\n\nconst encodeLiteralPathSegment = (segment: string) =>\n\tsegment\n\t\t.split(\":\")\n\t\t.map((part) => encodeURIComponent(part))\n\t\t.join(\":\");\n\nfunction resolvePathSegment(segment: string, pathParams: Map<string, string>) {\n\tconst pathParam = pathParams.get(segment);\n\tif (pathParam === undefined) {\n\t\treturn encodeLiteralPathSegment(segment);\n\t}\n\tif (isReservedPathSegment(pathParam)) {\n\t\tthrow new TypeError(\"Path parameters cannot be reserved path segments\");\n\t}\n\treturn encodeURIComponent(pathParam);\n}\n\nfunction getPathParams(path: string, params: BetterFetchOption[\"params\"]) {\n\tconst pathParams = new Map<string, string>();\n\tif (params) {\n\t\tif (Array.isArray(params)) {\n\t\t\tconst paramPaths = path.split(\"/\").filter((p) => p.startsWith(\":\"));\n\t\t\tfor (const [index, key] of paramPaths.entries()) {\n\t\t\t\tconst value = params[index];\n\t\t\t\tpathParams.set(key, String(value));\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\t\tpathParams.set(`:${key}`, String(value));\n\t\t\t}\n\t\t}\n\t}\n\treturn pathParams;\n}\n\n/**\n * Replaces `:name` segments with their encoded params.\n */\nfunction fillPath(path: string, params: BetterFetchOption[\"params\"]) {\n\tconst pathParams = getPathParams(path, params);\n\treturn path\n\t\t.split(\"/\")\n\t\t.map((segment) => resolvePathSegment(segment, pathParams))\n\t\t.join(\"/\");\n}\n\nfunction serializeQuery(\n\turlQuery: string | undefined,\n\tquery: BetterFetchOption[\"query\"],\n) {\n\tconst queryParams = new URLSearchParams(urlQuery);\n\tfor (const [key, value] of Object.entries(query || {})) {\n\t\tif (value == null) continue;\n\t\tlet serializedValue;\n\t\tif (typeof value === \"string\") {\n\t\t\tserializedValue = value;\n\t\t} else if (Array.isArray(value)) {\n\t\t\tfor (const val of value) {\n\t\t\t\tqueryParams.append(key, val);\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tserializedValue = JSON.stringify(value);\n\t\t}\n\t\tqueryParams.set(key, serializedValue);\n\t}\n\tconst queryParamString = queryParams.toString();\n\treturn queryParamString.length > 0\n\t\t? `?${queryParamString}`.replace(/\\+/g, \"%20\")\n\t\t: \"\";\n}\n\nfunction withoutBase(input: string, baseURL: string | undefined) {\n\tif (!baseURL) {\n\t\treturn input;\n\t}\n\tconst basePath = `${withoutTrailingSlashes(baseURL)}/`;\n\treturn input.startsWith(basePath) ? input.slice(basePath.length) : input;\n}\n\n/**\n * Appends a path and query to a base as strings, with exactly one slash at the\n * boundary. The path never decides the scheme or host. The base's own query\n * comes first, and its fragment is dropped as it belongs to the base document.\n */\nfunction joinURL(\n\tbase: string,\n\tpath: string,\n\turlQuery: string | undefined,\n\tquery: BetterFetchOption[\"query\"],\n) {\n\tconst [baseWithoutHash] = splitOnce(base, \"#\");\n\tconst [basePath, baseQuery = \"\"] = splitOnce(baseWithoutHash, \"?\");\n\tconst relativePath = path.replace(LEADING_SLASHES_RE, \"\");\n\tconst search = serializeQuery(`${baseQuery}&${urlQuery ?? \"\"}`, query);\n\tconst href = `${withoutTrailingSlashes(basePath)}/${relativePath}${search}`;\n\treturn ORIGIN_RE.test(href) ? new URL(href) : href;\n}\n\n/**\n * Normalize URL\n */\nexport function getURL(url: string, option?: BetterFetchOption) {\n\tconst { baseURL, params, query } = option || {\n\t\tquery: {},\n\t\tparams: {},\n\t\tbaseURL: \"\",\n\t};\n\tconst { path: requestPath } = parseMethodModifier(url);\n\tconst input = requestPath === url ? url : `/${requestPath}`;\n\n\t// A URL that names its own host keeps it. Anything else is a path under\n\t// baseURL.\n\tconst origin = input.match(ORIGIN_RE)?.[0];\n\tconst relative = origin\n\t\t? input.slice(origin.length)\n\t\t: withoutBase(input, baseURL);\n\tconst [path, urlQuery] = splitOnce(relative, \"?\");\n\tconst filledPath = fillPath(path, params);\n\treturn joinURL(origin ?? baseURL ?? \"\", filledPath, urlQuery, query);\n}\n","import type { BetterFetchOption } from \"./types\";\n\nexport type typeOrTypeReturning<T> = T | (() => T);\n/**\n * Bearer token authentication\n *\n * the value of `token` will be added to a header as\n * `auth: Bearer token`,\n */\nexport type Bearer = {\n\ttype: \"Bearer\";\n\ttoken: typeOrTypeReturning<string | undefined | Promise<string | undefined>>;\n};\n\n/**\n * Basic auth\n */\nexport type Basic = {\n\ttype: \"Basic\";\n\tusername: typeOrTypeReturning<string | undefined>;\n\tpassword: typeOrTypeReturning<string | undefined>;\n};\n\n/**\n * Custom auth\n *\n * @param prefix - prefix of the header\n * @param value - value of the header\n *\n * @example\n * ```ts\n * {\n *  type: \"Custom\",\n *  prefix: \"Token\",\n *  value: \"token\"\n * }\n * ```\n */\nexport type Custom = {\n\ttype: \"Custom\";\n\tprefix: typeOrTypeReturning<string | undefined>;\n\tvalue: typeOrTypeReturning<string | undefined>;\n};\n\nexport type Auth = Bearer | Basic | Custom;\n\nexport const getAuthHeader = async (options?: BetterFetchOption) => {\n\tconst headers: Record<string, string> = {};\n\tconst getValue = async (\n\t\tvalue: typeOrTypeReturning<\n\t\t\tstring | undefined | Promise<string | undefined>\n\t\t>,\n\t) => (typeof value === \"function\" ? await value() : value);\n\tif (options?.auth) {\n\t\tif (options.auth.type === \"Bearer\") {\n\t\t\tconst token = await getValue(options.auth.token);\n\t\t\tif (!token) {\n\t\t\t\treturn headers;\n\t\t\t}\n\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t} else if (options.auth.type === \"Basic\") {\n\t\t\tconst [username, password] = await Promise.all([\n\t\t\t\tgetValue(options.auth.username),\n\t\t\t\tgetValue(options.auth.password),\n\t\t\t]);\n\t\t\tif (!username || !password) {\n\t\t\t\treturn headers;\n\t\t\t}\n\t\t\theaders[\"authorization\"] = `Basic ${btoa(`${username}:${password}`)}`;\n\t\t} else if (options.auth.type === \"Custom\") {\n\t\t\tconst [prefix, value] = await Promise.all([\n\t\t\t\tgetValue(options.auth.prefix),\n\t\t\t\tgetValue(options.auth.value),\n\t\t\t]);\n\t\t\tif (!value) {\n\t\t\t\treturn headers;\n\t\t\t}\n\t\t\theaders[\"authorization\"] = `${prefix ?? \"\"} ${value}`;\n\t\t}\n\t}\n\treturn headers;\n};\n","import { getAuthHeader } from \"./auth\";\nimport { parseMethodModifier } from \"./method\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\nimport type { BetterFetchOption, FetchEsque } from \"./types\";\n\nconst JSON_RE = /^application\\/(?:[\\w!#$%&*.^`~-]*\\+)?json(;.+)?$/i;\n\ntype RequestBody = Exclude<RequestInit[\"body\"], undefined>;\ntype RequestHeaders = RequestInit[\"headers\"];\n\nexport type ResponseType = \"json\" | \"text\" | \"blob\";\nexport function detectResponseType(request: Response): ResponseType {\n\tconst _contentType = request.headers.get(\"content-type\");\n\tconst textTypes = new Set([\n\t\t\"image/svg\",\n\t\t\"application/xml\",\n\t\t\"application/xhtml\",\n\t\t\"application/html\",\n\t]);\n\tif (!_contentType) {\n\t\treturn \"json\";\n\t}\n\tconst contentType = _contentType.split(\";\").shift() || \"\";\n\tif (JSON_RE.test(contentType)) {\n\t\treturn \"json\";\n\t}\n\tif (textTypes.has(contentType) || contentType.startsWith(\"text/\")) {\n\t\treturn \"text\";\n\t}\n\treturn \"blob\";\n}\n\nexport function isJSONParsable(value: any) {\n\ttry {\n\t\tJSON.parse(value);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\n//https://github.com/unjs/ofetch/blob/main/src/utils.ts\nexport function isJSONSerializable(value: any) {\n\tif (value === undefined) {\n\t\treturn false;\n\t}\n\tconst t = typeof value;\n\tif (t === \"string\" || t === \"number\" || t === \"boolean\" || t === null) {\n\t\treturn true;\n\t}\n\tif (t !== \"object\") {\n\t\treturn false;\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn true;\n\t}\n\tif (value.buffer) {\n\t\treturn false;\n\t}\n\treturn (\n\t\t(value.constructor && value.constructor.name === \"Object\") ||\n\t\ttypeof value.toJSON === \"function\"\n\t);\n}\n\nexport function jsonParse(text: string) {\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch (error) {\n\t\treturn text;\n\t}\n}\n\nexport function isFunction(value: any): value is () => any {\n\treturn typeof value === \"function\";\n}\n\nexport function getFetch(options?: BetterFetchOption): FetchEsque {\n\tif (options?.customFetchImpl) {\n\t\treturn options.customFetchImpl;\n\t}\n\tif (typeof globalThis !== \"undefined\" && isFunction(globalThis.fetch)) {\n\t\treturn globalThis.fetch;\n\t}\n\tif (typeof window !== \"undefined\" && isFunction(window.fetch)) {\n\t\treturn window.fetch;\n\t}\n\tthrow new Error(\"No fetch implementation found\");\n}\n\nexport function isPayloadMethod(method?: string) {\n\tif (!method) {\n\t\treturn false;\n\t}\n\tconst payloadMethod = [\"POST\", \"PUT\", \"PATCH\", \"DELETE\"];\n\treturn payloadMethod.includes(method.toUpperCase());\n}\n\nexport function isRouteMethod(method?: string) {\n\tconst routeMethod = [\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"];\n\tif (!method) {\n\t\treturn false;\n\t}\n\treturn routeMethod.includes(method.toUpperCase());\n}\n\nexport function mergeHeaders(\n\t...sources: (RequestHeaders | Record<string, string | undefined>)[]\n): Record<string, string> {\n\tconst merged: Record<string, string> = {};\n\tfor (const source of sources) {\n\t\tif (!source) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Headers has no enumerable keys (Object.entries/spread drops it); the\n\t\t// result stays a plain object so plugins can spread `options.headers`.\n\t\tif (source instanceof Headers) {\n\t\t\tsource.forEach((value, key) => {\n\t\t\t\tmerged[key] = value;\n\t\t\t});\n\t\t} else {\n\t\t\tconst entries = Array.isArray(source) ? source : Object.entries(source);\n\t\t\tfor (const [key, value] of entries) {\n\t\t\t\tif (value !== null && value !== undefined) {\n\t\t\t\t\tmerged[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn merged;\n}\n\nexport async function getHeaders(opts?: BetterFetchOption) {\n\tconst headers = new Headers(\n\t\tmergeHeaders(opts?.headers, await getAuthHeader(opts)),\n\t);\n\n\tif (!headers.has(\"content-type\")) {\n\t\tconst contentType = detectContentType(opts?.body);\n\t\tif (contentType) {\n\t\t\theaders.set(\"content-type\", contentType);\n\t\t}\n\t}\n\n\treturn headers;\n}\n\nexport function getURL(url: string, options?: BetterFetchOption) {\n\tconst { path } = parseMethodModifier(url);\n\tif (path !== url) {\n\t\turl = `/${path}`;\n\t}\n\tlet _url: string | URL;\n\ttry {\n\t\tif (url.startsWith(\"http\")) {\n\t\t\t_url = url;\n\t\t} else {\n\t\t\tlet baseURL = options?.baseURL;\n\t\t\tif (baseURL && !baseURL?.endsWith(\"/\")) {\n\t\t\t\tbaseURL = baseURL + \"/\";\n\t\t\t}\n\t\t\tif (url.startsWith(\"/\")) {\n\t\t\t\t_url = new URL(url.substring(1), baseURL);\n\t\t\t} else {\n\t\t\t\t_url = new URL(url, options?.baseURL);\n\t\t\t}\n\t\t}\n\t} catch (e) {\n\t\tif (e instanceof TypeError) {\n\t\t\tif (!options?.baseURL) {\n\t\t\t\tthrow TypeError(\n\t\t\t\t\t`Invalid URL ${url}. Are you passing in a relative url but not setting the baseURL?`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow TypeError(\n\t\t\t\t`Invalid URL ${url}. Please validate that you are passing the correct input.`,\n\t\t\t);\n\t\t}\n\t\tthrow e;\n\t}\n\n\t/**\n\t * Dynamic Parameters.\n\t */\n\tif (options?.params) {\n\t\tif (Array.isArray(options?.params)) {\n\t\t\tconst params = options?.params\n\t\t\t\t? Array.isArray(options.params)\n\t\t\t\t\t? `/${options.params.join(\"/\")}`\n\t\t\t\t\t: `/${Object.values(options.params).join(\"/\")}`\n\t\t\t\t: \"\";\n\t\t\t_url = _url.toString().split(\"/:\")[0];\n\t\t\t_url = `${_url.toString()}${params}`;\n\t\t} else {\n\t\t\tfor (const [key, value] of Object.entries(options?.params)) {\n\t\t\t\t_url = _url.toString().replace(`:${key}`, String(value));\n\t\t\t}\n\t\t}\n\t}\n\tconst __url = new URL(_url);\n\t/**\n\t * Query Parameters\n\t */\n\tconst queryParams = options?.query;\n\tif (queryParams) {\n\t\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\t\t__url.searchParams.append(key, String(value));\n\t\t}\n\t}\n\treturn __url;\n}\n\nexport function detectContentType(body: any) {\n\tif (isJSONSerializable(body)) {\n\t\treturn \"application/json\";\n\t}\n\n\treturn null;\n}\n\nfunction getMediaType(headers: Headers): string | null {\n\tconst contentType = headers.get(\"content-type\");\n\treturn contentType ? contentType.split(\";\")[0].trim().toLowerCase() : null;\n}\n\nexport function getBody(\n\toptions: BetterFetchOption,\n\theaders: Headers,\n): RequestBody {\n\tconst { body } = options;\n\tif (!body) {\n\t\treturn null;\n\t}\n\tif (!isJSONSerializable(body)) {\n\t\treturn body as RequestBody;\n\t}\n\tif (typeof body === \"string\") {\n\t\treturn body;\n\t}\n\tif (getMediaType(headers) === \"application/x-www-form-urlencoded\") {\n\t\treturn new URLSearchParams(body as Record<string, string>).toString();\n\t}\n\treturn JSON.stringify(body);\n}\n\nexport function getMethod(url: string, options?: BetterFetchOption) {\n\tif (options?.method) {\n\t\treturn options.method.toUpperCase();\n\t}\n\tconst { method } = parseMethodModifier(url);\n\tif (method) {\n\t\treturn method.toUpperCase();\n\t}\n\treturn options?.body ? \"POST\" : \"GET\";\n}\n\ntype TimeoutHandle = ReturnType<typeof setTimeout>;\n\nexport function getTimeout(\n\toptions?: BetterFetchOption,\n\tcontroller?: AbortController,\n): {\n\tabortTimeout: TimeoutHandle | undefined;\n\tclearTimeout: () => void;\n} {\n\tlet abortTimeout: TimeoutHandle | undefined;\n\tif (!options?.signal && options?.timeout) {\n\t\tabortTimeout = setTimeout(() => controller?.abort(), options?.timeout);\n\t}\n\treturn {\n\t\tabortTimeout,\n\t\tclearTimeout: () => {\n\t\t\tif (abortTimeout) {\n\t\t\t\tclearTimeout(abortTimeout);\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function bodyParser(data: any, responseType: ResponseType) {\n\tif (responseType === \"json\") {\n\t\treturn JSON.parse(data);\n\t}\n\treturn data;\n}\n\nexport class ValidationError extends Error {\n\tpublic readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;\n\n\tconstructor(issues: ReadonlyArray<StandardSchemaV1.Issue>, message?: string) {\n\t\t// Default message fallback in case one isn't supplied.\n\t\tsuper(message || JSON.stringify(issues, null, 2));\n\t\tthis.issues = issues;\n\n\t\t// Set the prototype explicitly to ensure that instanceof works correctly.\n\t\tObject.setPrototypeOf(this, ValidationError.prototype);\n\t}\n}\n\nexport async function parseStandardSchema<TSchema extends StandardSchemaV1>(\n\tschema: TSchema,\n\tinput: StandardSchemaV1.InferInput<TSchema>,\n): Promise<StandardSchemaV1.InferOutput<TSchema>> {\n\tconst result = await schema[\"~standard\"].validate(input);\n\n\tif (result.issues) {\n\t\tthrow new ValidationError(result.issues);\n\t}\n\treturn result.value;\n}\n","import { BetterFetchError } from \"./error\";\nimport { initializePlugins } from \"./plugins\";\nimport { createRetryStrategy } from \"./retry\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\nimport type { BetterFetchOption, BetterFetchResponse } from \"./types\";\nimport { getURL } from \"./url\";\nimport {\n\tdetectResponseType,\n\tgetBody,\n\tgetFetch,\n\tgetHeaders,\n\tgetMethod,\n\tgetTimeout,\n\tisJSONParsable,\n\tjsonParse,\n\tparseStandardSchema,\n} from \"./utils\";\n\nexport const betterFetch = async <\n\tTRes extends Option[\"output\"] extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferOutput<Option[\"output\"]>\n\t\t: unknown,\n\tTErr = unknown,\n\tOption extends BetterFetchOption = BetterFetchOption<any, any, any, TRes>,\n>(\n\turl: string,\n\toptions?: Option,\n): Promise<\n\tBetterFetchResponse<\n\t\tTRes,\n\t\tTErr,\n\t\tOption[\"throw\"] extends true ? true : TErr extends false ? true : false\n\t>\n> => {\n\tconst {\n\t\thooks,\n\t\turl: __url,\n\t\toptions: opts,\n\t} = await initializePlugins(url, options);\n\tconst fetch = getFetch(opts);\n\tconst controller = new AbortController();\n\tconst signal = opts.signal ?? controller.signal;\n\tconst _url = getURL(__url, opts);\n\tconst headers = await getHeaders(opts);\n\tconst body = getBody(opts, headers);\n\tconst method = getMethod(__url, opts);\n\t// one stable object for the whole request so per-request state keyed on\n\t// its identity survives hooks that return a replacement context\n\tconst context = {\n\t\t...opts,\n\t\turl: _url,\n\t\theaders,\n\t\tbody,\n\t\tmethod,\n\t\tsignal,\n\t};\n\t/**\n\t * Run all on request hooks\n\t */\n\tfor (const onRequest of hooks.onRequest) {\n\t\tif (onRequest) {\n\t\t\tconst res = await onRequest(context);\n\t\t\tif (typeof res === \"object\" && res !== null) {\n\t\t\t\tObject.assign(context, res);\n\t\t\t}\n\t\t}\n\t}\n\tif (\n\t\t(\"pipeTo\" in context && typeof context.pipeTo === \"function\") ||\n\t\ttypeof options?.body?.pipe === \"function\"\n\t) {\n\t\tif (!(\"duplex\" in context)) {\n\t\t\tcontext.duplex = \"half\";\n\t\t}\n\t}\n\n\tconst { clearTimeout } = getTimeout(opts, controller);\n\tlet response = await fetch(context.url, context);\n\tclearTimeout();\n\n\tconst responseContext = {\n\t\tresponse,\n\t\trequest: context,\n\t};\n\n\tfor (const onResponse of hooks.onResponse) {\n\t\tif (onResponse) {\n\t\t\tconst r = await onResponse({\n\t\t\t\t...responseContext,\n\t\t\t\tresponse: options?.hookOptions?.cloneResponse\n\t\t\t\t\t? response.clone()\n\t\t\t\t\t: response,\n\t\t\t});\n\t\t\tif (r instanceof Response) {\n\t\t\t\tresponse = r;\n\t\t\t} else if (typeof r === \"object\" && r !== null) {\n\t\t\t\tresponse = r.response;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * OK Branch\n\t */\n\tif (response.ok) {\n\t\tconst hasBody = context.method !== \"HEAD\";\n\t\tif (!hasBody) {\n\t\t\treturn {\n\t\t\t\tdata: \"\" as any,\n\t\t\t\terror: null,\n\t\t\t} as any;\n\t\t}\n\t\tconst responseType = detectResponseType(response);\n\t\tconst successContext = {\n\t\t\tdata: null as any,\n\t\t\tresponse,\n\t\t\trequest: context,\n\t\t};\n\t\tif (responseType === \"json\" || responseType === \"text\") {\n\t\t\tconst text = await response.text();\n\t\t\tconst parser = context.jsonParser ?? jsonParse;\n\t\t\tsuccessContext.data = await parser(text);\n\t\t} else {\n\t\t\tsuccessContext.data = await response[responseType]();\n\t\t}\n\n\t\t/**\n\t\t * Parse the data if the output schema is defined\n\t\t */\n\t\tif (context?.output) {\n\t\t\tif (context.output && !context.disableValidation) {\n\t\t\t\tsuccessContext.data = await parseStandardSchema(\n\t\t\t\t\tcontext.output as StandardSchemaV1,\n\t\t\t\t\tsuccessContext.data,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tfor (const onSuccess of hooks.onSuccess) {\n\t\t\tif (onSuccess) {\n\t\t\t\tawait onSuccess({\n\t\t\t\t\t...successContext,\n\t\t\t\t\tresponse: options?.hookOptions?.cloneResponse\n\t\t\t\t\t\t? response.clone()\n\t\t\t\t\t\t: response,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (options?.throw) {\n\t\t\treturn successContext.data;\n\t\t}\n\n\t\treturn {\n\t\t\tdata: successContext.data,\n\t\t\terror: null,\n\t\t} as any;\n\t}\n\tconst parser = options?.jsonParser ?? jsonParse;\n\tconst responseText = await response.text();\n\tconst isJSONResponse = isJSONParsable(responseText);\n\tconst errorObject = isJSONResponse ? await parser(responseText) : null;\n\t/**\n\t * Error Branch\n\t */\n\tconst errorContext = {\n\t\tresponse,\n\t\tresponseText,\n\t\trequest: context,\n\t\terror: {\n\t\t\t...errorObject,\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t},\n\t};\n\tfor (const onError of hooks.onError) {\n\t\tif (onError) {\n\t\t\tawait onError({\n\t\t\t\t...errorContext,\n\t\t\t\tresponse: options?.hookOptions?.cloneResponse\n\t\t\t\t\t? response.clone()\n\t\t\t\t\t: response,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (options?.retry) {\n\t\tconst retryStrategy = createRetryStrategy(options.retry);\n\t\tconst _retryAttempt = options.retryAttempt ?? 0;\n\t\tif (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {\n\t\t\tfor (const onRetry of hooks.onRetry) {\n\t\t\t\tif (onRetry) {\n\t\t\t\t\tawait onRetry(responseContext);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst delay = retryStrategy.getDelay(_retryAttempt);\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, delay));\n\t\t\treturn await betterFetch(url, {\n\t\t\t\t...options,\n\t\t\t\tretryAttempt: _retryAttempt + 1,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (options?.throw) {\n\t\tthrow new BetterFetchError(\n\t\t\tresponse.status,\n\t\t\tresponse.statusText,\n\t\t\tisJSONResponse ? errorObject : responseText,\n\t\t);\n\t}\n\treturn {\n\t\tdata: null,\n\t\terror: {\n\t\t\t...errorObject,\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t},\n\t} as any;\n};\n","import { betterFetch } from \"../fetch\";\nimport { parseMethodModifier } from \"../method\";\nimport { BetterFetchPlugin } from \"../plugins\";\nimport type { BetterFetchOption } from \"../types\";\nimport { mergeHeaders, parseStandardSchema } from \"../utils\";\nimport type { BetterFetch, CreateFetchOption } from \"./types\";\n\nexport const applySchemaPlugin = (config: CreateFetchOption) =>\n\t({\n\t\tid: \"apply-schema\",\n\t\tname: \"Apply Schema\",\n\t\tversion: \"1.0.0\",\n\t\tasync init(url, options: BetterFetchOption | undefined) {\n\t\t\tlet opts: BetterFetchOption = {\n\t\t\t\t...options,\n\t\t\t\t...(config.query !== undefined && {\n\t\t\t\t\tquery: { ...config.query, ...options?.query },\n\t\t\t\t}),\n\t\t\t};\n\t\t\tconst schema =\n\t\t\t\tconfig.plugins?.find((plugin) =>\n\t\t\t\t\tplugin.schema?.config\n\t\t\t\t\t\t? url.startsWith(plugin.schema.config.baseURL || \"\") ||\n\t\t\t\t\t\t\turl.startsWith(plugin.schema.config.prefix || \"\")\n\t\t\t\t\t\t: false,\n\t\t\t\t)?.schema || config.schema;\n\t\t\tif (schema) {\n\t\t\t\tlet urlKey = url;\n\t\t\t\tif (schema.config?.prefix) {\n\t\t\t\t\tif (urlKey.startsWith(schema.config.prefix)) {\n\t\t\t\t\t\turlKey = urlKey.replace(schema.config.prefix, \"\");\n\t\t\t\t\t\tif (schema.config.baseURL) {\n\t\t\t\t\t\t\turl = url.replace(schema.config.prefix, schema.config.baseURL);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (schema.config?.baseURL) {\n\t\t\t\t\tif (urlKey.startsWith(schema.config.baseURL)) {\n\t\t\t\t\t\turlKey = urlKey.replace(schema.config.baseURL, \"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (urlKey.startsWith(\"/\") && urlKey.charAt(1) === \"@\") {\n\t\t\t\t\turlKey = urlKey.substring(1);\n\t\t\t\t}\n\n\t\t\t\tconst keySchema = schema.schema[urlKey];\n\t\t\t\tif (keySchema) {\n\t\t\t\t\tconst { method: schemaMethod, path } = parseMethodModifier(urlKey);\n\t\t\t\t\tif (schemaMethod) {\n\t\t\t\t\t\turl = url.slice(0, url.length - urlKey.length) + path;\n\t\t\t\t\t}\n\t\t\t\t\tlet validatedHeaders = options?.headers;\n\t\t\t\t\tif (keySchema.headers && !options?.disableValidation) {\n\t\t\t\t\t\tconst normalizedHeaders: Record<string, string> = {};\n\t\t\t\t\t\tif (options?.headers) {\n\t\t\t\t\t\t\tif (options.headers instanceof Headers) {\n\t\t\t\t\t\t\t\toptions.headers.forEach((value, key) => {\n\t\t\t\t\t\t\t\t\tnormalizedHeaders[key.toLowerCase()] = value;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else if (typeof options.headers === \"object\") {\n\t\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(options.headers)) {\n\t\t\t\t\t\t\t\t\tif (value !== null && value !== undefined) {\n\t\t\t\t\t\t\t\t\t\tnormalizedHeaders[key.toLowerCase()] = value;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst validated = (await parseStandardSchema(\n\t\t\t\t\t\t\tkeySchema.headers,\n\t\t\t\t\t\t\tnormalizedHeaders,\n\t\t\t\t\t\t)) as Record<string, string | undefined>;\n\n\t\t\t\t\t\tconst finalHeaders: Record<string, string | undefined> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(validated)) {\n\t\t\t\t\t\t\tfinalHeaders[key.toLowerCase()] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidatedHeaders = finalHeaders;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst method = keySchema.method ?? schemaMethod;\n\t\t\t\t\topts = {\n\t\t\t\t\t\t...opts,\n\t\t\t\t\t\t...(method !== undefined && { method }),\n\t\t\t\t\t\t...(keySchema.output !== undefined && { output: keySchema.output }),\n\t\t\t\t\t\t...(validatedHeaders !== undefined && {\n\t\t\t\t\t\t\theaders: validatedHeaders,\n\t\t\t\t\t\t}),\n\t\t\t\t\t};\n\n\t\t\t\t\tif (!options?.disableValidation) {\n\t\t\t\t\t\tif (keySchema.query) {\n\t\t\t\t\t\t\topts.query = await parseStandardSchema(\n\t\t\t\t\t\t\t\tkeySchema.query,\n\t\t\t\t\t\t\t\toptions?.query,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (opts.query !== null && typeof opts.query === \"object\") {\n\t\t\t\t\t\t\t\tconst defaults = { ...config.query };\n\t\t\t\t\t\t\t\tfor (const key of Object.keys(defaults)) {\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\toptions?.query &&\n\t\t\t\t\t\t\t\t\t\tObject.prototype.hasOwnProperty.call(options.query, key)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tdefaults[key] = options.query[key];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\topts.query = { ...defaults, ...opts.query };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topts = {\n\t\t\t\t\t\t\t...opts,\n\t\t\t\t\t\t\tbody: keySchema.input\n\t\t\t\t\t\t\t\t? await parseStandardSchema(keySchema.input, options?.body)\n\t\t\t\t\t\t\t\t: options?.body,\n\t\t\t\t\t\t\tparams: keySchema.params\n\t\t\t\t\t\t\t\t? await parseStandardSchema(keySchema.params, options?.params)\n\t\t\t\t\t\t\t\t: options?.params,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\turl,\n\t\t\t\t\t\toptions: opts,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\turl,\n\t\t\t\t...((options !== undefined || config.query !== undefined) && {\n\t\t\t\t\toptions: opts,\n\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t}) satisfies BetterFetchPlugin;\n\nexport const createFetch = <Option extends CreateFetchOption>(\n\tconfig?: Option,\n) => {\n\tasync function $fetch(url: string, options?: BetterFetchOption) {\n\t\tconst opts = {\n\t\t\t...config,\n\t\t\t...options,\n\t\t\theaders: mergeHeaders(config?.headers, options?.headers),\n\t\t\tplugins: [\n\t\t\t\t...(config?.plugins || []),\n\t\t\t\tapplySchemaPlugin(config || {}),\n\t\t\t\t...(options?.plugins || []),\n\t\t\t],\n\t\t} as BetterFetchOption;\n\n\t\tif (config?.catchAllError) {\n\t\t\ttry {\n\t\t\t\treturn await betterFetch(url, opts);\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tdata: null,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tstatus: 500,\n\t\t\t\t\t\tstatusText: \"Fetch Error\",\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\"Fetch related error. Captured by catchAllError option. See error property for more details.\",\n\t\t\t\t\t\terror,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn await betterFetch(url, opts);\n\t}\n\treturn $fetch as BetterFetch<Option>;\n};\n\nexport * from \"./schema\";\nexport * from \"./types\";\n"],"mappings":";;AAAA,IAAa,mBAAb,cAAsC,MAAM;CAC3C,YACC,QACA,YACA,OACC;EACD,MAAM,cAAc,OAAO,SAAS,GAAG,EACtC,OAAO,MACR,CAAC;EANM,KAAA,SAAA;EACA,KAAA,aAAA;EACA,KAAA,QAAA;EAKP,MAAM,kBAAkB,MAAM,KAAK,WAAW;CAC/C;AACD;;;ACqIA,MAAa,oBAAoB,OAChC,KACA,YACI;CACJ,IAAI,OAAO,WAAW,CAAC;CACvB,MAAM,QAMF;EACH,WAAW,CAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAC,QAAS,SAAS;EAC9B,YAAY,CAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAC,QAAS,UAAU;EAChC,WAAW,CAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAC,QAAS,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