"use strict";const e=require("../../../../common/vendor.js"),a=require("../../common/Toast/index.js"),s=require("./utils.js"),t=require("../../../utils/enableSampleTaskStatus.js"),o=require("../offlinePushInfoManager/index.js"),l=require("../../common/Toast/type.js"),n=new Map([[3123,"文本包含本地审核拦截词"],[4004,"图片消息失败,无效的图片格式"],[4005,"文件消息失败,禁止发送违规封禁的文件"],[7004,"文件不存在,请检查文件路径是否正确"],[7005,"文件大小超出了限制,如果上传文件,最大限制是100MB"],[8001,"消息长度超出限制,消息长度不要超过12K"],[80001,"消息或者资料中文本存在敏感内容,发送失败"],[80004,"消息中图片存在敏感内容,发送失败"],[10017,"您已被禁止聊天"]]);exports.sendMessages=async(i,d)=>{e.Jt.getData(e.o.CHAT,"messageSource")&&e.Jt.update(e.o.CHAT,"messageSource",void 0),null==i||i.forEach((async i=>{var r,u,f,p,g,y,T;try{const a={to:(null==(r=null==d?void 0:d.groupProfile)?void 0:r.groupID)||(null==(u=null==d?void 0:d.userProfile)?void 0:u.userID),conversationType:null==d?void 0:d.type,payload:{},needReadReceipt:s.isEnabledMessageReadReceiptGlobal()};let l;const n={offlinePushInfo:{}},c={conversation:d,payload:i.payload,messageType:""};switch(null==i?void 0:i.type){case"text":if(l=JSON.parse(JSON.stringify(null==(f=i.payload)?void 0:f.text)),!l)break;a.payload={text:l},c.messageType=e.qt.TYPES.MSG_TEXT,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),(null==(p=i.payload)?void 0:p.atUserList)?(a.payload.atUserList=i.payload.atUserList,await e.Qt.sendTextAtMessage(a,n)):await e.Qt.sendTextMessage(a,n);break;case"image":a.payload={file:null==(g=i.payload)?void 0:g.file},c.messageType=e.qt.TYPES.MSG_IMAGE,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),await e.Qt.sendImageMessage(a,n);break;case"video":a.payload={file:null==(y=i.payload)?void 0:y.file},c.messageType=e.qt.TYPES.MSG_VIDEO,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),await e.Qt.sendVideoMessage(a,n);break;case"file":a.payload={file:null==(T=i.payload)?void 0:T.file},c.messageType=e.qt.TYPES.MSG_FILE,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),await e.Qt.sendFileMessage(a,n)}t.enableSampleTaskStatus("sendMessage")}catch(c){a.Toast({message:n.get(null==c?void 0:c.code)?e.Wt.t(`TUIChat.${n.get(c.code)}`):null==c?void 0:c.message,type:l.TOAST_TYPE.ERROR}),e.Jt.getData(e.o.CHAT,"quoteMessage")&&e.Jt.update(e.o.CHAT,"quoteMessage",{})}}))},exports.sendTyping=(a,s)=>{a||s?e.Qt.leaveTypingState():e.Qt.enterTypingState()};
