"use strict";

require("core-js/modules/es.object.define-property.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MicrophoneDevice = exports.CameraDevice = exports.AudioRecordinDeviceIcon = void 0;
require("core-js/modules/web.timers.js");
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = require("react");
require("./index.css");
var _icon = require("../../icon");
var _type = require("../../icon/type");
var _microphoneIndicator = require("../../microphone-indicator");
var _i18n = require("../../../i18n");
var _jsxRuntime = require("react/jsx-runtime");
var AudioRecordinDeviceIcon = exports.AudioRecordinDeviceIcon = function AudioRecordinDeviceIcon(_ref) {
  var _ref$size = _ref.size,
    size = _ref$size === void 0 ? 32 : _ref$size,
    _ref$micEnabled = _ref.micEnabled,
    micEnabled = _ref$micEnabled === void 0 ? false : _ref$micEnabled,
    _ref$volume = _ref.volume,
    volume = _ref$volume === void 0 ? 0 : _ref$volume;
  var muteColor = {
    iconPrimary: "var(--fcr_ui_scene_ramp_red6)",
    iconSecondary: 'var(--fcr_ui_scene_ramp_red6)'
  };
  return !micEnabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
    type: _type.FcrIconType.FCR_NOMUTE,
    colors: muteColor,
    size: size
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_microphoneIndicator.MicrophoneIndicator, {
      size: size,
      voicePercent: volume
    })
  });
};
var MicrophoneDevice = exports.MicrophoneDevice = function MicrophoneDevice(_ref2) {
  var isMuted = _ref2.isMuted;
  var t = (0, _i18n.useI18n)();
  var _useState = (0, _react.useState)(0),
    _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
    volume = _useState2[0],
    setVolume = _useState2[1];
  (0, _react.useEffect)(function () {
    var timer = setInterval(function () {
      setVolume(11 + Math.floor(Math.random() * 90));
    }, 1000);
    return function () {
      return clearInterval(timer);
    };
  }, []);
  var title = (0, _react.useMemo)(function () {
    return !isMuted ? t('fmt_device_label_audio_mute') : t('fmt_device_label_audio_unmute');
  }, [isMuted]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "fcr-action-bar-item-wrapper",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-action-bar-device",
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: "fcr-action-bar-device-inner",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AudioRecordinDeviceIcon, {
          micEnabled: !isMuted,
          volume: volume
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "fcr-action-bar-device-text",
          children: title
        })]
      })
    })
  });
};
var CameraDevice = exports.CameraDevice = function CameraDevice(_ref3) {
  var isMuted = _ref3.isMuted;
  var t = (0, _i18n.useI18n)();
  var muteColor = {
    iconPrimary: !isMuted ? "var(--fcr_ui_scene_icontext5)" : 'var(--fcr_ui_scene_ramp_red6)',
    iconSecondary: 'var(--fcr_ui_scene_ramp_red6)'
  };
  var icon = !isMuted ? _type.FcrIconType.FCR_CAMERA : _type.FcrIconType.FCR_CAMERAOFF;
  var title = (0, _react.useMemo)(function () {
    return !isMuted ? t('fmt_toolbar_label_camera') : t('fmt_toolbar_options_enablecamera');
  }, [isMuted]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "fcr-action-bar-item-wrapper",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-action-bar-device",
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: "fcr-action-bar-device-inner",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
          type: icon,
          colors: muteColor,
          size: 32
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "fcr-action-bar-device-text",
          children: title
        })]
      })
    })
  });
};