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 { FlexBlock } from '../flexBlock/FlexBlock';
export var Switcher =
/*#__PURE__*/
function (_React$PureComponent) {
  _inheritsLoose(Switcher, _React$PureComponent);

  function Switcher() {
    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), "onItemClick", function (id) {
      _this.props.onToggle(id);
    });

    return _this;
  }

  var _proto = Switcher.prototype;

  _proto.getChildContext = function getChildContext() {
    return {
      selectedId: this.props.selectedId,
      onItemClick: this.onItemClick
    };
  };

  _proto.render = function render() {
    var _this$props = this.props,
        children = _this$props.children,
        testAutomationId = _this$props.testAutomationId;
    return React.createElement(FlexBlock, {
      testAutomationId: testAutomationId,
      className: "rc-switcher"
    }, children);
  };

  return Switcher;
}(React.PureComponent);

_defineProperty(Switcher, "childContextTypes", {
  selectedId: PropTypes.string,
  onItemClick: PropTypes.func
});

_defineProperty(Switcher, "propTypes", {
  selectedId: PropTypes.string.isRequired,
  testAutomationId: PropTypes.string,
  onToggle: PropTypes.func
});

_defineProperty(Switcher, "defaultProps", {
  testAutomationId: null,
  onToggle: function onToggle() {}
});