"use strict";
const common_vendor = require("../../../../common/vendor.js");
const TUIKit_components_TUIChat_emojiConfig_index = require("../emoji-config/index.js");
const TUIKit_components_TUIChat_offlinePushInfoManager_info = require("./info.js");
const TUIKit_components_TUIChat_offlinePushInfoManager_const = require("./const.js");
const _OfflinePushInfoManager = class _OfflinePushInfoManager {
  constructor() {
    this.name = "OfflinePushInfoManager";
    this.offlinePushInfo = {};
    this.offlinePushInfo = {
      [TUIKit_components_TUIChat_offlinePushInfoManager_const.PUSH_SCENE.CHAT]: TUIKit_components_TUIChat_offlinePushInfoManager_info.chatOfflinePushInfo,
      [TUIKit_components_TUIChat_offlinePushInfoManager_const.PUSH_SCENE.CALL]: TUIKit_components_TUIChat_offlinePushInfoManager_info.callOfflinePushInfo
    };
  }
  static getInstance() {
    if (!_OfflinePushInfoManager.instance) {
      _OfflinePushInfoManager.instance = new _OfflinePushInfoManager();
    }
    return _OfflinePushInfoManager.instance;
  }
  getOfflinePushInfo(scene) {
    if (!Object.values(TUIKit_components_TUIChat_offlinePushInfoManager_const.PUSH_SCENE).includes(scene)) {
      common_vendor.index.__f__("error", "at TUIKit/components/TUIChat/offlinePushInfoManager/offlinePushInfoManager.ts:32", `${this.name} getOfflinePushInfo scene: ${scene} is invalid`);
      return null;
    }
    return this.offlinePushInfo[scene];
  }
  genTitle(conversation, userInfo) {
    let title = conversation == null ? void 0 : conversation.getShowName();
    if (conversation.type === common_vendor.qt.TYPES.CONV_C2C) {
      title = (userInfo == null ? void 0 : userInfo.nick) || (userInfo == null ? void 0 : userInfo.userID);
    }
    return title;
  }
  genDesc(messageType, payload) {
    let desc = "";
    if (messageType === common_vendor.qt.TYPES.MSG_TEXT) {
      desc = TUIKit_components_TUIChat_emojiConfig_index.transformTextWithKeysToEmojiNames(payload.text);
    }
    if (messageType === common_vendor.qt.TYPES.MSG_CUSTOM) {
      desc = payload.description;
    }
    return desc || common_vendor.Wt.t(`TUIChat.${TUIKit_components_TUIChat_offlinePushInfoManager_const.DEFAULT_DESC[messageType]}`);
  }
  create(options) {
    var _a;
    const { conversation, messageType = "", payload = {} } = options || {};
    const userInfo = common_vendor.Jt.getData(common_vendor.o.USER, "userProfile");
    const entity = {
      sender: conversation.type === common_vendor.qt.TYPES.CONV_GROUP ? (_a = conversation.groupProfile) == null ? void 0 : _a.groupID : userInfo == null ? void 0 : userInfo.userID,
      nickName: userInfo == null ? void 0 : userInfo.nick,
      chatType: conversation.type === common_vendor.qt.TYPES.CONV_GROUP ? 2 : 1,
      version: 1,
      action: 1
    };
    return {
      title: this.genTitle(conversation, userInfo),
      description: this.genDesc(messageType, payload),
      extension: JSON.stringify({ entity }),
      ...this.offlinePushInfo[TUIKit_components_TUIChat_offlinePushInfoManager_const.PUSH_SCENE.CHAT]
    };
  }
};
_OfflinePushInfoManager.instance = null;
let OfflinePushInfoManager = _OfflinePushInfoManager;
exports.OfflinePushInfoManager = OfflinePushInfoManager;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/offlinePushInfoManager/offlinePushInfoManager.js.map
