import { defineComponent, ref, unref, withDirectives, openBlock, createElementBlock, createVNode, createBlock, createCommentVNode } from "vue";
import IconButton from "../common/base/IconButton.vue.mjs";
import InviteIcon from "../common/icons/InviteIcon.vue.mjs";
import { useBasicStore } from "../../stores/basic.mjs";
import { storeToRefs } from "pinia";
import { useI18n } from "../../locales/index.mjs";
import { isMobile } from "../../utils/environment.mjs";
import Index from "../RoomInvite/index.mjs";
import "../../services/main.mjs";
import { roomService } from "../../services/roomService.mjs";
import "@tencentcloud/tuiroom-engine-js";
import "mitt";
import "../../services/manager/roomActionManager.mjs";
import "@tencentcloud/tui-core";
import vClickOutside from "../../directives/vClickOutside.mjs";
const _hoisted_1 = {
  key: 0,
  class: "invite-control-container"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "InviteControl",
  setup(__props) {
    const basicStore = useBasicStore();
    const { sidebarName } = storeToRefs(basicStore);
    const { t } = useI18n();
    const isShowInviteTab = ref(false);
    const inviteRef = ref();
    const inviteControlConfig = roomService.getComponentConfig("InviteControl");
    function toggleInviteSidebar() {
      isShowInviteTab.value = !isShowInviteTab.value;
      if (isMobile) {
        if (basicStore.sidebarName === "invite") {
          basicStore.setSidebarName("");
          return;
        }
        basicStore.setSidebarName("invite");
      }
    }
    function handleCloseInvite() {
      isShowInviteTab.value = false;
    }
    function handleClickOutSide() {
      if (isShowInviteTab.value) {
        isShowInviteTab.value = false;
      }
    }
    return (_ctx, _cache) => {
      return unref(inviteControlConfig).visible ? withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(IconButton, {
          class: "invite",
          "is-active": unref(sidebarName) === "invite",
          title: unref(t)("Invite"),
          icon: InviteIcon,
          onClickIcon: toggleInviteSidebar
        }, null, 8, ["is-active", "title"]),
        isShowInviteTab.value ? (openBlock(), createBlock(unref(Index), {
          key: 0,
          ref_key: "inviteRef",
          ref: inviteRef,
          onOnCloseInvite: handleCloseInvite
        }, null, 512)) : createCommentVNode("", true)
      ])), [
        [unref(vClickOutside), handleClickOutSide]
      ]) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
