{"version":3,"sources":["../../../../src/client/components/app-router-instance.ts"],"sourcesContent":["import {\n  type AppRouterState,\n  type ReducerActions,\n  type ReducerState,\n  ACTION_REFRESH,\n  ACTION_SERVER_ACTION,\n  ACTION_NAVIGATE,\n  ACTION_RESTORE,\n  type NavigateAction,\n  ACTION_HMR_REFRESH,\n  PrefetchKind,\n  ScrollBehavior,\n  type AppHistoryState,\n} from './router-reducer/router-reducer-types'\nimport { reducer } from './router-reducer/router-reducer'\nimport { addTransitionType, startTransition } from 'react'\nimport { isThenable } from '../../shared/lib/is-thenable'\nimport {\n  FetchStrategy,\n  type PrefetchTaskFetchStrategy,\n} from './segment-cache/types'\nimport { prefetch as prefetchWithSegmentCache } from './segment-cache/prefetch'\nimport { navigate } from './segment-cache/navigation'\nimport {\n  dispatchAppRouterAction,\n  dispatchGestureState,\n} from './use-action-queue'\nimport { resetKnownRoutes } from './segment-cache/optimistic-routes'\nimport { FreshnessPolicy } from './router-reducer/ppr-navigations'\nimport { addBasePath } from '../add-base-path'\nimport { isExternalURL } from './app-router-utils'\nimport type {\n  AppRouterInstance,\n  NavigateOptions,\n  PrefetchOptions,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport { setLinkForCurrentNavigation, type LinkInstance } from './links'\nimport type { RouterTransitionPrefetchIntent } from '../router-transition-types'\nimport type { GlobalErrorComponent } from './builtin/global-error'\nimport { isJavaScriptURLString } from '../lib/javascript-url'\nimport { startRouterTransition } from './router-transition'\n\nexport type DispatchStatePromise = React.Dispatch<ReducerState>\n\nexport type AppRouterActionQueue = {\n  state: AppRouterState\n  dispatch: (payload: ReducerActions, setState: DispatchStatePromise) => void\n  action: (state: AppRouterState, action: ReducerActions) => ReducerState\n\n  pending: ActionQueueNode | null\n  needsRefresh?: boolean\n  last: ActionQueueNode | null\n}\n\nexport type GlobalErrorState = [\n  GlobalError: GlobalErrorComponent,\n  styles: React.ReactNode,\n]\n\nexport type ActionQueueNode = {\n  payload: ReducerActions\n  next: ActionQueueNode | null\n  resolve: (value: ReducerState) => void\n  reject: (err: Error) => void\n  discarded?: boolean\n}\n\nfunction runRemainingActions(\n  actionQueue: AppRouterActionQueue,\n  settledAction: ActionQueueNode,\n  setState: DispatchStatePromise\n) {\n  // Only advance the queue if the settled action is still at its head. If a\n  // navigation discarded this action, the navigation took its place and is\n  // still in flight — starting the next queued action now would run it\n  // against router state that doesn't include the navigation yet.\n  if (actionQueue.pending === settledAction) {\n    actionQueue.pending = settledAction.next\n    if (actionQueue.pending !== null) {\n      runAction({\n        actionQueue,\n        action: actionQueue.pending,\n        setState,\n      })\n      return\n    }\n  }\n\n  if (actionQueue.pending === null && actionQueue.needsRefresh) {\n    // The queue is idle; flush the refresh requested by a discarded server\n    // action that revalidated data.\n    actionQueue.needsRefresh = false\n    actionQueue.dispatch({ type: ACTION_REFRESH }, setState)\n  }\n}\n\nasync function runAction({\n  actionQueue,\n  action,\n  setState,\n}: {\n  actionQueue: AppRouterActionQueue\n  action: ActionQueueNode\n  setState: DispatchStatePromise\n}) {\n  const prevState = actionQueue.state\n\n  actionQueue.pending = action\n\n  const payload = action.payload\n  const actionResult = actionQueue.action(prevState, payload)\n\n  function handleResult(nextState: AppRouterState) {\n    // if we discarded this action, the state should also be discarded\n    if (action.discarded) {\n      // Check if the discarded server action revalidated data\n      if (\n        action.payload.type === ACTION_SERVER_ACTION &&\n        action.payload.didRevalidate\n      ) {\n        // The server action was discarded but it revalidated data,\n        // mark that we need to refresh after all actions complete\n        actionQueue.needsRefresh = true\n      }\n      // This can't advance the queue (this action is no longer its head), but\n      // if the queue has already drained, it flushes the refresh now.\n      runRemainingActions(actionQueue, action, setState)\n      return\n    }\n\n    actionQueue.state = nextState\n\n    runRemainingActions(actionQueue, action, setState)\n    action.resolve(nextState)\n  }\n\n  // if the action is a promise, set up a callback to resolve it\n  if (isThenable(actionResult)) {\n    actionResult.then(handleResult, (err) => {\n      runRemainingActions(actionQueue, action, setState)\n      action.reject(err)\n    })\n  } else {\n    handleResult(actionResult)\n  }\n}\n\nfunction dispatchAction(\n  actionQueue: AppRouterActionQueue,\n  payload: ReducerActions,\n  setState: DispatchStatePromise\n) {\n  let resolvers: {\n    resolve: (value: ReducerState) => void\n    reject: (reason: any) => void\n  } = { resolve: setState, reject: () => {} }\n\n  // most of the action types are async with the exception of restore\n  // it's important that restore is handled quickly since it's fired on the popstate event\n  // and we don't want to add any delay on a back/forward nav\n  // this only creates a promise for the async actions\n  if (payload.type !== ACTION_RESTORE) {\n    // Create the promise and assign the resolvers to the object.\n    const deferredPromise = new Promise<AppRouterState>((resolve, reject) => {\n      resolvers = { resolve, reject }\n    })\n\n    startTransition(() => {\n      // we immediately notify React of the pending promise -- the resolver is attached to the action node\n      // and will be called when the associated action promise resolves\n      setState(deferredPromise)\n    })\n  }\n\n  const newAction: ActionQueueNode = {\n    payload,\n    next: null,\n    resolve: resolvers.resolve,\n    reject: resolvers.reject,\n  }\n\n  // Check if the queue is empty\n  if (actionQueue.pending === null) {\n    // The queue is empty, so add the action and start it immediately\n    // Mark this action as the last in the queue\n    actionQueue.last = newAction\n\n    runAction({\n      actionQueue,\n      action: newAction,\n      setState,\n    })\n  } else if (\n    payload.type === ACTION_NAVIGATE ||\n    payload.type === ACTION_RESTORE\n  ) {\n    // Navigations (including back/forward) take priority over any pending actions.\n    // Mark the pending action as discarded (so the state is never applied) and start the navigation action immediately.\n    actionQueue.pending.discarded = true\n\n    // The rest of the current queue should still execute after this navigation.\n    // (Note that it can't contain any earlier navigations, because we always put those into `actionQueue.pending` by calling `runAction`)\n    newAction.next = actionQueue.pending.next\n\n    if (actionQueue.last === actionQueue.pending) {\n      actionQueue.last = newAction\n    }\n\n    runAction({\n      actionQueue,\n      action: newAction,\n      setState,\n    })\n  } else {\n    // The queue is not empty, so add the action to the end of the queue\n    // It will be started by runRemainingActions after the previous action finishes\n    if (actionQueue.last !== null) {\n      actionQueue.last.next = newAction\n    }\n    actionQueue.last = newAction\n  }\n}\n\nlet globalActionQueue: AppRouterActionQueue | null = null\n\nexport function createMutableActionQueue(\n  initialState: AppRouterState\n): AppRouterActionQueue {\n  const actionQueue: AppRouterActionQueue = {\n    state: initialState,\n    dispatch: (payload: ReducerActions, setState: DispatchStatePromise) =>\n      dispatchAction(actionQueue, payload, setState),\n    action: async (state: AppRouterState, action: ReducerActions) => {\n      const result = reducer(state, action)\n      return result\n    },\n    pending: null,\n    last: null,\n  }\n\n  if (typeof window !== 'undefined') {\n    // The action queue is lazily created on hydration, but after that point\n    // it doesn't change. So we can store it in a global rather than pass\n    // it around everywhere via props/context.\n    if (globalActionQueue !== null) {\n      throw new Error(\n        'Internal Next.js Error: createMutableActionQueue was called more ' +\n          'than once'\n      )\n    }\n    globalActionQueue = actionQueue\n  }\n\n  return actionQueue\n}\n\nexport function getCurrentAppRouterState(): AppRouterState | null {\n  return globalActionQueue !== null ? globalActionQueue.state : null\n}\n\nfunction getAppRouterActionQueue(): AppRouterActionQueue {\n  if (globalActionQueue === null) {\n    throw new Error(\n      'Internal Next.js error: Router action dispatched before initialization.'\n    )\n  }\n  return globalActionQueue\n}\n\nexport function dispatchNavigateAction(\n  href: string,\n  navigateType: NavigateAction['navigateType'],\n  scrollBehavior: ScrollBehavior,\n  linkInstanceRef: LinkInstance | null,\n  transitionTypes: string[] | undefined,\n  prefetchIntent: RouterTransitionPrefetchIntent | null\n): void {\n  // TODO: This stuff could just go into the reducer. Leaving as-is for now\n  // since we're about to rewrite all the router reducer stuff anyway.\n\n  if (transitionTypes) {\n    for (const type of transitionTypes) {\n      addTransitionType(type)\n    }\n  }\n\n  const url = new URL(addBasePath(href), location.href)\n  if (process.env.__NEXT_APP_NAV_FAIL_HANDLING) {\n    window.next.__pendingUrl = url\n  }\n\n  setLinkForCurrentNavigation(linkInstanceRef)\n  startRouterTransition(\n    href,\n    navigateType,\n    getAppRouterActionQueue().state.tree,\n    prefetchIntent\n  )\n\n  dispatchAppRouterAction({\n    type: ACTION_NAVIGATE,\n    url,\n    isExternalUrl: isExternalURL(url),\n    locationSearch: location.search,\n    scrollBehavior,\n    navigateType,\n  })\n}\n\nexport function dispatchTraverseAction(\n  href: string,\n  historyState: AppHistoryState | undefined\n) {\n  startRouterTransition(\n    href,\n    'traverse',\n    getAppRouterActionQueue().state.tree,\n    null\n  )\n  dispatchAppRouterAction({\n    type: ACTION_RESTORE,\n    url: new URL(href),\n    historyState,\n  })\n}\n\n/**\n * (Experimental) Perform a gesture navigation. This dispatches through React's\n * useOptimistic instead of the main action queue, allowing the state to be\n * shown during a gesture transition and discarded when the canonical navigation\n * completes.\n *\n * Only available when experimental.gestureTransition is enabled.\n */\nfunction gesturePush(href: string, options?: NavigateOptions): void {\n  if (process.env.__NEXT_GESTURE_TRANSITION) {\n    // TODO: Trigger a prefetch so the cache starts populating if there isn't\n    // already a prefetch for this route.\n    if (isJavaScriptURLString(href)) {\n      throw new Error(\n        'Next.js has blocked a javascript: URL as a security precaution.'\n      )\n    }\n\n    const state = getCurrentAppRouterState()\n    if (state === null) {\n      return\n    }\n    const url = new URL(addBasePath(href), location.href)\n    if (isExternalURL(url)) {\n      return\n    }\n\n    // Fork the router state for the duration of the gesture transition.\n    const currentUrl = new URL(state.canonicalUrl, location.href)\n    const scrollBehavior =\n      options?.scroll === false\n        ? ScrollBehavior.NoScroll\n        : ScrollBehavior.Default\n    // This is a special freshness policy that prevents dynamic requests from\n    // being spawned. During the gesture, we should only show the cached\n    // prefetched UI, not dynamic data.\n    // TODO: In the case of navigations to an unknown route, this will still\n    // end up performing a dynamic request. The plan is to do prefetch instead.\n    // There's a separate TODO for this.\n    const freshnessPolicy = FreshnessPolicy.Gesture\n    const forkedGestureState = navigate(\n      state,\n      url,\n      currentUrl,\n      state.renderedSearch,\n      state.cache,\n      state.tree,\n      state.nextUrl,\n      freshnessPolicy,\n      scrollBehavior,\n      'push'\n    )\n    dispatchGestureState(forkedGestureState)\n  }\n}\n\n// Tracks the newest HMR refresh generation so that a newer refresh can abort\n// the request of the one it supersedes. Development only.\nlet activeHmrRefreshController: AbortController | null = null\n\n/**\n * The app router that is exposed through `useRouter`. These are public API\n * methods. Internal Next.js code should call the lower level methods directly\n * (although there's lots of existing code that doesn't do that).\n */\nexport const publicAppRouterInstance: AppRouterInstance = {\n  back: () => window.history.back(),\n  forward: () => window.history.forward(),\n  prefetch:\n    // Unlike the old implementation, the Segment Cache doesn't store its\n    // data in the router reducer state; it writes into a global mutable\n    // cache. So we don't need to dispatch an action.\n    (href: string, options?: PrefetchOptions) => {\n      if (isJavaScriptURLString(href)) {\n        throw new Error(\n          'Next.js has blocked a javascript: URL as a security precaution.'\n        )\n      }\n      const actionQueue = getAppRouterActionQueue()\n      const prefetchKind = options?.kind ?? PrefetchKind.AUTO\n\n      // We don't currently offer a way to issue a runtime prefetch via `router.prefetch()`.\n      // This will be possible when we update its API to not take a PrefetchKind.\n      let fetchStrategy: PrefetchTaskFetchStrategy\n      switch (prefetchKind) {\n        case PrefetchKind.AUTO: {\n          // We default to PPR. We'll discover whether or not the route supports it with the initial prefetch.\n          fetchStrategy = FetchStrategy.PPR\n          break\n        }\n        case PrefetchKind.FULL: {\n          fetchStrategy = FetchStrategy.Full\n          break\n        }\n        default: {\n          prefetchKind satisfies never\n          // Despite typescript thinking that this can't happen,\n          // we might get an unexpected value from user code.\n          // We don't know what they want, but we know they want a prefetch,\n          // so use the default.\n          fetchStrategy = FetchStrategy.PPR\n        }\n      }\n\n      prefetchWithSegmentCache(\n        href,\n        actionQueue.state.nextUrl,\n        actionQueue.state.tree,\n        fetchStrategy,\n        options?.onInvalidate ?? null\n      )\n    },\n  replace: (href: string, options?: NavigateOptions) => {\n    if (isJavaScriptURLString(href)) {\n      throw new Error(\n        'Next.js has blocked a javascript: URL as a security precaution.'\n      )\n    }\n    startTransition(() => {\n      dispatchNavigateAction(\n        href,\n        'replace',\n        options?.scroll === false\n          ? ScrollBehavior.NoScroll\n          : ScrollBehavior.Default,\n        null,\n        options?.transitionTypes,\n        null\n      )\n    })\n  },\n  push: (href: string, options?: NavigateOptions) => {\n    if (isJavaScriptURLString(href)) {\n      throw new Error(\n        'Next.js has blocked a javascript: URL as a security precaution.'\n      )\n    }\n    startTransition(() => {\n      dispatchNavigateAction(\n        href,\n        'push',\n        options?.scroll === false\n          ? ScrollBehavior.NoScroll\n          : ScrollBehavior.Default,\n        null,\n        options?.transitionTypes,\n        null\n      )\n    })\n  },\n  refresh: () => {\n    startTransition(() => {\n      dispatchAppRouterAction({\n        type: ACTION_REFRESH,\n      })\n    })\n  },\n  hmrRefresh: () => {\n    if (process.env.NODE_ENV !== 'development') {\n      throw new Error(\n        'hmrRefresh can only be used in development mode. Please use refresh instead.'\n      )\n    } else {\n      // Reset the known routes table so that route predictions are cleared\n      // when routes change during development.\n      resetKnownRoutes()\n      let signal: AbortSignal | undefined\n      if (process.env.__NEXT_SERVER_COMPONENTS_HMR_CANCELLATION) {\n        // Abort the superseded generation before scheduling the new one, so its\n        // request is torn down as early as possible. Halting (not rejecting)\n        // makes the abort safe regardless of order.\n        activeHmrRefreshController?.abort()\n        activeHmrRefreshController = new AbortController()\n        signal = activeHmrRefreshController.signal\n      }\n      startTransition(() => {\n        dispatchAppRouterAction({\n          type: ACTION_HMR_REFRESH,\n          signal,\n        })\n      })\n    }\n  },\n  // Default value. Each route segment provides its own value at runtime. Refer\n  // to `useRouter()`.\n  bfcacheId: '0',\n}\n\n// Conditionally add experimental_gesturePush when gestureTransition is enabled\nif (process.env.__NEXT_GESTURE_TRANSITION) {\n  ;(publicAppRouterInstance as any).experimental_gesturePush = gesturePush\n}\n\n// Exists for debugging purposes. Don't use in application code.\nif (typeof window !== 'undefined' && window.next) {\n  window.next.router = publicAppRouterInstance\n}\n"],"names":["ACTION_REFRESH","ACTION_SERVER_ACTION","ACTION_NAVIGATE","ACTION_RESTORE","ACTION_HMR_REFRESH","PrefetchKind","ScrollBehavior","reducer","addTransitionType","startTransition","isThenable","FetchStrategy","prefetch","prefetchWithSegmentCache","navigate","dispatchAppRouterAction","dispatchGestureState","resetKnownRoutes","FreshnessPolicy","addBasePath","isExternalURL","setLinkForCurrentNavigation","isJavaScriptURLString","startRouterTransition","runRemainingActions","actionQueue","settledAction","setState","pending","next","runAction","action","needsRefresh","dispatch","type","prevState","state","payload","actionResult","handleResult","nextState","discarded","didRevalidate","resolve","then","err","reject","dispatchAction","resolvers","deferredPromise","Promise","newAction","last","globalActionQueue","createMutableActionQueue","initialState","result","window","Error","getCurrentAppRouterState","getAppRouterActionQueue","dispatchNavigateAction","href","navigateType","scrollBehavior","linkInstanceRef","transitionTypes","prefetchIntent","url","URL","location","process","env","__NEXT_APP_NAV_FAIL_HANDLING","__pendingUrl","tree","isExternalUrl","locationSearch","search","dispatchTraverseAction","historyState","gesturePush","options","__NEXT_GESTURE_TRANSITION","currentUrl","canonicalUrl","scroll","NoScroll","Default","freshnessPolicy","Gesture","forkedGestureState","renderedSearch","cache","nextUrl","activeHmrRefreshController","publicAppRouterInstance","back","history","forward","prefetchKind","kind","AUTO","fetchStrategy","PPR","FULL","Full","onInvalidate","replace","push","refresh","hmrRefresh","NODE_ENV","signal","__NEXT_SERVER_COMPONENTS_HMR_CANCELLATION","abort","AbortController","bfcacheId","experimental_gesturePush","router"],"mappings":"AAAA,SAIEA,cAAc,EACdC,oBAAoB,EACpBC,eAAe,EACfC,cAAc,EAEdC,kBAAkB,EAClBC,YAAY,EACZC,cAAc,QAET,wCAAuC;AAC9C,SAASC,OAAO,QAAQ,kCAAiC;AACzD,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,QAAO;AAC1D,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SACEC,aAAa,QAER,wBAAuB;AAC9B,SAASC,YAAYC,wBAAwB,QAAQ,2BAA0B;AAC/E,SAASC,QAAQ,QAAQ,6BAA4B;AACrD,SACEC,uBAAuB,EACvBC,oBAAoB,QACf,qBAAoB;AAC3B,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC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