"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _box = _interopRequireDefault(require("../../atoms/box/box"));
var _pearl = require("../../../pearl");
var _pressable = _interopRequireDefault(require("../../atoms/pressable/pressable"));
var _hooks = require("../../../hooks");
var _styleFunctions = require("../../../theme/src/style-functions");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
const BaseSwitch = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  children,
  atoms,
  ...rest
}, ref) => {
  let {
    isChecked,
    isDisabled,
    ...otherTrackProps
  } = atoms.track;
  const {
    propsWithCheckedStyles: propsWithCheckedStylesForTrack
  } = (0, _hooks.useCheckedState)(otherTrackProps, _styleFunctions.boxStyleFunctions, "molecule", true, isChecked);
  otherTrackProps = propsWithCheckedStylesForTrack;
  const {
    propsWithCheckedStyles: propsWithCheckedStylesForKnob
  } = (0, _hooks.useCheckedState)(atoms.knob, _styleFunctions.boxStyleFunctions, "molecule", true, isChecked);
  atoms.knob = propsWithCheckedStylesForKnob;
  return /*#__PURE__*/_react.default.createElement(_pressable.default, _extends({}, otherTrackProps, {
    ref: ref,
    accessible: true,
    accessibilityRole: "switch",
    isDisabled: isDisabled,
    accessibilityLabel: atoms.track.accessibilityLabel,
    accessibilityState: {
      disabled: isDisabled,
      checked: isChecked
    },
    accessibilityHint: rest.accessibilityHint
  }), /*#__PURE__*/_react.default.createElement(_box.default, atoms.knob));
}));

/** The Progress component is a visual indicator of completion percentage. */
const Switch = (0, _pearl.pearl)(BaseSwitch, {
  componentName: "Switch",
  type: "molecule",
  animatable: true
}, undefined, {
  partForOverridenAnimationProps: "track",
  partForOverridenNativeProps: "track",
  partForOverridenStyleProps: "track"
});
Switch.displayName = "Switch";
var _default = exports.default = Switch;
//# sourceMappingURL=switch.js.map