import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React, { PureComponent } from "react";
export var RuleGroupExtActions = /*#__PURE__*/function (_PureComponent) {
  function RuleGroupExtActions() {
    _classCallCheck(this, RuleGroupExtActions);
    return _callSuper(this, RuleGroupExtActions, arguments);
  }
  _inherits(RuleGroupExtActions, _PureComponent);
  return _createClass(RuleGroupExtActions, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
        config = _this$props.config,
        addRule = _this$props.addRule,
        addGroup = _this$props.addGroup,
        canAddRule = _this$props.canAddRule,
        canAddGroup = _this$props.canAddGroup,
        canDeleteGroup = _this$props.canDeleteGroup,
        removeSelf = _this$props.removeSelf,
        setLock = _this$props.setLock,
        isLocked = _this$props.isLocked,
        isTrueLocked = _this$props.isTrueLocked,
        id = _this$props.id;
      var _config$settings = config.settings,
        immutableGroupsMode = _config$settings.immutableGroupsMode,
        addSubRuleLabel = _config$settings.addSubRuleLabel,
        addSubGroupLabel = _config$settings.addSubGroupLabel,
        delGroupLabel = _config$settings.delGroupLabel,
        renderButton = _config$settings.renderButton,
        renderIcon = _config$settings.renderIcon,
        renderSwitch = _config$settings.renderSwitch,
        renderButtonGroup = _config$settings.renderButtonGroup,
        lockLabel = _config$settings.lockLabel,
        lockedLabel = _config$settings.lockedLabel,
        showLock = _config$settings.showLock,
        canDeleteLocked = _config$settings.canDeleteLocked;
      var Icon = function Icon(pr) {
        return renderIcon(pr, config.ctx);
      };
      var Btn = function Btn(pr) {
        return renderButton(pr, config.ctx);
      };
      var Switch = function Switch(pr) {
        return renderSwitch(pr, config.ctx);
      };
      var BtnGrp = function BtnGrp(pr) {
        return renderButtonGroup(pr, config.ctx);
      };
      var setLockSwitch = showLock && !(isLocked && !isTrueLocked) && /*#__PURE__*/React.createElement(Switch, {
        type: "lock",
        id: id,
        value: isLocked,
        setValue: setLock,
        label: lockLabel,
        checkedLabel: lockedLabel,
        config: config
      });
      var addSubRuleBtn = !immutableGroupsMode && canAddRule && !isLocked && /*#__PURE__*/React.createElement(Btn, {
        type: "addSubRule",
        onClick: addRule,
        label: addSubRuleLabel,
        readonly: isLocked,
        config: config,
        renderIcon: Icon
      });
      var addSubGroupBtn = !immutableGroupsMode && canAddGroup && !isLocked && /*#__PURE__*/React.createElement(Btn, {
        type: "addSubGroup",
        onClick: addGroup,
        label: addSubGroupLabel,
        readonly: isLocked,
        config: config,
        renderIcon: Icon
      });
      var delGroupBtn = !immutableGroupsMode && canDeleteGroup && (!isLocked || isLocked && canDeleteLocked) && /*#__PURE__*/React.createElement(Btn, {
        type: "delRuleGroup",
        onClick: removeSelf,
        label: delGroupLabel,
        config: config,
        renderIcon: Icon
      });
      return /*#__PURE__*/React.createElement("div", {
        className: "group--actions group--actions--tr"
      }, /*#__PURE__*/React.createElement(BtnGrp, {
        config: config
      }, setLockSwitch, addSubRuleBtn, addSubGroupBtn, delGroupBtn));
    }
  }]);
}(PureComponent);