import { isSpecialLinkClick } from "@contember/ui";
import { memo, useCallback } from "react";
import { useRoutingLink } from "./useRoutingLink.js";
import { jsx } from "react/jsx-runtime";
const defaultComponent = ({
  active,
  ...props
}) => /* @__PURE__ */ jsx("a", {
  ...props
});
const RoutingLink = memo(({
  onClick,
  to,
  parametersResolver,
  parameters,
  Component,
  componentProps,
  target,
  ...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) || target) {
        return;
      }
    }
    navigate(e);
  }, [navigate, onClick, target]);
  const InnerComponent = Component ?? defaultComponent;
  return /* @__PURE__ */ jsx(InnerComponent, {
    active,
    href,
    target,
    ...componentProps,
    ...props,
    onClick: innerOnClick
  });
});
RoutingLink.displayName = "RoutingLink";
export {
  RoutingLink
};
//# sourceMappingURL=RoutingLink.js.map
