import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from './Button';
import BSMenuItem from 'react-bootstrap/lib/MenuItem';
export var CTAControl =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(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 = _objectWithoutPropertiesLoose(_this$props, ["testAutomationId", "children"]);

    if (this.isInsideDropdown()) {
      return React.createElement(BSMenuItem, _extends({
        "data-test-automation-id": testAutomationId
      }, props), children);
    } else {
      return React.createElement(Button, _extends({
        testAutomationId: testAutomationId
      }, props), children);
    }
  };

  return CTAControl;
}(React.Component);

_defineProperty(CTAControl, "propTypes", Object.assign({}, Button.propTypes, BSMenuItem.propTypes));

_defineProperty(CTAControl, "defaultProps", {
  testAutomationId: 'CATControl'
});

_defineProperty(CTAControl, "contextTypes", {
  isCTADropdown: PropTypes.bool
});