import { defineComponent, ref, onMounted, onUnmounted, openBlock, createElementBlock, unref, withDirectives, createVNode, createCommentVNode, createElementVNode, createBlock, createTextVNode, toDisplayString } from "vue";
import IconButton from "../../common/base/IconButton.vue.mjs";
import useControl from "./useMoreControlHooks.mjs";
import _sfc_main$1 from "../ChatControl.vue.mjs";
import InviteControl from "../InviteControl.vue.mjs";
import ContactControl from "../ContactControl.vue.mjs";
import { useRoomStore } from "../../../stores/room.mjs";
import ExtensionIcon from "../../common/icons/ExtensionIcon.vue.mjs";
import bus from "../../../hooks/useMitt.mjs";
import vTap from "../../../directives/vTap.mjs";
import "../../../services/main.mjs";
import { roomService } from "../../../services/roomService.mjs";
import "../../../locales/index.mjs";
import "@tencentcloud/tuiroom-engine-js";
import "mitt";
import "../../../services/manager/roomActionManager.mjs";
import "@tencentcloud/tui-core";
const _hoisted_1 = {
  key: 0,
  class: "more-control-container"
};
const _hoisted_2 = { class: "control-compent" };
const _hoisted_3 = { class: "close" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "MoreControlH5",
  setup(__props) {
    const moreControlConfig = roomService.getComponentConfig("MoreControl");
    const showMoreContent = ref(false);
    const moreContentRef = ref();
    const { t, sidebarName } = useControl();
    const roomStore = useRoomStore();
    function showMore() {
      showMoreContent.value = true;
    }
    function handleCancelControl() {
      showMoreContent.value = false;
    }
    function handleControlClick(name) {
      bus.emit("experience-communication", name);
    }
    function handleDocumentClick(event) {
      if (showMoreContent.value && !moreContentRef.value.contains(event.target)) {
        showMoreContent.value = false;
      }
    }
    onMounted(() => {
      document == null ? void 0 : document.addEventListener("click", handleDocumentClick, true);
    });
    onUnmounted(() => {
      document == null ? void 0 : document.removeEventListener("click", handleDocumentClick, true);
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", null, [
        unref(moreControlConfig).visible ? (openBlock(), createElementBlock("div", _hoisted_1, [
          withDirectives(createVNode(IconButton, {
            "is-active": unref(sidebarName) === "more",
            title: unref(t)("More"),
            icon: ExtensionIcon
          }, null, 8, ["is-active", "title"]), [
            [unref(vTap), showMore]
          ])
        ])) : createCommentVNode("", true),
        showMoreContent.value ? (openBlock(), createElementBlock("div", {
          key: 1,
          ref_key: "moreContentRef",
          ref: moreContentRef,
          class: "show-more-content"
        }, [
          createElementVNode("div", _hoisted_2, [
            unref(roomStore).isSpeakAfterTakingSeatMode ? (openBlock(), createBlock(_sfc_main$1, {
              key: 0,
              onClick: _cache[0] || (_cache[0] = ($event) => handleControlClick("chatControl"))
            })) : createCommentVNode("", true),
            createVNode(ContactControl, {
              onClick: _cache[1] || (_cache[1] = ($event) => handleControlClick("contactControl"))
            }),
            createVNode(InviteControl, {
              onClick: _cache[2] || (_cache[2] = ($event) => handleControlClick("inviteControl"))
            })
          ]),
          withDirectives((openBlock(), createElementBlock("div", _hoisted_3, [
            createTextVNode(toDisplayString(unref(t)("Cancel")), 1)
          ])), [
            [unref(vTap), handleCancelControl]
          ])
        ], 512)) : createCommentVNode("", true)
      ]);
    };
  }
});
export {
  _sfc_main as default
};
