import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
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';
export var SwitcherItem =
/*#__PURE__*/
function (_React$PureComponent) {
  _inheritsLoose(SwitcherItem, _React$PureComponent);

  function SwitcherItem() {
    var _this;

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;

    _defineProperty(_assertThisInitialized(_this), "onClick", function () {
      _this.context.onItemClick(_this.props.id);
    });

    return _this;
  }

  var _proto = SwitcherItem.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        children = _this$props.children,
        id = _this$props.id,
        label = _this$props.label,
        testAutomationId = _this$props.testAutomationId;
    var className = classnames('rc-switcher__item', {
      'rc-switcher__item_selected': this.context.selectedId === id
    });
    return React.createElement("button", {
      "data-test-automation-id": testAutomationId,
      className: className,
      onClick: this.onClick,
      "aria-label": label
    }, children);
  };

  return SwitcherItem;
}(React.PureComponent);

_defineProperty(SwitcherItem, "contextTypes", {
  selectedId: PropTypes.string.isRequired,
  onItemClick: PropTypes.func.isRequired
});

_defineProperty(SwitcherItem, "propTypes", {
  id: PropTypes.string.isRequired,
  testAutomationId: PropTypes.string,
  label: PropTypes.string.isRequired
});

_defineProperty(SwitcherItem, "defaultProps", {
  testAutomationId: null
});