{"version":3,"sources":["../../../../../src/server/app-render/instant-validation/instant-validation.tsx"],"sourcesContent":["import type {\n  CacheNodeSeedData,\n  FlightRouterState,\n  HeadData,\n  InitialRSCPayload,\n  Segment,\n} from '../../../shared/lib/app-router-types'\nimport type { VaryParamsThenable } from '../../../shared/lib/segment-cache/vary-params-decoding'\nimport { InvariantError } from '../../../shared/lib/invariant-error'\nimport { RenderStage } from '../staged-rendering'\nimport { getServerModuleMap } from '../manifests-singleton'\nimport { runInSequentialTasks } from '../app-render-render-utils'\nimport { workAsyncStorage } from '../work-async-storage.external'\nimport {\n  Phase,\n  printDebugThrownValueForProspectiveRender,\n} from '../prospective-render-utils'\nimport { getDigestForWellKnownError } from '../create-error-handler'\nimport {\n  // NOTE: we're in the server layer, so this is a client reference\n  PlaceValidationBoundaryBelowThisLevel,\n} from '../../../client/components/instant-validation/boundary'\nimport type { ValidationBoundaryTracking } from './boundary-tracking'\nimport {\n  getLayoutOrPageModule,\n  type LoaderTree,\n} from '../../lib/app-dir-module'\nimport { parseLoaderTree } from '../../../shared/lib/router/utils/parse-loader-tree'\nimport type { GetDynamicParamFromSegment } from '../app-render'\nimport type {\n  AppSegmentConfig,\n  Instant,\n} from '../../../build/segment-config/app/app-segment-config'\nimport { Readable } from 'node:stream'\nimport {\n  createNodeStreamWithLateRelease,\n  createNodeStreamFromChunks,\n} from './stream-utils'\nimport { createDebugChannel } from '../debug-channel-server'\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { createFromNodeStream } from 'react-server-dom-webpack/client'\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { renderToReadableStream } from 'react-server-dom-webpack/server'\nimport {\n  addSearchParamsIfPageSegment,\n  isGroupSegment,\n  PAGE_SEGMENT_KEY,\n  DEFAULT_SEGMENT_KEY,\n  NOT_FOUND_SEGMENT_KEY,\n} from '../../../shared/lib/segment'\nimport type { NextParsedUrlQuery } from '../../request-meta'\n\nconst filterStackFrame =\n  process.env.NODE_ENV !== 'production'\n    ? (\n        require('../../lib/source-maps') as typeof import('../../lib/source-maps')\n      ).filterStackFrameDEV\n    : undefined\nconst findSourceMapURL =\n  process.env.NODE_ENV !== 'production'\n    ? (\n        require('../../lib/source-maps') as typeof import('../../lib/source-maps')\n      ).findSourceMapURLDEV\n    : undefined\n\n// FIXME: this causes typescript errors related to 'flight-client-entry-plugin.d.ts'\n// type ClientReferenceManifest = ReturnType<\n//   (typeof import('../manifests-singleton'))['getClientReferenceManifest']\n// >\ntype ClientReferenceManifest = Record<string, any>\n\nconst debug =\n  process.env.NEXT_PRIVATE_DEBUG_VALIDATION === '1' ? console.log : undefined\n\n//===============================================================\n// 1. Validation planning\n//===============================================================\n\n/** Used to identify a segment. Conceptually similar to request keys in the Client Segment Cache. */\nexport type SegmentPath = string & { _tag: 'SegmentPath' }\n\n/**\n * Isomorphic to a FlightRouterState, but with extra data attached.\n * Carries the segment path for each segment so we can easily get it from the cache.\n *  */\nexport type RouteTree = {\n  path: SegmentPath\n  segment: Segment\n  module: null | {\n    type: 'layout' | 'page'\n    // TODO(instant-validation): We should know if a layout segment is shared\n    instantConfig: Instant | null\n    conventionPath: string\n    createInstantStack: (() => Error) | null\n  }\n\n  slots: { [parallelRouteKey: string]: RouteTree } | null\n}\n\nfunction traverseRootSeedDataSegments(\n  initialRSCPayload: InitialRSCPayload,\n  processSegment: (\n    segmentPath: SegmentPath,\n    seedData: CacheNodeSeedData\n  ) => void\n) {\n  const { flightRouterState, seedData } =\n    getRootDataFromPayload(initialRSCPayload)\n\n  const [rootSegment] = flightRouterState\n  const rootPath = stringifySegment(rootSegment)\n  return traverseCacheNodeSegments(\n    rootPath,\n    flightRouterState,\n    seedData,\n    processSegment\n  )\n}\n\nfunction traverseCacheNodeSegments(\n  path: SegmentPath,\n  route: FlightRouterState,\n  seedData: CacheNodeSeedData,\n  processSegment: (\n    segmentPath: SegmentPath,\n    seedData: CacheNodeSeedData\n  ) => void\n): void {\n  processSegment(path, seedData)\n\n  const [_segment, childRoutes] = route\n  const [_node, parallelRoutesData, _loading, _isPartial] = seedData\n\n  for (const parallelRouteKey in childRoutes) {\n    const childSeedData = parallelRoutesData[parallelRouteKey]\n    if (!childSeedData) {\n      throw new InvariantError(\n        `Got unexpected empty seed data during instant validation`\n      )\n    }\n\n    const childRoute = childRoutes[parallelRouteKey]\n    // NOTE: if this is a __PAGE__ segment, it might have search params appended.\n    // Whoever reads from the cache needs to append them as well.\n    const [childSegment] = childRoute\n    const childPath = createChildSegmentPath(\n      path,\n      parallelRouteKey,\n      childSegment\n    )\n\n    traverseCacheNodeSegments(\n      childPath,\n      childRoute,\n      childSeedData,\n      processSegment\n    )\n  }\n}\n\nfunction createChildSegmentPath(\n  parentPath: SegmentPath,\n  parallelRouteKey: string,\n  segment: Segment\n): SegmentPath {\n  const parallelRoutePrefix =\n    parallelRouteKey === 'children'\n      ? ''\n      : `@${encodeURIComponent(parallelRouteKey)}/`\n  return `${parentPath}/${parallelRoutePrefix}${stringifySegment(segment)}` as SegmentPath\n}\n\nfunction stringifySegment(segment: Segment): SegmentPath {\n  return (\n    typeof segment === 'string'\n      ? encodeURIComponent(segment)\n      : encodeURIComponent(segment[0]) + '|' + segment[1] + '|' + segment[2]\n  ) as SegmentPath\n}\n\n//===============================================================\n// 2. Separating a stream into segments\n//===============================================================\n\nexport type SegmentStage =\n  | RenderStage.Static\n  | RenderStage.Runtime\n  | RenderStage.Dynamic\n\nexport type StageChunks = Record<SegmentStage, Uint8Array[]>\n\nexport type StageEndTimes = {\n  [RenderStage.Static]: number\n  [RenderStage.Runtime]: number\n}\n\n/**\n * Splits an existing staged stream (represented as arrays of chunks)\n * into separate staged streams (also in arrays-of-chunks form), one for each segment.\n * */\nexport async function collectStagedSegmentData(\n  fullPageChunks: StageChunks,\n  fullPageDebugChunks: Uint8Array[] | null,\n  startTime: number,\n  hasRuntimePrefetch: boolean,\n  clientReferenceManifest: ClientReferenceManifest\n) {\n  const debugChannelAbortController = new AbortController()\n  const debugStream = fullPageDebugChunks\n    ? createNodeStreamFromChunks(\n        fullPageDebugChunks,\n        debugChannelAbortController.signal\n      )\n    : null\n\n  const { stream, controller } = createStagedStreamFromChunks(fullPageChunks)\n  stream.on('end', () => {\n    // When the stream finishes, we have to close the debug stream too,\n    // but delay it to avoid \"Connection closed.\" errors.\n    setImmediate(() => debugChannelAbortController.abort())\n  })\n\n  // Technically we're just re-encoding, so nothing new should be emitted,\n  // but we add an environment name just in case.\n  const environmentName = () => {\n    const currentStage = controller.currentStage\n    switch (currentStage) {\n      case RenderStage.Static:\n        return 'Prerender'\n      case RenderStage.Runtime:\n        return hasRuntimePrefetch ? 'Prefetch' : 'Prefetchable'\n      case RenderStage.Dynamic:\n        return 'Server'\n      default:\n        currentStage satisfies never\n        throw new InvariantError(`Invalid render stage: ${currentStage}`)\n    }\n  }\n\n  // Deserialize the payload.\n  // NOTE: the stream will initially be in the static stage, so that's as far as we get here.\n  // We still expect the outer structure of the payload to be readable in this state.\n  const serverConsumerManifest = {\n    moduleLoading: null,\n    moduleMap: clientReferenceManifest.rscModuleMapping,\n    serverModuleMap: getServerModuleMap(),\n  }\n\n  const payload = await createFromNodeStream<InitialRSCPayload>(\n    stream,\n    serverConsumerManifest,\n    {\n      findSourceMapURL,\n      debugChannel: debugStream ?? undefined,\n      // Do not pass start/end timings - we do not want to omit any debug info.\n      startTime: undefined,\n      endTime: undefined,\n    }\n  )\n\n  // Deconstruct the payload into separate streams per segment.\n  // We have to preserve the stage information for each of them,\n  // so that we can later render each segment in any stage we need.\n\n  const { head } = getRootDataFromPayload(payload)\n\n  const segments = new Map<SegmentPath, SegmentData>()\n  traverseRootSeedDataSegments(payload, (segmentPath, seedData) => {\n    segments.set(segmentPath, createSegmentData(seedData))\n  })\n\n  const cache = createSegmentCache()\n  const pendingTasks: Promise<void>[] = []\n\n  /** Track when we advance stages so we can pass them as `endTime` later. */\n  const stageEndTimes: StageEndTimes = {\n    [RenderStage.Static]: -1,\n    [RenderStage.Runtime]: -1,\n  }\n\n  const renderIntoCacheItem = async (\n    data: HeadData | SegmentData,\n    cacheEntry: SegmentCacheItem\n  ): Promise<void> => {\n    const segmentDebugChannel = cacheEntry.debugChunks\n      ? createDebugChannel()\n      : undefined\n\n    const itemStream = renderToReadableStream(\n      data,\n      clientReferenceManifest.clientModules,\n      {\n        filterStackFrame,\n        debugChannel: segmentDebugChannel?.serverSide,\n        environmentName,\n        startTime,\n        onError(error: unknown) {\n          const digest = getDigestForWellKnownError(error)\n          if (digest) {\n            return digest\n          }\n\n          // Forward existing digests\n          if (\n            error &&\n            typeof error === 'object' &&\n            'digest' in error &&\n            typeof error.digest === 'string'\n          ) {\n            return error.digest\n          }\n\n          // We don't need to log the errors because we would have already done that\n          // when generating the original Flight stream for the whole page.\n          if (\n            process.env.NEXT_DEBUG_BUILD ||\n            process.env.__NEXT_VERBOSE_LOGGING\n          ) {\n            const workStore = workAsyncStorage.getStore()\n            printDebugThrownValueForProspectiveRender(\n              error,\n              workStore?.route ?? 'unknown route',\n              Phase.InstantValidation\n            )\n          }\n        },\n      }\n    )\n\n    await Promise.all([\n      // accumulate Flight chunks\n      (async () => {\n        for await (const chunk of itemStream.values()) {\n          writeChunk(cacheEntry.chunks, controller.currentStage, chunk)\n        }\n      })(),\n      // accumulate Debug chunks\n      segmentDebugChannel &&\n        (async () => {\n          for await (const chunk of segmentDebugChannel.clientSide.readable.values()) {\n            cacheEntry.debugChunks!.push(chunk)\n          }\n        })(),\n    ])\n  }\n\n  await runInSequentialTasks(\n    () => {\n      {\n        const headCacheItem = createSegmentCacheItem(!!fullPageDebugChunks)\n        cache.head = headCacheItem\n        pendingTasks.push(renderIntoCacheItem(head, headCacheItem))\n      }\n\n      for (const [segmentPath, segmentData] of segments) {\n        const segmentCacheItem = createSegmentCacheItem(!!fullPageDebugChunks)\n        cache.segments.set(segmentPath, segmentCacheItem)\n        pendingTasks.push(renderIntoCacheItem(segmentData, segmentCacheItem))\n      }\n    },\n    () => {\n      stageEndTimes[RenderStage.Static] =\n        performance.now() + performance.timeOrigin\n\n      controller.advanceStage(RenderStage.Runtime)\n    },\n    () => {\n      stageEndTimes[RenderStage.Runtime] =\n        performance.now() + performance.timeOrigin\n\n      controller.advanceStage(RenderStage.Dynamic)\n    }\n  )\n  await Promise.all(pendingTasks)\n\n  return { cache, payload, stageEndTimes }\n}\n\n/**\n * Turns accumulated stage chunks into a stream.\n * The stream starts out in Static stage, and can be advanced further\n * using the returned controller object.\n * Conceptually, this is similar to how we unblock more content\n * by advancing stages in a regular staged render.\n * */\nfunction createStagedStreamFromChunks(stageChunks: StageChunks) {\n  // The successive stages are supersets of one another,\n  // so we can index into the dynamic chunks everywhere\n  // and just look at the lengths of the Static/Runtime arrays\n  const allChunks = stageChunks[RenderStage.Dynamic]\n\n  const numStaticChunks = stageChunks[RenderStage.Static].length\n  const numRuntimeChunks = stageChunks[RenderStage.Runtime].length\n  const numDynamicChunks = stageChunks[RenderStage.Dynamic].length\n\n  let chunkIx = 0\n  let currentStage:\n    | RenderStage.Static\n    | RenderStage.Runtime\n    | RenderStage.Dynamic = RenderStage.Static\n  let closed = false\n\n  function push(chunk: Uint8Array) {\n    stream.push(chunk)\n  }\n\n  function close() {\n    closed = true\n    stream.push(null)\n  }\n\n  const stream = new Readable({\n    read() {\n      // Emit static chunks\n      for (; chunkIx < numStaticChunks; chunkIx++) {\n        push(allChunks[chunkIx])\n      }\n\n      // If there's no more chunks after this stage, finish the stream.\n      if (chunkIx >= allChunks.length) {\n        close()\n        return\n      }\n    },\n  })\n\n  function advanceStage(\n    stage: RenderStage.Runtime | RenderStage.Dynamic\n  ): boolean {\n    if (closed) return true\n\n    switch (stage) {\n      case RenderStage.Runtime: {\n        currentStage = RenderStage.Runtime\n        for (; chunkIx < numRuntimeChunks; chunkIx++) {\n          push(allChunks[chunkIx])\n        }\n        break\n      }\n\n      case RenderStage.Dynamic: {\n        currentStage = RenderStage.Dynamic\n        for (; chunkIx < numDynamicChunks; chunkIx++) {\n          push(allChunks[chunkIx])\n        }\n        break\n      }\n\n      default: {\n        stage satisfies never\n      }\n    }\n\n    // If there's no more chunks after this stage, finish the stream.\n    if (chunkIx >= allChunks.length) {\n      close()\n      return true\n    } else {\n      return false\n    }\n  }\n\n  return {\n    stream,\n    controller: {\n      get currentStage() {\n        return currentStage\n      },\n      advanceStage,\n    },\n  }\n}\n\nfunction writeChunk(\n  stageChunks: StageChunks,\n  stage: SegmentStage,\n  chunk: Uint8Array\n) {\n  switch (stage) {\n    case RenderStage.Static: {\n      stageChunks[RenderStage.Static].push(chunk)\n      // fallthrough\n    }\n    case RenderStage.Runtime: {\n      stageChunks[RenderStage.Runtime].push(chunk)\n      // fallthrough\n    }\n    case RenderStage.Dynamic: {\n      stageChunks[RenderStage.Dynamic].push(chunk)\n      break\n    }\n    default: {\n      stage satisfies never\n    }\n  }\n}\n\n//===============================================================\n// 3. Recombining segments into a new payload\n//===============================================================\n\n/**\n * Creates a late-release stream for a given payload.\n * When `renderSignal` is triggered, the stream will release late chunks\n * to provide extra debug info.\n * */\nexport async function createCombinedPayloadStream(\n  payload: InitialRSCPayload,\n  extraChunksAbortController: AbortController,\n  renderSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  startTime: number,\n  isDebugChannelEnabled: boolean\n) {\n  // Collect all the chunks so that we're not dependent on timing of the render.\n\n  let isRenderable = true\n  const renderableChunks: Uint8Array[] = []\n  const allChunks: Uint8Array[] = []\n\n  const debugChunks: Uint8Array[] | null = isDebugChannelEnabled ? [] : null\n  const debugChannel = isDebugChannelEnabled ? createDebugChannel() : null\n\n  let streamFinished: Promise<any>\n\n  await runInSequentialTasks(\n    () => {\n      const stream = renderToReadableStream(\n        payload,\n        clientReferenceManifest.clientModules,\n        {\n          filterStackFrame,\n          debugChannel: debugChannel?.serverSide,\n          startTime,\n          onError(error: unknown) {\n            const digest = getDigestForWellKnownError(error)\n            if (digest) {\n              return digest\n            }\n\n            // Forward existing digests\n            if (\n              error &&\n              typeof error === 'object' &&\n              'digest' in error &&\n              typeof error.digest === 'string'\n            ) {\n              return error.digest\n            }\n\n            // We don't need to log the errors because we would have already done that\n            // when generating the original Flight stream for the whole page.\n            if (\n              process.env.NEXT_DEBUG_BUILD ||\n              process.env.__NEXT_VERBOSE_LOGGING\n            ) {\n              const workStore = workAsyncStorage.getStore()\n              printDebugThrownValueForProspectiveRender(\n                error,\n                workStore?.route ?? 'unknown route',\n                Phase.InstantValidation\n              )\n            }\n          },\n        }\n      )\n\n      streamFinished = Promise.all([\n        // Accumulate Flight chunks\n        (async () => {\n          for await (const chunk of stream.values()) {\n            allChunks.push(chunk)\n            if (isRenderable) {\n              renderableChunks.push(chunk)\n            }\n          }\n        })(),\n        // Accumulate debug chunks\n        debugChannel &&\n          (async () => {\n            for await (const chunk of debugChannel.clientSide.readable.values()) {\n              debugChunks!.push(chunk)\n            }\n          })(),\n      ])\n    },\n    () => {\n      isRenderable = false\n      extraChunksAbortController.abort()\n    }\n  )\n\n  await streamFinished!\n\n  return {\n    stream: createNodeStreamWithLateRelease(\n      renderableChunks,\n      allChunks,\n      renderSignal\n    ),\n    debugStream: debugChunks\n      ? createNodeStreamFromChunks(debugChunks, renderSignal)\n      : null,\n  }\n}\n\nfunction getRootDataFromPayload(initialRSCPayload: InitialRSCPayload) {\n  // FlightDataPath is an unsound type, hence the additional checks.\n  const flightDataPaths = initialRSCPayload.f\n  if (flightDataPaths.length !== 1 && flightDataPaths[0].length !== 3) {\n    throw new InvariantError(\n      'InitialRSCPayload does not match the expected shape during instant validation.'\n    )\n  }\n  const flightRouterState: FlightRouterState = flightDataPaths[0][0]\n  const seedData: CacheNodeSeedData = flightDataPaths[0][1]\n  // TODO: handle head\n  const head: HeadData = flightDataPaths[0][2]\n\n  return { flightRouterState, seedData, head }\n}\n\nasync function createValidationHead(\n  cache: SegmentCache,\n  releaseSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  stageEndTimes: StageEndTimes,\n  stage: RenderStage.Static | RenderStage.Runtime\n): Promise<HeadData> {\n  const segmentCacheItem = cache.head\n  if (!segmentCacheItem) {\n    throw new InvariantError(`Missing segment data: <head>`)\n  }\n  return await deserializeFromChunks<HeadData>(\n    segmentCacheItem.chunks[stage],\n    segmentCacheItem.chunks[RenderStage.Dynamic],\n    segmentCacheItem.debugChunks,\n    releaseSignal,\n    clientReferenceManifest,\n    { startTime: undefined, endTime: stageEndTimes[stage] }\n  )\n}\n\ntype Timings = {\n  startTime?: number\n  endTime?: number\n}\n\n/**\n * Deserializes a (partial possibly partial) RSC stream, given as a chunk-array.\n * If the stream is partial, we'll wait for `releaseSignal` to fire\n * and then complete the deserialization using `allChunks`.\n *\n * This is used to obtain a partially-complete model (that might contain unresolved holes)\n * and then release any late debug info from chunks that came later before we abort the render.\n * */\nfunction deserializeFromChunks<T>(\n  partialChunks: Uint8Array[],\n  allChunks: Uint8Array[],\n  debugChunks: Uint8Array[] | null,\n  releaseSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  timings: Timings | null\n): Promise<T> {\n  const debugChannelAbortController = new AbortController()\n  const debugStream = debugChunks\n    ? createNodeStreamFromChunks(\n        debugChunks,\n        debugChannelAbortController.signal\n      )\n    : null\n\n  const serverConsumerManifest = {\n    moduleLoading: null,\n    moduleMap: clientReferenceManifest.rscModuleMapping,\n    serverModuleMap: getServerModuleMap(),\n  }\n\n  const segmentStream =\n    partialChunks.length < allChunks.length\n      ? createNodeStreamWithLateRelease(partialChunks, allChunks, releaseSignal)\n      : createNodeStreamFromChunks(partialChunks)\n\n  segmentStream.on('end', () => {\n    // When the stream finishes, we have to close the debug stream too,\n    // but delay it to avoid \"Connection closed.\" errors.\n    setImmediate(() => debugChannelAbortController.abort())\n  })\n\n  return createFromNodeStream(segmentStream, serverConsumerManifest, {\n    findSourceMapURL,\n    debugChannel: debugStream ?? undefined,\n    startTime: timings?.startTime,\n    endTime: timings?.endTime,\n  }) as Promise<T>\n}\n\n//===============================================================\n// Validation segment cache\n//===============================================================\n\n/** An object version of `CacheNodeSeedData`, without slots. */\ntype SegmentData = {\n  node: React.ReactNode | null\n  isPartial: boolean\n  varyParams: VaryParamsThenable | null\n}\n\nfunction createSegmentData(seedData: CacheNodeSeedData): SegmentData {\n  const [node, _parallelRoutesData, _unused, isPartial, varyParams] = seedData\n  return {\n    node,\n    isPartial,\n    varyParams,\n  }\n}\ntype CacheNodeSeedDataSlots = CacheNodeSeedData[1]\n\nfunction getCacheNodeSeedDataFromSegment(\n  data: SegmentData,\n  slots: CacheNodeSeedDataSlots\n): CacheNodeSeedData {\n  return [\n    data.node,\n    slots,\n    /* unused (previously `loading`) */ null,\n    data.isPartial,\n    data.varyParams,\n  ]\n}\n\nfunction createSegmentCache(): SegmentCache {\n  return { head: null, segments: new Map() }\n}\n\nfunction createSegmentCacheItem(withDebugChunks: boolean): SegmentCacheItem {\n  return {\n    chunks: {\n      [RenderStage.Static]: [],\n      [RenderStage.Runtime]: [],\n      [RenderStage.Dynamic]: [],\n    },\n    debugChunks: withDebugChunks ? [] : null,\n  }\n}\n\nexport type SegmentCache = {\n  head: SegmentCacheItem | null\n  segments: Map<SegmentPath, SegmentCacheItem>\n}\n\ntype SegmentCacheItem = {\n  chunks: StageChunks\n  debugChunks: Uint8Array[] | null\n}\n\ntype TreeResult = {\n  seedData: CacheNodeSeedData\n  requiresInstantUI: boolean\n  createInstantStack: (() => Error) | null\n}\n\n/**\n * Whether this segment consumes a URL depth level. Each URL depth\n * represents a potential navigation boundary.\n *\n * The root segment ('') consumes depth 0. Regular segments like\n * 'dashboard' consume the next depth — whether or not they have a\n * layout. Route groups, __PAGE__, __DEFAULT__, and /_not-found don't\n * consume a depth — they share the boundary of their parent.\n */\nfunction segmentConsumesURLDepth(segment: Segment): boolean {\n  // Dynamic segments (tuples) always consume a URL depth.\n  if (typeof segment !== 'string') return true\n  // Route groups, pages, defaults, and not-found don't consume a depth.\n  if (\n    segment.startsWith(PAGE_SEGMENT_KEY) ||\n    isGroupSegment(segment) ||\n    segment === DEFAULT_SEGMENT_KEY ||\n    segment === NOT_FOUND_SEGMENT_KEY\n  ) {\n    return false\n  }\n  // Everything else consumes a depth, including the root segment ''.\n  return true\n}\n\n/**\n * Walks the LoaderTree to discover validation depth bounds.\n *\n * Each route group between URL segments represents a potential\n * shared/new boundary in a client navigation. When a user navigates\n * between sibling routes that share a route group layout, that\n * layout is already mounted — its Suspense boundaries are revealed\n * and don't cover new content below. By tracking the max group\n * depth at each URL depth, we can iterate all possible group\n * boundaries and validate that blocking code is always covered by\n * Suspense in the new tree. This is conservative: some boundaries\n * may not correspond to real navigations (e.g. a route group with\n * no siblings), but it ensures we don't miss real violations.\n *\n * The max is taken across all parallel slots. When slots have\n * different numbers of groups, the deepest slot determines the\n * iteration range. Shallower slots simply stay entirely shared\n * at group depths beyond their own group count — they run out\n * of groups before reaching the boundary, so their content\n * remains in the Dynamic stage.\n *\n * Returns an array where:\n * - length = max URL depth (number of URL-consuming segments)\n * - array[i] = max group depth at URL depth i (number of route group\n *   segments between this URL depth and the next)\n *\n * For example, a tree like:\n *   '' / (outer) / (inner) / dashboard / page\n * returns [2, 0] — URL depth 0 (root) has 2 group layers before\n * the next URL segment (dashboard), and URL depth 1 (dashboard) has\n * 0 group layers before the leaf.\n */\nexport function discoverValidationDepths(loaderTree: LoaderTree): number[] {\n  const groupDepthsByUrlDepth: number[] = []\n\n  function recordGroupDepth(urlDepth: number, groupDepth: number): void {\n    while (groupDepthsByUrlDepth.length <= urlDepth) {\n      groupDepthsByUrlDepth.push(0)\n    }\n    if (groupDepth > groupDepthsByUrlDepth[urlDepth]) {\n      groupDepthsByUrlDepth[urlDepth] = groupDepth\n    }\n  }\n\n  // urlDepth tracks the index of the current URL-consuming segment.\n  // Groups accumulate at the same index. When the next URL segment\n  // is reached, it increments the index and resets the group counter.\n  // We start at -1 so the root segment '' increments to 0.\n  function walk(tree: LoaderTree, urlDepth: number, groupDepth: number): void {\n    const segment = tree[0]\n    const { parallelRoutes } = parseLoaderTree(tree)\n    const consumesDepth = segmentConsumesURLDepth(segment)\n\n    let nextUrlDepth = urlDepth\n    let nextGroupDepth = groupDepth\n    if (consumesDepth) {\n      nextUrlDepth = urlDepth + 1\n      nextGroupDepth = 0\n      recordGroupDepth(nextUrlDepth, 0)\n    } else if (\n      typeof segment === 'string' &&\n      isGroupSegment(segment) &&\n      segment !== '(__SLOT__)'\n    ) {\n      // Count real route groups but not the synthetic '(__SLOT__)' segment\n      // that Next.js inserts for parallel slots. The synthetic group\n      // can't be a real navigation boundary.\n      nextGroupDepth++\n      recordGroupDepth(urlDepth, nextGroupDepth)\n    }\n\n    for (const key in parallelRoutes) {\n      walk(parallelRoutes[key], nextUrlDepth, nextGroupDepth)\n    }\n  }\n\n  walk(loaderTree, -1, 0)\n  return groupDepthsByUrlDepth\n}\n\n/**\n * Builds a combined RSC payload for validation at a given URL depth.\n *\n * Walks the LoaderTree directly, loading modules and counting\n * URL-contributing layouts. When `depth` URL segments have been\n * consumed, the boundary flips from shared (dynamic stage) to new\n * (static/runtime stage). As the new subtree is built, we check for\n * instant configs. If none are found, returns null — no validation\n * needed at this depth or deeper.\n *\n * This combines module loading, tree walking, config discovery, and\n * payload construction into a single pass.\n */\nexport type ValidationPayloadResult = {\n  payload: InitialRSCPayload\n  /** Whether errors from this payload could be ambiguous between runtime\n   * API access (cookies, headers) and uncached IO (connection, fetch).\n   * True when some segments used Static stage. False when all segments\n   * used Runtime stage and errors are definitively from uncached IO. */\n  hasAmbiguousErrors: boolean\n  createInstantStack: (() => Error) | null\n}\n\nexport async function createCombinedPayloadAtDepth(\n  initialRSCPayload: InitialRSCPayload,\n  cache: SegmentCache,\n  initialLoaderTree: LoaderTree,\n  getDynamicParamFromSegment: GetDynamicParamFromSegment,\n  query: NextParsedUrlQuery | null,\n  depth: number,\n  groupDepth: number,\n  releaseSignal: AbortSignal,\n  boundaryState: ValidationBoundaryTracking,\n  clientReferenceManifest: ClientReferenceManifest,\n  stageEndTimes: StageEndTimes,\n  useRuntimeStageForPartialSegments: boolean\n): Promise<ValidationPayloadResult | null> {\n  let hasStaticSegments = false\n  let hasRuntimeSegments = false\n\n  function getSegment(loaderTree: LoaderTree): Segment {\n    const dynamicParam = getDynamicParamFromSegment(loaderTree)\n    if (dynamicParam) {\n      return dynamicParam.treeSegment\n    }\n    const segment = loaderTree[0]\n    return query ? addSearchParamsIfPageSegment(segment, query) : segment\n  }\n\n  async function buildSharedTreeSeedData(\n    loaderTree: LoaderTree,\n    parentPath: SegmentPath | null,\n    key: string | null,\n    urlDepthConsumed: number,\n    groupDepthConsumed: number\n  ): Promise<TreeResult> {\n    const { parallelRoutes } = parseLoaderTree(loaderTree)\n\n    const segment = getSegment(loaderTree)\n    const path: SegmentPath =\n      parentPath === null\n        ? stringifySegment(segment)\n        : createChildSegmentPath(parentPath, key!, segment)\n\n    debug?.(`    ${path || '/'} - Dynamic`)\n    const segmentCacheItem = cache.segments.get(path)\n    if (!segmentCacheItem) {\n      throw new InvariantError(`Missing segment data: ${path}`)\n    }\n\n    const segmentData = await deserializeFromChunks<SegmentData>(\n      segmentCacheItem.chunks[RenderStage.Dynamic],\n      segmentCacheItem.chunks[RenderStage.Dynamic],\n      segmentCacheItem.debugChunks,\n      releaseSignal,\n      clientReferenceManifest,\n      null\n    )\n\n    const consumesUrlDepth = segmentConsumesURLDepth(segment)\n    const isGroup =\n      typeof segment === 'string' &&\n      isGroupSegment(segment) &&\n      segment !== '(__SLOT__)'\n\n    // Advance counters for this segment before the boundary check,\n    // mirroring how discoverValidationDepths counts. URL segments\n    // increment urlDepthConsumed, groups increment groupDepthConsumed.\n    // The synthetic '(__SLOT__)' segment is excluded — it can't be a\n    // real navigation boundary.\n    let nextUrlDepth = urlDepthConsumed\n    let currentGroupDepth = groupDepthConsumed\n    if (consumesUrlDepth) {\n      nextUrlDepth++\n      currentGroupDepth = 0\n    } else if (isGroup) {\n      currentGroupDepth++\n    }\n\n    const pastUrlBoundary = nextUrlDepth > depth\n    const isBoundary = pastUrlBoundary && currentGroupDepth >= groupDepth\n\n    if (isBoundary) {\n      debug?.(\n        `    ['${path}' is the boundary (url=${nextUrlDepth}, group=${currentGroupDepth})]`\n      )\n      boundaryState.expectedIds.add(path)\n      const finalSegmentData: SegmentData = {\n        ...segmentData,\n        node: (\n          // eslint-disable-next-line @next/internal/no-ambiguous-jsx -- bundled in the server layer\n          <PlaceValidationBoundaryBelowThisLevel id={path} key=\"c\">\n            {segmentData.node}\n          </PlaceValidationBoundaryBelowThisLevel>\n        ),\n      }\n\n      const slots: CacheNodeSeedDataSlots = {}\n      let requiresInstantUI = false\n      let createInstantStack: (() => Error) | null = null\n      for (const parallelRouteKey in parallelRoutes) {\n        const result = await buildNewTreeSeedData(\n          parallelRoutes[parallelRouteKey],\n          path,\n          parallelRouteKey,\n          false /* isInsideRuntimePrefetch */\n        )\n        slots[parallelRouteKey] = result.seedData\n        if (result.requiresInstantUI) {\n          requiresInstantUI = true\n          if (createInstantStack === null) {\n            createInstantStack = result.createInstantStack\n          }\n        }\n      }\n      return {\n        seedData: getCacheNodeSeedDataFromSegment(finalSegmentData, slots),\n        requiresInstantUI,\n        createInstantStack,\n      }\n    }\n\n    // Not at the boundary yet — keep walking as shared.\n    const slots: CacheNodeSeedDataSlots = {}\n    let requiresInstantUI = false\n    let createInstantStack: (() => Error) | null = null\n    for (const parallelRouteKey in parallelRoutes) {\n      const result = await buildSharedTreeSeedData(\n        parallelRoutes[parallelRouteKey],\n        path,\n        parallelRouteKey,\n        nextUrlDepth,\n        currentGroupDepth\n      )\n      slots[parallelRouteKey] = result.seedData\n      if (result.requiresInstantUI) {\n        requiresInstantUI = true\n        if (createInstantStack === null) {\n          createInstantStack = result.createInstantStack\n        }\n      }\n    }\n    return {\n      seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),\n      requiresInstantUI,\n      createInstantStack,\n    }\n  }\n\n  async function buildNewTreeSeedData(\n    lt: LoaderTree,\n    parentPath: SegmentPath | null,\n    key: string | null,\n    isInsideRuntimePrefetch: boolean\n  ): Promise<TreeResult> {\n    const { parallelRoutes } = parseLoaderTree(lt)\n    const { mod: layoutOrPageMod } = await getLayoutOrPageModule(lt)\n\n    const segment = getSegment(lt)\n    const path: SegmentPath =\n      parentPath === null\n        ? stringifySegment(segment)\n        : createChildSegmentPath(parentPath, key!, segment)\n\n    let instantConfig: Instant | null = null\n    let localCreateInstantStack: (() => Error) | null = null\n    if (layoutOrPageMod !== undefined) {\n      instantConfig =\n        (layoutOrPageMod as AppSegmentConfig).unstable_instant ?? null\n      if (instantConfig && typeof instantConfig === 'object') {\n        const rawFactory: unknown = (layoutOrPageMod as any)\n          .__debugCreateInstantConfigStack\n        localCreateInstantStack =\n          typeof rawFactory === 'function' ? (rawFactory as () => Error) : null\n      }\n    }\n\n    let childIsInsideRuntimePrefetch = isInsideRuntimePrefetch\n    let stage: SegmentStage\n    if (!isInsideRuntimePrefetch) {\n      if (\n        instantConfig &&\n        typeof instantConfig === 'object' &&\n        instantConfig.prefetch === 'runtime'\n      ) {\n        stage = RenderStage.Runtime\n        childIsInsideRuntimePrefetch = true\n        hasRuntimeSegments = true\n      } else {\n        if (useRuntimeStageForPartialSegments) {\n          stage = RenderStage.Runtime\n          hasRuntimeSegments = true\n        } else {\n          stage = RenderStage.Static\n          hasStaticSegments = true\n        }\n      }\n    } else {\n      stage = RenderStage.Runtime\n      hasRuntimeSegments = true\n    }\n\n    debug?.(`    ${path || '/'} - ${RenderStage[stage]}`)\n    const segmentCacheItem = cache.segments.get(path)\n    if (!segmentCacheItem) {\n      throw new InvariantError(`Missing segment data: ${path}`)\n    }\n\n    const segmentData = await deserializeFromChunks<SegmentData>(\n      segmentCacheItem.chunks[stage],\n      segmentCacheItem.chunks[RenderStage.Dynamic],\n      segmentCacheItem.debugChunks,\n      releaseSignal,\n      clientReferenceManifest,\n      { startTime: undefined, endTime: stageEndTimes[stage] }\n    )\n\n    // Build children first, then determine requiresInstantUI.\n    const slots: CacheNodeSeedDataSlots = {}\n    let childrenRequireInstantUI = false\n    let childCreateInstantStack: (() => Error) | null = null\n    for (const parallelRouteKey in parallelRoutes) {\n      const result = await buildNewTreeSeedData(\n        parallelRoutes[parallelRouteKey],\n        path,\n        parallelRouteKey,\n        childIsInsideRuntimePrefetch\n      )\n      slots[parallelRouteKey] = result.seedData\n      if (result.requiresInstantUI) {\n        childrenRequireInstantUI = true\n        if (childCreateInstantStack === null) {\n          childCreateInstantStack = result.createInstantStack\n        }\n      }\n    }\n\n    // Local config takes precedence over children.\n    let requiresInstantUI: boolean\n    let createInstantStack: (() => Error) | null\n    if (instantConfig === false) {\n      requiresInstantUI = false\n      createInstantStack = null\n    } else if (instantConfig && typeof instantConfig === 'object') {\n      requiresInstantUI = true\n      createInstantStack = localCreateInstantStack\n    } else {\n      requiresInstantUI = childrenRequireInstantUI\n      createInstantStack = childCreateInstantStack\n    }\n\n    return {\n      seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),\n      requiresInstantUI,\n      createInstantStack,\n    }\n  }\n\n  const { seedData, requiresInstantUI, createInstantStack } =\n    await buildSharedTreeSeedData(\n      initialLoaderTree,\n      null /* parentPath */,\n      null /* key */,\n      0 /* urlDepthConsumed */,\n      0 /* groupDepthConsumed */\n    )\n\n  if (!requiresInstantUI) {\n    return null\n  }\n\n  const { flightRouterState } = getRootDataFromPayload(initialRSCPayload)\n\n  const headStage = hasRuntimeSegments\n    ? RenderStage.Runtime\n    : RenderStage.Static\n\n  const head = await createValidationHead(\n    cache,\n    releaseSignal,\n    clientReferenceManifest,\n    stageEndTimes,\n    headStage\n  )\n\n  const payload: InitialRSCPayload = {\n    ...initialRSCPayload,\n    f: [[flightRouterState, seedData, head]],\n  }\n\n  return {\n    payload,\n    hasAmbiguousErrors: hasStaticSegments,\n    createInstantStack,\n  }\n}\n"],"names":["InvariantError","RenderStage","getServerModuleMap","runInSequentialTasks","workAsyncStorage","Phase","printDebugThrownValueForProspectiveRender","getDigestForWellKnownError","PlaceValidationBoundaryBelowThisLevel","getLayoutOrPageModule","parseLoaderTree","Readable","createNodeStreamWithLateRelease","createNodeStreamFromChunks","createDebugChannel","createFromNodeStream","renderToReadableStream","addSearchParamsIfPageSegment","isGroupSegment","PAGE_SEGMENT_KEY","DEFAULT_SEGMENT_KEY","NOT_FOUND_SEGMENT_KEY","filterStackFrame","process","env","NODE_ENV","require","filterStackFrameDEV","undefined","findSourceMapURL","findSourceMapURLDEV","debug","NEXT_PRIVATE_DEBUG_VALIDATION","console","log","traverseRootSeedDataSegments","initialRSCPayload","processSegment","flightRouterState","seedData","getRootDataFromPayload","rootSegment","rootPath","stringifySegment","traverseCacheNodeSegments","path","route","_segment","childRoutes","_node","parallelRoutesData","_loading","_isPartial","parallelRouteKey","childSeedData","childRoute","childSegment","childPath","createChildSegmentPath","parentPath","segment","parallelRoutePrefix","encodeURIComponent","collectStagedSegmentData","fullPageChunks","fullPageDebugChunks","startTime","hasRuntimePrefetch","clientReferenceManifest","debugChannelAbortController","AbortController","debugStream","signal","stream","controller","createStagedStreamFromChunks","on","setImmediate","abort","environmentName","currentStage","Static","Runtime","Dynamic","serverConsumerManifest","moduleLoading","moduleMap","rscModuleMapping","serverModuleMap","payload","debugChannel","endTime","head","segments","Map","segmentPath","set","createSegmentData","cache","createSegmentCache","pendingTasks","stageEndTimes","renderIntoCacheItem","data","cacheEntry","segmentDebugChannel","debugChunks","itemStream","clientModules","serverSide","onError","error","digest","NEXT_DEBUG_BUILD","__NEXT_VERBOSE_LOGGING","workStore","getStore","InstantValidation","Promise","all","chunk","values","writeChunk","chunks","clientSide","readable","push","headCacheItem","createSegmentCacheItem","segmentData","segmentCacheItem","performance","now","timeOrigin","advanceStage","stageChunks","allChunks","numStaticChunks","length","numRuntimeChunks","numDynamicChunks","chunkIx","closed","close","read","stage","createCombinedPayloadStream","extraChunksAbortController","renderSignal","isDebugChannelEnabled","isRenderable","renderableChunks","streamFinished","flightDataPaths","f","createValidationHead","releaseSignal","deserializeFromChunks","partialChunks","timings","segmentStream","node","_parallelRoutesData","_unused","isPartial","varyParams","getCacheNodeSeedDataFromSegment","slots","withDebugChunks","segmentConsumesURLDepth","startsWith","discoverValidationDepths","loaderTree","groupDepthsByUrlDepth","recordGroupDepth","urlDepth","groupDepth","walk","tree","parallelRoutes","consumesDepth","nextUrlDepth","nextGroupDepth","key","createCombinedPayloadAtDepth","initialLoaderTree","getDynamicParamFromSegment","query","depth","boundaryState","useRuntimeStageForPartialSegments","hasStaticSegments","hasRuntimeSegments","getSegment","dynamicParam","treeSegment","buildSharedTreeSeedData","urlDepthConsumed","groupDepthConsumed","get","consumesUrlDepth","isGroup","currentGroupDepth","pastUrlBoundary","isBoundary","expectedIds","add","finalSegmentData","id","requiresInstantUI","createInstantStack","result","buildNewTreeSeedData","lt","isInsideRuntimePrefetch","mod","layoutOrPageMod","instantConfig","localCreateInstantStack","unstable_instant","rawFactory","__debugCreateInstantConfigStack","childIsInsideRuntimePrefetch","prefetch","childrenRequireInstantUI","childCreateInstantStack","headStage","hasAmbiguousErrors"],"mappings":";AAQA,SAASA,cAAc,QAAQ,sCAAqC;AACpE,SAASC,WAAW,QAAQ,sBAAqB;AACjD,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,gBAAgB,QAAQ,iCAAgC;AACjE,SACEC,KAAK,EACLC,yCAAyC,QACpC,8BAA6B;AACpC,SAASC,0BAA0B,QAAQ,0BAAyB;AACpE,SAEEC,AADA,iEAAiE;AACjEA,qCAAqC,QAChC,yDAAwD;AAE/D,SACEC,qBAAqB,QAEhB,2BAA0B;AACjC,SAASC,eAAe,QAAQ,qDAAoD;AAMpF,SAASC,QAAQ,QAAQ,cAAa;AACtC,SACEC,+BAA+B,EAC/BC,0BAA0B,QACrB,iBAAgB;AACvB,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,6DAA6D;AAC7D,SAASC,oBAAoB,QAAQ,kCAAiC;AACtE,6DAA6D;AAC7D,SAASC,sBAAsB,QAAQ,kCAAiC;AACxE,SACEC,4BAA4B,EAC5BC,cAAc,EAC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