import { memo, useCallback, createElement } from "react";
import { isSpecialLinkClick } from "@contember/ui";
import { useRoutingLink } from "./useRoutingLink.js";
const defaultComponent = ({ active, ...props }) => /* @__PURE__ */ createElement("a", {
  ...props
});
const RoutingLink = memo(({ onClick, to, parametersResolver, parameters, Component, componentProps, ...props }) => {
  const { navigate, isActive: active, href } = useRoutingLink(to, parametersResolver, parameters);
  const innerOnClick = useCallback((e) => {
    if (e) {
      if (onClick) {
        onClick(e);
      }
      if (e.isDefaultPrevented() || isSpecialLinkClick(e.nativeEvent)) {
        return;
      }
    }
    navigate(e);
  }, [navigate, onClick]);
  const InnerComponent = Component ?? defaultComponent;
  return /* @__PURE__ */ createElement(InnerComponent, {
    active,
    href,
    ...componentProps,
    ...props,
    onClick: innerOnClick
  });
});
RoutingLink.displayName = "RoutingLink";
export { RoutingLink };
//# sourceMappingURL=RoutingLink.js.map
