import TUIChatEngine from "@tencentcloud/chat-uikit-engine";
import { isCustomerServicePluginMessage } from "@tencentcloud/tui-customer-service-plugin";
import { JSONToObject } from "../../utils/type-check.mjs";
function isCallMessage(message) {
  var _a;
  const payloadData = JSONToObject((_a = message == null ? void 0 : message.payload) == null ? void 0 : _a.data);
  if ((payloadData == null ? void 0 : payloadData.businessID) === 1 && (payloadData == null ? void 0 : payloadData.data)) {
    const payloadDataData = JSONToObject(payloadData.data);
    if (payloadDataData.businessID === "av_call") {
      return true;
    }
  }
  return false;
}
function isRoomSignalingMessage(message) {
  var _a;
  const payloadData = JSONToObject((_a = message == null ? void 0 : message.payload) == null ? void 0 : _a.data);
  return (payloadData == null ? void 0 : payloadData.businessID) === "ROOM_INVITE_ACTION" || (payloadData == null ? void 0 : payloadData.businessID) === "tuikit_engine_room";
}
function isRoomCardMessage(message) {
  var _a;
  const payloadData = JSONToObject((_a = message == null ? void 0 : message.payload) == null ? void 0 : _a.data);
  return (payloadData == null ? void 0 : payloadData.businessID) === "group_room_message";
}
function isPluginMessage(message) {
  return message.type === TUIChatEngine.TYPES.MSG_CUSTOM && (isCallMessage(message) || isCustomerServicePluginMessage(message) || isRoomCardMessage(message) || isRoomSignalingMessage(message));
}
export {
  isCallMessage,
  isPluginMessage,
  isRoomCardMessage,
  isRoomSignalingMessage
};
