'use strict';

var Icons = require('@transferwise/icons');
var clsx = require('clsx');
var reactIntl = require('react-intl');
require('../primitives/PrimitiveButton/src/PrimitiveButton.js');
var PrimitiveAnchor = require('../primitives/PrimitiveAnchor/src/PrimitiveAnchor.js');
var Link_messages = require('./Link.messages.js');
var jsxRuntime = require('react/jsx-runtime');

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

module.exports = Link;
//# sourceMappingURL=Link.js.map
