"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const uikitBaseComponentVue3 = require("@tencentcloud/uikit-base-component-vue3");
const chat = require("tuikit-atomicx-vue3/chat");
const room = require("tuikit-atomicx-vue3/room");
const CustomMessage = require("./CustomMessage.vue3.js");
const _hoisted_1 = { class: "room-chat" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  props: {
    isChatOpen: { type: Boolean, default: false }
  },
  setup(__props) {
    const props = __props;
    const messageListRef = vue.ref(null);
    const { t } = uikitBaseComponentVue3.useUIKit();
    const { localParticipant } = room.useRoomParticipantState();
    const placeholder = vue.computed(
      () => {
        var _a;
        return ((_a = localParticipant.value) == null ? void 0 : _a.isMessageDisabled) ? t("RoomChat.disabled_placeholder") : t("RoomChat.input_placeholder");
      }
    );
    const messageActionList = chat.useMessageActions(["copy", "recall", "delete"]);
    vue.watch(() => props.isChatOpen, (newVal, oldVal) => {
      var _a;
      if (newVal && !oldVal && messageListRef.value) {
        (_a = messageListRef.value) == null ? void 0 : _a.scrollToBottom({ behavior: "instant" });
      }
    });
    return (_ctx, _cache) => {
      var _a;
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(chat.MessageList), {
          ref_key: "messageListRef",
          ref: messageListRef,
          class: "room-message-list",
          messageActionList: vue.unref(messageActionList),
          Message: CustomMessage.default
        }, null, 8, ["messageActionList"]),
        vue.createVNode(vue.unref(chat.MessageInput), {
          class: "room-message-input",
          hideSendButton: "",
          placeholder: placeholder.value,
          disabled: (_a = vue.unref(localParticipant)) == null ? void 0 : _a.isMessageDisabled
        }, null, 8, ["placeholder", "disabled"])
      ]);
    };
  }
});
exports.default = _sfc_main;
