"use strict";

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

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

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

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 _FlexBlock = require("../flexBlock/FlexBlock");

var Switcher =
/*#__PURE__*/
function (_React$PureComponent) {
  (0, _inheritsLoose2.default)(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;
    (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_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.default.createElement(_FlexBlock.FlexBlock, {
      testAutomationId: testAutomationId,
      className: "rc-switcher"
    }, children);
  };

  return Switcher;
}(_react.default.PureComponent);

exports.Switcher = Switcher;
(0, _defineProperty2.default)(Switcher, "childContextTypes", {
  selectedId: _propTypes.default.string,
  onItemClick: _propTypes.default.func
});
(0, _defineProperty2.default)(Switcher, "propTypes", {
  selectedId: _propTypes.default.string.isRequired,
  testAutomationId: _propTypes.default.string,
  onToggle: _propTypes.default.func
});
(0, _defineProperty2.default)(Switcher, "defaultProps", {
  testAutomationId: null,
  onToggle: function onToggle() {}
});