import { defineComponent, unref, openBlock, createElementBlock, createVNode, withCtx, createCommentVNode } from "vue";
import IconButton from "../common/base/IconButton.vue.mjs";
import ChatIcon from "../common/icons/ChatIcon.vue.mjs";
import { useBasicStore } from "../../stores/basic.mjs";
import { useChatStore } from "../../stores/chat.mjs";
import { storeToRefs } from "pinia";
import { useI18n } from "../../locales/index.mjs";
import TuiBadge from "../common/base/Badge.vue.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";
const _hoisted_1 = {
  key: 0,
  class: "chat-control-container"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ChatControl",
  setup(__props) {
    const { t } = useI18n();
    const chatControlConfig = roomService.getComponentConfig("ChatControl");
    const basicStore = useBasicStore();
    const chatStore = useChatStore();
    const { sidebarName } = storeToRefs(basicStore);
    async function toggleChatSidebar() {
      if (basicStore.isSidebarOpen && basicStore.sidebarName === "chat") {
        basicStore.setSidebarOpenStatus(false);
        basicStore.setSidebarName("");
        return;
      }
      basicStore.setSidebarOpenStatus(true);
      basicStore.setSidebarName("chat");
      chatStore.updateUnReadCount(0);
    }
    return (_ctx, _cache) => {
      return unref(chatControlConfig).visible ? (openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(TuiBadge, {
          hidden: unref(chatStore).unReadCount === 0,
          value: unref(chatStore).unReadCount,
          max: 10
        }, {
          default: withCtx(() => [
            createVNode(IconButton, {
              title: unref(t)("Chat"),
              icon: ChatIcon,
              "is-active": unref(sidebarName) === "chat",
              onClickIcon: toggleChatSidebar
            }, null, 8, ["title", "is-active"])
          ]),
          _: 1
        }, 8, ["hidden", "value"])
      ])) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
