"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const IconButton = require("../common/base/IconButton.vue.js");
const ChatIcon = require("../common/icons/ChatIcon.vue.js");
const basic = require("../../stores/basic.js");
const chat = require("../../stores/chat.js");
const pinia = require("pinia");
const index = require("../../locales/index.js");
const Badge = require("../common/base/Badge.vue.js");
require("../../services/main.js");
const roomService = require("../../services/roomService.js");
require("@tencentcloud/tuiroom-engine-js");
require("mitt");
require("../../services/manager/roomActionManager.js");
require("@tencentcloud/tui-core");
const _hoisted_1 = {
  key: 0,
  class: "chat-control-container"
};
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "ChatControl",
  setup(__props) {
    const { t } = index.useI18n();
    const chatControlConfig = roomService.roomService.getComponentConfig("ChatControl");
    const basicStore = basic.useBasicStore();
    const chatStore = chat.useChatStore();
    const { sidebarName } = pinia.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 Vue.unref(chatControlConfig).visible ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        Vue.createVNode(Badge.default, {
          hidden: Vue.unref(chatStore).unReadCount === 0,
          value: Vue.unref(chatStore).unReadCount,
          max: 10
        }, {
          default: Vue.withCtx(() => [
            Vue.createVNode(IconButton.default, {
              title: Vue.unref(t)("Chat"),
              icon: ChatIcon.default,
              "is-active": Vue.unref(sidebarName) === "chat",
              onClickIcon: toggleChatSidebar
            }, null, 8, ["title", "is-active"])
          ]),
          _: 1
        }, 8, ["hidden", "value"])
      ])) : Vue.createCommentVNode("", true);
    };
  }
});
exports.default = _sfc_main;
