import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
var _excluded = ["children", "className", "icon", "onClose", "fullWidth"];

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Box from '../box';
import Island from '../island';
import Section from '../section';
import IconButton from '../iconButton';
import theme from './theme.css';
import { IconCloseMediumOutline } from '@teamleader/ui-icons';
/** @type {React.ComponentType<any>} */

var Banner = /*#__PURE__*/function (_PureComponent) {
  _inherits(Banner, _PureComponent);

  var _super = _createSuper(Banner);

  function Banner() {
    _classCallCheck(this, Banner);

    return _super.apply(this, arguments);
  }

  _createClass(Banner, [{
    key: "getCloseButtonColor",
    value: function getCloseButtonColor() {
      var color = this.props.color;
      return color === 'white' ? 'neutral' : color;
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          children = _this$props.children,
          className = _this$props.className,
          icon = _this$props.icon,
          onClose = _this$props.onClose,
          fullWidth = _this$props.fullWidth,
          others = _objectWithoutProperties(_this$props, _excluded);

      var Element = fullWidth ? Section : Island;
      return /*#__PURE__*/React.createElement(Element, _extends({
        "data-teamleader-ui": "banner",
        className: className
      }, others), /*#__PURE__*/React.createElement("div", {
        className: theme['inner']
      }, icon && /*#__PURE__*/React.createElement("span", {
        className: theme['icon']
      }, icon), /*#__PURE__*/React.createElement(Box, {
        flex: 1,
        element: "span",
        paddingRight: onClose && 7
      }, children), onClose && /*#__PURE__*/React.createElement(IconButton, {
        className: theme['close-button'],
        icon: /*#__PURE__*/React.createElement(IconCloseMediumOutline, null),
        color: this.getCloseButtonColor(),
        onClick: onClose
      })));
    }
  }]);

  return Banner;
}(PureComponent);

Banner.defaultProps = {
  color: 'white'
};
export default Banner;