{"version":3,"file":"Match.cjs","names":["Solid","createControlledPromise","getLocationChangeInfo","invariant","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","getNotFound","nearestMatchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","NearestMatchContext","Component","value","children","Match","props","matchId","router","match","createMemo","id","undefined","stores","activeMatchStoresById","get","state","rawMatchState","currentMatch","routeId","parentRouteId","routesById","parentRoute","ssr","_displayPending","hasPendingMatch","currentRouteId","Boolean","pendingRouteIds","nearestMatch","hasPending","_$createComponent","Show","when","currentMatchState","route","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","ResolvedSuspenseBoundary","Loading","ResolvedCatchBoundary","ResolvedNotFoundBoundary","ShellComponent","shellComponent","fallback","_$memo","getResetKey","loadedAt","error","Error","notFoundError","process","env","NODE_ENV","console","warn","_$mergeProps","Switch","MatchInner","OnRendered","scrollRestoration","lastOnRenderedKey","WeakMap","location","resolvedLocation","__TSR_key","locationState","resolvedLocationState","createEffect","const","currentLocationState","currentResolvedLocationState","set","emit","type","useContext","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","Comp","defaultComponent","OutComponent","C","Outlet","RenderOut","keyedOut","keyed","_key","_","displayPendingResult","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","pendingMinMs","untrack","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","matchError","_routeId","RouteErrorComponent","info","componentStack","nearestParentMatch","parentMatch","parentGlobalNotFound","globalNotFound","childMatchId","childMatchIdByRouteId","childRouteId","childRoute","childPendingComponent","childMatchStatus","shouldShowNotFound","resolvedRoute","childMatchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n  createControlledPromise,\n  getLocationChangeInfo,\n  invariant,\n  isNotFound,\n  isRedirect,\n  rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound, getNotFound } from './not-found'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n  value: any\n  children?: any\n}>\n\nexport const Match = (props: { matchId: string }) => {\n  const router = useRouter()\n\n  const match = Solid.createMemo(() => {\n    const id = props.matchId\n    if (!id) return undefined\n    return router.stores.activeMatchStoresById.get(id)?.state\n  })\n\n  const rawMatchState = Solid.createMemo(() => {\n    const currentMatch = match()\n    if (!currentMatch) {\n      return null\n    }\n\n    const routeId = currentMatch.routeId as string\n    const parentRouteId = (router.routesById[routeId] as AnyRoute)?.parentRoute\n      ?.id\n\n    return {\n      matchId: currentMatch.id,\n      routeId,\n      ssr: currentMatch.ssr,\n      _displayPending: currentMatch._displayPending,\n      parentRouteId: parentRouteId as string | undefined,\n    }\n  })\n\n  const hasPendingMatch = Solid.createMemo(() => {\n    const currentRouteId = rawMatchState()?.routeId\n    return currentRouteId\n      ? Boolean(router.stores.pendingRouteIds.state[currentRouteId])\n      : false\n  })\n  const nearestMatch = {\n    matchId: () => rawMatchState()?.matchId,\n    routeId: () => rawMatchState()?.routeId,\n    match,\n    hasPending: hasPendingMatch,\n  }\n\n  return (\n    <Solid.Show when={rawMatchState()}>\n      {(currentMatchState) => {\n        const route = Solid.createMemo(\n          () => router.routesById[currentMatchState().routeId] as AnyRoute,\n        )\n\n        const resolvePendingComponent = Solid.createMemo(\n          () =>\n            route().options.pendingComponent ??\n            router.options.defaultPendingComponent,\n        )\n\n        const routeErrorComponent = Solid.createMemo(\n          () =>\n            route().options.errorComponent ??\n            router.options.defaultErrorComponent,\n        )\n\n        const routeOnCatch = Solid.createMemo(\n          () => route().options.onCatch ?? router.options.defaultOnCatch,\n        )\n\n        const routeNotFoundComponent = Solid.createMemo(() =>\n          route().isRoot\n            ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n              (route().options.notFoundComponent ??\n              router.options.notFoundRoute?.options.component)\n            : route().options.notFoundComponent,\n        )\n\n        const resolvedNoSsr = Solid.createMemo(\n          () =>\n            currentMatchState().ssr === false ||\n            currentMatchState().ssr === 'data-only',\n        )\n\n        const ResolvedSuspenseBoundary = Solid.createMemo(() =>\n          resolvedNoSsr() ? SafeFragment : Solid.Loading,\n        )\n\n        const ResolvedCatchBoundary = Solid.createMemo(() =>\n          routeErrorComponent() ? CatchBoundary : SafeFragment,\n        )\n\n        const ResolvedNotFoundBoundary = Solid.createMemo(() =>\n          routeNotFoundComponent() ? CatchNotFound : SafeFragment,\n        )\n\n        const ShellComponent = Solid.createMemo(() =>\n          route().isRoot\n            ? ((route().options as RootRouteOptions).shellComponent ??\n              SafeFragment)\n            : SafeFragment,\n        )\n\n        return (\n          <Dynamic component={ShellComponent()}>\n            <NearestMatchContext value={nearestMatch}>\n              <Dynamic\n                component={ResolvedSuspenseBoundary()}\n                fallback={\n                  // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n                  (isServer ?? router.isServer) &&\n                  resolvedNoSsr() ? undefined : (\n                    <Dynamic component={resolvePendingComponent()} />\n                  )\n                }\n              >\n                <Dynamic\n                  component={ResolvedCatchBoundary()}\n                  getResetKey={() => router.stores.loadedAt.state}\n                  errorComponent={routeErrorComponent() || ErrorComponent}\n                  onCatch={(error: Error) => {\n                    // Forward not found errors (we don't want to show the error component for these)\n                    const notFoundError = getNotFound(error)\n                    if (notFoundError) {\n                      notFoundError.routeId ??= currentMatchState()\n                        .routeId as any\n                      throw notFoundError\n                    }\n                    if (process.env.NODE_ENV !== 'production') {\n                      console.warn(\n                        `Warning: Error in route match: ${currentMatchState().routeId}`,\n                      )\n                    }\n                    routeOnCatch()?.(error)\n                  }}\n                >\n                  <Dynamic\n                    component={ResolvedNotFoundBoundary()}\n                    fallback={(error: any) => {\n                      const notFoundError = getNotFound(error) ?? error\n\n                      notFoundError.routeId ??= currentMatchState()\n                        .routeId as any\n\n                      // If the current not found handler doesn't exist or it has a\n                      // route ID which doesn't match the current route, rethrow the error\n                      if (\n                        !routeNotFoundComponent() ||\n                        (notFoundError.routeId &&\n                          notFoundError.routeId !==\n                            currentMatchState().routeId) ||\n                        (!notFoundError.routeId && !route().isRoot)\n                      )\n                        throw notFoundError\n\n                      return (\n                        <Dynamic\n                          component={routeNotFoundComponent()}\n                          {...notFoundError}\n                        />\n                      )\n                    }}\n                  >\n                    <Solid.Switch>\n                      <Solid.Match when={resolvedNoSsr()}>\n                        <Solid.Show\n                          when={!(isServer ?? router.isServer)}\n                          fallback={\n                            <Dynamic component={resolvePendingComponent()} />\n                          }\n                        >\n                          <MatchInner />\n                        </Solid.Show>\n                      </Solid.Match>\n                      <Solid.Match when={!resolvedNoSsr()}>\n                        <MatchInner />\n                      </Solid.Match>\n                    </Solid.Switch>\n                  </Dynamic>\n                </Dynamic>\n              </Dynamic>\n            </NearestMatchContext>\n\n            {currentMatchState().parentRouteId === rootRouteId ? (\n              <>\n                <OnRendered />\n                {router.options.scrollRestoration &&\n                (isServer ?? router.isServer) ? (\n                  <ScrollRestoration />\n                ) : null}\n              </>\n            ) : null}\n          </Dynamic>\n        )\n      }}\n    </Solid.Show>\n  )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\n//\n// In Solid, createEffect(source, fn) fires on initial mount as well as on\n// reactive changes. OnRendered can also remount when the first child route\n// changes (e.g. navigating from / to /posts). We deduplicate by tracking\n// the last emitted resolvedLocation key per router so each unique resolved\n// location only triggers one onRendered event regardless of remounts.\nconst lastOnRenderedKey = new WeakMap<object, string>()\n\nfunction OnRendered() {\n  const router = useRouter()\n\n  const location = Solid.createMemo(\n    () => router.stores.resolvedLocation.state?.state.__TSR_key,\n  )\n  const locationState = Solid.createMemo(() => router.stores.location.state)\n  const resolvedLocationState = Solid.createMemo(\n    () => router.stores.resolvedLocation.state,\n  )\n  Solid.createEffect(\n    () => [location(), locationState(), resolvedLocationState()] as const,\n    ([location, currentLocationState, currentResolvedLocationState]) => {\n      if (!location) return\n      if (lastOnRenderedKey.get(router) === location) return\n      lastOnRenderedKey.set(router, location)\n      router.emit({\n        type: 'onRendered',\n        ...getLocationChangeInfo(\n          currentLocationState,\n          currentResolvedLocationState,\n        ),\n      })\n    },\n  )\n  return null\n}\n\nexport const MatchInner = (): any => {\n  const router = useRouter()\n  const match = Solid.useContext(nearestMatchContext).match\n\n  const rawMatchState = Solid.createMemo(() => {\n    const currentMatch = match()\n    if (!currentMatch) {\n      return null\n    }\n\n    const routeId = currentMatch.routeId as string\n\n    const remountFn =\n      (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n      router.options.defaultRemountDeps\n    const remountDeps = remountFn?.({\n      routeId,\n      loaderDeps: currentMatch.loaderDeps,\n      params: currentMatch._strictParams,\n      search: currentMatch._strictSearch,\n    })\n    const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n    return {\n      key,\n      routeId,\n      match: {\n        id: currentMatch.id,\n        status: currentMatch.status,\n        error: currentMatch.error,\n        _forcePending: currentMatch._forcePending ?? false,\n        _displayPending: currentMatch._displayPending ?? false,\n      },\n    }\n  })\n\n  return (\n    <Solid.Show when={rawMatchState()}>\n      {(currentMatchState) => {\n        const route = Solid.createMemo(\n          () => router.routesById[currentMatchState().routeId]!,\n        )\n\n        const currentMatch = Solid.createMemo(() => currentMatchState().match)\n\n        const componentKey = Solid.createMemo(\n          () => currentMatchState().key ?? currentMatchState().match.id,\n        )\n\n        const Comp = Solid.createMemo(\n          () => route().options.component ?? router.options.defaultComponent,\n        )\n\n        const OutComponent = Solid.createMemo(() => {\n          const C = Comp()\n          return C || Outlet\n        })\n\n        const RenderOut = () => <Dynamic component={OutComponent()} />\n\n        const keyedOut = () => (\n          <Solid.Show when={componentKey()} keyed>\n            {(_key) => <RenderOut />}\n          </Solid.Show>\n        )\n\n        return (\n          <Solid.Switch>\n            <Solid.Match when={currentMatch()._displayPending}>\n              {(_) => {\n                const displayPendingResult = Solid.createMemo(\n                  () =>\n                    router.getMatch(currentMatch().id)?._nonReactive\n                      .displayPendingPromise,\n                )\n\n                return <>{displayPendingResult()}</>\n              }}\n            </Solid.Match>\n            <Solid.Match when={currentMatch()._forcePending}>\n              {(_) => {\n                const minPendingResult = Solid.createMemo(\n                  () =>\n                    router.getMatch(currentMatch().id)?._nonReactive\n                      .minPendingPromise,\n                )\n\n                return <>{minPendingResult()}</>\n              }}\n            </Solid.Match>\n            <Solid.Match when={currentMatch().status === 'pending'}>\n              {(_) => {\n                const pendingMinMs = Solid.untrack(\n                  () =>\n                    route().options.pendingMinMs ??\n                    router.options.defaultPendingMinMs,\n                )\n\n                if (pendingMinMs) {\n                  const routerMatch = Solid.untrack(() =>\n                    router.getMatch(currentMatch().id),\n                  )\n                  if (\n                    routerMatch &&\n                    !routerMatch._nonReactive.minPendingPromise\n                  ) {\n                    // Create a promise that will resolve after the minPendingMs\n                    if (!(isServer ?? router.isServer)) {\n                      const minPendingPromise = createControlledPromise<void>()\n\n                      routerMatch._nonReactive.minPendingPromise =\n                        minPendingPromise\n\n                      setTimeout(() => {\n                        minPendingPromise.resolve()\n                        // We've handled the minPendingPromise, so we can delete it\n                        routerMatch._nonReactive.minPendingPromise = undefined\n                      }, pendingMinMs)\n                    }\n                  }\n                }\n\n                const loaderResult = Solid.createMemo(async () => {\n                  await new Promise((r) => setTimeout(r, 0))\n                  return router.getMatch(currentMatch().id)?._nonReactive\n                    .loadPromise\n                })\n\n                const FallbackComponent = Solid.untrack(\n                  () =>\n                    route().options.pendingComponent ??\n                    router.options.defaultPendingComponent,\n                )\n\n                return (\n                  <>\n                    {FallbackComponent && pendingMinMs > 0 ? (\n                      <Dynamic component={FallbackComponent} />\n                    ) : null}\n                    {loaderResult()}\n                  </>\n                )\n              }}\n            </Solid.Match>\n            <Solid.Match when={currentMatch().status === 'notFound'}>\n              {(_) => {\n                const matchError = Solid.untrack(() => currentMatch().error)\n                if (!isNotFound(matchError)) {\n                  if (process.env.NODE_ENV !== 'production') {\n                    throw new Error(\n                      'Invariant failed: Expected a notFound error',\n                    )\n                  }\n                  invariant()\n                }\n\n                // Use Show with keyed to ensure re-render when routeId changes\n                return (\n                  <Solid.Show when={currentMatchState().routeId} keyed>\n                    {(_routeId) =>\n                      Solid.untrack(() =>\n                        renderRouteNotFound(router, route(), matchError),\n                      )\n                    }\n                  </Solid.Show>\n                )\n              }}\n            </Solid.Match>\n            <Solid.Match when={currentMatch().status === 'redirected'}>\n              {(_) => {\n                const matchError = Solid.untrack(() => currentMatch().error)\n                if (!isRedirect(matchError)) {\n                  if (process.env.NODE_ENV !== 'production') {\n                    throw new Error(\n                      'Invariant failed: Expected a redirect error',\n                    )\n                  }\n                  invariant()\n                }\n\n                return null\n              }}\n            </Solid.Match>\n            <Solid.Match when={currentMatch().status === 'error'}>\n              {(_) => {\n                const matchError = Solid.untrack(() => currentMatch().error)\n                if (isServer ?? router.isServer) {\n                  const RouteErrorComponent =\n                    (route().options.errorComponent ??\n                      router.options.defaultErrorComponent) ||\n                    ErrorComponent\n\n                  return (\n                    <RouteErrorComponent\n                      error={matchError}\n                      info={{\n                        componentStack: '',\n                      }}\n                    />\n                  )\n                }\n\n                throw matchError\n              }}\n            </Solid.Match>\n            <Solid.Match when={currentMatch().status === 'success'}>\n              {keyedOut()}\n            </Solid.Match>\n          </Solid.Switch>\n        )\n      }}\n    </Solid.Show>\n  )\n}\n\nexport const Outlet = () => {\n  const router = useRouter()\n  const nearestParentMatch = Solid.useContext(nearestMatchContext)\n  const parentMatch = nearestParentMatch.match\n  const routeId = nearestParentMatch.routeId\n  const route = Solid.createMemo(() =>\n    routeId() ? router.routesById[routeId()!] : undefined,\n  )\n\n  const parentGlobalNotFound = Solid.createMemo(\n    () => parentMatch()?.globalNotFound ?? false,\n  )\n\n  const childMatchId = Solid.createMemo(() => {\n    const currentRouteId = routeId()\n    return currentRouteId\n      ? router.stores.childMatchIdByRouteId.state[currentRouteId]\n      : undefined\n  })\n\n  const childRouteId = Solid.createMemo(() => {\n    const id = childMatchId()\n    if (!id) return undefined\n    return router.stores.activeMatchStoresById.get(id)?.state.routeId\n  })\n\n  const childRoute = Solid.createMemo(() => {\n    const id = childRouteId()\n    return id ? (router.routesById[id] as AnyRoute) : undefined\n  })\n\n  const childPendingComponent = Solid.createMemo(\n    () =>\n      childRoute()?.options.pendingComponent ??\n      router.options.defaultPendingComponent,\n  )\n\n  const childMatchStatus = Solid.createMemo(() => {\n    const id = childMatchId()\n    if (!id) return undefined\n    return router.stores.activeMatchStoresById.get(id)?.state.status\n  })\n\n  // Only show not-found if we're not in a redirected state\n  const shouldShowNotFound = () =>\n    childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n  return (\n    <Solid.Show\n      when={!shouldShowNotFound() && childMatchId()}\n      fallback={\n        <Solid.Show when={shouldShowNotFound() && route()}>\n          {(resolvedRoute) =>\n            Solid.untrack(() =>\n              renderRouteNotFound(router, resolvedRoute(), undefined),\n            )\n          }\n        </Solid.Show>\n      }\n    >\n      {(childMatchIdAccessor) => {\n        const currentMatchId = Solid.createMemo(() => childMatchIdAccessor())\n\n        return (\n          <Solid.Show\n            when={routeId() === rootRouteId}\n            fallback={<Match matchId={currentMatchId()} />}\n          >\n            <Solid.Show when={childRouteId()} keyed>\n              {(_routeId) => (\n                <Solid.Loading\n                  fallback={\n                    childPendingComponent() ? (\n                      <Dynamic component={childPendingComponent()} />\n                    ) : null\n                  }\n                >\n                  <Match matchId={currentMatchId()} />\n                </Solid.Loading>\n              )}\n            </Solid.Show>\n          </Solid.Show>\n        )\n      }}\n    </Solid.Show>\n  )\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAMoB,sBAAsBN,qBAAAA;AAK5B,IAAaU,SAASC,UAA+B;CACnD,MAAME,SAAShB,kBAAAA,WAAW;CAE1B,MAAMiB,QAAQ5B,SAAM6B,iBAAiB;EACnC,MAAMC,KAAKL,MAAMC;AACjB,MAAI,CAACI,GAAI,QAAOC,KAAAA;AAChB,SAAOJ,OAAOK,OAAOC,sBAAsBC,IAAIJ,GAAG,EAAEK;GACpD;CAEF,MAAMC,gBAAgBpC,SAAM6B,iBAAiB;EAC3C,MAAMQ,eAAeT,OAAO;AAC5B,MAAI,CAACS,aACH,QAAO;EAGT,MAAMC,UAAUD,aAAaC;EAC7B,MAAMC,gBAAiBZ,OAAOa,WAAWF,UAAuBG,aAC5DX;AAEJ,SAAO;GACLJ,SAASW,aAAaP;GACtBQ;GACAI,KAAKL,aAAaK;GAClBC,iBAAiBN,aAAaM;GACfJ;GAChB;GACD;CAQF,MAAMS,eAAe;EACnBtB,eAAeU,eAAe,EAAEV;EAChCY,eAAeF,eAAe,EAAEE;EAChCV;EACAqB,YAVsBjD,SAAM6B,iBAAiB;GAC7C,MAAMgB,iBAAiBT,eAAe,EAAEE;AACxC,UAAOO,iBACHC,QAAQnB,OAAOK,OAAOe,gBAAgBZ,MAAMU,gBAAgB,GAC5D;IACJ;EAMD;AAED,SAAA,GAAA,aAAA,iBACG7C,SAAMmD,MAAI;EAAA,IAACC,OAAI;AAAA,UAAEhB,eAAe;;EAAAb,WAC7B8B,sBAAsB;GACtB,MAAMC,QAAQtD,SAAM6B,iBACZF,OAAOa,WAAWa,mBAAmB,CAACf,SAC7C;GAED,MAAMiB,0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