import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import { useEffect, useState } from 'react';
import classNames from 'classnames';
import './mobile.css';
import { jsx as _jsx } from "react/jsx-runtime";
export var FcrMobileSwitch = function FcrMobileSwitch(_ref) {
  var labels = _ref.labels,
    value = _ref.value,
    _ref$onChange = _ref.onChange,
    onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
  var _useState = useState(value),
    _useState2 = _slicedToArray(_useState, 2),
    toggle = _useState2[0],
    setToggle = _useState2[1];
  var cls = classNames('fcr-switch', {
    'fcr-switch--on': toggle,
    'fcr-switch--off': !toggle
  });
  var handleClick = function handleClick() {
    setToggle(!toggle);
    onChange(!toggle);
  };
  useEffect(function () {
    setToggle(value);
  }, [value]);
  return /*#__PURE__*/_jsx("div", {
    className: cls,
    onClick: handleClick,
    children: /*#__PURE__*/_jsx("div", {
      className: "fcr-switch__slider"
    })
  });
};