{"version":3,"file":"index.umd.cjs","sources":["../../lib/common/unique-id.ts","../../lib/router/match-algorithm/build-root-to-leaf-route-matrix.ts","../../lib/router/match-algorithm/nested-match-route.ts","../../lib/router/build-router/handle-routes-matched-result.ts","../../lib/router/router.v2.ts","../../lib/router/link.ts","../../lib/router/navigate.ts","../../lib/router/match-algorithm/match.ts"],"sourcesContent":["\n\nfunction uniqueId() {\n    return Math.random().toString(36).slice(2, 12);\n}\n\nexport {\n    uniqueId as uniqueId\n}\n","\nimport type { RouteConfig } from \"./match-route.type\";\n\nexport function buildRootToLeafRouteMatrix<R extends RouteConfig = RouteConfig>(routes: R[]): R[][] {\n    const matrix: R[][] = [];\n    const buildMatrix = (routes: R[], acc: R[] = []) => {\n        for (const route of routes) {\n            const newAcc = [...acc, omitKey(route, 'children') as R];\n            if (route.children && route.children.length > 0) {\n                buildMatrix(route.children as R[], newAcc);\n            } else {\n                matrix.push(newAcc);\n            }\n        }\n    };\n    buildMatrix(routes);\n    return matrix;\n}\n  \nfunction omitKeys<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n  const clone = { ...obj };\n  for (const key of keys) {\n    delete clone[key];\n  }\n  return clone;\n}\n\nfunction omitKey(obj: Record<string, any>, key: string) {\n  return omitKeys(obj, [key]);\n}","\nimport { buildRootToLeafRouteMatrix } from \"./build-root-to-leaf-route-matrix\";\nimport { RouteConfig } from \"./match-route.type\";\n\n\nexport function matchRoutePaths(\n  routePathParts: string[],\n  pathParts: string[]\n): { \n  isMatch: boolean; \n  params?: Record<string, string>; \n  isExactMatch?: boolean;\n  firstMatchedParamIndex?: number \n} {\n  const params: Record<string, string> = {};\n  let firstMatchedParamIndex = -1;\n\n  const isMatch = routePathParts.every((part, index) => {\n    if (part.startsWith(':')) {\n      if (pathParts.length <= index) {\n        return false;\n      }\n      if (firstMatchedParamIndex === -1) {\n        firstMatchedParamIndex = index;\n      }\n      params[part.slice(1)] = pathParts[index];\n      return true;\n    }\n    return part === pathParts[index];\n  });\n  const isExactMatch = isMatch && routePathParts.length === pathParts.length;\n  return { isMatch, params, isExactMatch, firstMatchedParamIndex };\n}\n\n\n\nexport interface MatchRouteResult<R extends RouteConfig = RouteConfig> {\n  routes: R[];\n  params: Record<string, string>;\n}\n\nexport interface MatchedRoute<R extends RouteConfig = RouteConfig> {\n  route: R;\n  params: Record<string, string>;\n  routeParts: string[],\n  firstMatchedParamIndex: number\n  children: MatchedRoute<R>[];\n}\n\n\nexport function matchRoute<R extends RouteConfig = RouteConfig>(path: string, routes: R[]): MatchRouteResult<R> {\n  const rootToLeafMatrix = buildRootToLeafRouteMatrix(routes);\n  const pathParts = splitPath(path);\n  const processedMatchedRoutes: {\n    routeParts: {\n      route: R;\n      fullPath: string;\n      routePathParts: string[];\n      isIndex?: boolean;\n    }[];\n    firstMatchedParamIndex: number;\n    matchParams: Record<string, string>;\n  }[] = [];\n\n  for (const pathRootToLeaf of rootToLeafMatrix) {\n    let fullPathToCurrentRoutePart = '/';\n    let firstMatchedParamIndex = -1;\n    const matchParams: Record<string, string> = {};\n    const processedRouteParts: {\n      route: R;\n      fullPath: string;\n      routePathParts: string[];\n      isIndex?: boolean;\n    }[] = [];\n\n    for (const routePart of pathRootToLeaf) {\n      if ('index' in routePart) {\n        const prevRoutePathParts = processedRouteParts.at(-1)?.routePathParts || [];\n        processedRouteParts.push({\n          route: routePart,\n          fullPath: fullPathToCurrentRoutePart,\n          routePathParts: prevRoutePathParts,\n          isIndex: true,\n        });\n        break;\n      } \n      else if ('path' in routePart && routePart.path === '*') {\n        processedRouteParts.push({\n          route: routePart,\n          fullPath: fullPathToCurrentRoutePart,\n          routePathParts: splitPath(fullPathToCurrentRoutePart),\n        });\n        break;\n      } else {\n        fullPathToCurrentRoutePart = resolvePath(fullPathToCurrentRoutePart, routePart.path);\n        const routePathParts = splitPath(fullPathToCurrentRoutePart); //  == '/' ? [''] : fullPathToCurrentRoutePart.split('/');\n        \n        const {\n          isMatch, \n          params: currentMatchParams,\n          firstMatchedParamIndex: currentFirstMatchedParamIndex  \n        } = matchRoutePaths(routePathParts, pathParts);\n\n        if (isMatch) {\n          if (currentMatchParams && Object.keys(currentMatchParams).length) {\n            Object.assign(matchParams, currentMatchParams);\n            if (firstMatchedParamIndex === -1 && currentFirstMatchedParamIndex !== undefined) {\n              firstMatchedParamIndex = currentFirstMatchedParamIndex;\n            }\n          }\n          processedRouteParts.push({\n            route: routePart,\n            fullPath: fullPathToCurrentRoutePart,\n            routePathParts,\n          });\n        } else {\n          break;\n        }\n      }\n    }\n\n    if (processedRouteParts.length) {\n      processedMatchedRoutes.push({\n        routeParts: processedRouteParts,\n        firstMatchedParamIndex,\n        matchParams,\n      });\n    }\n  }\n\n\n  let postProcessedMatchedRoutes = processedMatchedRoutes.map(({\n    routeParts,\n    firstMatchedParamIndex,\n    matchParams\n  }) => {\n    const mostSpecificRoute = routeParts.at(-1);\n    const overallRouteParts = splitPath(mostSpecificRoute?.fullPath); // === '/' ? [''] : mostSpecificRoute?.fullPath.split('/') || [];\n    const depth = overallRouteParts.length;\n    const isFullMatch = depth === pathParts.length;\n    const isExactMatch = firstMatchedParamIndex === -1 && isFullMatch;\n    const isNotFound \n      = mostSpecificRoute \n      && 'path' in mostSpecificRoute?.route \n      && mostSpecificRoute.route.path === '*';\n\n    return {\n      params: matchParams,\n      routeParts,\n      firstMatchedParamIndex,\n      depth,\n      isFullMatch,\n      isExactMatch,\n      isNotFound\n    };\n  });\n\n  const notFoundMatch = postProcessedMatchedRoutes.find(({ isNotFound }) => isNotFound);\n  postProcessedMatchedRoutes = postProcessedMatchedRoutes.filter(({ isNotFound }) => !isNotFound);\n\n  const exactMatch = postProcessedMatchedRoutes.find(({ isExactMatch }) => isExactMatch);\n  if (exactMatch) {\n    return {\n      routes: exactMatch.routeParts.map(({ route }) => route),\n      params: exactMatch.params\n    };\n  }\n\n  const fullMatches = postProcessedMatchedRoutes.find(({ isFullMatch }) => isFullMatch);\n  if (fullMatches) {\n    return {\n      routes: fullMatches.routeParts.map(({ route }) => route),\n      params: fullMatches.params\n    };\n  }\n\n  const mostDepthMatch = postProcessedMatchedRoutes.reduce((acc, curr) => acc.depth > curr.depth ? acc : curr);\n  if (notFoundMatch && (mostDepthMatch.depth <= notFoundMatch.depth)) {\n    return {\n      routes: notFoundMatch.routeParts.map(({ route }) => route),\n      params: notFoundMatch.params\n    };\n  }\n  \n  return {\n    routes: mostDepthMatch.routeParts.map(({ route }) => route),\n    params: mostDepthMatch.params\n  };\n}\n\n\nfunction resolvePath(...pathParts: string[]): string {\n  const trimmedSlashPathParts = pathParts.map((part) => part.replace(/^\\/|\\/$/g, ''));\n  const joinedPath = trimmedSlashPathParts\n    .filter((part) => part.length > 0)\n    .join('/');\n  return `/${joinedPath}`;\n}\n\n\nexport function splitPath(path?: string): string[] {\n  if (path === undefined) {\n    return [];\n  }\n  return path == '/' ? [''] : path.split('/');\n}","\nimport { DOM } from \"@/core/html\";\nimport { isPromise } from \"@/common/is-promise\";\nimport logger from \"@/common/logger/logger\";\nimport { KeyBuilder } from \"@/common/key-builder/key-builder\";\nimport { createElement } from \"@/jsx\";\nimport { render } from '@/core/dom-render/render/core-render';\nimport type { RouteComponentProps, Router, RouteConfig, RouterPushParameters, ShouldEnterCallback } from \"../router.type\";\n\nexport async function handleRoutesMatchedResult(\n    router: Router,\n    routes: RouteConfig[],\n    params: Record<string, string>,\n    path: string,\n    _base: string,\n    memoRenderedRoute: Record<string, HTMLElement | Text | ChildNode[]>,\n    renderKey: KeyBuilder,\n    onRouteChange: () => void\n) {\n    let rootComponentDom: HTMLElement | Text | ChildNode[] | undefined | null = null;\n    let componentDom: HTMLElement | Text | ChildNode[] | undefined;\n    const renderedComponentList: {\n        routeId: string;\n        componentDom: HTMLElement | Text | ChildNode[];\n        componentContainer: HTMLElement | null;\n        memo: boolean;\n    }[] = [];\n\n    for (const [index, route] of routes.entries()) {\n        const currentRouteRenderKey = renderKey.clone();\n        const prevComponentDom = componentDom;\n        const actualShouldEnterResult = await runShouldEnterStage(router, route, path, params);\n\n        // Enforce the shouldEnter result \n        //  - stop the rendering process if the result is not true\n        //  - if the result is an object, navigate to the path \n        if (actualShouldEnterResult != true) {\n            logger.warn(`Route ${'path' in route ? route.path : route.id} should not enter`);\n            if (actualShouldEnterResult && 'path' in actualShouldEnterResult) {\n                const { path, state } = actualShouldEnterResult;\n                setTimeout(() => router.push(path, state));\n            }\n            break;\n        }\n\n        const routeId = route.id + (params ? JSON.stringify(params) : '');\n        const componentContainer: HTMLElement | null = buildRouteContainer(\n            router,\n            index,\n            prevComponentDom,\n            currentRouteRenderKey\n        );\n\n        let renderMatchResult: {\n            routeId: string,\n            componentDom: HTMLElement | Text | ChildNode[],\n            memo: boolean\n        };\n\n        router.matchedRouteId = routeId;\n        const routeSync = route;\n        let currentComponentDom: HTMLElement | Text | ChildNode[];\n        if (route.memo !== false && memoRenderedRoute[routeId]) {\n            currentComponentDom = memoRenderedRoute[routeId];\n            emptyOutComponentOutlet(currentComponentDom);\n            renderMatchResult = {\n                routeId,\n                componentDom: currentComponentDom,\n                memo: true\n            };\n        } else {\n            const loaderResult = await runLoaderStage(route, params, path);\n            const routeComponentProps: RouteComponentProps = {\n                loaderResult,\n                params,\n                state: history.state\n            };\n            const componentVirtualElement = createElement(routeSync.component, routeComponentProps);\n            currentComponentDom = render(componentVirtualElement, componentContainer, currentRouteRenderKey.push(routeId));\n            if(currentComponentDom === componentContainer) {\n                currentComponentDom = DOM.getChildNodes(componentContainer);\n            }\n            memoRenderedRoute[routeId] = currentComponentDom;\n            renderMatchResult = {\n                routeId,\n                componentDom: currentComponentDom,\n                memo: false\n            };\n        }\n\n        const { memo: isMemo } = renderMatchResult;\n        componentDom = renderMatchResult.componentDom;\n        renderedComponentList.push({ routeId, componentDom, componentContainer, memo: isMemo });\n        if (isMemo) {\n            logger.log(`Route ${'path' in route ? route.path : route.id} is memoized`);\n        }\n        if (rootComponentDom === null) {\n            rootComponentDom = componentDom;\n        }\n    }\n\n    // let isFirstNonMemoComponentAttached = false;\n    for (const {\n        // memo, \n        componentDom: componentDomToRender,\n        componentContainer\n    } of renderedComponentList) {\n        // (isFirstNonMemoComponentAttached || !memo) &&\n        if (componentDomToRender && componentContainer) {\n            // isFirstNonMemoComponentAttached = true;\n            componentContainer.innerHTML = '';\n            DOM.appendChild(componentContainer, componentDomToRender);\n        }\n    }\n    if (renderedComponentList.length > 0) {\n        onRouteChange();\n    }\n    return rootComponentDom;\n}\n\nfunction emptyOutComponentOutlet(componentDom: HTMLElement | Text | ChildNode[]) {\n    if (componentDom instanceof Element) {\n        const outlet = componentDom.querySelector('router-outlet');\n        if (outlet) {\n            outlet.innerHTML = '';\n        }\n    } else if (Array.isArray(componentDom)) {\n        componentDom.forEach(node => {\n            if (node instanceof Element) {\n                const outlet = node.querySelector('router-outlet');\n                if (outlet) {\n                    outlet.innerHTML = '';\n                }\n            }\n        });\n    }\n}\n\nfunction buildRouteContainer(\n    router: Router,\n    index: number,\n    prevComponentDom: HTMLElement | Text | ChildNode[] | undefined,\n    currentRouteRenderKey: KeyBuilder\n): HTMLElement {\n    let componentContainer: HTMLElement | null = null;\n    if (index === 0) {\n        componentContainer = router.container;\n    } else if (prevComponentDom && prevComponentDom instanceof HTMLElement) {\n        componentContainer = prevComponentDom.querySelector('router-outlet');\n        if (!componentContainer && prevComponentDom.tagName === 'ROUTER-OUTLET') {\n            componentContainer = prevComponentDom;\n        }\n    }\n\n    return componentContainer\n        || DOM.createElement('router-outlet', currentRouteRenderKey.clone().push('router-outlet'));\n} \n\nasync function runShouldEnterStage(\n    router: Router,\n    route: RouteConfig,\n    path: string,\n    params: Record<string, string>,\n): Promise<Awaited<ReturnType<ShouldEnterCallback>>> {\n    const shouldEnterFunction = route.shouldEnter || function shouldEnterTrue() { return true; }\n    let shouldEnterResult: ReturnType<ShouldEnterCallback>;\n    router.navigateState = {\n        isNavigating: true,\n    };\n    try {\n        shouldEnterResult = shouldEnterFunction({ path, params, state: history.state, router });\n    } catch (error) {\n        logger.warn(`Route ${'path' in route ? route.path : route.id} throws an error on shouldEnter, instead of returning a boolean, prefer handling the error and return false.`);\n        shouldEnterResult = false;\n    }\n\n    let actualShouldEnterResult: Awaited<ReturnType<ShouldEnterCallback>> = false;\n    if (isPromise<boolean | RouterPushParameters>(shouldEnterResult)) {\n        try {\n            actualShouldEnterResult = await shouldEnterResult;\n        } catch (error) {\n            logger.warn(`Route ${'path' in route ? route.path : route.id} should not enter`);\n            actualShouldEnterResult = false;\n        }\n    } else {\n        actualShouldEnterResult = shouldEnterResult;\n    }\n    router.navigateState.isNavigating = false;\n    return actualShouldEnterResult;\n}\n\nasync function runLoaderStage(\n    route: RouteConfig,\n    params: Record<string, string>,\n    path: string,\n): Promise<unknown> {\n    const loaderFunction = route.loader;\n    if (loaderFunction) {\n        const result = loaderFunction({ path, params, state: history.state });\n        if (isPromise(result)) {\n            try {\n                return await result;\n            } catch (error) {\n                logger.warn(`Route ${path} throws an error on loader, instead of returning a component, prefer handling the error and return a component.`);\n                return null;\n            }\n        } else {\n            return result;\n        }\n    }\n}","\nimport logger from \"@/common/logger/logger\";\nimport { uniqueId } from \"@/common/unique-id\";\nimport { getRenderedRoot } from \"@/core/global\";\nimport { createElement } from \"@/jsx\";\nimport { DOM } from \"@/core/html\";\nimport { matchRoute } from \"./match-algorithm/nested-match-route\";\nimport { keyBuilder } from \"@/common/key-builder/key-builder\";\nimport { getActiveContext } from \"@/core/dom-render/component-context/component-context\";\nimport { handleRoutesMatchedResult } from \"./build-router/handle-routes-matched-result\";\nimport type { RootElementWithMetadata } from \"@/core/dom-render/create-root\";\nimport type { VirtualElement } from \"@/types\";\nimport type { Router, RouterConfig, RouteConfig, OnRouteChangeCallback } from \"./router.type\";\n\nconst routersStore: Record<string, Router> = {};\n\ncustomElements.define('app-router', class extends HTMLElement { });\n\ncustomElements.define('router-outlet', class extends HTMLElement { });\n\nconst history = window.history;\n\n/**\n * Get the current router instance\n * @returns The current router instance, must be called within a router context\n * @throws {Error} If called outside of a router context  \n * \n * using {@link Router}\n * \n * @example\n * const router = getRouter();\n * console.log(router);\n * // console logs:\n * // > { container: HTMLElement, push: Function, replace: Function, navigate: Function, ... }\n */\nfunction getRouter(): Router {\n    const renderedRootId = getRenderedRoot();\n    if (!renderedRootId) {\n        throw new Error('Out of a root context');\n    }\n    const router = routersStore[renderedRootId.id];\n    if (!router) {\n        throw new Error('No router found');\n    }\n    return router;\n}\n\n/**\n * Get the params of the current route\n * @returns The params of the current route\n * @throws {Error} If called outside of a router context\n * @example\n * // Assume the current route is '/user/1'\n * // And the route path is defined as '/user/:id',\n * const params = getParams();\n * console.log(params);\n * // console logs:\n * // > { id: '1' }\n */\nfunction getParams(): Record<string, string> {\n    const router = getRouter();\n    if (router.navigationMatchMetadata) {\n        return router.navigationMatchMetadata.params || {};\n    }\n    return {};\n}\n\nconst appendIdToAllRouteTree = (routes: RouteConfig[]): RouteConfig[] => {\n    return routes.map(route => {\n        return {\n            ...route,\n            id: route.id ? route.id : uniqueId(),\n            children: 'children' in route ? (\n                route.children ? appendIdToAllRouteTree(route.children) : route.children\n            ) : undefined\n        }\n    });\n}\n\nfunction buildRouter(config: RouterConfig, renderedRoot: RootElementWithMetadata): Router {\n    window.addEventListener('popstate', (event) => {\n        logger.log(event.state);\n        navigate(window.location.pathname);\n    });\n    \n    const _onRouteChangeCbs: OnRouteChangeCallback[] = [];\n    const { routes, base = '', onNoMatch, useViewTransition = true } = config;\n    const context = getActiveContext();\n    if(!context) {\n        throw new Error('No active context');\n    }\n    const renderKey = keyBuilder(context.key).push(`router:${renderedRoot.id}`);\n    const redirectStack: Parameters<typeof push>[] = [];\n    const routesWithId = appendIdToAllRouteTree(routes);\n    const routerElement = DOM.createElement('app-router', renderKey);\n    const memoRenderedRoute: Record<string, HTMLElement | Text | ChildNode[]> = {};\n\n    const router: Router = {\n        navigateState: {\n            isNavigating: false,\n        },\n        rootId: renderedRoot.id,\n        container: routerElement,\n        push,\n        replace,\n        navigate,\n        get state() { return history.state; },\n        matchedRouteId: '',\n        events: {\n            onRouteChange: (cb) => { _onRouteChangeCbs.push(cb); }\n        }\n    };\n    routersStore[router.rootId] = router;\n    \n    function replace(path: string | URL, state?: Record<string, unknown>) {\n        if (router.navigateState.isNavigating) {\n            logger.warn('Router is currently navigating');\n            redirectStack.push([path, state]);\n            return;\n        }\n        const prevPathname = window.location.pathname;\n        history.replaceState(state, \"\", path);\n        if (prevPathname !== window.location.pathname) {\n            navigate(window.location.pathname);\n        }\n    }\n\n    function push(path: string | URL, state?: Record<string, unknown>) {\n        if (router.navigateState.isNavigating) {\n            logger.warn('Router is currently navigating');\n            redirectStack.push([path, state]);\n            return;\n        }\n        const prevPathname = window.location.pathname;\n        history.pushState(state, \"\", path);\n        if (prevPathname !== window.location.pathname) {\n            navigate(window.location.pathname);\n        }\n    }\n\n    function navigate(path: string) {\n        if (router.navigateState.isNavigating) {\n            logger.warn('Router is currently navigating');\n            return;\n        }\n\n        // Find the route that matches the path\n        const matchResult = matchRoute(path, routesWithId);\n        if (!matchResult) {\n            if (onNoMatch) {\n                onNoMatch();\n            }\n            logger.warn(`No route found for path ${path}`);\n            return;\n        }\n\n        const { routes, params } = matchResult;\n\n        if (router.navigationMatchMetadata) {\n            const { routes: prevRoutes, params: prevParams = {} } = router.navigationMatchMetadata;\n            prevRoutes.forEach((prevRoute) => {\n                if (prevRoute.onLeave) prevRoute.onLeave(prevParams);\n            });\n        }\n    \n        router.navigationMatchMetadata = {\n            path,\n            routes,\n            params\n        };\n\n        if (routes.length === 0) {\n            logger.warn(`No route found for path ${path}`);\n            return;\n        }\n\n        function onRouteChange() {\n            _onRouteChangeCbs.forEach(cb => cb({ path, params, state: history.state }));\n        }\n\n        const delayedHandleRoutesMatchedResult = () => {\n            handleRoutesMatchedResult(\n                router,\n                routes,\n                params,\n                path,\n                base,\n                memoRenderedRoute,\n                renderKey,\n                onRouteChange\n            ).then(() => {\n                if(redirectStack.length) {\n                    const redirectParameters = redirectStack.at(-1);\n                    if(redirectParameters) {\n                        redirectStack.length = 0;\n                        const [path, state] = redirectParameters;\n                        push(path, state);\n                    }\n                }\n            });\n        }\n        if (!useViewTransition) {\n            delayedHandleRoutesMatchedResult();\n        } else {\n            applyViewTransition(delayedHandleRoutesMatchedResult);\n        }\n    }\n\n    // Navigate to the initial route\n    navigate(window.location.pathname);\n    return router;\n}\n\n/**\n * Create a router\n * @param {RouterConfig} config The router configuration\n * @returns The root router element\n * \n * using {@link RouterConfig}\n * \n * @example\n * createRouter({\n *    routes: [\n *        { \n *            path: '/', component: () => <Layout />,\n *            children: [\n *                { index: true, component: () => <Navigate to=\"/categories\" />, memo: false },\n *                { path: '/categories', component: Categories },\n *                { path: '/recipes', component: Recipes, memo: false },\n *                { path: '/recipe/:id', component: Recipe }\n *            ]\n *        }\n *    ]\n * });\n */\nfunction createRouter(config: RouterConfig): VirtualElement {\n    \n    const renderedRoot = getRenderedRoot();\n    if (!renderedRoot) {\n        throw new Error('Out of a root context');\n    }\n    const router = buildRouter(config, renderedRoot);\n    if (!config.ignoreRouterLink) {\n        overrideNativeNavigation(router.container, router);\n    }\n    const rootRouterElement = createElement(router.container, {}) as VirtualElement;\n    return rootRouterElement;\n}\n\nfunction overrideNativeNavigation(rootRouterElement: HTMLElement, router: Router) {\n    rootRouterElement.addEventListener('click', (event) => {\n        const target = (event.target as HTMLElement).closest('a');\n        if (target && target.tagName === 'A' && target.hasAttribute('href') && target.hasAttribute('router-link')) {\n            event.preventDefault();\n            const href = target.getAttribute('href');\n            if (href) {\n                router.push(href);\n            }\n        }\n    });\n}\n\nfunction applyViewTransition(updateDom: () => void) {\n    if ('startViewTransition' in document && typeof document.startViewTransition === 'function') {\n        document.startViewTransition(() => updateDom());\n    } else {\n        updateDom();\n    }\n}\n\nexport { createRouter, getRouter, getParams };","import { getRouter, match } from '@/router';\nimport { createElement } from '@/jsx';\nimport { createSignal } from '@/core/signal';\n\nexport interface LinkProps {\n    to: string;\n    onClick?: (e: MouseEvent) => void;\n    className?: string;\n    /**\n     * The class to apply when the link is active\n     * @default 'active'\n     */\n    activeClass?: string;\n}\n\nconst DEFAULT_ACTIVE_CLASS = 'active';\n\n/**\n * A link component that navigates using the app router, preventing the default behavior.\n * Anchor elements resulting from this component will have the class 'router-link'.\n * @param {LinkProps} props The props of the component\n * @throws {Error} If being called outside of a router context\n * \n * using {@link LinkProps}\n * \n * @example\n * <Link to=\"/categories\">Categories</Link> // A link to the categories route\n * <Link to=\"/categories\" className=\"link\">Categories</Link> // A link to the categories route with a class of link\n * \n */\nexport function Link({ \n    to, \n    onClick,\n    className,\n    activeClass\n}: LinkProps, children?: any) {\n    const router = getRouter();\n    const [activeClass$, setActiveClass] = createSignal('');\n    router.events.onRouteChange((e) => {\n        const matchResult = match(to, e.path);\n        if(matchResult.isMatch) {\n            setActiveClass(activeClass ?? DEFAULT_ACTIVE_CLASS);\n        } else {\n            setActiveClass('');\n        }\n    });\n\n    return (createElement('a',{ \n        href: to,\n        className: ['router-link', (className ?? ''), activeClass$],\n        onClick: (e: MouseEvent) => {\n            e.preventDefault();\n            router.push(to);\n            onClick?.(e);\n        }\n    }, ...children));\n}","import { VirtualElement } from \"@/types\";\nimport { createFragment } from \"@/jsx\";\nimport { getRouter } from \"./router.v2\";\n\nexport interface NavigateProps {\n    to: string;\n    replace?: boolean;\n}\n\n/**\n * Navigate to a new route\n * @param {NavigateProps} props The props of the component\n * @throws {Error} If being called outside of a router context\n * \n * using {@link NavigateProps}\n * \n * @example\n * <Navigate to=\"/categories\" /> // Navigate to the categories route using push\n * <Navigate to=\"/categories\" replace /> // Navigate to the categories route using replace\n * \n */\nexport function Navigate({ to, replace }: NavigateProps) {\n    const router = getRouter();\n    if (replace) {\n        router.replace(to);\n    }\n    else {\n        router.push(to);\n    }\n    return createFragment(null, []) as unknown as VirtualElement;\n}","\nimport { matchRoutePaths, splitPath } from './nested-match-route'\n\n/**\n * The result of a match\n * @property {boolean} isMatch Whether the path matched the route path\n * @property {Record<string, string>} params The parameters extracted from the path\n * @property {boolean} isExactMatch Whether the path is an exact match\n * \n * used in {@link match}\n */\nexport interface MatchResult {\n    isMatch: boolean;\n    isExactMatch: boolean;\n    params?: Record<string, string>;\n}\n\n\n/**\n * Match the given path to the given route path\n * @param {string} toMatch The path to match\n * @param {string} matchTo The route path to match against\n * @returns {MatchResult} The match result\n * \n * using {@link MatchResult}\n * \n * @example\n * match('/user/:id/profile', '/user/123/profile') // { isMatch: true, params: { id: '123' } }\n * match('/user/:id', '/user') // { isMatch: false }\n * match('/user', '/user/123') // { isMatch: true } \n * \n */\nexport function match(toMatch: string, matchTo: string): MatchResult {\n    const toMatchParts = splitPath(toMatch);\n    const matchToParts = splitPath(matchTo);\n    const { isMatch, params, isExactMatch = false } = matchRoutePaths(toMatchParts, matchToParts);\n    return { isMatch, params, isExactMatch };\n}"],"names":["uniqueId","buildRootToLeafRouteMatrix","routes","matrix","buildMatrix","acc","route","newAcc","omitKey","omitKeys","obj","keys","clone","key","matchRoutePaths","routePathParts","pathParts","params","firstMatchedParamIndex","isMatch","part","index","isExactMatch","matchRoute","path","rootToLeafMatrix","splitPath","processedMatchedRoutes","pathRootToLeaf","fullPathToCurrentRoutePart","matchParams","processedRouteParts","routePart","prevRoutePathParts","_a","resolvePath","currentMatchParams","currentFirstMatchedParamIndex","postProcessedMatchedRoutes","routeParts","mostSpecificRoute","depth","isFullMatch","isNotFound","notFoundMatch","exactMatch","fullMatches","mostDepthMatch","curr","handleRoutesMatchedResult","router","_base","memoRenderedRoute","renderKey","onRouteChange","rootComponentDom","componentDom","renderedComponentList","currentRouteRenderKey","prevComponentDom","actualShouldEnterResult","runShouldEnterStage","logger","state","routeId","componentContainer","buildRouteContainer","renderMatchResult","routeSync","currentComponentDom","emptyOutComponentOutlet","routeComponentProps","runLoaderStage","componentVirtualElement","createElement","render","DOM","isMemo","componentDomToRender","outlet","node","shouldEnterFunction","shouldEnterResult","isPromise","loaderFunction","result","routersStore","history","getRouter","renderedRootId","getRenderedRoot","getParams","appendIdToAllRouteTree","buildRouter","config","renderedRoot","event","navigate","_onRouteChangeCbs","base","onNoMatch","useViewTransition","context","getActiveContext","keyBuilder","redirectStack","routesWithId","routerElement","push","replace","cb","prevPathname","matchResult","prevRoutes","prevParams","prevRoute","delayedHandleRoutesMatchedResult","redirectParameters","applyViewTransition","createRouter","overrideNativeNavigation","rootRouterElement","target","href","updateDom","DEFAULT_ACTIVE_CLASS","Link","to","onClick","className","activeClass","children","activeClass$","setActiveClass","createSignal","e","match","Navigate","createFragment","toMatch","matchTo","toMatchParts","matchToParts"],"mappings":"yOAEA,SAASA,GAAW,CACT,OAAA,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,EAAG,EAAE,CACjD,CCDO,SAASC,EAAgEC,EAAoB,CAChG,MAAMC,EAAgB,CAAC,EACjBC,EAAc,CAACF,EAAaG,EAAW,CAAA,IAAO,CAChD,UAAWC,KAASJ,EAAQ,CACxB,MAAMK,EAAS,CAAC,GAAGF,EAAKG,EAAQF,EAAO,UAAU,CAAM,EACnDA,EAAM,UAAYA,EAAM,SAAS,OAAS,EAC9BF,EAAAE,EAAM,SAAiBC,CAAM,EAEzCJ,EAAO,KAAKI,CAAM,CACtB,CAER,EACA,OAAAH,EAAYF,CAAM,EACXC,CACX,CAEA,SAASM,EAA2DC,EAAQC,EAAuB,CAC3F,MAAAC,EAAQ,CAAE,GAAGF,CAAI,EACvB,UAAWG,KAAOF,EAChB,OAAOC,EAAMC,CAAG,EAEX,OAAAD,CACT,CAEA,SAASJ,EAAQE,EAA0BG,EAAa,CACtD,OAAOJ,EAASC,EAAK,CAACG,CAAG,CAAC,CAC5B,CCxBgB,SAAAC,EACdC,EACAC,EAMA,CACA,MAAMC,EAAiC,CAAC,EACxC,IAAIC,EAAyB,GAE7B,MAAMC,EAAUJ,EAAe,MAAM,CAACK,EAAMC,IACtCD,EAAK,WAAW,GAAG,EACjBJ,EAAU,QAAUK,EACf,IAELH,IAA2B,KACJA,EAAAG,GAE3BJ,EAAOG,EAAK,MAAM,CAAC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