import { AlertCircleFill, Alert } from '@transferwise/icons';
import { useTheme } from '@wise/components-theming';
import { clsx } from 'clsx';
import { AvatarType } from '../avatar/avatarTypes.mjs';
import Avatar from '../avatar/Avatar.mjs';
import Body from '../body/Body.mjs';
import Button from '../button/Button.mjs';
import Title from '../title/Title.mjs';
import { jsx, jsxs } from 'react/jsx-runtime';
import { Size } from '../common/propsValues/size.mjs';
import { Typography } from '../common/propsValues/typography.mjs';
import { ControlType, Priority } from '../common/propsValues/control.mjs';

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

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