import "core-js/modules/es.array.unshift.js";
import { FcrButton } from '../../button';
import { FcrCheckbox } from '../../checkbox';
import { FcrDropMenu } from '../../drop-menu';
import { FcrIconType } from '../../icon/type';
import { FcrPopover } from '../../popover';
import { FcrToolTip } from '../../tooltip';
import { useI18n } from '../../../i18n';
import './index.css';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var ACTION_MUTE_ALL_AUDIO = 'MUTE_ALL_AUDIO';
var ACTION_UNMUTE_ALL_AUDIO = 'UNMUTE_ALL_AUDIO';
var ACTION_REVOKE_HOST = 'REVOKE_HOST';
var ACTION_PLAY_JOIN_LEAVE_SOUND = 'PLAY_JOIN_LEAVE_SOUND';
var ACTION_LOCK_ROOM = 'LOCK_ROOM';
var ACTION_ENABLE_WAITING_ROOM = 'ENABLE_WAITING_ROOM';
var ACTION_ALLOW_ATTENDEE_TO_UNMUTE = 'ALLOW_ATTENDEE_TO_UNMUTE';
var ACTION_RENAME = 'RENAME';
var ACTION_ALLOW_ATTENDEE_TO_OPEN_CAMERA = 'ALLOW_ATTENDEE_TO_OPEN_CAMERA';
var ACTION_REVOKE_HOST_BY_TICKET = 'ACTION_REVOKE_HOST_BY_TICKET';
var ACTION_CHANGE_NAME = 'ACTION_CHANGE_NAME';
var createAllActions = function createAllActions(t, onRoomControlClick, hasRevokeHostPermission) {
  var allActions = [{
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_security_buttons_allhandsdown'),
      styleType: "white"
    }),
    key: 'mute_all',
    type: 'disabled',
    onButtonClick: function onButtonClick() {},
    classNames: 'room-control-drop-with-under-line'
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: true,
      label: t('fmt_security_options_silence'),
      styleType: "white"
    }),
    key: 'join_room_with_mute',
    type: 'primary',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_MUTE_ALL_AUDIO);
    }
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_security_options_playnotification'),
      styleType: "white"
    }),
    key: 'play_join_leave_sound',
    type: 'disabled',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_PLAY_JOIN_LEAVE_SOUND);
    }
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_screenshare_controlbar_security_list_lock'),
      styleType: "white"
    }),
    key: 'lock_room',
    type: 'disabled',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_LOCK_ROOM);
    }
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_security_options_activatewaitingroom'),
      styleType: "white"
    }),
    key: 'enable_waiting_room',
    type: 'disabled',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_ENABLE_WAITING_ROOM);
    },
    classNames: 'room-control-drop-with-under-line'
  }, {
    title: t('fmt_screenshare_options_allow'),
    key: 'allow_attendee_title',
    type: 'title'
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_screenshare_controlbar_security_list_participant_unmute'),
      styleType: "white"
    }),
    key: 'unmute_yourself',
    type: 'primary',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_ALLOW_ATTENDEE_TO_UNMUTE);
    }
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_screenshare_controlbar_security_list_participant_changeName'),
      styleType: "white"
    }),
    key: 'rename',
    type: 'disabled',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_RENAME);
    }
  }, {
    title: /*#__PURE__*/_jsx(FcrCheckbox, {
      checked: false,
      label: t('fmt_security_start_video'),
      styleType: "white"
    }),
    key: 'start_video',
    type: 'primary',
    onButtonClick: function onButtonClick() {
      onRoomControlClick(ACTION_ALLOW_ATTENDEE_TO_OPEN_CAMERA);
    },
    classNames: 'room-control-drop-with-under-line'
  }];
  if (hasRevokeHostPermission) {
    allActions.unshift({
      title: /*#__PURE__*/_jsx(FcrCheckbox, {
        checked: false,
        label: t('fmt_security_options_restract'),
        styleType: "white"
      }),
      key: 'revoke_host',
      type: 'primary',
      onButtonClick: function onButtonClick() {
        onRoomControlClick(ACTION_REVOKE_HOST);
      },
      classNames: 'room-control-drop-with-under-line'
    });
  }
  return allActions;
};
export var FcrParticipantsFooter = function FcrParticipantsFooter(props) {
  var _props$onRoomControlC = props.onRoomControlClick,
    onRoomControlClick = _props$onRoomControlC === void 0 ? function () {} : _props$onRoomControlC,
    moreDropMenu = props.moreDropMenu,
    hasRevokeHostPermission = props.hasRevokeHostPermission,
    _props$openMuteAllDia = props.openMuteAllDialog,
    openMuteAllDialog = _props$openMuteAllDia === void 0 ? function () {} : _props$openMuteAllDia;
  var t = useI18n();
  var ParticipantsFooterMore = function ParticipantsFooterMore() {
    var allActions = createAllActions(t, onRoomControlClick, !!hasRevokeHostPermission);
    return /*#__PURE__*/_jsx(FcrDropMenu, {
      options: allActions
    });
  };
  return /*#__PURE__*/_jsxs("div", {
    className: "fcr-participant__footer",
    children: [/*#__PURE__*/_jsx(FcrToolTip, {
      content: t('fmt_participants_options_allmute'),
      mouseEnterDelay: 0,
      trigger: "hover",
      children: /*#__PURE__*/_jsx(FcrButton, {
        type: "secondary-bordered",
        size: "XS",
        onClick: openMuteAllDialog,
        children: t('fmt_participants_options_allmute')
      })
    }), /*#__PURE__*/_jsx(FcrToolTip, {
      content: t('fmt_participants_options_allunmute'),
      mouseEnterDelay: 0,
      trigger: "hover",
      children: /*#__PURE__*/_jsx(FcrButton, {
        type: "secondary-bordered",
        size: "XS",
        onClick: function onClick() {
          return onRoomControlClick(ACTION_UNMUTE_ALL_AUDIO);
        },
        children: t('fmt_participants_button_unmuteAll')
      })
    }), /*#__PURE__*/_jsx(FcrPopover, {
      showArrow: false,
      trigger: "click",
      overlayClassName: "attendee__footer-more-actions",
      mouseEnterDelay: 0,
      overlayInnerStyle: {
        boxShadow: 'none',
        border: 'none',
        minWidth: '200px',
        width: 'auto',
        maxWidth: '280px'
      },
      content: moreDropMenu ? moreDropMenu : /*#__PURE__*/_jsx(ParticipantsFooterMore, {}),
      children: /*#__PURE__*/_jsx(FcrButton, {
        type: "secondary-bordered",
        size: "XS",
        postIcon: FcrIconType.FCR_DROPDOWN,
        children: t('fmt_participants_button_meetingManagement')
      })
    })]
  });
};
export var FcrParticipantsFooterRename = function FcrParticipantsFooterRename(_ref) {
  var onRoomControlClick = _ref.onRoomControlClick;
  var t = useI18n();
  return /*#__PURE__*/_jsx(FcrToolTip, {
    content: t('fmt_additional_option_rename_in_meeting'),
    mouseEnterDelay: 0,
    trigger: "hover",
    children: /*#__PURE__*/_jsx(FcrButton, {
      type: "secondary-bordered",
      shape: "rounded",
      size: "XS",
      onClick: function onClick() {
        return onRoomControlClick === null || onRoomControlClick === void 0 ? void 0 : onRoomControlClick(ACTION_CHANGE_NAME);
      },
      children: t('fmt_additional_option_rename_in_meeting')
    })
  });
};
export var FcrParticipantsFooterWithRevokeHost = function FcrParticipantsFooterWithRevokeHost(_ref2) {
  var type = _ref2.type,
    onRoomControlClick = _ref2.onRoomControlClick;
  var t = useI18n();
  var isRevoke = type === 'revoke';
  return /*#__PURE__*/_jsx(FcrToolTip, {
    content: t(isRevoke ? 'fmt_hostkey_participant_button_reclaim_host' : 'fmt_hostkey_participant_button_claim_host'),
    mouseEnterDelay: 0,
    trigger: "hover",
    children: /*#__PURE__*/_jsx(FcrButton, {
      type: "secondary-bordered",
      size: "XS",
      onClick: function onClick() {
        return onRoomControlClick === null || onRoomControlClick === void 0 ? void 0 : onRoomControlClick(isRevoke ? ACTION_REVOKE_HOST : ACTION_REVOKE_HOST_BY_TICKET);
      },
      children: isRevoke ? t('fmt_hostkey_participant_button_reclaim_host') : t('fmt_hostkey_participant_button_claim_host')
    })
  });
};