'use strict';

var icons = require('@transferwise/icons');
var componentsTheming = require('@wise/components-theming');
var clsx = require('clsx');
var avatarTypes = require('../avatar/avatarTypes.js');
var Avatar = require('../avatar/Avatar.js');
var Body = require('../body/Body.js');
var Button = require('../button/Button.js');
var Title = require('../title/Title.js');
var jsxRuntime = require('react/jsx-runtime');
var size = require('../common/propsValues/size.js');
var typography = require('../common/propsValues/typography.js');
var control = require('../common/propsValues/control.js');

function CriticalCommsBanner({
  title,
  subtitle,
  action,
  className
}) {
  const {
    isModern
  } = componentsTheming.useTheme();
  return /*#__PURE__*/jsxRuntime.jsx("div", {
    className: clsx.clsx('critical-comms', className),
    children: /*#__PURE__*/jsxRuntime.jsxs("div", {
      className: "critical-comms-body",
      children: [/*#__PURE__*/jsxRuntime.jsx(Avatar, {
        size: size.Size.MEDIUM,
        type: avatarTypes.AvatarType.ICON,
        className: clsx.clsx(isModern ? 'm-r-2' : 'm-r-1'),
        backgroundColor: isModern ? 'var(--color-sentiment-negative)' : 'var(--color-background-negative)',
        children: isModern ? /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircleFill, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.Alert, {
          size: 24
        })
      }), /*#__PURE__*/jsxRuntime.jsxs("div", {
        className: "critical-comms-content d-flex align-items-center flex-grow-1",
        children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
          className: clsx.clsx('flex-grow-1', {
            'p-x-2': !isModern
          }),
          children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
            type: isModern ? typography.Typography.TITLE_BODY : typography.Typography.TITLE_GROUP,
            className: "critical-comms--title",
            children: title
          }), /*#__PURE__*/jsxRuntime.jsx(Body, {
            className: "critical-comms--subtitle",
            children: subtitle
          })]
        }), action ? /*#__PURE__*/jsxRuntime.jsx("div", {
          className: "critical-comms--cta",
          children: /*#__PURE__*/jsxRuntime.jsx(Button, {
            block: isModern,
            size: size.Size.SMALL,
            type: control.ControlType.NEGATIVE,
            priority: isModern ? control.Priority.SECONDARY : control.Priority.PRIMARY,
            className: "cta-btn",
            onClick: () => {
              if (action) {
                window.location.href = action.href;
              }
            },
            children: action.label
          })
        }) : null]
      })]
    })
  });
}

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