"use strict";

require("core-js/modules/es.object.define-property.js");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MicrophoneState = void 0;
var _icon = require("../../icon");
var _mic = require("../../icon/mic");
var _type = require("../../icon/type");
var _jsxRuntime = require("react/jsx-runtime");
var MicrophoneState = exports.MicrophoneState = function MicrophoneState(_ref) {
  var isMicrophoneMuted = _ref.isMicrophoneMuted,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? 20 : _ref$size,
    _ref$voicePercent = _ref.voicePercent,
    voicePercent = _ref$voicePercent === void 0 ? 0 : _ref$voicePercent,
    _ref$isPhoneMic = _ref.isPhoneMic,
    isPhoneMic = _ref$isPhoneMic === void 0 ? false : _ref$isPhoneMic,
    _ref$mutedColor = _ref.mutedColor,
    mutedColor = _ref$mutedColor === void 0 ? 'var(--fcr_ui_scene_ramp_red6)' : _ref$mutedColor,
    _ref$activeColor = _ref.activeColor,
    activeColor = _ref$activeColor === void 0 ? 'var(--fcr_ui_scene_ramp_green6)' : _ref$activeColor;
  var renderIcon = function renderIcon(type, iconPrimary) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
      size: size,
      type: type,
      colors: {
        iconPrimary: iconPrimary
      }
    });
  };
  if (isPhoneMic) {
    var iconType = _type.FcrIconType.FCR_PHONECALL3; // Default to the highest level
    if (isMicrophoneMuted) {
      iconType = _type.FcrIconType.FCR_PHONECALL_SILENCE;
    } else if (voicePercent >= 20) {
      iconType = _type.FcrIconType.FCR_PHONECALL3;
    } else if (voicePercent >= 10) {
      iconType = _type.FcrIconType.FCR_PHONECALL2;
    } else if (voicePercent >= 5) {
      iconType = _type.FcrIconType.FCR_PHONECALL1;
    }
    return renderIcon(iconType, isMicrophoneMuted ? mutedColor : activeColor);
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
    children: isMicrophoneMuted ? renderIcon(_type.FcrIconType.FCR_NOMUTE, mutedColor) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_mic.FcrMicrophoneIndicator, {
      voicePercent: voicePercent,
      size: size
    })
  });
};