"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _Checkbox = _interopRequireDefault(require("../../Checkbox"));
var _SelectorList = require("../SelectorList.helpers");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/SelectorList/ToggleAllCheckbox/ToggleAllCheckbox.jsx",
  _this = void 0;
var ToggleAllCheckbox = function ToggleAllCheckbox(_ref) {
  var _ref$selectAllText = _ref.selectAllText,
    selectAllText = _ref$selectAllText === void 0 ? 'Select all' : _ref$selectAllText,
    _ref$deselectAllText = _ref.deselectAllText,
    deselectAllText = _ref$deselectAllText === void 0 ? 'Deselect all' : _ref$deselectAllText,
    enabledItemsAmount = _ref.enabledItemsAmount,
    selectedEnabledItemsAmount = _ref.selectedEnabledItemsAmount,
    selectAll = _ref.selectAll,
    deselectAll = _ref.deselectAll,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? 'medium' : _ref$size,
    _ref$dataHook = _ref.dataHook,
    dataHook = _ref$dataHook === void 0 ? _SelectorList.dataHooks.toggleAllCheckbox : _ref$dataHook;
  var cases = {
    select: {
      text: selectAllText,
      number: enabledItemsAmount,
      onChange: selectAll,
      indeterminate: false,
      checked: false
    },
    deselect: {
      text: deselectAllText,
      number: selectedEnabledItemsAmount,
      onChange: deselectAll,
      indeterminate: selectedEnabledItemsAmount < enabledItemsAmount,
      checked: true
    }
  };
  var _ref2 = selectedEnabledItemsAmount ? cases.deselect : cases.select,
    text = _ref2.text,
    num = _ref2.number,
    onChange = _ref2.onChange,
    checked = _ref2.checked,
    indeterminate = _ref2.indeterminate;
  return /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
    dataHook: dataHook,
    checked: checked,
    onChange: onChange,
    indeterminate: indeterminate,
    size: size,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 42,
      columnNumber: 5
    }
  }, " ".concat(text, " (").concat(num, ")"));
};
var _default = exports["default"] = ToggleAllCheckbox;