{"version":3,"file":"useRoute-BBfRYSpV.mjs","names":["RouterKey","NavigatorKey","RouteKey","HTTP_STATUS_KEY","useRoute","routeContext","inject"],"sources":["../../src/context.ts","../../src/composables/useRoute.ts"],"sourcesContent":["import type { RouteContext as RouteContextType } from \"./types\";\nimport type { HttpStatusSink } from \"./utils/createHttpStatusSink\";\nimport type { Router, Navigator } from \"@real-router/core\";\nimport type { InjectionKey } from \"vue\";\n\nexport const RouterKey: InjectionKey<Router> = Symbol(\"RouterKey\");\n\nexport const NavigatorKey: InjectionKey<Navigator> = Symbol(\"NavigatorKey\");\n\nexport const RouteKey: InjectionKey<RouteContextType> = Symbol(\"RouteKey\");\n\nexport const HTTP_STATUS_KEY: InjectionKey<HttpStatusSink> =\n  Symbol(\"HttpStatusSink\");\n","import { inject } from \"vue\";\n\nimport { RouteKey } from \"../context\";\n\nimport type { RouteContext } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\nimport type { Ref } from \"vue\";\n\n/**\n * Return shape for `useRoute()` — `RouteContext<P>` with `route` narrowed\n * to the non-nullable variant. The composable throws when `route.value`\n * would be `undefined`, so consumers can read `.value.params.x` without a\n * nullable guard. Extracted from inline duplication at two call sites.\n */\nexport type UseRouteReturn<P extends Params = Params> = Omit<\n  RouteContext<P>,\n  \"route\"\n> & { route: Readonly<Ref<State<P>>> };\n\nexport const useRoute = <P extends Params = Params>(): UseRouteReturn<P> => {\n  const routeContext = inject(RouteKey);\n\n  if (!routeContext) {\n    throw new Error(\"useRoute must be used within a RouterProvider\");\n  }\n\n  if (!routeContext.route.value) {\n    throw new Error(\n      \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n    );\n  }\n\n  return routeContext as UseRouteReturn<P>;\n};\n"],"mappings":"A,6BAKA,MAAaA,EAAkC,OAAO,WAAW,EAEpDC,EAAwC,OAAO,cAAc,EAE7DC,EAA2C,OAAO,UAAU,EAE5DC,EACX,OAAO,gBAAgB,ECOZC,MAA+D,CAC1E,IAAMC,EAAeC,EAAOJ,CAAQ,EAEpC,GAAI,CAACG,EACH,MAAU,MAAM,+CAA+C,EAGjE,GAAI,CAACA,EAAa,MAAM,MACtB,MAAU,MACR,mIACF,EAGF,OAAOA,CACT,E"}