{"version":3,"sources":["../../../src/client/components/layout-router.tsx"],"sourcesContent":["'use client'\n\nimport type { CacheNode } from '../../shared/lib/app-router-types'\nimport type { LoadingModuleData } from '../../shared/lib/app-router-types'\nimport type {\n  FlightRouterState,\n  FlightSegmentPath,\n  Segment,\n} from '../../shared/lib/app-router-types'\nimport type { ErrorComponent } from './error-boundary'\nimport type { FocusAndScrollRef } from './router-reducer/router-reducer-types'\n\nimport React, {\n  Activity,\n  Fragment,\n  useContext,\n  use,\n  Suspense,\n  useDeferredValue,\n  useLayoutEffect,\n  type FragmentInstance,\n  type JSX,\n  type ActivityProps,\n} from 'react'\nimport ReactDOM from 'react-dom'\nimport {\n  LayoutRouterContext,\n  GlobalLayoutRouterContext,\n  TemplateContext,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport { unresolvedThenable } from './unresolved-thenable'\nimport { ErrorBoundary } from './error-boundary'\nimport { disableSmoothScrollDuringRouteTransition } from '../../shared/lib/router/utils/disable-smooth-scroll'\nimport { RedirectBoundary } from './redirect-boundary'\nimport { HTTPAccessFallbackBoundary } from './http-access-fallback/error-boundary'\nimport { createRouterCacheKey } from './router-reducer/create-router-cache-key'\nimport {\n  useRouterBFCache,\n  type RouterBFCacheEntry,\n} from './bfcache-state-manager'\nimport { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'\nimport {\n  NavigationPromisesContext,\n  type NavigationPromises,\n} from '../../shared/lib/hooks-client-context.shared-runtime'\nimport { getParamValueFromCacheKey } from '../route-params'\nimport type { Params } from '../../server/request/params'\nimport { isDeferredRsc } from './router-reducer/ppr-navigations'\n\nconst enableNewScrollHandler = process.env.__NEXT_APP_NEW_SCROLL_HANDLER\n\nconst __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = (\n  ReactDOM as any\n).__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE\n\n// TODO-APP: Replace with new React API for finding dom nodes without a `ref` when available\n/**\n * Wraps ReactDOM.findDOMNode with additional logic to hide React Strict Mode warning\n */\nfunction findDOMNode(\n  instance: React.ReactInstance | null | undefined\n): Element | Text | null {\n  // Tree-shake for server bundle\n  if (typeof window === 'undefined') return null\n\n  // __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode is null during module init.\n  // We need to lazily reference it.\n  const internal_reactDOMfindDOMNode =\n    __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode\n  return internal_reactDOMfindDOMNode(instance)\n}\n\nconst rectProperties = [\n  'bottom',\n  'height',\n  'left',\n  'right',\n  'top',\n  'width',\n  'x',\n  'y',\n] as const\n/**\n * Check if a HTMLElement is hidden or fixed/sticky position\n */\nfunction shouldSkipElement(element: HTMLElement) {\n  // we ignore fixed or sticky positioned elements since they'll likely pass the \"in-viewport\" check\n  // and will result in a situation we bail on scroll because of something like a fixed nav,\n  // even though the actual page content is offscreen\n  if (['sticky', 'fixed'].includes(getComputedStyle(element).position)) {\n    return true\n  }\n\n  // Uses `getBoundingClientRect` to check if the element is hidden instead of `offsetParent`\n  // because `offsetParent` doesn't consider document/body\n  const rect = element.getBoundingClientRect()\n  return rectProperties.every((item) => rect[item] === 0)\n}\n\n/**\n * Check if the top corner of the HTMLElement is in the viewport.\n */\nfunction topOfElementInViewport(\n  instance: HTMLElement | FragmentInstance,\n  viewportHeight: number\n): boolean {\n  const rects = instance.getClientRects()\n  if (rects.length === 0) {\n    // Just to be explicit.\n    return false\n  }\n  let elementTop = Number.POSITIVE_INFINITY\n  for (let i = 0; i < rects.length; i++) {\n    const rect = rects[i]\n    if (rect.top < elementTop) {\n      elementTop = rect.top\n    }\n  }\n  return elementTop >= 0 && elementTop <= viewportHeight\n}\n\n/**\n * Find the DOM node for a hash fragment.\n * If `top` the page has to scroll to the top of the page. This mirrors the browser's behavior.\n * If the hash fragment is an id, the page has to scroll to the element with that id.\n * If the hash fragment is a name, the page has to scroll to the first element with that name.\n */\nfunction getHashFragmentDomNode(hashFragment: string) {\n  // If the hash fragment is `top` the page has to scroll to the top of the page.\n  if (hashFragment === 'top') {\n    return document.body\n  }\n\n  // If the hash fragment is an id, the page has to scroll to the element with that id.\n  return (\n    document.getElementById(hashFragment) ??\n    // If the hash fragment is a name, the page has to scroll to the first element with that name.\n    document.getElementsByName(hashFragment)[0]\n  )\n}\ninterface ScrollAndMaybeFocusHandlerProps {\n  focusAndScrollRef: FocusAndScrollRef\n  children: React.ReactNode\n  cacheNode: CacheNode\n}\nclass InnerScrollAndFocusHandlerOld extends React.Component<ScrollAndMaybeFocusHandlerProps> {\n  handlePotentialScroll = () => {\n    // Handle scroll and focus, it's only applied once.\n    const { focusAndScrollRef, cacheNode } = this.props\n\n    const scrollRef = focusAndScrollRef.forceScroll\n      ? focusAndScrollRef.scrollRef\n      : cacheNode.scrollRef\n    if (scrollRef === null || !scrollRef.current) return\n\n    let domNode:\n      | ReturnType<typeof getHashFragmentDomNode>\n      | ReturnType<typeof findDOMNode> = null\n    const hashFragment = focusAndScrollRef.hashFragment\n\n    if (hashFragment) {\n      domNode = getHashFragmentDomNode(hashFragment)\n    }\n\n    // `findDOMNode` is tricky because it returns just the first child if the component is a fragment.\n    // This already caused a bug where the first child was a <link/> in head.\n    if (!domNode) {\n      domNode = findDOMNode(this)\n    }\n\n    // If there is no DOM node this layout-router level is skipped. It'll be handled higher-up in the tree.\n    if (!(domNode instanceof Element)) {\n      return\n    }\n\n    // Verify if the element is a HTMLElement and if we want to consider it for scroll behavior.\n    // If the element is skipped, try to select the next sibling and try again.\n    while (!(domNode instanceof HTMLElement) || shouldSkipElement(domNode)) {\n      if (process.env.NODE_ENV !== 'production') {\n        if (domNode.parentElement?.localName === 'head') {\n          // We enter this state when metadata was rendered as part of the page or via Next.js.\n          // This is always a bug in Next.js and caused by React hoisting metadata.\n          // Fixed with `experimental.appNewScrollHandler`\n        }\n      }\n\n      // No siblings found that match the criteria are found, so handle scroll higher up in the tree instead.\n      if (domNode.nextElementSibling === null) {\n        return\n      }\n      domNode = domNode.nextElementSibling\n    }\n\n    // Mark as scrolled so no other segment scrolls for this navigation.\n    scrollRef.current = false\n\n    disableSmoothScrollDuringRouteTransition(\n      () => {\n        // In case of hash scroll, we only need to scroll the element into view\n        if (hashFragment) {\n          domNode.scrollIntoView()\n\n          return\n        }\n        // Store the current viewport height because reading `clientHeight` causes a reflow,\n        // and it won't change during this function.\n        const htmlElement = document.documentElement\n        const viewportHeight = htmlElement.clientHeight\n\n        // If the element's top edge is already in the viewport, exit early.\n        if (topOfElementInViewport(domNode, viewportHeight)) {\n          return\n        }\n\n        // Otherwise, try scrolling go the top of the document to be backward compatible with pages\n        // scrollIntoView() called on `<html/>` element scrolls horizontally on chrome and firefox (that shouldn't happen)\n        // We could use it to scroll horizontally following RTL but that also seems to be broken - it will always scroll left\n        // scrollLeft = 0 also seems to ignore RTL and manually checking for RTL is too much hassle so we will scroll just vertically\n        htmlElement.scrollTop = 0\n\n        // Scroll to domNode if domNode is not in viewport when scrolled to top of document\n        if (!topOfElementInViewport(domNode, viewportHeight)) {\n          // Scroll into view doesn't scroll horizontally by default when not needed\n          domNode.scrollIntoView()\n        }\n      },\n      {\n        // We will force layout by querying domNode position\n        dontForceLayout: true,\n        onlyHashChange: focusAndScrollRef.onlyHashChange,\n      }\n    )\n\n    // Mutate after scrolling so that it can be read by `disableSmoothScrollDuringRouteTransition`\n    focusAndScrollRef.onlyHashChange = false\n    focusAndScrollRef.hashFragment = null\n\n    // Set focus on the element\n    domNode.focus()\n  }\n\n  componentDidMount() {\n    this.handlePotentialScroll()\n  }\n\n  componentDidUpdate() {\n    this.handlePotentialScroll()\n  }\n\n  render() {\n    return this.props.children\n  }\n}\n\n/**\n * Fork of InnerScrollAndFocusHandlerOld using Fragment refs for scrolling.\n * No longer focuses the first host descendant.\n */\nfunction InnerScrollHandlerNew(props: ScrollAndMaybeFocusHandlerProps) {\n  const childrenRef = React.useRef<FragmentInstance>(null)\n\n  useLayoutEffect(\n    () => {\n      const { focusAndScrollRef, cacheNode } = props\n\n      const scrollRef = focusAndScrollRef.forceScroll\n        ? focusAndScrollRef.scrollRef\n        : cacheNode.scrollRef\n      if (scrollRef === null || !scrollRef.current) return\n\n      let instance: FragmentInstance | HTMLElement | null = null\n      const hashFragment = focusAndScrollRef.hashFragment\n\n      if (hashFragment) {\n        instance = getHashFragmentDomNode(hashFragment)\n      }\n\n      if (!instance) {\n        instance = childrenRef.current\n      }\n\n      // If there is no DOM node this layout-router level is skipped. It'll be handled higher-up in the tree.\n      if (instance === null) {\n        return\n      }\n\n      // Mark as scrolled so no other segment scrolls for this navigation.\n      scrollRef.current = false\n\n      const activeElement = document.activeElement\n      if (\n        activeElement !== null &&\n        'blur' in activeElement &&\n        typeof activeElement.blur === 'function'\n      ) {\n        // Trying to match hard navigations.\n        // Ideally we'd move the internal focus cursor either to the top\n        // or at least before the segment. But there's no DOM API to do that,\n        // so we just blur.\n        // We could workaround this by moving focus to a temporary element in\n        // the body. But adding elements might trigger layout or other effects\n        // so it should be well motivated.\n        activeElement.blur()\n      }\n\n      disableSmoothScrollDuringRouteTransition(\n        () => {\n          // In case of hash scroll, we only need to scroll the element into view\n          if (hashFragment) {\n            instance.scrollIntoView()\n\n            return\n          }\n          // Store the current viewport height because reading `clientHeight` causes a reflow,\n          // and it won't change during this function.\n          const htmlElement = document.documentElement\n          const viewportHeight = htmlElement.clientHeight\n\n          // If the element's top edge is already in the viewport, exit early.\n          if (topOfElementInViewport(instance, viewportHeight)) {\n            return\n          }\n\n          // Otherwise, try scrolling go the top of the document to be backward compatible with pages\n          // scrollIntoView() called on `<html/>` element scrolls horizontally on chrome and firefox (that shouldn't happen)\n          // We could use it to scroll horizontally following RTL but that also seems to be broken - it will always scroll left\n          // scrollLeft = 0 also seems to ignore RTL and manually checking for RTL is too much hassle so we will scroll just vertically\n          htmlElement.scrollTop = 0\n\n          // Scroll to domNode if domNode is not in viewport when scrolled to top of document\n          if (!topOfElementInViewport(instance, viewportHeight)) {\n            // Scroll into view doesn't scroll horizontally by default when not needed\n            instance.scrollIntoView()\n          }\n        },\n        {\n          // We will force layout by querying domNode position\n          dontForceLayout: true,\n          onlyHashChange: focusAndScrollRef.onlyHashChange,\n        }\n      )\n\n      // Mutate after scrolling so that it can be read by `disableSmoothScrollDuringRouteTransition`\n      focusAndScrollRef.onlyHashChange = false\n      focusAndScrollRef.hashFragment = null\n    },\n    // Used to run on every commit. We may be able to be smarter about this\n    // but be prepared for lots of manual testing.\n    undefined\n  )\n\n  return <Fragment ref={childrenRef}>{props.children}</Fragment>\n}\n\nconst InnerScrollAndMaybeFocusHandler = enableNewScrollHandler\n  ? InnerScrollHandlerNew\n  : InnerScrollAndFocusHandlerOld\n\nfunction ScrollAndMaybeFocusHandler({\n  children,\n  cacheNode,\n}: {\n  children: React.ReactNode\n  cacheNode: CacheNode\n}) {\n  const context = useContext(GlobalLayoutRouterContext)\n  if (!context) {\n    throw new Error('invariant global layout router not mounted')\n  }\n\n  return (\n    <InnerScrollAndMaybeFocusHandler\n      focusAndScrollRef={context.focusAndScrollRef}\n      cacheNode={cacheNode}\n    >\n      {children}\n    </InnerScrollAndMaybeFocusHandler>\n  )\n}\n\n/**\n * InnerLayoutRouter handles rendering the provided segment based on the cache.\n */\nfunction InnerLayoutRouter({\n  tree,\n  segmentPath,\n  debugNameContext,\n  cacheNode: maybeCacheNode,\n  params,\n  url,\n  isActive,\n}: {\n  tree: FlightRouterState\n  segmentPath: FlightSegmentPath\n  debugNameContext: string\n  cacheNode: CacheNode | null\n  params: Params\n  url: string\n  isActive: boolean\n}) {\n  const context = useContext(GlobalLayoutRouterContext)\n  const parentNavPromises = useContext(NavigationPromisesContext)\n\n  if (!context) {\n    throw new Error('invariant global layout router not mounted')\n  }\n\n  const cacheNode =\n    maybeCacheNode !== null\n      ? maybeCacheNode\n      : // This segment is not in the cache. Suspend indefinitely.\n        //\n        // This should only be reachable for inactive/hidden segments, during\n        // prerendering The active segment should always be consistent with the\n        // CacheNode tree. Regardless, if we don't have a matching CacheNode, we\n        // must suspend rather than render nothing, to prevent showing an\n        // inconsistent route.\n\n        (use(unresolvedThenable) as never)\n\n  // `rsc` represents the renderable node for this segment.\n\n  // If this segment has a `prefetchRsc`, it's the statically prefetched data.\n  // We should use that on initial render instead of `rsc`. Then we'll switch\n  // to `rsc` when the dynamic response streams in.\n  //\n  // If no prefetch data is available, then we go straight to rendering `rsc`.\n  const resolvedPrefetchRsc =\n    cacheNode.prefetchRsc !== null ? cacheNode.prefetchRsc : cacheNode.rsc\n\n  // We use `useDeferredValue` to handle switching between the prefetched and\n  // final values. The second argument is returned on initial render, then it\n  // re-renders with the first argument.\n  const rsc: any = useDeferredValue(cacheNode.rsc, resolvedPrefetchRsc)\n\n  // `rsc` is either a React node or a promise for a React node, except we\n  // special case `null` to represent that this segment's data is missing. If\n  // it's a promise, we need to unwrap it so we can determine whether or not the\n  // data is missing.\n  let resolvedRsc: React.ReactNode\n  if (isDeferredRsc(rsc)) {\n    const unwrappedRsc = use(rsc)\n    if (unwrappedRsc === null) {\n      // If the promise was resolved to `null`, it means the data for this\n      // segment was not returned by the server. Suspend indefinitely. When this\n      // happens, the router is responsible for triggering a new state update to\n      // un-suspend this segment.\n      use(unresolvedThenable) as never\n    }\n    resolvedRsc = unwrappedRsc\n  } else {\n    // This is not a deferred RSC promise. Don't need to unwrap it.\n    if (rsc === null) {\n      use(unresolvedThenable) as never\n    }\n    resolvedRsc = rsc\n  }\n\n  // In dev, we create a NavigationPromisesContext containing the instrumented promises that provide\n  // `useSelectedLayoutSegment` and `useSelectedLayoutSegments`.\n  // Promises are cached outside of render to survive suspense retries.\n  let navigationPromises: NavigationPromises | null = null\n  if (process.env.NODE_ENV !== 'production') {\n    const { createNestedLayoutNavigationPromises } =\n      require('./navigation-devtools') as typeof import('./navigation-devtools')\n\n    navigationPromises = createNestedLayoutNavigationPromises(\n      tree,\n      parentNavPromises\n    )\n  }\n\n  let children = resolvedRsc\n\n  if (navigationPromises) {\n    children = (\n      <NavigationPromisesContext.Provider value={navigationPromises}>\n        {resolvedRsc}\n      </NavigationPromisesContext.Provider>\n    )\n  }\n\n  children = (\n    // The layout router context narrows down tree and childNodes at each level.\n    <LayoutRouterContext.Provider\n      value={{\n        parentTree: tree,\n        parentCacheNode: cacheNode,\n        parentSegmentPath: segmentPath,\n        parentParams: params,\n        // This is always set to null as we enter a child segment. It's\n        // populated by LoadingBoundaryProvider the next time we reach a\n        // loading boundary.\n        parentLoadingData: null,\n        debugNameContext: debugNameContext,\n\n        // TODO-APP: overriding of url for parallel routes\n        url: url,\n        isActive: isActive,\n      }}\n    >\n      {children}\n    </LayoutRouterContext.Provider>\n  )\n\n  return children\n}\n\nexport function LoadingBoundaryProvider({\n  loading,\n  children,\n}: {\n  loading: LoadingModuleData\n  children: React.ReactNode\n}) {\n  // Provides the data needed to render a loading.tsx boundary, via context.\n  //\n  // loading.tsx creates a Suspense boundary around each of a layout's child\n  // slots. (Might be bit confusing to think about the data flow, but: if\n  // loading.tsx and layout.tsx are in the same directory, they are assigned\n  // to the same CacheNode.)\n  //\n  // This provider component does not render the Suspense boundary directly;\n  // that's handled by LoadingBoundary.\n  //\n  // TODO: For simplicity, we should combine this provider with LoadingBoundary\n  // and render the Suspense boundary directly. The only real benefit of doing\n  // it separately is so that when there are multiple parallel routes, we only\n  // send the boundary data once, rather than once per child. But that's a\n  // negligible benefit and can be achieved via caching instead.\n  const parentContext = use(LayoutRouterContext)\n  if (parentContext === null) {\n    return children\n  }\n  // All values except for parentLoadingData are the same as the parent context.\n  return (\n    <LayoutRouterContext.Provider\n      value={{\n        parentTree: parentContext.parentTree,\n        parentCacheNode: parentContext.parentCacheNode,\n        parentSegmentPath: parentContext.parentSegmentPath,\n        parentParams: parentContext.parentParams,\n        parentLoadingData: loading,\n        debugNameContext: parentContext.debugNameContext,\n        url: parentContext.url,\n        isActive: parentContext.isActive,\n      }}\n    >\n      {children}\n    </LayoutRouterContext.Provider>\n  )\n}\n\n/**\n * Renders suspense boundary with the provided \"loading\" property as the fallback.\n * If no loading property is provided it renders the children without a suspense boundary.\n */\nfunction LoadingBoundary({\n  name,\n  loading,\n  children,\n}: {\n  name: ActivityProps['name']\n  loading: LoadingModuleData | null\n  children: React.ReactNode\n}): JSX.Element {\n  // TODO: For LoadingBoundary, and the other built-in boundary types, don't\n  // wrap in an extra function component if no user-defined boundary is\n  // provided. In other words, inline this conditional wrapping logic into\n  // the parent component. More efficient and keeps unnecessary junk out of\n  // the component stack.\n  if (loading !== null) {\n    const loadingRsc = loading[0]\n    const loadingStyles = loading[1]\n    const loadingScripts = loading[2]\n    return (\n      <Suspense\n        name={name}\n        fallback={\n          <>\n            {loadingStyles}\n            {loadingScripts}\n            {loadingRsc}\n          </>\n        }\n      >\n        {children}\n      </Suspense>\n    )\n  }\n\n  return <>{children}</>\n}\n\n/**\n * OuterLayoutRouter handles the current segment as well as <Offscreen> rendering of other segments.\n * It can be rendered next to each other with a different `parallelRouterKey`, allowing for Parallel routes.\n */\nexport default function OuterLayoutRouter({\n  parallelRouterKey,\n  error,\n  errorStyles,\n  errorScripts,\n  templateStyles,\n  templateScripts,\n  template,\n  notFound,\n  forbidden,\n  unauthorized,\n  segmentViewBoundaries,\n}: {\n  parallelRouterKey: string\n  error: ErrorComponent | undefined\n  errorStyles: React.ReactNode | undefined\n  errorScripts: React.ReactNode | undefined\n  templateStyles: React.ReactNode | undefined\n  templateScripts: React.ReactNode | undefined\n  template: React.ReactNode\n  notFound: React.ReactNode | undefined\n  forbidden: React.ReactNode | undefined\n  unauthorized: React.ReactNode | undefined\n  segmentViewBoundaries?: React.ReactNode\n}) {\n  const context = useContext(LayoutRouterContext)\n  if (!context) {\n    throw new Error('invariant expected layout router to be mounted')\n  }\n\n  const {\n    parentTree,\n    parentCacheNode,\n    parentSegmentPath,\n    parentParams,\n    parentLoadingData,\n    url,\n    isActive,\n    debugNameContext,\n  } = context\n\n  // Get the CacheNode for this segment by reading it from the parent segment's\n  // child map.\n  const parentTreeSegment = parentTree[0]\n  const segmentPath =\n    parentSegmentPath === null\n      ? // TODO: The root segment value is currently omitted from the segment\n        // path. This has led to a bunch of special cases scattered throughout\n        // the code. We should clean this up.\n        [parallelRouterKey]\n      : parentSegmentPath.concat([parentTreeSegment, parallelRouterKey])\n\n  // The \"state\" key of a segment is the one passed to React — it represents the\n  // identity of the UI tree. Whenever the state key changes, the tree is\n  // recreated and the state is reset. In the App Router model, search params do\n  // not cause state to be lost, so two segments with the same segment path but\n  // different search params should have the same state key.\n  //\n  // The \"cache\" key of a segment, however, *does* include the search params, if\n  // it's possible that the segment accessed the search params on the server.\n  // (This only applies to page segments; layout segments cannot access search\n  // params on the server.)\n  const activeTree = parentTree[1][parallelRouterKey]\n  const maybeParentSlots = parentCacheNode.slots\n  if (activeTree === undefined || maybeParentSlots === null) {\n    // Could not find a matching segment. The client tree is inconsistent with\n    // the server tree. Suspend indefinitely; the router will have already\n    // detected the inconsistency when handling the server response, and\n    // triggered a refresh of the page to recover.\n    use(unresolvedThenable) as never\n  }\n\n  let maybeValidationBoundaryId: string | null = null\n  if (typeof window === 'undefined' && process.env.__NEXT_CACHE_COMPONENTS) {\n    const { InstantValidationBoundaryContext } =\n      require('./instant-validation/boundary') as typeof import('./instant-validation/boundary')\n    maybeValidationBoundaryId = use(InstantValidationBoundaryContext)\n  }\n\n  const activeSegment = activeTree[0]\n  const activeCacheNode = maybeParentSlots![parallelRouterKey] ?? null\n  const activeStateKey = createRouterCacheKey(activeSegment, true) // no search params\n\n  // At each level of the route tree, not only do we render the currently\n  // active segment — we also render the last N segments that were active at\n  // this level inside a hidden <Activity> boundary, to preserve their state\n  // if or when the user navigates to them again.\n  //\n  // bfcacheEntry is a linked list of FlightRouterStates.\n  let bfcacheEntry: RouterBFCacheEntry | null = useRouterBFCache(\n    activeTree,\n    activeCacheNode,\n    activeStateKey\n  )\n  let children: Array<React.ReactNode> = []\n  do {\n    const tree = bfcacheEntry.tree\n    const cacheNode = bfcacheEntry.cacheNode\n    const stateKey = bfcacheEntry.stateKey\n    const segment = tree[0]\n\n    /*\n    - Error boundary\n      - Only renders error boundary if error component is provided.\n      - Rendered for each segment to ensure they have their own error state.\n      - When gracefully degrade for bots, skip rendering error boundary.\n    - Loading boundary\n      - Only renders suspense boundary if loading components is provided.\n      - Rendered for each segment to ensure they have their own loading state.\n      - Passed to the router during rendering to ensure it can be immediately rendered when suspending on a Flight fetch.\n  */\n\n    let segmentBoundaryTriggerNode: React.ReactNode = null\n    let segmentViewStateNode: React.ReactNode = null\n    if (process.env.NODE_ENV !== 'production') {\n      const { SegmentBoundaryTriggerNode, SegmentViewStateNode } =\n        require('../../next-devtools/userspace/app/segment-explorer-node') as typeof import('../../next-devtools/userspace/app/segment-explorer-node')\n\n      const pagePrefix = normalizeAppPath(url)\n      segmentViewStateNode = (\n        <SegmentViewStateNode key={pagePrefix} page={pagePrefix} />\n      )\n\n      segmentBoundaryTriggerNode = (\n        <>\n          <SegmentBoundaryTriggerNode />\n        </>\n      )\n    }\n\n    let params = parentParams\n    if (Array.isArray(segment)) {\n      // This segment contains a route param. Accumulate these as we traverse\n      // down the router tree. The result represents the set of params that\n      // the layout/page components are permitted to access below this point.\n      const paramName = segment[0]\n      const paramCacheKey = segment[1]\n      const paramType = segment[2]\n      const paramValue = getParamValueFromCacheKey(paramCacheKey, paramType)\n      if (paramValue !== null) {\n        params = {\n          ...parentParams,\n          [paramName]: paramValue,\n        }\n      }\n    }\n\n    const debugName = getBoundaryDebugNameFromSegment(segment)\n    // `debugNameContext` represents the nearest non-\"virtual\" parent segment.\n    // `getBoundaryDebugNameFromSegment` returns undefined for virtual segments.\n    // So if `debugName` is undefined, the context is passed through unchanged.\n    const childDebugNameContext = debugName ?? debugNameContext\n\n    // In practical terms, clicking this name in the Suspense DevTools\n    // should select the child slots of that layout.\n    //\n    // So the name we apply to the Activity boundary is actually based on\n    // the nearest parent segments.\n    //\n    // We skip over \"virtual\" parents, i.e. ones inserted by Next.js that\n    // don't correspond to application-defined code.\n    const isVirtual = debugName === undefined\n    const debugNameToDisplay = isVirtual ? undefined : debugNameContext\n\n    let templateValue = (\n      <ScrollAndMaybeFocusHandler cacheNode={cacheNode}>\n        <ErrorBoundary\n          errorComponent={error}\n          errorStyles={errorStyles}\n          errorScripts={errorScripts}\n        >\n          <LoadingBoundary\n            name={debugNameToDisplay}\n            // TODO: The loading module data for a segment is stored on the\n            // parent, then applied to each of that parent segment's\n            // parallel route slots. In the simple case where there's only\n            // one parallel route (the `children` slot), this is no\n            // different from if the loading module data were stored on the\n            // child directly. But I'm not sure this actually makes sense\n            // when there are multiple parallel routes. It's not a huge\n            // issue because you always have the option to define a narrower\n            // loading boundary for a particular slot. But this sort of\n            // smells like an implementation accident to me.\n            loading={parentLoadingData}\n          >\n            <HTTPAccessFallbackBoundary\n              notFound={notFound}\n              forbidden={forbidden}\n              unauthorized={unauthorized}\n            >\n              <RedirectBoundary>\n                <InnerLayoutRouter\n                  url={url}\n                  tree={tree}\n                  params={params}\n                  cacheNode={cacheNode}\n                  segmentPath={segmentPath}\n                  debugNameContext={childDebugNameContext}\n                  isActive={isActive && stateKey === activeStateKey}\n                />\n                {segmentBoundaryTriggerNode}\n              </RedirectBoundary>\n            </HTTPAccessFallbackBoundary>\n          </LoadingBoundary>\n        </ErrorBoundary>\n        {segmentViewStateNode}\n      </ScrollAndMaybeFocusHandler>\n    )\n\n    if (\n      typeof window === 'undefined' &&\n      process.env.__NEXT_CACHE_COMPONENTS &&\n      typeof maybeValidationBoundaryId === 'string'\n    ) {\n      const { RenderValidationBoundaryAtThisLevel } =\n        require('./instant-validation/boundary') as typeof import('./instant-validation/boundary')\n      templateValue = (\n        <RenderValidationBoundaryAtThisLevel id={maybeValidationBoundaryId}>\n          {templateValue}\n        </RenderValidationBoundaryAtThisLevel>\n      )\n    }\n\n    let child = (\n      <TemplateContext.Provider key={stateKey} value={templateValue}>\n        {templateStyles}\n        {templateScripts}\n        {template}\n      </TemplateContext.Provider>\n    )\n\n    if (process.env.NODE_ENV !== 'production') {\n      const { SegmentStateProvider } =\n        require('../../next-devtools/userspace/app/segment-explorer-node') as typeof import('../../next-devtools/userspace/app/segment-explorer-node')\n\n      child = (\n        <SegmentStateProvider key={stateKey}>\n          {child}\n          {segmentViewBoundaries}\n        </SegmentStateProvider>\n      )\n    }\n\n    if (process.env.__NEXT_CACHE_COMPONENTS) {\n      child = (\n        <Activity\n          name={debugNameToDisplay}\n          key={stateKey}\n          mode={stateKey === activeStateKey ? 'visible' : 'hidden'}\n        >\n          {child}\n        </Activity>\n      )\n    }\n\n    children.push(child)\n\n    bfcacheEntry = bfcacheEntry.next\n  } while (bfcacheEntry !== null)\n\n  return children\n}\n\nfunction getBoundaryDebugNameFromSegment(segment: Segment): string | undefined {\n  if (segment === '/') {\n    // Reached the root\n    return '/'\n  }\n  if (typeof segment === 'string') {\n    if (isVirtualLayout(segment)) {\n      return undefined\n    } else {\n      return segment + '/'\n    }\n  }\n  const paramCacheKey = segment[1]\n  return paramCacheKey + '/'\n}\n\nfunction isVirtualLayout(segment: string): boolean {\n  return (\n    // This is inserted by the loader. Uses double-underscore convention\n    // (like __PAGE__ and __DEFAULT__) to avoid collisions with\n    // user-defined route groups.\n    segment === '(__SLOT__)'\n  )\n}\n"],"names":["LoadingBoundaryProvider","OuterLayoutRouter","enableNewScrollHandler","process","env","__NEXT_APP_NEW_SCROLL_HANDLER","__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE","ReactDOM","findDOMNode","instance","window","internal_reactDOMfindDOMNode","rectProperties","shouldSkipElement","element","includes","getComputedStyle","position","rect","getBoundingClientRect","every","item","topOfElementInViewport","viewportHeight","rects","getClientRects","length","elementTop","Number","POSITIVE_INFINITY","i","top","getHashFragmentDomNode","hashFragment","document","body","getElementById","getElementsByName","InnerScrollAndFocusHandlerOld","React","Component","componentDidMount","handlePotentialScroll","componentDidUpdate","render","props","children","focusAndScrollRef","cacheNode","scrollRef","forceScroll","current","domNode","Element","HTMLElement","NODE_ENV","parentElement","localName","nextElementSibling","disableSmoothScrollDuringRouteTransition","scrollIntoView","htmlElement","documentElement","clientHeight","scrollTop","dontForceLayout","onlyHashChange","focus","InnerScrollHandlerNew","childrenRef","useRef","useLayoutEffect","activeElement","blur","undefined","Fragment","ref","InnerScrollAndMaybeFocusHandler","ScrollAndMaybeFocusHandler","context","useContext","GlobalLayoutRouterContext","Error","InnerLayoutRouter","tree","segmentPath","debugNameContext","maybeCacheNode","params","url","isActive","parentNavPromises","NavigationPromisesContext","use","unresolvedThenable","resolvedPrefetchRsc","prefetchRsc","rsc","useDeferredValue","resolvedRsc","isDeferredRsc","unwrappedRsc","navigationPromises","createNestedLayoutNavigationPromises","require","Provider","value","LayoutRouterContext","parentTree","parentCacheNode","parentSegmentPath","parentParams","parentLoadingData","loading","parentContext","LoadingBoundary","name","loadingRsc","loadingStyles","loadingScripts","Suspense","fallback","parallelRouterKey","error","errorStyles","errorScripts","templateStyles","templateScripts","template","notFound","forbidden","unauthorized","segmentViewBoundaries","parentTreeSegment","concat","activeTree","maybeParentSlots","slots","maybeValidationBoundaryId","__NEXT_CACHE_COMPONENTS","InstantValidationBoundaryContext","activeSegment","activeCacheNode","activeStateKey","createRouterCacheKey","bfcacheEntry","useRouterBFCache","stateKey","segment","segmentBoundaryTriggerNode","segmentViewStateNode","SegmentBoundaryTriggerNode","SegmentViewStateNode","pagePrefix","normalizeAppPath","page","Array","isArray","paramName","paramCacheKey","paramType","paramValue","getParamValueFromCacheKey","debugName","getBoundaryDebugNameFromSegment","childDebugNameContext","isVirtual","debugNameToDisplay","templateValue","ErrorBoundary","errorComponent","HTTPAccessFallbackBoundary","RedirectBoundary","RenderValidationBoundaryAtThisLevel","id","child","TemplateContext","SegmentStateProvider","Activity","mode","push","next","isVirtualLayout"],"mappings":"AAAA;;;;;;;;;;;;;;;;IA4fgBA,uBAAuB;eAAvBA;;IAsFhB;;;CAGC,GACD,OAqQC;eArQuBC;;;;;;iEA/jBj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