'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var icons = require('@transferwise/icons');
var clsx = require('clsx');
var reactIntl = require('react-intl');
var SentimentSurface = require('../sentimentSurface/SentimentSurface.js');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
var breakpoint = require('../common/propsValues/breakpoint.js');
var size = require('../common/propsValues/size.js');
require('../common/propsValues/typography.js');
require('../common/propsValues/width.js');
require('../common/propsValues/type.js');
require('../common/propsValues/dateMode.js');
require('../common/propsValues/monthFormat.js');
require('../common/propsValues/position.js');
require('../common/propsValues/layouts.js');
var status = require('../common/propsValues/status.js');
var sentiment = require('../common/propsValues/sentiment.js');
require('../common/propsValues/profileType.js');
require('../common/propsValues/variant.js');
require('../common/propsValues/scroll.js');
require('../common/propsValues/markdownNodeType.js');
require('../common/fileType.js');
require('react');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var Circle = require('../common/circle/Circle.js');
var useMedia = require('../common/hooks/useMedia.js');
var StatusIcon_messages = require('./StatusIcon.messages.js');

const mapLegacySize = {
  [String(size.Size.SMALL)]: 16,
  [String(size.Size.MEDIUM)]: 40,
  [String(size.Size.LARGE)]: 48
};
const StatusIcon = ({
  sentiment: sentiment$1 = 'neutral',
  size: sizeProp = 40,
  iconLabel
}) => {
  const intl = reactIntl.useIntl();
  const iconMetaBySentiment = {
    [sentiment.Sentiment.NEGATIVE]: {
      Icon: icons.Cross,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.errorLabel)
    },
    [sentiment.Sentiment.POSITIVE]: {
      Icon: icons.Check,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.successLabel)
    },
    [sentiment.Sentiment.WARNING]: {
      Icon: icons.Alert,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.warningLabel)
    },
    [status.Status.PENDING]: {
      Icon: icons.ClockBorderless,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.pendingLabel)
    },
    [sentiment.Sentiment.NEUTRAL]: {
      Icon: icons.Info,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.informationLabel)
    },
    // deprecated
    [sentiment.Sentiment.ERROR]: {
      Icon: icons.Cross,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.errorLabel)
    },
    [sentiment.Sentiment.INFO]: {
      Icon: icons.Info,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.informationLabel)
    },
    [sentiment.Sentiment.SUCCESS]: {
      Icon: icons.Check,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.default.successLabel)
    }
  };
  const {
    Icon,
    defaultIconLabel
  } = iconMetaBySentiment[sentiment$1];
  const iconColor = sentiment$1 === 'warning' || sentiment$1 === 'pending' ? 'dark' : 'light';
  const isTinyViewport = useMedia.useMedia(`(max-width: ${breakpoint.Breakpoint.ZOOM_400}px)`);
  const size = mapLegacySize[sizeProp] ?? sizeProp;
  // eslint-disable-next-line react/no-unstable-nested-components
  const SentimentSurfaceSetting = props => /*#__PURE__*/jsxRuntime.jsx(SentimentSurface.default, {
    as: "span"
    // @ts-expect-error sentiment and SentimentSurface types mismatch
    ,
    sentiment: sentiment$1 === 'positive' ? 'success' : sentiment$1 === 'pending' ? 'warning' : sentiment$1,
    ...props
  });
  return /*#__PURE__*/jsxRuntime.jsx(Circle.default, {
    as: SentimentSurfaceSetting,
    size: isTinyViewport && size < 40 ? 32 : size,
    "data-testid": "status-icon",
    className: clsx.clsx('status-circle', sentiment$1),
    children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
      className: clsx.clsx('status-icon', iconColor),
      title: iconLabel === null ? undefined : iconLabel || defaultIconLabel
    })
  });
};

exports.default = StatusIcon;
//# sourceMappingURL=StatusIcon.js.map
