import { jsx as _jsx } from "react/jsx-runtime";
import { FixLinks } from "./FixLinks";
import { RouteComponent } from "./RouteComponent";
import { ReactRouterContext, useRouterContext } from "./Router";
import { joinPath } from "./path";
export function NestedNavigationContext({ basePath, fixLinks = false, children }) {
    const ctx = useRouterContext();
    const wrapWithFixLinks = fixLinks ?
        (elem) => _jsx(FixLinks, { basePath: ctx.matchedRoutePath, children: elem })
        : (elem) => elem;
    return (_jsx(ReactRouterContext.Provider, { value: {
            ...ctx,
            navigate: (to, options) => {
                const actualBasePath = options?.basePath ? joinPath(basePath, options.basePath) : basePath;
                return ctx.navigate(to, { ...options, basePath: actualBasePath });
            }
        }, children: wrapWithFixLinks(children ? children : _jsx(RouteComponent, {})) }));
}
//# sourceMappingURL=NestedNavigationContext.js.map