function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
var _excluded = ["checked", "children", "className", "error", "indeterminate", "style", "requiredMark", "tooltip"],
  _excluded2 = ["checked", "children", "className", "disabled", "error", "indeterminate", "style"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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; }
import { useLabel } from '@react-aria/label';
import React from 'react';
import { FormFieldTooltip } from '../Form/FormFieldTooltip';
import { Required } from '../Required/Required';
import { StyledCheckboxContainer, StyledCheckboxInput, StyledCheckboxLabel, StyledCheckboxLabelWrapper, StyledFakeCheckboxInput, StyledFakeCheckboxLabel } from './Checkbox.styles';
/**


 We use checkboxes to provide users with the ability to either select or
 deselect multiple values from a list of options (e.g. items on list pages),
 or to select or deselect a single option (e.g. settings on configure pages).

 @since 10.19.0

 @see [Storybook](https://stories.core.procore.com/?path=/story/core-react_demos-checkbox--demo)

 @see [Design Guidelines](https://design.procore.com/checkbox)

 */
export var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref) {
  var checked = _ref.checked,
    children = _ref.children,
    className = _ref.className,
    _ref$error = _ref.error,
    error = _ref$error === void 0 ? false : _ref$error,
    _ref$indeterminate = _ref.indeterminate,
    indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
    style = _ref.style,
    requiredMark = _ref.requiredMark,
    tooltip = _ref.tooltip,
    props = _objectWithoutProperties(_ref, _excluded);
  var _useLabel = useLabel(_objectSpread(_objectSpread({}, props), {}, {
      // to always generate labelProps, so checkbox icon can be clickable for empty labels
      label: true
    })),
    fieldProps = _useLabel.fieldProps,
    labelProps = _useLabel.labelProps;
  return /*#__PURE__*/React.createElement(StyledCheckboxContainer, {
    className: className,
    style: style
  }, /*#__PURE__*/React.createElement(StyledCheckboxInput, _extends({}, props, fieldProps, {
    "aria-checked": indeterminate ? 'mixed' : checked,
    type: "checkbox",
    checked: checked,
    $error: error,
    $indeterminate: indeterminate,
    ref: ref
  })), /*#__PURE__*/React.createElement(StyledCheckboxLabelWrapper, {
    $hasLabel: Boolean(children)
  }, /*#__PURE__*/React.createElement(StyledCheckboxLabel, labelProps, children, requiredMark && /*#__PURE__*/React.createElement(Required, null)), tooltip && /*#__PURE__*/React.createElement(FormFieldTooltip, {
    overlay: tooltip
  })));
});
Checkbox.displayName = 'Checkbox';

/**
 *  This checkbox was created to be used as a non-interactive Checkbox component
 *  for VoiceOver inside MenuImperative.CheckboxItem.
 *
 *  @since 11.3.0
 */

export var FakeCheckbox = /*#__PURE__*/React.forwardRef(function FakeCheckbox(_ref2, ref) {
  var _ref2$checked = _ref2.checked,
    checked = _ref2$checked === void 0 ? false : _ref2$checked,
    children = _ref2.children,
    className = _ref2.className,
    _ref2$disabled = _ref2.disabled,
    disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
    _ref2$error = _ref2.error,
    error = _ref2$error === void 0 ? false : _ref2$error,
    _ref2$indeterminate = _ref2.indeterminate,
    indeterminate = _ref2$indeterminate === void 0 ? false : _ref2$indeterminate,
    style = _ref2.style,
    props = _objectWithoutProperties(_ref2, _excluded2);
  return /*#__PURE__*/React.createElement(StyledCheckboxContainer, {
    className: className,
    style: style
  }, /*#__PURE__*/React.createElement(StyledFakeCheckboxInput, _extends({}, props, {
    $checked: checked,
    $disabled: disabled,
    $error: error,
    $indeterminate: indeterminate,
    ref: ref
  })), /*#__PURE__*/React.createElement(StyledFakeCheckboxLabel, {
    $checked: checked,
    $disabled: disabled
  }, children));
});
FakeCheckbox.displayName = 'FakeCheckbox';
//# sourceMappingURL=Checkbox.js.map