"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _ActionButton = _interopRequireDefault(require("./ActionButton"));

var _icons = require("@material-ui/icons");

var _styles = require("@material-ui/core/styles");

var _hooks = require("subfirelib/hooks");

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

const style = theme => {
  return {
    enabled: {
      color: theme.palette.primary.light
    },
    paused: {
      color: '#999999'
    },
    disabled: {
      display: 'none'
    }
  };
};

const RemoteReceiverToggleButton = props => {
  const {
    remoteEnabled,
    setRemoteEnabled
  } = (0, _hooks.useRemoteReceiver)();

  const icon = /*#__PURE__*/_react.default.createElement(_icons.Airplay, {
    className: props.iconClassName
  });

  const label = remoteEnabled ? 'Disable' : 'Enable';

  const action = () => setRemoteEnabled(x => !x);

  const classes = props.classes;
  const coreProps = {
    action: action,
    label: label,
    disabled: props.isLoading,
    fab: props.fab,
    standalone: props.standalone,
    buttonClassName: remoteEnabled ? props.classes.enabled : props.classes.paused
  };
  return /*#__PURE__*/_react.default.createElement(_ActionButton.default, coreProps, icon);
};

var _default = (0, _styles.withStyles)(style)(RemoteReceiverToggleButton);

exports.default = _default;