"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const IconButton = require("./base/IconButton.vue.js");
const index$1 = require("./base/MessageBox/index.js");
const AudioSettingTab = require("./AudioSettingTab.vue.js");
const AudioIcon = require("./AudioIcon.vue.js");
const index = require("../../locales/index.js");
const vClickOutside = require("../../directives/vClickOutside.js");
const mediaAbility = require("../../utils/mediaAbility.js");
const _hoisted_1 = { class: "audio-control-container" };
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "AudioMediaControl",
  props: {
    hasMore: { type: Boolean, default: true },
    isMuted: { type: Boolean },
    isDisabled: { type: Boolean, default: false },
    audioVolume: { default: 0 }
  },
  emits: ["click"],
  setup(__props, { emit: __emit }) {
    const emits = __emit;
    const showAudioSettingTab = Vue.ref(false);
    const isSupportAudioMedia = mediaAbility.isGetUserMediaSupported && mediaAbility.isEnumerateDevicesSupported;
    const { t } = index.useI18n();
    async function handleClickIcon() {
      if (!isSupportAudioMedia) {
        index$1.default({
          title: t("Note"),
          message: t("The current browser does not support capturing audio"),
          confirmButtonText: t("Sure")
        });
        return;
      }
      emits("click");
      showAudioSettingTab.value = false;
    }
    function handleMore() {
      showAudioSettingTab.value = !showAudioSettingTab.value;
    }
    function handleHideAudioSettingTab() {
      if (showAudioSettingTab.value) {
        showAudioSettingTab.value = false;
      }
    }
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", null, [
        Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
          Vue.createVNode(IconButton.default, {
            title: Vue.unref(t)("Mic"),
            "has-more": _ctx.hasMore,
            disabled: _ctx.isDisabled,
            "is-not-support": !Vue.unref(isSupportAudioMedia),
            onClickIcon: handleClickIcon,
            onClickMore: handleMore
          }, {
            default: Vue.withCtx(() => [
              Vue.createVNode(AudioIcon.default, {
                "audio-volume": _ctx.audioVolume,
                "is-muted": _ctx.isMuted,
                "is-disabled": _ctx.isDisabled
              }, null, 8, ["audio-volume", "is-muted", "is-disabled"])
            ]),
            _: 1
          }, 8, ["title", "has-more", "disabled", "is-not-support"]),
          Vue.withDirectives(Vue.createVNode(AudioSettingTab.default, {
            theme: "white",
            class: "audio-tab",
            "audio-volume": _ctx.audioVolume
          }, null, 8, ["audio-volume"]), [
            [Vue.vShow, showAudioSettingTab.value]
          ])
        ])), [
          [Vue.unref(vClickOutside.default), handleHideAudioSettingTab]
        ])
      ]);
    };
  }
});
exports.default = _sfc_main;
