"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
var _CheckboxProps = _interopRequireWildcard(require("./CheckboxProps"));
var _styles = require("@material-ui/core/styles");
var _classnames = _interopRequireDefault(require("classnames"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    /* Checkboxes */
    checkBoxIcon: {
      border: "1px solid",
      borderColor: theme.palette.grey.borders,
      width: theme.spacing(1.6),
      height: theme.spacing(1.6),
      borderRadius: 3,
      ".MuiCheckbox-root:focus &, .MuiCheckbox-root:active &": {
        boxShadow: "0 0 4px ".concat(theme.palette.focus),
        outline: "none"
      },
      backgroundColor: theme.palette.background.default
    },
    checkBoxIconChecked: {
      backgroundColor: "currentColor",
      borderColor: "currentColor",
      "&:before": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(0.7),
        top: theme.spacing(1.4),
        width: theme.spacing(0.6),
        height: theme.spacing(0.2),
        backgroundColor: "white",
        borderRadius: 2,
        transform: "rotate(46deg)"
      },
      "&:after": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(1.3),
        top: theme.spacing(0.9),
        width: theme.spacing(0.2),
        height: theme.spacing(0.9),
        backgroundColor: "white",
        borderRadius: 2,
        transform: "rotate(33deg)"
      }
    },
    checkBoxIconReadOnlyChecked: {
      "&:before": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(0.7),
        top: theme.spacing(0.4),
        width: theme.spacing(0.9),
        height: theme.spacing(0.3),
        backgroundColor: theme.palette.grey.dark,
        borderRadius: 3,
        transform: "rotate(46deg)",
        cursor: "auto"
      },
      "&:after": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(1.6),
        top: theme.spacing(-0.4),
        width: theme.spacing(0.3),
        height: theme.spacing(1.4),
        backgroundColor: theme.palette.grey.dark,
        borderRadius: 3,
        transform: "rotate(33deg)",
        cursor: "auto"
      }
    },
    checkBoxIconReadOnly: {
      "&:before": {
        content: "\" \"",
        position: "absolute",
        top: theme.spacing(-0.15),
        left: theme.spacing(1.2),
        width: theme.spacing(0.2),
        height: theme.spacing(1.25),
        backgroundColor: "red",
        borderRadius: 3,
        transform: "rotate(45deg)",
        cursor: "auto"
      },
      "&:after": {
        content: "\" \"",
        position: "absolute",
        top: theme.spacing(-0.15),
        left: theme.spacing(1.2),
        width: theme.spacing(0.2),
        height: theme.spacing(1.25),
        backgroundColor: "red",
        borderRadius: 3,
        transform: "rotate(-45deg)",
        cursor: "auto"
      }
    },
    indeterminateIconChecked: {
      backgroundColor: "currentColor",
      borderColor: "currentColor",
      "&:before": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(0.8),
        top: theme.spacing(1.3),
        width: theme.spacing(1),
        height: theme.spacing(0.2),
        backgroundColor: "white"
      }
    },
    indeterminateIconReadOnly: {
      "&:before": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(0.8),
        top: theme.spacing(1.3),
        width: theme.spacing(1),
        height: theme.spacing(0.2),
        backgroundColor: theme.palette.grey.dark
      }
    }
  };
});
var Checkbox = function Checkbox(_ref) {
  var checkboxProps = _ref.checkboxProps;
  if ((0, _CheckboxProps.isCheckboxProps)(checkboxProps) === false) {
    throw new TypeError("checkboxProps property is not of type CheckboxProps");
  }
  var onChange = checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.onChange);
  var indeterminate = (checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.indeterminate)) || false;
  var update = checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.update);
  var value = checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.value);
  var label = checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.label);
  var readOnly = (checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.readOnly)) || false;
  var disabled = (checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.disabled)) || false;
  var metadata = checkboxProps == null ? void 0 : checkboxProps.get(_CheckboxProps.default.propNames.metadata);
  var handleChange = function handleChange(event) {
    update(event.target.checked, metadata);
  };
  var onUseChange = function onUseChange(event) {
    if (onChange) {
      onChange(event);
    } else {
      handleChange(event);
    }
  };
  var classes = useStyles();
  var checkBoxMui = /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
    checked: value,
    onChange: !readOnly ? onUseChange : null,
    indeterminate: indeterminate,
    disabled: disabled,
    color: "primary",
    checkedIcon: /*#__PURE__*/_react.default.createElement("span", {
      className: (0, _classnames.default)(_defineProperty(_defineProperty(_defineProperty({}, "".concat(classes.checkBoxIcon), !readOnly), "".concat(classes.checkBoxIconChecked), !readOnly && value), "".concat(classes.checkBoxIconReadOnlyChecked), readOnly && value))
    }),
    icon: /*#__PURE__*/_react.default.createElement("span", {
      className: (0, _classnames.default)(_defineProperty(_defineProperty({}, "".concat(classes.checkBoxIcon), !readOnly), "".concat(classes.checkBoxIconReadOnly), readOnly && !value))
    }),
    indeterminateIcon: /*#__PURE__*/_react.default.createElement("span", {
      className: (0, _classnames.default)(_defineProperty(_defineProperty(_defineProperty({}, "".concat(classes.checkBoxIcon), !readOnly), "".concat(classes.indeterminateIconChecked), !readOnly && indeterminate), "".concat(classes.indeterminateIconReadOnly), readOnly && indeterminate))
    })
  });
  return label == null ? checkBoxMui : /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, {
    control: checkBoxMui,
    label: label
  });
};
__signature__(Checkbox, "useStyles{classes}", function () {
  return [useStyles];
});
__signature__(Checkbox, "useStyles{classes}", function () {
  return [useStyles];
});
var _default = _react.default.memo(Checkbox);
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Checkbox.js");
  reactHotLoader.register(Checkbox, "Checkbox", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Checkbox.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Checkbox.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Checkbox.js");
  reactHotLoader.register(Checkbox, "Checkbox", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Checkbox.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Checkbox.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();