@tanstack/router-core
Version:
Modern and scalable routing for React applications
1 lines • 108 kB
Source Map (JSON)
{"version":3,"file":"load-client.cjs","names":[],"sources":["../../src/load-client.ts"],"sourcesContent":["// Keep this filename free of a secondary extension so declaration generation\n// can rewrite relative imports for both ESM and CJS.\nimport { isNotFound } from './not-found'\nimport { isRedirect } from './redirect'\nimport { getLocationChangeInfo, runRouteLifecycle } from './router'\nimport { hydrateSsrMatchId } from './ssr/ssr-match-id'\nimport type { GLOBAL_SEROVAL, GLOBAL_TSR } from './ssr/constants'\nimport type { AnySerializationAdapter } from './ssr/serializer/transformer'\nimport type { TsrSsrGlobal } from './ssr/types'\nimport type { ParsedLocation } from './location'\nimport type { NavigateOptions } from './link'\nimport type { AnyRouteMatch } from './Matches'\nimport type { NotFoundError } from './not-found'\nimport type {\n AnyRoute,\n LoaderFnContext,\n RouteContextOptions,\n RouteLoaderFn,\n} from './route'\nimport type { AnyRedirect } from './redirect'\nimport type { AnyRouter, RouterCore, TrailingSlashOption } from './router'\nimport type { RoutePaths } from './routeInfo'\nimport type { RouterHistory } from '@tanstack/history'\n\ntype RouteComponentType =\n | 'component'\n | 'pendingComponent'\n | 'errorComponent'\n | 'notFoundComponent'\n\nexport function replaceRouteChunk(\n route: AnyRoute,\n lazyFn: AnyRoute['lazyFn'],\n): void {\n route.lazyFn = lazyFn ?? route.lazyFn\n route._lazy = undefined\n}\n\nfunction preloadComponent(\n route: AnyRoute,\n type: RouteComponentType,\n): Promise<void> | undefined {\n return (route.options[type] as any)?.preload?.()\n}\n\nfunction loadComponents(\n route: AnyRoute,\n onPendingReady?: () => void,\n): Promise<void> | undefined {\n const component = preloadComponent(route, 'component')\n let pending = preloadComponent(route, 'pendingComponent')\n if (onPendingReady) {\n if (pending) {\n pending = pending.then(onPendingReady)\n } else {\n onPendingReady()\n }\n }\n if (component && pending) {\n return Promise.all([component, pending]).then(() => {})\n }\n return component ?? pending\n}\n\nexport function loadRouteChunk(\n route: AnyRoute,\n // `false` waits only for lazy route options, before a boundary is selected.\n componentType?: 'errorComponent' | 'notFoundComponent' | false,\n onPendingReady?: () => void,\n): Promise<void> | undefined {\n const afterLazy = () =>\n componentType === false\n ? undefined\n : componentType\n ? preloadComponent(route, componentType)\n : loadComponents(route, onPendingReady)\n const current = route._lazy\n if (current) {\n return current === true ? afterLazy() : current.then(afterLazy)\n }\n if (!route.lazyFn) {\n return afterLazy()\n }\n\n const promise = route.lazyFn().then(\n (lazyRoute) => {\n // HMR clears the owner before an obsolete import can settle.\n if (process.env.NODE_ENV === 'production' || route._lazy === promise) {\n const { id: _id, ...options } = lazyRoute.options\n Object.assign(route.options, options)\n route._lazy = true\n }\n },\n (error) => {\n if (process.env.NODE_ENV === 'production' || route._lazy === promise) {\n route._lazy = undefined\n }\n throw error\n },\n )\n route._lazy = promise\n return promise.then(afterLazy)\n}\n\n/** Return the structural lane through the first terminal render boundary. */\nexport function _getRenderedMatches(\n matches: Array<AnyRouteMatch>,\n): Array<AnyRouteMatch> {\n const end =\n matches.findIndex(\n (match) => match.status !== 'success' || match._notFound,\n ) + 1\n return end && end < matches.length ? matches.slice(0, end) : matches\n}\n\n/** Return the lane whose document assets belong to the current presentation. */\nexport function _getAssetMatches(\n matches: Array<AnyRouteMatch>,\n): Array<AnyRouteMatch> {\n let end = matches.length\n for (let index = 0; index < end; index++) {\n const match = matches[index]!\n // `_assetEnd` is only ever set on hydration presentation clones that are\n // `status: 'pending'`, `ssr: 'data-only'`, error-free, and not not-found\n // (see hydrate.ts), and commits clear it — so its presence alone is the guard.\n if (match._assetEnd !== undefined) {\n end = Math.min(end, Math.max(index + 1, match._assetEnd))\n continue\n }\n if (match.status !== 'success' || match._notFound) {\n end = index + 1\n break\n }\n }\n // `end` only ever shrinks to `index + 1 >= 1`, so no zero guard is needed.\n return end < matches.length ? matches.slice(0, end) : matches\n}\n\ndeclare const lanePhase: unique symbol\n\ntype LanePhase = 'matched' | 'contextualized' | 'reduced' | 'projected'\n\n/**\n * Lane matches carry their lane's phase so functions can demand evidence of\n * pipeline position (e.g. `commitMatches` only accepts a projected lane's\n * matches). The brand is phantom — it never exists at runtime.\n */\ntype LaneMatches<TPhase extends LanePhase> = Array<WorkMatch> & {\n readonly [lanePhase]?: TPhase\n}\n\ntype Lane<TPhase extends LanePhase> = [\n location: ParsedLocation,\n matches: LaneMatches<TPhase>,\n background?: Array<BackgroundLoaderTask>,\n backgroundSettlement?: Promise<IndexedOutcome | undefined>,\n] & { readonly [lanePhase]?: TPhase }\n\ntype MatchedLane = Lane<'matched'>\ntype ContextualizedLane = Lane<'contextualized'>\ntype ReducedLane = Lane<'reduced'>\ntype ProjectedLane = Lane<'projected'>\n\nconst SUCCESS = 0\nconst ERROR = 1\nconst NOT_FOUND = 2\n// Control outcomes stay contiguous so the hot path can test them together.\nconst REDIRECTED = 3\nconst CANCELED = 4\nconst CANCELED_OUTCOME: [kind: typeof CANCELED] = [CANCELED]\n\ntype RedirectOutcome = [\n kind: typeof REDIRECTED,\n redirect: AnyRedirect,\n location?: ParsedLocation,\n]\n\ntype NonRedirectOutcome =\n | [kind: typeof SUCCESS, data: unknown]\n | [kind: typeof ERROR, error: unknown]\n | [kind: typeof NOT_FOUND, error: NotFoundError]\n | [kind: typeof CANCELED]\n\ntype RawLoaderOutcome =\n | NonRedirectOutcome\n | [kind: typeof REDIRECTED, redirect: AnyRedirect]\n\ntype LoaderOutcome = NonRedirectOutcome | RedirectOutcome\n\ntype IndexedOutcome = [index: number, outcome: LoaderOutcome, boundary?: number]\n\nexport type LoaderFlight = [\n outcome: Promise<RawLoaderOutcome>,\n controller: AbortController,\n leases: number,\n]\n\ntype WorkMatch = AnyRouteMatch & {\n _flight?: LoaderFlight\n}\n\ndeclare const matchPhase: unique symbol\n\n/**\n * A match whose loader outcome has been applied by `settleInto`, which is the\n * sole granter of this brand (phantom, zero-runtime). Consumers that require\n * it — e.g. `cacheLoaderMatch` — can only be reached after settlement, so the\n * compiler enforces the loader→settle→cache ordering. Sources that arrive\n * already settled (dehydrated server data) must cast at a named boundary.\n */\ntype SettledMatch = WorkMatch & { readonly [matchPhase]: 'settled' }\n\nexport type LoadTransaction = [\n controller: AbortController,\n redirects: number,\n location: ParsedLocation,\n matches: Array<AnyRouteMatch>,\n startedAt: number,\n done: Promise<void>,\n /**\n * Dev-only HMR refresh mode. Presence forces successor rematerialization\n * until this publication is acknowledged. The optional hydration handoff is\n * retired when the refresh publishes.\n */\n refresh?: [handoff: NonNullable<AnyRouter['_handoff']> | undefined],\n]\n\nexport type PendingSession = [\n generation: LoadTransaction,\n boundaryId: string,\n /** Pending reveal time until acknowledged, then minimum-visible-until time. */\n deadline: number,\n revealTimer?: ReturnType<typeof setTimeout>,\n ack?: Promise<boolean> | true,\n component?: unknown,\n]\n\ntype CoordinatorRouter = AnyRouter & {\n /** Active speculative lanes retained for cancellation, invalidation, and cache clearing. */\n _preloads?: Map<AbortController, Array<AnyRouteMatch>>\n _refreshNextLoad?: boolean\n}\n\ntype LoaderTask = [\n index: number,\n outcome: Promise<LoaderOutcome>,\n chunkFailure: Promise<IndexedOutcome | undefined>,\n candidate?: WorkMatch,\n]\n\ntype BackgroundLoaderTask = [\n index: number,\n outcome: Promise<LoaderOutcome>,\n chunkFailure: Promise<IndexedOutcome | undefined>,\n candidate: WorkMatch,\n]\n\ntype ExecuteLaneOptions = [\n controller: AbortController,\n redirects: number,\n base: Array<AnyRouteMatch>,\n preload?: boolean,\n sync?: boolean,\n forceStaleReload?: boolean,\n resolvedPrefix?: number,\n onReady?: () => void,\n]\n\ntype ControlOutcome = RedirectOutcome | [kind: typeof CANCELED]\n\ntype LaneResult = ProjectedLane | ControlOutcome\n\nfunction isControl(\n result: Lane<any> | ControlOutcome,\n): result is ControlOutcome {\n return typeof result[0 /* location or kind */] === 'number'\n}\n\nexport function waitFor<T>(\n value: T | PromiseLike<T>,\n signal: AbortSignal,\n): Promise<T> {\n if (signal.aborted) {\n return Promise.race([Promise.reject(signal), value])\n }\n return new Promise<T>((resolve, reject) => {\n const abort = () => reject(signal)\n signal.addEventListener('abort', abort, { once: true })\n Promise.resolve(value)\n .then(resolve, reject)\n .finally(() => signal.removeEventListener('abort', abort))\n })\n}\n\nexport function getRoute(router: AnyRouter, match: WorkMatch): AnyRoute {\n return (router.routesById as Record<string, AnyRoute>)[match.routeId]!\n}\n\nfunction normalize(\n value: unknown,\n rejected: boolean,\n routeId?: string,\n): RawLoaderOutcome {\n if (isRedirect(value)) {\n return [REDIRECTED, value]\n }\n if (isNotFound(value)) {\n value.routeId ||= routeId\n return [NOT_FOUND, value]\n }\n if (!rejected) {\n return [SUCCESS, value]\n }\n if (typeof (value as any)?.then === 'function') {\n value = new Error('A Promise was thrown', { cause: value })\n }\n return [ERROR, value]\n}\n\nfunction normalizeError(route: AnyRoute, cause: unknown): RawLoaderOutcome {\n let outcome = normalize(cause, true, route.id)\n if (outcome[0 /* kind */] !== ERROR) {\n return outcome\n }\n try {\n route.options.onError?.(outcome[1 /* error */])\n } catch (onErrorCause) {\n outcome = normalize(onErrorCause, true, route.id)\n }\n return outcome\n}\n\nfunction normalizeLaneError(\n router: AnyRouter,\n lane: Lane<any>,\n route: AnyRoute,\n cause: unknown,\n options: ExecuteLaneOptions,\n): LoaderOutcome {\n if (options[0 /* controller */].signal.aborted) {\n return CANCELED_OUTCOME\n }\n return materializeRedirect(\n router,\n lane,\n route,\n normalizeError(route, cause),\n options,\n )\n}\n\nasync function contextualize(\n router: AnyRouter,\n lane: MatchedLane,\n options: ExecuteLaneOptions,\n end: number,\n planSuccessfulLane: () => void,\n retainedEnd: number,\n): Promise<IndexedOutcome | undefined> {\n const [location, matches] = lane\n const signal = options[0 /* controller */].signal\n const preload = !!options[3 /* preload */]\n for (let index = options[6 /* resolvedPrefix */] ?? 0; index < end; index++) {\n const match = matches[index]!\n const route = getRoute(router, match)\n\n match.abortController = options[0 /* controller */]\n // Contextualization is serial, so the previous match already contains the\n // complete parent context for this route.\n const parentContext =\n matches[index - 1]?.context ?? router.options.context ?? {}\n const common = {\n params: match.params,\n location,\n navigate: (opts: any) =>\n router.navigate({\n ...opts,\n _fromLocation: location,\n }),\n buildLocation: router.buildLocation,\n cause: preload ? ('preload' as const) : match.cause,\n abortController: options[0 /* controller */],\n preload,\n matches,\n routeId: route.id,\n }\n try {\n // Reuse the route's cached contribution while rebuilding its inheritance.\n const routeContext = (match._ctx ||= route.options.context\n ? route.options.context({\n ...common,\n deps: match.loaderDeps,\n context: parentContext,\n } satisfies RouteContextOptions<any, any, any, any, any>) || {}\n : undefined)\n match.context = {\n ...parentContext,\n ...routeContext,\n }\n } catch (cause) {\n releaseFlight(router, match)\n return [index, normalizeLaneError(router, lane, route, cause, options)]\n }\n if (signal.aborted) {\n return [index, CANCELED_OUTCOME]\n }\n const validationError = match.paramsError ?? match.searchError\n if (validationError !== undefined) {\n releaseFlight(router, match)\n return [\n index,\n normalizeLaneError(router, lane, route, validationError, options),\n ]\n }\n const beforeLoad = route.options.beforeLoad\n if (!beforeLoad) {\n continue\n }\n\n const previousStatus = match.status\n if (index >= retainedEnd) {\n match.status = 'pending'\n options[7 /* onReady */]?.()\n }\n try {\n setFetching(router, match, 'beforeLoad', options[0 /* controller */])\n const result = await waitFor(\n beforeLoad({\n ...common,\n search: match.search,\n context: match.context,\n ...router.options.additionalContext,\n }),\n signal,\n )\n if (signal.aborted) {\n return [index, CANCELED_OUTCOME]\n }\n const outcome = materializeRedirect(\n router,\n lane,\n route,\n normalize(result, false, route.id),\n options,\n )\n if (outcome[0 /* kind */] !== SUCCESS) {\n releaseFlight(router, match)\n return [index, outcome]\n }\n match.context = {\n ...match.context,\n ...result,\n }\n } catch (cause) {\n releaseFlight(router, match)\n return [index, normalizeLaneError(router, lane, route, cause, options)]\n } finally {\n match.status = previousStatus\n setFetching(router, match, false, options[0 /* controller */])\n }\n }\n\n // Let a synchronous lane claim predecessor flights before this frame yields.\n planSuccessfulLane()\n return\n}\n\nfunction releaseOwnedFlight(\n router: AnyRouter,\n match: WorkMatch,\n flight?: LoaderFlight,\n): AbortController | undefined {\n if (!flight || --flight[2 /* leases */]) {\n return\n }\n if (router._flights?.get(match.id) === flight) {\n const current = router._tx\n if (\n current &&\n !current[0 /* controller */].signal.aborted &&\n !current[3 /* matches */].includes(match) &&\n current[3 /* matches */].some((candidate) => candidate.id === match.id) &&\n current[3 /* matches */].some(\n (candidate) => candidate.isFetching === 'beforeLoad',\n )\n ) {\n // Keep work discoverable only while the current lane is still running\n // beforeLoad. Loader planning performs the matching zero-owner sweep.\n return\n }\n router._flights.delete(match.id)\n }\n return flight[1 /* controller */]\n}\n\nfunction releaseFlight(router: AnyRouter, match: WorkMatch): void {\n const flight = match._flight\n match._flight = undefined\n releaseOwnedFlight(router, match, flight)?.abort()\n}\n/**\n * Not passing in a `next` ownership recipient\n * is equivalent to discarding the match resources\n */\nfunction transferMatchResources(\n router: AnyRouter,\n previous: Array<AnyRouteMatch>,\n next?: Array<AnyRouteMatch>,\n deferSameIdFlight?: true,\n): void {\n const abort: Array<AbortController> = []\n for (const match of previous as Array<WorkMatch>) {\n if (!next?.includes(match)) {\n const flight = match._flight\n match._flight = undefined\n if (\n deferSameIdFlight &&\n flight?.[2 /* leases */] === 1 &&\n router._flights?.get(match.id) === flight &&\n next?.some((candidate) => candidate.id === match.id)\n ) {\n // The successor has not made its same-ID reload decision yet.\n flight[2 /* leases */] = 0\n } else {\n const controller = releaseOwnedFlight(router, match, flight)\n if (controller) {\n abort.push(controller)\n }\n }\n }\n }\n for (const controller of abort) {\n controller.abort()\n }\n}\n\nfunction acquireMatchResources(matches: Array<AnyRouteMatch>): void {\n for (const match of matches as Array<WorkMatch>) {\n const flight = match._flight\n if (flight) {\n flight[2 /* leases */]++\n }\n }\n}\n\nfunction setFetching(\n router: AnyRouter,\n match: WorkMatch,\n value: AnyRouteMatch['isFetching'],\n owner?: AbortController,\n): void {\n match.isFetching = value\n if (owner && router._tx?.[0 /* controller */] !== owner) {\n return\n }\n const store = router.stores.byRoute.get(match.routeId)\n const presented = store?.get()\n if (presented?.id === match.id) {\n store!.set({ ...presented, isFetching: value })\n }\n}\n\nfunction getLoaderContext(\n router: AnyRouter,\n lane: ContextualizedLane,\n match: WorkMatch,\n route: AnyRoute,\n controller: AbortController,\n parentMatchPromise: Promise<WorkMatch> | undefined,\n preload: boolean,\n): LoaderFnContext {\n const location = lane[0 /* location */]\n return {\n params: match.params,\n location,\n navigate: (opts: any) =>\n router.navigate({\n ...opts,\n _fromLocation: location,\n }),\n cause: preload ? ('preload' as const) : match.cause,\n abortController: controller,\n preload,\n deps: match.loaderDeps,\n parentMatchPromise: parentMatchPromise as any,\n context: match.context,\n route,\n ...router.options.additionalContext,\n }\n}\n\nasync function loadResource(\n router: AnyRouter,\n lane: ContextualizedLane,\n match: WorkMatch,\n route: AnyRoute,\n loader: RouteLoaderFn<any> | undefined,\n parentMatchPromise: Promise<WorkMatch> | undefined,\n options: ExecuteLaneOptions,\n): Promise<LoaderOutcome> {\n const owner = options[0 /* controller */]\n const signal = owner.signal\n if (signal.aborted) {\n return CANCELED_OUTCOME\n }\n if (!loader) {\n return [SUCCESS, undefined]\n }\n\n let flight = match._flight\n setFetching(router, match, 'loader', owner)\n try {\n if (!flight) {\n const controller = new AbortController()\n flight = [\n Promise.resolve()\n .then(() =>\n loader(\n getLoaderContext(\n router,\n lane,\n match,\n route,\n controller,\n parentMatchPromise,\n !!options[3 /* preload */],\n ),\n ),\n )\n .then(\n (value) => normalize(value, false, route.id),\n (cause) => normalize(cause, true, route.id),\n )\n .then((result): RawLoaderOutcome => {\n // The registry controls discovery; leases keep current consumers\n // sharing the same terminal outcome.\n if (\n result[0 /* kind */] !== SUCCESS &&\n router._flights?.get(match.id) === flight\n ) {\n router._flights!.delete(match.id)\n if (!flight![2 /* leases */]) {\n controller.abort()\n }\n }\n return result[0 /* kind */] === ERROR && flight![2 /* leases */]\n ? normalizeError(route, result[1 /* error */])\n : result\n }),\n controller,\n 1,\n ]\n ;(router._flights ??= new Map()).set(match.id, flight)\n }\n match._flight = flight\n match.abortController = flight[1 /* controller */]\n return materializeRedirect(\n router,\n lane,\n route,\n await waitFor(flight[0 /* outcome */], signal),\n options,\n )\n } catch (cause) {\n if (cause !== signal || !signal.aborted) {\n throw cause\n }\n releaseFlight(router, match)\n return CANCELED_OUTCOME\n } finally {\n setFetching(router, match, false, owner)\n }\n}\n\nfunction settleInto(\n match: WorkMatch,\n result: LoaderOutcome,\n preload: boolean,\n): asserts match is SettledMatch {\n if (result[0 /* kind */] === REDIRECTED) {\n return\n }\n // Reduction installs only the selected terminal failure. Every other\n // settled attempt remains a renderable, stale match in that lane.\n match.status = 'success'\n match.error = undefined\n if (result[0 /* kind */] === SUCCESS) {\n match.loaderData = result[1 /* data */]\n match.invalid = false\n match.updatedAt = Date.now()\n match.preload = preload\n } else {\n match.invalid = true\n }\n}\n\nexport function cacheLoaderMatch(\n router: CoordinatorRouter,\n match: SettledMatch,\n planned: AnyRouteMatch | undefined,\n): void {\n const current = router._cache.get(match.id) as WorkMatch | undefined\n if (\n current !== planned ||\n router._committed.some(\n (candidate) =>\n candidate.id === match.id &&\n (candidate as WorkMatch)._flight === match._flight,\n )\n ) {\n return\n }\n const cached = {\n ...match,\n _notFound: undefined,\n context: {},\n } as WorkMatch\n if (cached._flight) {\n cached._flight[2 /* leases */]++\n }\n router._cache.set(match.id, cached)\n if (current) {\n releaseFlight(router, current)\n }\n}\n\nfunction getParentSnapshot(\n match: WorkMatch,\n outcome: LoaderOutcome,\n): WorkMatch {\n if (outcome[0 /* kind */] === ERROR || outcome[0 /* kind */] === NOT_FOUND) {\n return {\n ...match,\n status: outcome[0 /* kind */] === ERROR ? 'error' : 'notFound',\n error: outcome[1 /* error */],\n _flight: undefined,\n }\n }\n return match\n}\n\nfunction createLoaderTask(\n router: AnyRouter,\n lane: ContextualizedLane,\n index: number,\n tasks: Array<LoaderTask>,\n semanticParent: Promise<WorkMatch> | undefined,\n options: ExecuteLaneOptions,\n retainedEnd: number,\n): Promise<WorkMatch> {\n const match = lane[1 /* matches */][index]!\n const route = getRoute(router, match)\n const preload = !!options[3 /* preload */]\n const plannedCacheMatch = router._cache.get(match.id)\n let configured\n let reload = false\n let reloadFailure: LoaderOutcome | undefined\n try {\n if (match.status === 'success') {\n configured = route.options.shouldReload\n if (typeof configured === 'function') {\n configured = configured(\n getLoaderContext(\n router,\n lane,\n match,\n route,\n options[0 /* controller */],\n semanticParent,\n preload,\n ),\n )\n }\n if (options[0 /* controller */].signal.aborted) {\n reloadFailure = CANCELED_OUTCOME\n }\n }\n if (!reloadFailure) {\n if (match.status !== 'success') {\n reload = true\n } else {\n const staleAge =\n preload || match.preload\n ? (route.options.preloadStaleTime ??\n router.options.defaultPreloadStaleTime ??\n 30_000)\n : (route.options.staleTime ?? router.options.defaultStaleTime ?? 0)\n reload = !!(\n match.invalid ||\n configured ||\n (configured === undefined &&\n Date.now() - match.updatedAt >= staleAge &&\n (options[5 /* forceStaleReload */] ||\n match.cause === 'enter' ||\n options[2 /* base */].some(\n (candidate) =>\n candidate.routeId === match.routeId &&\n candidate.id !== match.id,\n )))\n )\n }\n }\n } catch (cause) {\n match.invalid = true\n releaseFlight(router, match)\n reloadFailure = normalizeLaneError(router, lane, route, cause, options)\n }\n const routeLoader = route.options.loader\n const isLoaderFn = typeof routeLoader === 'function'\n const loader = isLoaderFn ? routeLoader : routeLoader?.handler\n const preloadable = !preload || route.options.preload !== false\n let donor =\n preloadable &&\n routeLoader &&\n !(process.env.NODE_ENV !== 'production' && router._tx?.[6 /* refresh */])\n ? router._flights?.get(match.id)\n : undefined\n if (donor === match._flight || reloadFailure) {\n donor = undefined\n } else if (donor && !reload && !preload && configured === undefined) {\n // Normal cache policy accepts an already-running generation even when this\n // lane itself would not have started another loader.\n reload = true\n } else if (!reload) {\n donor = undefined\n }\n const background = !!(\n routeLoader &&\n reload &&\n match.status === 'success' &&\n !preload &&\n !options[4 /* sync */] &&\n ((isLoaderFn ? undefined : routeLoader.staleReloadMode) ??\n router.options.defaultStaleReloadMode) !== 'blocking'\n )\n const loaded = reload && preloadable\n const blocking =\n loaded && !background && (match.status !== 'success' || !!routeLoader)\n const onReady = index >= retainedEnd ? options[7 /* onReady */] : undefined\n const onLazyReady = route.lazyFn && route._lazy !== true ? onReady : undefined\n if (loaded && !routeLoader) {\n match.invalid = false\n match.updatedAt = Date.now()\n }\n if (donor) {\n donor[2 /* leases */]++\n }\n if (blocking) {\n const acceptedFlight = match._flight\n match._flight = donor\n releaseOwnedFlight(router, match, acceptedFlight)?.abort()\n // A mounted success remains renderable while its loader revalidates. Every\n // non-retained blocking generation presents pending state.\n if (index >= retainedEnd) {\n match.status = 'pending'\n }\n onReady?.()\n }\n if (!loaded) {\n match.isFetching = false\n }\n const loaderOutcome = reloadFailure\n ? Promise.resolve(reloadFailure)\n : !blocking\n ? Promise.resolve<LoaderOutcome>([SUCCESS, match.loaderData])\n : loadResource(\n router,\n lane,\n match,\n route,\n loader,\n semanticParent,\n options,\n )\n const outcome = loaderOutcome.then((result) => {\n if (blocking) {\n settleInto(match, result, preload)\n if (result[0 /* kind */] === SUCCESS) {\n // A settled generation can outlive its lane without keeping unresolved\n // navigation work alive.\n if (routeLoader && !options[0 /* controller */].signal.aborted) {\n cacheLoaderMatch(router, match, plannedCacheMatch)\n }\n // A route is renderable only after both its data and normal component\n // chunk are ready. Its loader data is already available to descendants.\n if (index >= retainedEnd) {\n match.status = 'pending'\n }\n }\n }\n return result\n })\n\n const chunkOutcome = waitFor(\n Promise.resolve().then(() => loadRouteChunk(route, undefined, onLazyReady)),\n options[0 /* controller */].signal,\n ).then(\n () => undefined,\n (cause): IndexedOutcome | undefined =>\n lane[1 /* matches */].some(\n (candidate, candidateIndex) =>\n candidateIndex <= index &&\n (candidate.status === 'error' ||\n candidate.status === 'notFound' ||\n candidate._notFound),\n )\n ? undefined\n : [index, normalizeLaneError(router, lane, route, cause, options)],\n )\n const chunkFailure = chunkOutcome.then((failure) =>\n outcome.then((result) => {\n if (\n blocking &&\n !failure &&\n result[0 /* kind */] === SUCCESS &&\n match.status === 'pending' &&\n !options[0 /* controller */].signal.aborted\n ) {\n match.status = 'success'\n onReady?.()\n }\n return failure\n }),\n )\n tasks.push([index, outcome, chunkFailure])\n if (!background) {\n return outcome.then((result) => getParentSnapshot(match, result))\n }\n const candidate: WorkMatch = {\n ...match,\n status: 'pending',\n preload: false,\n _flight: donor,\n }\n match.invalid = false\n match.isFetching = 'loader'\n const backgroundOutcome = loadResource(\n router,\n lane,\n candidate,\n route,\n loader,\n semanticParent,\n options,\n ).then((result) => {\n match.isFetching = false\n settleInto(candidate, result, false)\n return result\n })\n ;(lane[2 /* background */] ??= []).push([\n index,\n backgroundOutcome,\n chunkFailure,\n candidate,\n ])\n return backgroundOutcome.then((result) =>\n getParentSnapshot(candidate, result),\n )\n}\n\nasync function getNotFoundBoundary(\n router: AnyRouter,\n matches: Array<WorkMatch>,\n indexed: IndexedOutcome | undefined,\n signal: AbortSignal,\n fallback = 0,\n): Promise<number> {\n const cause = indexed?.[1 /* outcome */][1 /* error or redirect */] as\n | NotFoundError\n | undefined\n let index = cause?.routeId\n ? matches.findIndex((match) => match.routeId === cause.routeId)\n : (indexed?.[0 /* index */] ?? matches.length - 1)\n if (index < 0) {\n index = 0\n }\n for (let i = index; i >= 0; i--) {\n const route = getRoute(router, matches[i]!)\n try {\n const loading = loadRouteChunk(route, false)\n if (loading) {\n await waitFor(loading, signal)\n }\n } catch (cause) {\n if (cause === signal && signal.aborted) {\n throw cause\n }\n }\n if (route.options.notFoundComponent) {\n return i\n }\n }\n return cause?.routeId ? index : fallback\n}\n\nfunction discardBackground(router: AnyRouter, lane: Lane<any>): void {\n if (lane[2 /* background */]) {\n transferMatchResources(\n router,\n lane[2 /* background */].map((task) => task[3 /* candidate */]),\n )\n lane[2 /* background */] = undefined\n }\n}\n\nasync function settleTasks(\n tasks: Array<LoaderTask>,\n serialFailure?: IndexedOutcome,\n redirectTasks?: Array<BackgroundLoaderTask>,\n gate?: number | Promise<number>,\n): Promise<IndexedOutcome | undefined> {\n let loaderFailure: IndexedOutcome | undefined\n\n try {\n await Promise.all(\n tasks.map((task) =>\n task[1 /* outcome */].then(async (outcome) => {\n const taskIndex = task[0 /* index */]\n if (gate && taskIndex >= (await gate)) {\n return\n }\n if (outcome[0 /* kind */] >= REDIRECTED) {\n throw [taskIndex, outcome] as IndexedOutcome\n }\n if (!loaderFailure && outcome[0 /* kind */] !== SUCCESS) {\n loaderFailure = [taskIndex, outcome]\n // Every started descendant must settle before an ordinary failure\n // wins because a redirect from any of them remains control flow.\n await Promise.all(\n (redirectTasks ?? []).map((nextTask) => {\n if (nextTask[0 /* index */] <= taskIndex) {\n return\n }\n return nextTask[1 /* outcome */].then((nextOutcome) => {\n if (nextOutcome[0 /* kind */] === REDIRECTED) {\n throw [\n nextTask[0 /* index */],\n nextOutcome,\n ] as IndexedOutcome\n }\n })\n }),\n )\n }\n }),\n ),\n )\n } catch (cause) {\n return cause as IndexedOutcome\n }\n return serialFailure ?? loaderFailure\n}\n\nfunction materializeRedirect(\n router: AnyRouter,\n lane: Lane<any>,\n route: AnyRoute,\n outcome: RawLoaderOutcome,\n options: ExecuteLaneOptions,\n failed?: true,\n): LoaderOutcome {\n while (outcome[0 /* kind */] === REDIRECTED) {\n const redirect = outcome[1 /* redirect */]\n const redirectOptions = redirect.options\n if (\n redirectOptions.reloadDocument\n ? options[3 /* preload */]\n : options[1 /* redirects */] >= 20\n ) {\n return outcome\n }\n try {\n if (redirectOptions.href && redirectOptions.reloadDocument) {\n router.resolveRedirect(redirect)\n return outcome\n }\n return [\n REDIRECTED,\n redirect,\n router.buildLocation({\n ...redirectOptions,\n _fromLocation: lane[0 /* location */],\n _includeValidateSearch: true,\n }),\n ]\n } catch (cause) {\n outcome = failed ? [ERROR, cause] : normalizeError(route, cause)\n failed = true\n }\n }\n return outcome\n}\n\nasync function reduceLane(\n router: AnyRouter,\n lane: ContextualizedLane,\n tasks: Array<LoaderTask>,\n controller: AbortController,\n settlement: Promise<IndexedOutcome | undefined>,\n onReady?: () => void,\n): Promise<ReducedLane | ControlOutcome> {\n const matches = lane[1 /* matches */]\n let failure = await settlement\n let redirectLimitExceeded = false\n const plannedBoundary = matches.findIndex((match) => match._notFound)\n const boundaryOf = (found: IndexedOutcome) =>\n found[1 /* outcome */][0 /* kind */] === NOT_FOUND\n ? getNotFoundBoundary(router, matches, found, controller.signal)\n : found[0 /* index */]\n let readinessEnd = plannedBoundary < 0 ? matches.length : plannedBoundary\n\n if ((failure?.[1 /* outcome */][0 /* kind */] ?? 0) >= REDIRECTED) {\n readinessEnd = 0\n } else if (failure) {\n readinessEnd = failure[2 /* boundary */] ??= await boundaryOf(failure)\n for (const task of tasks) {\n if (task[0 /* index */] >= readinessEnd) {\n break\n }\n const outcome = await task[1 /* outcome */]\n // Presence means a loader previously succeeded, even with `undefined`.\n if (\n outcome[0 /* kind */] !== SUCCESS &&\n outcome[0 /* kind */] < REDIRECTED &&\n !('loaderData' in matches[task[0 /* index */]]!)\n ) {\n failure = [task[0 /* index */], outcome]\n readinessEnd = failure[2 /* boundary */] = await boundaryOf(failure)\n break\n }\n }\n }\n\n for (const task of tasks) {\n if (task[0 /* index */] >= readinessEnd) {\n break\n }\n const chunkFailure = await task[2 /* chunkFailure */]\n if (!chunkFailure) {\n continue\n }\n failure = chunkFailure\n break\n }\n\n if ((failure?.[1 /* outcome */][0 /* kind */] ?? 0) >= REDIRECTED) {\n const outcome = failure![1 /* outcome */]\n if (\n outcome[0 /* kind */] !== REDIRECTED ||\n outcome[1 /* redirect */].options.reloadDocument ||\n outcome[2 /* location */]\n ) {\n discardBackground(router, lane)\n return outcome as ControlOutcome\n }\n redirectLimitExceeded = true\n failure = [0, [ERROR, new Error('Too many redirects')]]\n }\n\n const boundary = failure\n ? (failure[2 /* boundary */] ?? (await boundaryOf(failure)))\n : plannedBoundary\n if (boundary >= 0) {\n const outcome = failure?.[1 /* outcome */]\n const kind = outcome?.[0 /* kind */]\n const match = matches[boundary]!\n const cause = outcome?.[1 /* error or redirect */]\n const install = () => {\n if (outcome) {\n match._notFound = undefined\n if (kind === ERROR) {\n match.status = 'error'\n } else {\n ;(cause as NotFoundError).routeId = match.routeId\n if (match.routeId === router.routeTree.id) {\n match.status = 'success'\n match._notFound = true\n } else {\n match.status = 'notFound'\n }\n }\n match.error = cause\n match.isFetching = false\n }\n }\n install()\n if (!outcome) {\n onReady?.()\n }\n const route = getRoute(router, match)\n try {\n await waitFor<unknown>(\n outcome\n ? Promise.resolve().then(() =>\n loadRouteChunk(\n route,\n kind === ERROR ? 'errorComponent' : 'notFoundComponent',\n ),\n )\n : Promise.all([\n loadRouteChunk(route),\n loadRouteChunk(route, 'notFoundComponent'),\n ]),\n controller.signal,\n )\n } catch (cause) {\n if (cause === controller.signal && controller.signal.aborted) {\n discardBackground(router, lane)\n return CANCELED_OUTCOME\n }\n }\n if (!outcome) {\n match.status = 'success'\n } else if (redirectLimitExceeded) {\n controller.abort()\n await Promise.all([\n ...tasks.map((task) => task[1 /* outcome */]),\n ...tasks.map((task) => task[2 /* chunkFailure */]),\n ...(lane[2 /* background */] ?? []).map(\n (task) => task[1 /* outcome */],\n ),\n ])\n discardBackground(router, lane)\n transferMatchResources(router, matches)\n install()\n }\n }\n\n return lane as ReducedLane\n}\n\nexport async function projectLane(\n router: AnyRouter,\n lane: ReducedLane,\n signal: AbortSignal,\n start = 0,\n end = lane[1 /* matches */].length,\n): Promise<ProjectedLane> {\n const matches = lane[1 /* matches */]\n for (let index = start; index < end; index++) {\n const match = matches[index]!\n const routeOptions = getRoute(router, match).options\n if (routeOptions.head || routeOptions.scripts) {\n try {\n const context = {\n ssr: router.options.ssr,\n matches,\n match,\n params: match.params,\n loaderData: match.loaderData,\n }\n const [head, scripts] = await waitFor(\n Promise.all([\n routeOptions.head?.(context),\n routeOptions.scripts?.(context),\n ]),\n signal,\n )\n match.meta = head?.meta\n match.links = head?.links\n match.headScripts = head?.scripts\n match.styles = head?.styles\n match.scripts = scripts\n } catch (cause) {\n if (cause === signal && signal.aborted) {\n break\n }\n console.error(cause)\n }\n }\n if (match.status !== 'success' || match._notFound) {\n break\n }\n }\n return lane as ProjectedLane\n}\n\nasync function executeClientLane(\n router: AnyRouter,\n location: ParsedLocation,\n matches: Array<AnyRouteMatch>,\n options: ExecuteLaneOptions,\n): Promise<LaneResult> {\n const matched = [location, matches as Array<WorkMatch>] as MatchedLane\n const signal = options[0 /* controller */].signal\n let reduced: ReducedLane | ControlOutcome\n try {\n const presented = router.stores.matches.get()\n let plannedBoundary = matches.findIndex((match) => match._notFound)\n if (router.options.notFoundMode !== 'root' && plannedBoundary >= 0) {\n const boundary = await getNotFoundBoundary(\n router,\n matches as Array<WorkMatch>,\n undefined,\n signal,\n plannedBoundary,\n )\n matches[plannedBoundary]!._notFound = undefined\n matches[boundary]!._notFound = true\n plannedBoundary = boundary\n }\n let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1\n let retainedEnd = 0\n while (retainedEnd < end && retainedEnd !== plannedBoundary) {\n const match = matches[retainedEnd]!\n const committed = options[2 /* base */][retainedEnd]\n const visible = presented[retainedEnd]\n if (\n committed?.id !== match.id ||\n committed.status !== 'success' ||\n committed._notFound ||\n match.preload ||\n visible?.id !== match.id ||\n visible.status !== 'success' ||\n visible._notFound\n ) {\n break\n }\n retainedEnd++\n }\n const tasks: Array<LoaderTask> = []\n const start = options[6 /* resolvedPrefix */] ?? 0\n let semanticParent = start\n ? Promise.resolve(matches[start - 1] as WorkMatch)\n : undefined\n const planSuccessfulLane = () => {\n for (let index = start; index < end; index++) {\n if (signal.aborted) {\n break\n }\n semanticParent = createLoaderTask(\n router,\n matched as ContextualizedLane,\n index,\n tasks,\n semanticParent,\n options,\n retainedEnd,\n )\n }\n }\n // From here on `matched` is contextualized: `contextualize` communicates\n // through mutation plus a failure return, so the phase brand is asserted at\n // the two use sites below rather than granted by a (byte-costing) return.\n const failure = await contextualize(\n router,\n matched,\n options,\n end,\n planSuccessfulLane,\n retainedEnd,\n )\n if (failure) {\n options[4 /* sync */] = true\n end = failure[0 /* index */]\n if (failure[1 /* outcome */][0 /* kind */] === NOT_FOUND) {\n const boundary = await getNotFoundBoundary(\n router,\n matches as Array<WorkMatch>,\n failure,\n signal,\n )\n failure[2 /* boundary */] = boundary\n end = Math.min(end, boundary + 1)\n } else if (failure[1 /* outcome */][0 /* kind */] >= REDIRECTED) {\n end = 0\n }\n planSuccessfulLane()\n }\n if (!signal.aborted && !options[3 /* preload */]) {\n const abort: Array<AbortController> = []\n for (const [id, flight] of router._flights ?? []) {\n if (!flight[2 /* leases */]) {\n router._flights!.delete(id)\n abort.push(flight[1 /* controller */])\n }\n }\n for (const controller of abort) {\n controller.abort()\n }\n }\n const reduction = reduceLane(\n router,\n matched as ContextualizedLane,\n tasks,\n options[0 /* controller */],\n settleTasks(tasks, failure, matched[2 /* background */]),\n options[7 /* onReady */],\n )\n if (matched[2 /* background */]?.length) {\n matched[3 /* backgroundSettlement */] = settleTasks(\n matched[2 /* background */],\n undefined,\n undefined,\n reduction.then(\n (foreground) =>\n isControl(foreground) ? 0 : _getRenderedMatches(matches).length,\n () => 0,\n ),\n )\n }\n reduced = await reduction\n } catch (cause) {\n discardBackground(router, matched)\n if (cause === signal && signal.aborted) {\n return CANCELED_OUTCOME\n }\n throw cause\n }\n if (isControl(reduced)) {\n return reduced\n }\n return projectLane(\n router,\n reduced,\n signal,\n options[6 /* resolvedPrefix */] === matches.length\n ? options[6 /* resolvedPrefix */]\n : 0,\n )\n}\n\n/**\n * Waits for `pendingMs`, then presents the complete lane. Rendering applies the\n * selected boundary cutoff while retaining every match's structural state.\n * A replacement load for the same match keeps the timer; choosing a different\n * match resets it. `pendingMinMs` starts after the fallback renders.\n */\nfunction offerPending(router: CoordinatorRouter, tx: LoadTransaction): void {\n if (router._tx !== tx) {\n return\n }\n const matches = tx[3 /* matches */]\n const presented = router.stores.matches.get()\n let session = router._pending\n for (let index = 0; index < matches.length; index++) {\n const match = matches[index]!\n const success = match.status === 'success' && !match._notFound\n const presentedPending =\n presented[index]?.id === match.id &&\n presented[index]?.status === 'pending'\n if (success && !presentedPending) {\n continue\n }\n const route = getRoute(router, match as WorkMatch)\n const delay =\n success || match.invalid\n ? 0\n : (route.options.pendingMs ?? router.options.defaultPendingMs)\n const component =\n route.options.pendingComponent ??\n (router.options as any).defaultPendingComponent\n if (!component || typeof delay !== 'number' || delay === Infinity) {\n if (session) {\n session[0 /* generation */] = tx\n session[2 /* deadline */] = 0\n session[4 /* ack */] = true\n }\n return\n }\n const min =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs ?? 0\n let tookOver = false\n if (session?.[1 /* boundaryId */] === match.id) {\n tookOver = session[0 /* generation */] !== tx\n session[0 /* generation */] = tx\n } else {\n clearTimeout(session?.[3 /* revealTimer */])\n router._pending = session = undefined\n }\n if (!session) {\n // Hydration and redirects can preserve pending presentation without a session.\n // Do not delay it again; conservatively start pendingMinMs from now.\n router._pending = session = [\n tx,\n match.id,\n presentedPending ? Date.now() + min : tx[4 /* startedAt */] + delay,\n undefined,\n presentedPending || undefined,\n component,\n ]\n }\n if (\n session[4 /* ack */] &&\n !tookOver &&\n session[5 /* component */] === component\n ) {\n return\n }\n session[5 /* component */] = component\n if (!session[4 /* ack */]) {\n clearTimeout(session[3 /* revealTimer */])\n const remaining = session[2 /* deadline */] - Date.now()\n if (remaining > 0) {\n session[3 /* revealTimer */] = setTimeout(\n () => offerPending(router, tx),\n remaining,\n )\n return\n }\n session[2 /* deadline */] = 0\n }\n const offered = matches.map((match) => ({\n ...match,\n _flight: undefined,\n }))\n offered[index]!.status = 'pending'\n const ack = (session[4 /* ack */] = router\n .startTransition(() => router.stores.setMatches(offered), offered)\n .then((rendered) => {\n if (\n rendered &&\n router._pending === session &&\n session![4 /* ack */] === ack &&\n !session![2 /* deadline */]\n ) {\n session![2 /* deadline */] = Date.now() + min\n }\n return rendered\n }))\n return\n }\n}\n\n/**\n * Cancels pending UI timing unless the current successor can take over the\n * same boundary that remains painted.\n */\nfunction finishPending(router: CoordinatorRouter, tx: LoadTransaction): void {\n const session = router._pending\n if (\n router._tx === tx ||\n !router._tx?.[3 /* matches */].some(\n (match) => match.id === session?.[1 /* boundaryId */],\n )\n ) {\n clearTimeout(session?.[3 /* revealTimer */])\n router._pending = undefined\n }\n}\n\nasync function awaitPendingMinimum(\n router: CoordinatorRouter,\n tx: LoadTransaction,\n): Promise<void> {\n const session = router._pending\n if (!session) {\n return\n }\n clearTimeout(session[3 /* revealTimer */])\n const remaining = session[2 /* deadline */] - Date.now()\n if (\n !session[4 /* ack */] ||\n remaining <= 0 ||\n !_getRenderedMatches(tx[3 /* matches */]).some(\n (match) => match.id === session[1 /* boundaryId */],\n )\n ) {\n return\n }\n let timer: ReturnType<typeof setTimeout> | undefined\n try {\n await waitFor(\n new Promise<void>((resolve) => {\n timer = setTimeout(resolve, remaining)\n }),\n tx[0 /* controller */].signal,\n )\n } catch {}\n clearTimeout(timer)\n}\n\nfunction publishMatches(\n router: CoordinatorRouter,\n matches: Array<AnyRouteMatch>,\n): void {\n router._committed = matches\n router.stores.setMatches(matches)\n}\n\nfunction commitMatches(\n router: CoordinatorRouter,\n tx: LoadTransaction,\n matches: LaneMatches<'projected'>,\n resolvedPrefix?: number,\n): void {\n const previous = router._committed\n const previousCached = router._cache\n for (const match of matches) {\n match.preload = false\n if (resolvedPrefix) {\n match._assetEnd = undefined\n }\n }\n const cut = _getRenderedMatches(matches).length\n const cached = new Map<string, AnyRouteMatch>()\n if (process.env.NODE_ENV === 'production' || !tx[6 /* refresh */]) {\n const now = Date.now()\n for (const match of [...previous, ...previousCached.values()]) {\n // Rendered-prefix ids and settled successes anywhere in the lane are\n // authoritative: retaining an older same-id generation would shadow them\n // at the next planning pass. Unsettled beyond-boundary matches are not —\n // they must not evict a newer same-id preload.\n if (\n match.status !== 'success' ||\n matches.some(\n (candidate, index) =>\n candidate.id === match.id &&\n (index < cut || candidate.status === 'success'),\n )\n ) {\n continue\n }\n const work = match as WorkMatch\n const route = getRoute(router, work)\n if (\n !route.options.loader ||\n now - match.updatedAt >=\n (match.preload\n ? (route.options.preloadGcTime ??\n router.options.defaultPreloadGcTime ??\n 300_000)\n : (route.options.gcTime ?? router.options.defaultGcTime ?? 300_000))\n ) {\n continue\n }\n cached.set(\n match.id,\n previousCached.get(match.id) === match\n ? match\n : ({\n ...match,\n _flight: undefined,\n isFetching: false,\n context: {},\n } as WorkMatch),\n )\n }\n }\n // The lane becomes committed before publication can synchronously reenter.\n tx[3 /* matches */] = []\n router._cache = cached\n publishMatches(router, matches)\n transferMatchResources(\n router,\n [...previousCached.values(), ...previous],\n [...matches, ...cached.values()],\n )\n if (process.env.NODE_ENV !== 'production') {\n const handoff = tx[6 /* refresh */]?.[0 /* handoff */]\n if (handoff && router._handoff === handoff) {\n handoff[1 /* finish */]()\n }\n }\n runRouteLifecycle(router, previous, matches, tx)\n}\n\nasync function awaitCurrent(\n router: CoordinatorRouter,\n owner?: LoadTransaction,\n): Promise<void> {\n let current = router._tx\n while (current && current !== owner) {\n await current[5 /* done */]\n if (router._tx === current) {\n return\n }\n current = router._tx\n }\n}\n\nfunction followRedirect(\n router: CoordinatorRouter,\n tx: LoadTransaction,\n outcome: RedirectOutcome,\n): Promise<void> {\n const options = outcome[1 /* redirect */].options\n const location = outcome[2 /* location */]\n if (!location) {\n return router.navigate({\n ...options,\n replace: true,\n ignoreBlocker: true,\n } as any)\n }\n if (options.reloadDocument) {\n return router.navigate({\n href: location.publicHref,\n reloadDocument: true,\n replace: true,\n ignoreBlocker: true,\n } as any)\n }\n ;(location as ParsedLocation & { _redirects?: number })._redirects =\n tx[1 /* redirects */] + 1\n router._pendingLocation = location\n const committed = router.commitLocation({\n ...location,\n viewTransition: options.viewTransition,\n replace: true,\n resetScroll: options.resetScroll,\n hashScrollIntoView: options.hashScrollIntoView,\n ignoreBlocker: true,\n })\n queueMicrotask(() => {\n if (router._pendingLocation === location) {\n router._pendingLocation = undefined\n }\n })\n return committed\n}\n\nasync function runBackground(\n router: CoordinatorRouter,\n tx: LoadTransaction,\n base: Array<AnyRouteMatch>,\n tasks: Array<BackgroundLoaderTask>,\n settlement: Promise<IndexedOutcome | undefined>,\n): Promise<void> {\n const next = base.map((match) => ({ ...match }))\n acquireMatchResources(next)\n for (const task of tasks) {\n releaseFlight(router, next[task[0 /* index */]]!)\n next[task[0 /* index */]] = task[3 /* candidate */]\n }\n // Phase jump: the clones inherit beforeLoad context from the committed\n // foreground lane, which already ran `contextualize` for these matches.\n const lane = [tx[2 /* location */], next] as ContextualizedLane\n let reduced: ReducedLane | ControlOutcome\n try {\n reduced = await reduceLane(\n router,\n lane,\n tasks,\n tx[0 /* controller */],\n settlement,\n )\n } catch (cause) {\n transferMatchResources(router, next)\n throw cause\n }\n if (isControl(reduced)) {\n transferMatchResources(router, next)\n if (\n reduced[0 /* kind */] === REDIRECTED &&\n router._tx === tx &&\n router._committed === base\n ) {\n await followRedirect(router, tx, reduced)\n }\n return\n }\n await projectLane(router, reduced, tx[0 /* controller */].signal)\n if (router._tx !== tx || router._committed !== base) {\n transferMatchResources(router, next)\n return\n }\n for (const match of next as Array<WorkMatch>) {\n const cached = router._cache.get(match.id) as WorkMatch | undefined\n if (cached?._flight && cached._flight === match._flight) {\n router._cache.delete(match.id)\n releaseFlight(router, cached)\n }\n }\n publishMatches(router, next)\n transferMatchResources(router, base, next)\n}\n\nasync function runClientTransaction(\n router: CoordinatorRouter,\n tx: LoadTransaction,\n forceStaleReload: boolean,\n onReady?: () => void,\n sync?: boolean,\n resolvedPrefix?: number,\n): Promise<void> {\n const result = await executeClientLane(\n router,\n tx[2 /* location */],\n tx[3 /* matches */],\n [\n tx[0 /* controller */],\n tx[1 /* redirects */],\n router._committed,\n undefined,\n sync,\n forceStaleReload,\n resolvedPrefix,\n onReady,\n ],\n )\n\n if (isControl(result)) {\n const follow = result[0 /* kind */] === REDIRECTED && router._tx === tx\n if (!follow || result[1 /* redirect */].options.reloadDocument) {\n finishPending(router, tx)\n }\n transferMatchResources(router, tx[3 /* matches */])\n tx[3 /* matches */] = []\n if (!follow) {\n return\n }\n if (router._tx !== tx) {\n finishPending(router, tx)\n return\n }\n if (process.env.NODE_ENV !== 'production' && tx[6 /* refresh */]) {\n router._refreshNextLoad = true\n }\n await followRedirect(router, tx, result)\n return\n }\n const matches = result[1 /* matches */]\n if (router._tx === tx) {\n // Only an acknowledged fallback owns a minimum. Recheck at the commit\n // boundary because native view transitions can defer their update callback.\n await awaitPendingMinimum(router, tx)\n }\n if (router._tx !== tx) {\n finishPending(router, tx)\n transferMatchResources(router, matches)\n discardBackground(router, result)\n return\n }\n const toLocation = tx[2 /* location */]\n const changeInfo = getLocationChangeInfo(\n toLocation,\n router.stores.resolvedLocation.get(),\n )\n const background = result[2 /* background */]\n await router.startViewTransition(async () => {\n if (router._tx === tx) {\n await awaitPendingMinimum(router, tx)\n }\n if (router._tx !== tx) {\n finishPending(router, tx)\n transferMatchResources(router, matches)\n discardBackground(router, result)\n return\n }\n const commit = () => {\n finishPending(router, tx)\n commitMatches(router, tx, matches, resolvedPrefix)\n if (router._tx !== tx) {\n return\n }\n router.emit({ type: 'onLoad', ...changeInfo })\n if (router._tx === tx) {\n router.emit({ type: 'onBeforeRouteMount', ...changeInfo })\n }\n }\n const rendered = await router.startTransition(commit, matches)\n if (process.env.NODE_ENV !== 'production' && tx[6 /* refresh */]) {\n tx[6 /* refresh */] = undefined\n }\n if (router._tx !== tx) {\n discardBackground(router, result)\n return\n }\n if (background?.length) {\n // Publish background matches only after the foreground acknowledgement.\n // Otherwise fast work can replace the acknowledged generation\n // before the framework commits it and strand the navigation.\n runBackground(\n router,\n tx,\n matches,\n background,\n result[3 /* backgroundSettlement */]!,\n ).catch(console.error)\n }\n router.batch(() => {\n router.stores.resolvedLocation.set(toLocation)\n router.stores.status.set('idle')\n if (router._tx === tx) {\n router.emit({ type: 'onResolved', ...changeInfo })\n }\n if (rendered && router._tx === tx) {\n router.emit({ type: 'onRendered', ...changeInfo })\n }\n })\n if (router._tx !== tx) {\n return\n }\n router._commitPromise?.resolve()\n router._commitPromise = undefined\n })\n}\n\nexport async function loadClientRoute(\n router: CoordinatorRouter,\n opts?: { sync?: boolean },\n): Promise<void> {\n let rematerialize = false\n if (process.env.NODE_ENV !== 'production') {\n rematerialize = !!router._refreshNextLoad || !!router._tx?.[6 /* refresh */]\n }\n const previousOwner = router._tx\n const resolvedLocation = router.stores.resolvedLocation.get()\n const previousLocation = resolvedLocation ?? router.stores.location.get()\n const location = router.latestLocation\n const pendingLocation = router._pendingLocation as\n | (ParsedLocation & { _redirects?: number })\n | undefined\n const redirects =\n pendingLocation?.href === location.href\n ? (pendingLocation._redirects ?? 0)\n : 0\n const handoff = router._handoff\n const hydrationController = rematerialize\n ? undefined\n : handoff?.[0 /* claim */]()\n const preflight = new AbortController()\n const previousPreflight = router._preflight\n router._preflight = preflight\n if (!rematerialize && !hydrationController) {\n handoff?.[1 /* finish */]()\n }\n previousPreflight?.abort()\n // The preflight controller is not exposed to route hooks. Every replacement\n // aborts its predecessor, so a live signal is the sole authority here.\n if (!preflight.signal.aborted) {\n const changeInfo = getLocationChangeInfo(location, resolvedLocation)\n router.emit({ type: 'onBeforeNavigate', ...changeInfo })\n if (!preflight.signal.aborted) {\n router.emit({ type: 'onBeforeLoad', ...changeInfo })\n }\n }\n if (preflight.signal.aborted) {\n await awaitCurrent(router, previousOwner)\n return\n }\n const sameHref = previousLocation.href === location.href\n let controller = preflight\n const matches =\n process.env.NODE_ENV !== 'production' && rematerialize\n ? router.matchRoutes(location, {\n _controller: preflight,\n _rematerialize: true,\n })\n : router.matchRoutes(location, { _controller: preflight })\n acquireMatchResources(matches)\n const resolvedPrefix = hydrationController\n ? handoff\n : undefined\n if (resolvedPrefix) {\n controller = hydrationController!\n } else {\n hydrationController?.abort()\n }\n if (preflight.signal.aborted) {\n transferMatchResources(router, matches)\n await awaitCurrent(router, previousOwner)\n return\n }\n router._preflight = undefined\n\n let settle: ((value: void | PromiseLike<void>) => void) | undefined\n const run = () =>\n runClientTransaction(\n router,\n tx,\n sameHref,\n () => offerPending(router, tx),\n opts?.sync,\n resolvedPrefix,\n )\n const done = opts?.sync\n ? new Promise<void>((resolve) => (settle = resolve))\n : Promise.resolve().then(run).then()\n const tx: LoadTransaction = [\n controller,\n redirects,\n location,\n matches,\n Date.now(),\n done,\n ]\n if (process.env.NODE_ENV !== 'production' && rematerialize) {\n tx[6 /* refresh */] = [handoff]\n router._refreshNextLoad = undefined\n }\n router._tx = tx\n if (previousOwner) {\n for (const match of router.stores.matches.get() as Array<WorkMatch>) {\n if (router._tx !== tx) {\n break\n }\n if (match.isFetching) {\n setFetching(router, match, false)\n }\n }\n previousOwner[0 /* controller */].abort()\n transferMatchResources(\n router,\n previousOwner[3 /* matches */],\n tx[3 /* matches */],\n true,\n )\n }\n if (router._tx !== tx) {\n transferMatchResources(router, tx[3 /* matches */])\n tx[3 /* matches */] = []\n settle?.()\n await awaitCurrent(router, tx)\n return\n }\n router.batch(() => {\n router.stores.status.set('pending')\n router.stores.location.set(location)\n })\n // An unresolved cold root has no UI to retain. Provisional not-found waits\n // for lazy routes to place the final boundary.\n if (\n resolvedPrefix ||\n (!router._committed.length &&\n matches[0]?.status !== 'success' &&\n !matches.some((match) => match._notFound))\n ) {\n offerPending(router, tx)\n }\n // Let explicit synchronous loads publish ready pending work before paint.\n settle?.(run())\n await done\n await awaitCurrent(router, tx)\n}\n\nexport async function refreshClientRoute(\n router: CoordinatorRouter,\n): Promise<void> {\n const pending = router._tx\n if (\n pending &&\n !pending[6 /* refresh */] &&\n router.stores.status.get() === 'pending'\n ) {\n await pending[5 /* done */]\n if (router._tx !== pending) {\n await awaitCurrent(router, pending)\n }\n }\n // Existing owners remain presented but cannot donate stale work.\n router._flights?.clear()\n router.clearCache()\n router._refreshNextLoad = true\n await loadClientRoute(router, { sync: true })\n}\n\nexport async function preloadClientRoute<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n TDehydrated extends Record<string, any> = Record<string, any>,\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n router: RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n opts: NavigateOptions<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n >,\n): Promise<Array<AnyRouteMatch> | undefined> {\n if (\n process.env.NODE_ENV !== 'production' &&\n ((router as CoordinatorRouter)._refreshNextLoad ||\n router._tx?.[6 /* refresh */])\n ) {\n return\n }\n let location = router.buildLocation(\n opts as Parameters<typeof router.buildLocation>[0],\n )\n for (let redirects = 0; ; redirects++) {\n const base = router._committed\n const controller = new AbortController()\n let matches: Array<AnyRouteMatch> | undefined\n let active: boolean | Map<AbortController, Array<AnyRouteMatch>> | undefined\n let result: LaneResult\n try {\n try {\n matches = router.matchRoutes(location, {\n _controller: controller,\n })\n acquireMatchResources(matches)\n active = (router._preloads ??= new Map()).set(controller, matches)\n result = await executeClientLane(router, location, matches, [\n controller,\n redirects,\n base,\n true,\n ])\n } finally {\n if (active) {\n active = (\n active as Map<AbortController, Array<AnyRouteMatch>>\n ).delete(controller)\n transferMatchResources(router, matches!)\n }\n controller.abort()\n }\n if (!isControl(result)) {\n return result[1 /* matches */]\n }\n // Only a materialized redirect has a third tuple item.\n if (\n !active ||\n result.length < 3 ||\n (process.env.NODE_ENV !== 'production' &&\n ((router as CoordinatorRouter)._refreshNextLoad ||\n router._tx?.[6 /* refresh */]))\n ) {\n return\n }\n location = result[2 /* location */]!\n } catch (cause) {\n if (!isNotFound(cause)) {\n console.error(cause)\n }\n return\n }\n }\n}\n\n// --- SSR hydration (client entry via @tanstack/router-core/ssr/client) ---\n\ndeclare global {\n interface Window {\n [GLOBAL_TSR]?: TsrSsrGlobal\n [GLOBAL_SEROVAL]?: any\n }\n}\n\nexport async function hydrate(router: AnyRouter): Promise<void> {\n if (process.env.NODE_ENV !== 'production' && !window.$_TSR) {\n throw new Error(\n 'Invariant failed: Expected to find bootstrap data on window.$_TSR, but we did not. Please file an issue!',\n )\n }\n const tsr = window.$_TSR!\n\n const adapters = router.options.serializationAdapters as\n | Array<AnySerializationAdapter>\n | undefined\n if (adapters?.length) {\n tsr.t = new Map(\n adapters.map((adapter) => [adapter.key, adapter.fromSerializable]),\n )\n tsr.buffer.forEach((script) => script())\n }\n tsr.initialized = true\n\n const dehydratedRouter = tsr.router\n if (process.env.NODE_ENV !== 'production' && !dehydratedRouter) {\n throw new Error(\n 'Invariant failed: Expected to find a dehydrated data on window.$_TSR.router, but we did not. Please file an issue!',\n )\n }\n router.ssr = { manifest: dehydratedRouter!.manifest }\n router.options.ssr = {\n nonce: (\n document.querySelector('meta[property=\"csp-nonce\"]') as\n | HTMLMetaElement\n | undefined\n )?.content,\n }\n\n const dehydratedMatches = dehydratedRouter!.matches\n\n const controller = new AbortController()\n const previousPreflight = router._preflight\n router._preflight = controller\n previousPreflight?.abort()\n // Only a new slot owner supersedes hydration.\n const isCurrent = () => router._preflight === controller\n\n let location!: AnyRouter['latestLocation']\n let candidates!: Array<AnyRouteMatch>\n let handoffHistoryHref!: string\n let handoffHistoryState: unknown\n try {\n await waitFor(\n router.options.hydrate?.(dehydratedRouter!.dehydratedData),\n controller.signal,\n )\n if (!isCurrent()) {\n return\n }\n // Hydration trusts transported context and beforeLoad. The raw history\n // entry owns the handoff; route structure is verified after rematching.\n const historyLocation = router.history.location\n handoffHistoryHref = historyLocation.href\n handoffHistoryState = historyLocation.state\n router.updateLatestLocation()\n location = router.latestLocation\n router.stores.location.set(location)\n candidates = router.matchRoutes(location, {\n _controller: controller,\n })\n } catch (cause) {\n if (isCurrent()) {\n router._preflight = undefined\n }\n controller.abort(cause)\n if (cause !== controller.signal) {\n throw cause\n }\n }\n if (!isCurrent()) {\n return\n }\n const committed: Array<AnyRouteMatch> = []\n let pendingBoundary: number | undefined\n let verifiedAssetEnd = 0\n const retryFrom = (index: number) => {\n // The failing route's identity is still verified, but no descendant is.\n verifiedAssetEnd = Math.min(verifiedAssetEnd, index + 1)\n const removed = committed.splice(index)\n for (const match of removed) {\n if (\n getRoute(router, match).options.loader &&\n (match.status === 'success' ||\n (!match.invalid && 'loaderData' in match))\n ) {\n cacheLoaderMatch(\n router,\n // Phase jump: dehydrated server data is already past the loader\n // phase — the guard above verified a settled success (or transported\n // loaderData), so this clone is settled without a client settleInto.\n {\n ...match,\n status: 'success',\n error: undefined,\n preload: true,\n } as SettledMatch,\n router._cache.get(match.id),\n )\n }\n }\n transferMatchResources(router, removed)\n }\n\n // A longer server lane is valid only when the local match already caps the\n // branch at a global not-found boundary. Otherwise no transported work is\n // safe to attach to the shorter client lane.\n const shared =\n dehydratedMatches.length > candidates.length\n ? candidates.findIndex((match) => match._notFound) + 1\n : dehydratedMatches.length\n let isTerminal = false\n for (let index = 0; index < shared; index++) {\n const candidate = candidates[index]!\n const dehydrated = dehydratedMatches[index]!\n if (\n typeof dehydrated.i !== 'string' ||\n hydrateSsrMatchId(dehydrated.i) !== candidate.id\n ) {\n pendingBoundary ??= index\n break\n }\n verifiedAssetEnd = index + 1\n const route = getRoute(router, candidate)\n if (\n 'l' in dehydrated ||\n (dehydrated.s === 'success' &&\n dehydrated.e === undefined &&\n route.options.loader)\n ) {\n candidate.loaderData = dehydrated.l\n }\n candidate.status = dehydrated.s\n candidate.ssr = dehydrated.ssr\n route.options.ssr = candidate.ssr\n candidate.updatedAt = dehydrated.u\n candidate.error = dehydrated.e\n candidate._notFound ||= dehydrated.g\n const terminal =\n candidate.status === 'error' ||\n candidate.status === 'notFound' ||\n candidate._notFound\n if (terminal) {\n isTerminal = true\n committed.push(candidate)\n if (candidate.ssr === false || candidate.ssr === 'data-only') {\n pendingBoundary ??= index\n }\n break\n }\n if (candidate.status === 'pending') {\n pendingBoundary ??= index\n break\n }\n\n committed.push(candidate)\n if (candidate.ssr === 'data-only') {\n pendingBoundary ??= index\n }\n }\n if (\n !isTerminal &&\n committed.length === shared &&\n shared < candidates.length\n ) {\n pendingBoundary = shared\n }\n\n // Hooks observe structural membership. Execution remains limited to\n // `committed`, the accepted server prefix.\n const chunks = committed.map(async (match) => {\n try {\n const route = getRoute(router, match)\n await (match._notFound\n ? Promise.all([\n loadRouteChunk(route),\n loadRouteChunk(route, 'notFoundComponent'),\n ])\n : loadRouteChunk(\n route,\n match.status === 'error'\n ? 'errorComponent'\n : match.status === 'notFound'\n ? 'notFoundComponent'\n : undefined,\n ))\n return true\n } catch {\n return false\n }\n })\n let chunkFailure = 0\n try {\n while (\n chunkFailure < chunks.length &&\n (await waitFor(chunks[chunkFailure]!, controller.signal))\n ) {\n chunkFailure++\n }\n } catch {\n return\n }\n if (!isCurrent()) {\n return\n }\n if (chunkFailure < committed.length) {\n retryFrom(chunkFailure)\n }\n\n // The first pending match is already visible, so prepare its route context\n // without granting its beforeLoad or loader any hydration authority.\n const contextEnd = Math.max(\n pendingBoundary === committed.length\n ? committed.length + 1\n : committed.length,\n // `chunks.length` keeps the pre-retry committed length, so a smaller\n // `chunkFailure` is the exclusive bound of the verified context prefix.\n chunkFailure < chunks.length ? chunkFailure : verifiedAssetEnd,\n )\n for (let index = 0; index < contextEnd; index++) {\n const match = candidates[index]!\n const route = getRoute(router, match)\n const parentContext =\n candidates[index - 1]?.context ?? router.options.context ?? {}\n let routeContext\n if (route.options.context) {\n try {\n routeContext = match._ctx =\n route.options.context({\n deps: match.loaderDeps,\n params: match.params,\n context: parentContext,\n location,\n navigate: (opts: any) =>\n router.navigate({\n ...opts,\n _fromLocation: location,\n }),\n buildLocation: router.buildLocation,\n cause: match.cause,\n abortController: controller,\n preload: false,\n matches: candidates,\n routeId: route.id,\n }) || {}\n } catch {\n if (!isCurrent()) {\n return\n }\n if (\n match.status !== 'error' &&\n match.status !== 'notFound' &&\n !match._notFound\n ) {\n // Never present transported success without reconstructed context.\n pendingBoundary = Math.min(pendingBoundary ?? index, index)\n retryFrom(index)\n break\n }\n }\n if (!isCurrent()) {\n return\n }\n }\n match.context = {\n ...parentContext,\n ...routeContext,\n ...(committed[index] && dehydratedMatches[index]!.b),\n }\n }\n\n await projectLane(\n router,\n [location, candidates] as any,\n controller.signal,\n 0,\n verifiedAssetEnd,\n )\n if (!isCurrent()) {\n return\n }\n const needsClientLoad =\n pendingBoundary !== undefined || committed.length < shared\n const committedMatches =\n isTerminal && committed.length === shared ? candidates : committed\n let presented = needsClientLoad ? candidates : committedMatches\n let dataOnlyAssetEnd: number | undefined\n if (needsClientLoad && pendingBoundary !== undefined) {\n const boundary = presented[pendingBoundary]!\n // A verified descendant proves this data-only boundary was nonterminal.\n dataOnlyAssetEnd =\n boundary.ssr === 'data-only' && verifiedAssetEnd > pendingBoundary + 1\n ? verifiedAssetEnd\n : undefined\n presented = presented.slice()\n presented[pendingBoundary] = {\n ...boundary,\n status: 'pending',\n ssr: boundary.ssr === 'data-only' ? 'data-only' : false,\n _assetEnd: dataOnlyAssetEnd,\n }\n }\n\n const claim = () => {\n const historyLocation = router.history.location\n return needsClientLoad &&\n !router._tx &&\n historyLocation.href === handoffHistoryHref &&\n historyLocation.state === handoffHistoryState &&\n router._committed === committedMatches &&\n committedMatches.length &&\n !controller.signal.aborted\n ? controller\n : undefined\n }\n const handoff: NonNullable<AnyRouter['_handoff']> = [\n claim,\n (matches) => {\n if (router._handoff !== handoff) {\n return\n }\n // `finish` is single-use. Consume the slot before validating or moving\n // resources so reentrant work cannot claim the same handoff.\n router._handoff = undefined\n const prefix = committedMatches.length\n if (\n !matches ||\n !claim() ||\n committedMatches.some((match, index) => match.id !== matches[index]?.id)\n ) {\n controller.abort()\n return\n }\n let handoffAssetEnd = dataOnlyAssetEnd\n if (handoffAssetEnd !== undefined) {\n for (let index = prefix; index < handoffAssetEnd; index++) {\n if (candidates[index]?.id !== matches[index]?.id) {\n handoffAssetEnd = index > pendingBoundary! + 1 ? index : undefined\n break\n }\n }\n }\n const clones = committedMatches.map((match) => ({ ...match }))\n if (handoffAssetEnd !== undefined) {\n clones[pendingBoundary!]!._assetEnd = handoffAssetEnd\n }\n transferMatchResources(router, matches.splice(0, prefix, ...clones))\n for (let index = prefix; index < matches.length; index++) {\n const match = matches[index]!\n const hydrated = candidates[index]\n if (hydrated?.id === match.id && hydrated._ctx) {\n match._ctx = hydrated._ctx\n }\n match.abortController = controller\n }\n return prefix\n },\n ]\n router._committed = committedMatches\n router._handoff = handoff\n router._preflight = undefined\n router.batch(() => {\n router.stores.setMatches(presented)\n router.stores.status.set('idle')\n if (!needsClientLoad) {\n router.stores.resolvedLocation.set(router.stores.location.get())\n }\n })\n}\n"],"mappings":";;;;;AA8BA,SAAgB,kBACd,OACA,QACM;CACN,MAAM,SAAS,UAAU,MAAM;CAC/B,MAAM,QAAQ,KAAA;AAChB;AAEA,SAAS,iBACP,OACA,MAC2B;CAC3B,OAAQ,MAAM,QAAQ,OAAe,UAAU;AACjD;AAEA,SAAS,eACP,OACA,gBAC2B;CAC3B,MAAM,YAAY,iBAAiB,OAAO,WAAW;CACrD,IAAI,UAAU,iBAAiB,OAAO,kBAAkB;CACxD,IAAI,gBACF,IAAI,SACF,UAAU,QAAQ,KAAK,cAAc;MAErC,eAAe;CAGnB,IAAI,aAAa,SACf,OAAO,QAAQ,IAAI,CAAC,WAAW,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;CAExD,OAAO,aAAa;AACtB;AAEA,SAAgB,eACd,OAEA,eACA,gBAC2B;CAC3B,MAAM,kBACJ,kBAAkB,QACd,KAAA,IACA,gBACE,iBAAiB,OAAO,aAAa,IACrC,eAAe,OAAO,cAAc;CAC5C,MAAM,UAAU,MAAM;CACtB,IAAI,SACF,OAAO,YAAY,OAAO,UAAU,IAAI,QAAQ,KAAK,SAAS;CAEhE,IAAI,CAAC,MAAM,QACT,OAAO,UAAU;CAGnB,MAAM,UAAU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