import { jsx as _jsx } from "react/jsx-runtime";
import { useNavigate, useRouterContext } from "./Router";
export function Nav({ children, onClick }) {
    const navigate = useNavigate();
    const _onClick = (ev) => {
        const link = ev.target.closest('a');
        if (link && link.href) {
            ev.stopPropagation();
            ev.preventDefault();
            navigate(link.href, { replace: true });
            onClick?.(ev);
        }
    };
    return (_jsx("span", { onClick: _onClick, children: children }));
}
export function NavLink({ children, href, className, topLevelNav, clearBreadcrumbs = false }) {
    const { router } = useRouterContext();
    const _onClick = (ev) => {
        ev.stopPropagation();
        ev.preventDefault();
        const actualRouter = topLevelNav ? router.getTopRouter() : router;
        actualRouter.navigate(href, { replace: clearBreadcrumbs });
    };
    return (_jsx("a", { href: href, className: className, onClick: _onClick, children: children }));
}
//# sourceMappingURL=Nav.js.map