"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
require("../../adapter-vue.js");
const TUIChatEngine = require("@tencentcloud/chat-uikit-engine");
const tuiCustomerServicePlugin = require("@tencentcloud/tui-customer-service-plugin");
const index = require("./index.js");
const messagePluginLayout = require("./message-plugin-layout.vue.js");
const messageCallGroup = require("./message-call/message-call-group.vue.js");
const messageCallC2c = require("./message-call/message-call-c2c.vue.js");
const messageCustomerService = require("./message-customer/message-customer-service.vue.js");
const messageRoomDefault = require("./message-room/message-room-default.vue.js");
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "message-plugin",
  props: {
    message: { default: () => ({}) },
    blinkMessageIDList: { default: () => [] }
  },
  emits: ["resendMessage", "handleToggleMessageItem", "handleH5LongPress"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const messageModel = Vue.computed(() => TUIChatEngine.TUIStore.getMessageModel(props.message.ID));
    const messageSignalingInfo = Vue.computed(() => {
      var _a;
      return (_a = messageModel == null ? void 0 : messageModel.value) == null ? void 0 : _a.getSignalingInfo();
    });
    const messageCustomContent = Vue.computed(() => {
      var _a;
      return (_a = messageModel == null ? void 0 : messageModel.value) == null ? void 0 : _a.getMessageContent();
    });
    const pluginMessageType = Vue.computed(() => {
      var _a;
      let typeObj = { pluginType: "", showStyle: "" };
      if (index.isCallMessage(messageModel.value)) {
        typeObj = {
          pluginType: "call",
          showStyle: ((_a = messageModel.value) == null ? void 0 : _a.conversationType) === TUIChatEngine.TYPES.CONV_GROUP ? "tip" : "bubble"
        };
      } else if (index.isRoomCardMessage(messageModel.value)) {
        typeObj = {
          pluginType: "room",
          showStyle: "bubble"
        };
      } else if (tuiCustomerServicePlugin.isCustomerServicePluginMessage(messageModel.value)) {
        typeObj = {
          pluginType: "customer",
          showStyle: tuiCustomerServicePlugin.isMessageInvisible(messageModel.value) ? "" : "bubble"
        };
      }
      return typeObj;
    });
    const resendMessage = (message) => {
      emits("resendMessage", message);
    };
    const handleToggleMessageItem = (e, message, isLongpress = false) => {
      emits("handleToggleMessageItem", e, message, isLongpress);
    };
    const handleH5LongPress = (e, message, type) => {
      emits("handleH5LongPress", e, message, type);
    };
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(messagePluginLayout.default, {
        message: props.message,
        showStyle: Vue.unref(pluginMessageType).showStyle,
        bubbleClassNameList: [Vue.unref(pluginMessageType).pluginType === "room" ? "message-bubble-room" : ""],
        onResendMessage: resendMessage,
        onHandleToggleMessageItem: handleToggleMessageItem,
        onHandleH5LongPress: handleH5LongPress
      }, {
        messageTip: Vue.withCtx(() => [
          Vue.createVNode(messageCallGroup.default, {
            message: props.message,
            signalingInfo: Vue.unref(messageSignalingInfo),
            customContent: Vue.unref(messageCustomContent),
            blinkMessageIDList: props.blinkMessageIDList
          }, null, 8, ["message", "signalingInfo", "customContent", "blinkMessageIDList"])
        ]),
        messageBubble: Vue.withCtx(() => [
          Vue.unref(pluginMessageType).pluginType === "call" ? (Vue.openBlock(), Vue.createBlock(messageCallC2c.default, {
            key: 0,
            message: props.message,
            signalingInfo: Vue.unref(messageSignalingInfo),
            customContent: Vue.unref(messageCustomContent)
          }, null, 8, ["message", "signalingInfo", "customContent"])) : Vue.createCommentVNode("", true),
          Vue.unref(pluginMessageType).pluginType === "customer" ? (Vue.openBlock(), Vue.createBlock(messageCustomerService.default, {
            key: 1,
            message: props.message
          }, null, 8, ["message"])) : Vue.createCommentVNode("", true),
          Vue.unref(pluginMessageType).pluginType === "room" ? (Vue.openBlock(), Vue.createBlock(messageRoomDefault.default, {
            key: 2,
            message: props.message
          }, null, 8, ["message"])) : Vue.createCommentVNode("", true)
        ]),
        _: 1
      }, 8, ["message", "showStyle", "bubbleClassNameList"]);
    };
  }
});
exports.default = _sfc_main;
