"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.CTAControl = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _Button = require("./Button");

var _MenuItem = _interopRequireDefault(require("react-bootstrap/lib/MenuItem"));

var CTAControl =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(CTAControl, _React$Component);

  function CTAControl() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = CTAControl.prototype;

  _proto.isInsideDropdown = function isInsideDropdown() {
    return this.context.isCTADropdown;
  };

  _proto.render = function render() {
    var _this$props = this.props,
        testAutomationId = _this$props.testAutomationId,
        children = _this$props.children,
        props = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["testAutomationId", "children"]);

    if (this.isInsideDropdown()) {
      return _react.default.createElement(_MenuItem.default, (0, _extends2.default)({
        "data-test-automation-id": testAutomationId
      }, props), children);
    } else {
      return _react.default.createElement(_Button.Button, (0, _extends2.default)({
        testAutomationId: testAutomationId
      }, props), children);
    }
  };

  return CTAControl;
}(_react.default.Component);

exports.CTAControl = CTAControl;
(0, _defineProperty2.default)(CTAControl, "propTypes", Object.assign({}, _Button.Button.propTypes, _MenuItem.default.propTypes));
(0, _defineProperty2.default)(CTAControl, "defaultProps", {
  testAutomationId: 'CATControl'
});
(0, _defineProperty2.default)(CTAControl, "contextTypes", {
  isCTADropdown: _propTypes.default.bool
});