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 classnames from 'classnames';
import _ from 'lodash';
import { CTADropdown } from './CTADropdown';
import BSButtonToolbar from 'react-bootstrap/lib/ButtonToolbar';
export var CTAContainer =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(CTAContainer, _React$Component);

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

  var _proto = CTAContainer.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        visibleAmount = _this$props.visibleAmount,
        className = _this$props.className,
        testAutomationId = _this$props.testAutomationId,
        children = _this$props.children,
        props = _objectWithoutPropertiesLoose(_this$props, ["visibleAmount", "className", "testAutomationId", "children"]);

    var classNames = classnames(className, 'cta-toolbar');

    var head = _.take(children, visibleAmount);

    var tail = _.takeRight(children, children.length - visibleAmount);

    var showDropdown = tail.length > 0;
    var dropdown;

    if (showDropdown) {
      dropdown = React.createElement(CTADropdown, {
        testAutomationId: "moreActionDropdown"
      }, tail);
    }

    return React.createElement(BSButtonToolbar, _extends({
      "data-test-automation-id": testAutomationId,
      className: classNames
    }, props), head, dropdown);
  };

  return CTAContainer;
}(React.Component);

_defineProperty(CTAContainer, "propTypes", {
  visibleAmount: PropTypes.number,
  testAutomationId: PropTypes.string,
  className: PropTypes.string,
  children: PropTypes.node
});

_defineProperty(CTAContainer, "defaultProps", {
  visibleAmount: 2,
  testAutomationId: 'CATContainer',
  className: null,
  children: null
});