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); }
import React from "react";
import Box from "../../atoms/box/box";
import { pearl } from "../../../pearl";
import Pressable from "../../atoms/pressable/pressable";
import { useCheckedState } from "../../../hooks";
import { boxStyleFunctions } from "../../../theme/src/style-functions";
const BaseSwitch = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  children,
  atoms,
  ...rest
}, ref) => {
  let {
    isChecked,
    isDisabled,
    ...otherTrackProps
  } = atoms.track;
  const {
    propsWithCheckedStyles: propsWithCheckedStylesForTrack
  } = useCheckedState(otherTrackProps, boxStyleFunctions, "molecule", true, isChecked);
  otherTrackProps = propsWithCheckedStylesForTrack;
  const {
    propsWithCheckedStyles: propsWithCheckedStylesForKnob
  } = useCheckedState(atoms.knob, boxStyleFunctions, "molecule", true, isChecked);
  atoms.knob = propsWithCheckedStylesForKnob;
  return /*#__PURE__*/React.createElement(Pressable, _extends({}, otherTrackProps, {
    ref: ref,
    accessible: true,
    accessibilityRole: "switch",
    isDisabled: isDisabled,
    accessibilityLabel: atoms.track.accessibilityLabel,
    accessibilityState: {
      disabled: isDisabled,
      checked: isChecked
    },
    accessibilityHint: rest.accessibilityHint
  }), /*#__PURE__*/React.createElement(Box, atoms.knob));
}));

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