"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CheckMark = void 0;

var _preact = require("preact");

var _icon = require("./icon");

var _classnames = _interopRequireDefault(require("classnames"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

const CheckMark = (_ref) => {
  let {
    className,
    name,
    label,
    isComplete,
    isAuto,
    onClick
  } = _ref,
      rest = _objectWithoutProperties(_ref, ["className", "name", "label", "isComplete", "isAuto", "onClick"]);

  return (0, _preact.h)("label", _extends({
    htmlFor: name,
    className: (0, _classnames.default)('flex items-center mb2', className),
    "data-e2e": "checkMark",
    "data-state": isComplete ? 'checked' : 'unchecked'
  }, rest), (0, _preact.h)("input", {
    onClick: () => onClick(name),
    className: "checkbox o-0",
    id: name,
    checked: isComplete,
    type: "checkbox"
  }), !isAuto && isComplete && (0, _preact.h)(_icon.Icon, {
    className: "light-blue",
    size: "40",
    icon: "check_box"
  }), !isAuto && !isComplete && (0, _preact.h)(_icon.Icon, {
    size: "40",
    icon: "check_box_outline_blank"
  }), isAuto && (0, _preact.h)("div", {
    className: "relative bg-light-blue br2",
    style: {
      margin: '5px',
      width: '30px',
      height: '30px'
    }
  }, (0, _preact.h)(_icon.Icon, {
    size: "18",
    className: "absolute white",
    icon: "auto_awesome",
    style: {
      left: '6px',
      top: '2px'
    }
  }), (0, _preact.h)("span", {
    className: "helvetica absolute tc bottom-0 smallcaps white ttu fw6",
    style: {
      fontSize: '8px',
      width: '30px'
    }
  }, "auto")), (0, _preact.h)("span", {
    className: "ml2"
  }, label || name));
};

exports.CheckMark = CheckMark;