"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 SvgIcon = require("./base/SvgIcon.vue.js");
const CameraOnIcon = require("./icons/CameraOnIcon.vue.js");
const CameraOffIcon = require("./icons/CameraOffIcon.vue.js");
const VideoSettingTab = require("./VideoSettingTab.vue.js");
const index = require("../../locales/index.js");
const vClickOutside = require("../../directives/vClickOutside.js");
const mediaAbility = require("../../utils/mediaAbility.js");
const _hoisted_1 = { class: "video-control-container" };
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "VideoMediaControl",
  props: {
    hasMore: { type: Boolean, default: true },
    isMuted: { type: Boolean, default: void 0 },
    isDisabled: { type: Boolean, default: false }
  },
  emits: ["click"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const { t } = index.useI18n();
    const showVideoSettingTab = Vue.ref(false);
    const isSupportVideoMedia = mediaAbility.isGetUserMediaSupported && mediaAbility.isEnumerateDevicesSupported;
    const icon = Vue.computed(() => props.isMuted ? CameraOffIcon.default : CameraOnIcon.default);
    async function handleClickIcon() {
      if (!isSupportVideoMedia) {
        index$1.default({
          title: t("Note"),
          message: t("The current browser does not support capturing video"),
          confirmButtonText: t("Sure")
        });
        return;
      }
      emits("click");
      showVideoSettingTab.value = false;
    }
    function handleMore() {
      showVideoSettingTab.value = !showVideoSettingTab.value;
    }
    function handleHideVideoSettingTab() {
      if (showVideoSettingTab.value) {
        showVideoSettingTab.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)("Camera"),
            "has-more": _ctx.hasMore,
            disabled: _ctx.isDisabled,
            "is-not-support": !Vue.unref(isSupportVideoMedia),
            onClickIcon: handleClickIcon,
            onClickMore: handleMore
          }, {
            default: Vue.withCtx(() => [
              Vue.createVNode(SvgIcon.default, { icon: icon.value }, null, 8, ["icon"])
            ]),
            _: 1
          }, 8, ["title", "has-more", "disabled", "is-not-support"]),
          Vue.withDirectives(Vue.createVNode(VideoSettingTab.default, {
            class: "video-tab",
            "with-mirror": true,
            theme: "white"
          }, null, 512), [
            [Vue.vShow, showVideoSettingTab.value]
          ])
        ])), [
          [Vue.unref(vClickOutside.default), handleHideVideoSettingTab]
        ])
      ]);
    };
  }
});
exports.default = _sfc_main;
