import { NavigateAway } from '@transferwise/icons';
import { clsx } from 'clsx';
import { useIntl } from 'react-intl';
import '../primitives/PrimitiveButton/src/PrimitiveButton.mjs';
import PrimitiveAnchor from '../primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs';
import messages from './Link.messages.mjs';
import { jsxs, jsx } from 'react/jsx-runtime';

const Link = ({
  className,
  children,
  href,
  target,
  type,
  'aria-label': ariaLabel,
  onClick,
  ...props
}) => {
  const {
    formatMessage
  } = useIntl();
  const isBlank = target === '_blank';
  const classNames = clsx('np-link', 'd-inline-flex', {
    [`np-text-${type}`]: type
  }, className);
  return /*#__PURE__*/jsxs(PrimitiveAnchor, {
    href: href,
    target: target,
    className: classNames,
    "aria-label": ariaLabel,
    rel: isBlank ? 'noreferrer' : undefined,
    onClick: onClick,
    ...props,
    children: [children, " ", isBlank && /*#__PURE__*/jsx(NavigateAway, {
      title: formatMessage(messages.opensInNewTab)
    })]
  });
};

export { Link as default };
//# sourceMappingURL=Link.mjs.map
