import { isSpecialLinkClick } from "@contember/ui";
import { memo, useCallback } from "react";
import { useRoutingLink } from "./useRoutingLink.js";
import { jsxDEV } from "react/jsx-dev-runtime";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/routing/RoutingLink.tsx";
const defaultComponent = ({
  active,
  ...props
}) => /* @__PURE__ */ jsxDEV("a", {
  ...props
}, void 0, false, {
  fileName: _jsxFileName,
  lineNumber: 17,
  columnNumber: 2
}, void 0);
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__ */ jsxDEV(InnerComponent, {
    active,
    href,
    target,
    ...componentProps,
    ...props,
    onClick: innerOnClick
  }, void 0, false, {
    fileName: _jsxFileName,
    lineNumber: 36,
    columnNumber: 9
  }, void 0);
});
RoutingLink.displayName = "RoutingLink";
export {
  RoutingLink
};
//# sourceMappingURL=RoutingLink.js.map
