easemob-websdk 4.24.0 → 4.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[77],{706:function(e,t,r){var a=r(350).PROPER,n=r(9039),o=r(7452);e.exports=function(e){return n((function(){return!!o[e]()||"​…᠎"!=="​…᠎"[e]()||a&&o[e].name!==e}))}},2762:function(e,t,r){var a=r(6518),n=r(3802).trim;a({target:"String",proto:!0,forced:r(706)("trim")},{trim:function(){return n(this)}})},3352:function(e,t,r){r.d(t,{default:function(){return Ze}});var a={};r.r(a),r.d(a,{acceptContactInvite:function(){return re},acceptInvitation:function(){return te},addContact:function(){return Z},addConversationMark:function(){return Ne},addReaction:function(){return he},addToBlackList:function(){return oe},addUsersToBlacklist:function(){return ie},addUsersToBlocklist:function(){return se},declineContactInvite:function(){return ne},declineInvitation:function(){return ae},deleteAllMessagesAndConversations:function(){return Ae},deleteContact:function(){return ee},deleteConversation:function(){return G},deleteReaction:function(){return fe},deleteSession:function(){return B},fetchHistoryMessages:function(){return W},fetchUserInfoById:function(){return K},getAllContacts:function(){return je},getBlacklist:function(){return A},getBlocklist:function(){return P},getContacts:function(){return x},getContactsWithCursor:function(){return Re},getConversationlist:function(){return M},getHistoryMessages:function(){return X},getRTCToken:function(){return Xe},getReactionDetail:function(){return ge},getReactionList:function(){return me},getReactionlist:function(){return ve},getRoster:function(){return U},getSelfIdsOnOtherPlatform:function(){return we},getServerConversations:function(){return Ie},getServerConversationsByFilter:function(){return Oe},getServerPinnedConversations:function(){return Ce},getServerPinnedMessages:function(){return ze},getSessionList:function(){return L},getTokenExpireTimestamp:function(){return H},getUserIdByRTCUIds:function(){return Ye},modifyMessage:function(){return pe},pinConversation:function(){return be},pinMessage:function(){return Ue},recallMessage:function(){return de},removeConversationMark:function(){return ke},removeFromBlackList:function(){return ce},removeHistoryMessages:function(){return Te},removeRoster:function(){return $},removeUserFromBlackList:function(){return ue},removeUserFromBlocklist:function(){return le},reportMessage:function(){return ye},searchMessages:function(){return Y},setContactRemark:function(){return Se},unbindPushToken:function(){return Fe},unpinMessage:function(){return xe},updateCurrentUserNick:function(){return V},updateOwnUserInfo:function(){return q},updateUserInfo:function(){return J},uploadPushToken:function(){return F},uploadToken:function(){return z},voiceFileToText:function(){return Qe},voiceMessageToText:function(){return We}}),r(2675),r(9463),r(2259),r(8706),r(2008),r(1629),r(4423),r(4346),r(3792),r(8598),r(2062),r(4490),r(5086),r(6910),r(4554),r(9089),r(739),r(3288),r(2010),r(9085),r(9432),r(6099),r(6034),r(3362),r(8781),r(1415),r(1699),r(7764),r(2762),r(3500),r(2953);var n=r(1156),o=r(8093),i=r(3484),s=r(4269),c=r(4865),u=r(8579),l=r(3887),d=r.n(l),p=r(7968),h=r(3603),f=r(8211),m=r(1274),v=r(9254),g=r(4331),y=r(6981);function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}var I=function(){return I=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},I.apply(this,arguments)},E=function(e,t,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))},C=function(e,t){var r,a,n,o,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((n=(n=i.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},b={txt:"text",img:"image",video:"video",file:"file",loc:"location",custom:"custom"},S={text:"txt",image:"img",video:"video",file:"file",location:"loc",custom:"custom"},j=5,R=150,_=new Set(["audio","cmd"]);function N(e){return i.A.create({type:o.C.REQUEST_PARAMETER_ERROR,message:e})}function k(e,t){p.vF.error(e,t)}function O(e){var t,r,a,n=f.p[e.conversationType],o=S[e.contentType]||e.contentType,i=function(e,t){return"groupchat"===t.conversationType||"chatroom"===t.conversationType?t.receiverId:t.senderId!==e?t.senderId:t.receiverId}(this.context.userId,e),c={id:"".concat(e.messageId),conversationId:i,chatType:n,from:e.senderId,to:e.receiverId,ext:e.ext||{},time:new Date(e.sentTime).getTime()},l=e.content||{},d="string"==typeof e.text?e.text:void 0;switch(o){case"txt":a=I(I({},c),{type:"txt",msg:l.message||e.text||""}),Array.isArray(e.translations)&&e.translations.length>0&&(a.translations={translations:e.translations.map((function(e){return{text:e.text,to:e.code}}))});break;case"img":var p=l.url||l.remotePath||"",h=l.secret||l.secretKey||"",m=this.useOwnUploadFun?p:u.zK.call(this,{remotePath:p,secretKey:h});a=I(I({},c),{type:"img",url:m||"",width:(null===(t=l.size)||void 0===t?void 0:t.width)||l.width||0,height:(null===(r=l.size)||void 0===r?void 0:r.height)||l.height||0,secret:h,thumb:this.useOwnUploadFun?l.thumb||"":l.thumb?s.Wp.formatAttachUrl.call(this,l.thumb):m?"".concat(m,"&thumbnail=true"):"",thumb_secret:l.thumb_secret||l.thumbnailSecretKey||h||"",file_length:l.file_length||l.fileLength||0,filetype:l.filetype||"",file:{},isGif:"sub_gif"===l.subType||1===l.subType});break;case"video":p=l.url||l.remotePath||"",h=l.secret||l.secretKey||"",m=this.useOwnUploadFun?p:u.zK.call(this,{remotePath:p,secretKey:h}),a=I(I({},c),{type:"video",url:m||"",secret:h||"",thumb:l.thumb?s.Wp.formatAttachUrl.call(this,l.thumb):s.Wp.formatAttachUrl.call(this,l.thumbnailRemotePath||""),thumb_secret:l.thumb_secret||l.thumbnailSecretKey||"",filename:l.filename||l.displayName||"",length:l.length||l.duration||0,file:{},file_length:l.file_length||l.fileLength||0,filetype:l.filetype||""});break;case"file":p=l.url||l.remotePath||"",h=l.secret||l.secretKey||"",m=this.useOwnUploadFun?p:u.zK.call(this,{remotePath:p,secretKey:h}),a=I(I({},c),{type:"file",url:m||"",secret:h||"",file:{},filename:l.filename||l.displayName||"",length:l.length||l.duration||0,file_length:l.file_length||l.fileLength||0,filetype:l.filetype||""});break;case"loc":a=I(I({},c),{type:"loc",buildingName:l.buildingName||"",addr:l.addr||l.address||"",lat:l.lat||l.latitude||0,lng:l.lng||l.longitude||0});break;case"custom":a=I(I({},c),{type:"custom",customEvent:l.customEvent||"",customExts:l.customExts||{},params:l.params||{}});break;default:a=I(I({},c),{type:o})}if(void 0!==d&&(a.text=d),e.highlight&&"object"===T(e.highlight)){for(var v=[],g=0,y=Object.values(e.highlight);g<y.length;g++){var E=y[g];Array.isArray(E)&&v.push.apply(v,E)}v.length>0&&(a.highlight=v)}return a}var w={singleChat:"chat",chatRoom:"chatroom",groupChat:"groupchat"};function A(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c={url:this.apiUrl+"/"+a+"/"+o+"/users/"+this.user+"/blocks/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+i},success:function(t){var r={};t.data.forEach((function(e){r[e]={name:e}})),"function"==typeof(null==e?void 0:e.success)&&e.success(t)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return p.vF.debug("Call getBlocklist"),s.RD.call(this,c,h.jz.GET_BLACK_LIST)}var P=A,U=x;function x(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u={url:this.apiUrl+"/"+o+"/"+i+"/users/"+this.user+"/contacts/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+c},success:function(r){var a=[];r.data.forEach((function(e){a.push({name:e,subscription:"both",jid:t.context.jid})})),"function"==typeof(null==e?void 0:e.success)&&e.success(a)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return p.vF.debug("Call getContacts"),s.RD.call(this,u,h.jz.GET_CONTACTS)}function z(e){return p.vF.debug("Call uploadPushToken"),y.B.call(this,e)}var F=z;function L(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/user_channels"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return p.vF.debug("Call getSessionList"),s.RD.call(this,c)}function M(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=!!(e&&"number"==typeof e.pageNum&&"number"==typeof e.pageSize&&e.pageNum>0&&e.pageSize>0),l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/users/").concat(this.user,"/user_channels").concat(u?"/page":""),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return u&&(l.data={pageNum:e.pageNum,pageSize:e.pageSize}),p.vF.debug("Call getConversationlist"),s.RD.call(this,l,h.jz.GET_SESSION_LIST).then((function(e){return D.call(t,e)}))}function D(e){var t=this,r=e.data.channel_infos;return null==r||r.forEach((function(e){e.meta&&"{}"!==JSON.stringify(e.meta)?(e.meta.payload=JSON.parse(e.meta.payload),e.lastMessage=f.h.call(t,e.meta,{formatCustomExts:!1})):e.lastMessage=e.meta,delete e.meta})),e}function B(e){if(e&&"string"!=typeof e.channel)throw Error("Invalid parameter channel: ".concat(e.channel));if(e&&"singleChat"!==e.chatType&&"groupChat"!==e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(e&&"boolean"!=typeof e.deleteRoam)throw Error("Invalid parameter deleteRoam: ".concat(e.deleteRoam));var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r,a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=a.jid;r="singleChat"===e.chatType?"chat":"groupChat";var l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/user/").concat(this.user,"/user_channel?resource=").concat(u.clientResource),dataType:"json",type:"DELETE",data:JSON.stringify({channel:e.channel,type:r,delete_roam:e.deleteRoam}),headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"},success:e.success,error:e.error};return p.vF.debug("Call deleteSession",e),s.RD.call(this,l,h.jz.DELETE_SESSION)}var G=B;function q(e,t){var r=n.dO.call(this).error;if(r)return Promise.reject(r);var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=["nickname","avatarurl","mail","phone","gender","sign","birth","ext"],l={},d=s.Wp.getEnvInfo();if("wx"===d.platform||"qq"===d.platform)if("string"==typeof e&&void 0!==t){if(!u.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");l[e]=t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");u.forEach((function(t){u.includes(t)&&void 0!==e[t]&&(l[t]=e[t])}))}else if("string"==typeof e){if(!u.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");l=e+"="+t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");var f=[];u.forEach((function(t){if(u.includes(t)&&void 0!==e[t]){var r=encodeURIComponent(t),a=encodeURIComponent(e[t]);f.push(r+"="+a)}})),l=f.join("&")}var m={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/metadata/user/").concat(this.user),type:"PUT",data:l,dataType:"json",headers:{Authorization:"Bearer "+c,"Content-Type":"application/x-www-form-urlencoded"}};return p.vF.debug("Call updateOwnUserInfo",e),s.RD.call(this,m,h.jz.UPDATE_USER_INFO)}var J=q;function K(e,t){var r=n.dO.call(this).error;if(r)return Promise.reject(r);var a,o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=[];if("string"==typeof e)l=[e];else{if("[object Array]"!==Object.prototype.toString.call(e))throw new Error("illegal params");l=e}a="string"==typeof t?[t]:t&&"[object Array]"===Object.prototype.toString.call(t)?t:["nickname","avatarurl","mail","phone","gender","sign","birth","ext"];var d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/metadata/user/get"),type:"POST",data:JSON.stringify({targets:l,properties:a}),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return p.vF.debug("Call fetchUserInfoById",e),s.RD.call(this,d,h.jz.GET_USER_INFO)}function V(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user),type:"PUT",dataType:"json",data:JSON.stringify({nickname:e}),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return p.vF.debug("Call updateCurrentUserNick",e),s.RD.call(this,c)}function H(e){if("string"!=typeof e||""===e)throw Error('Invalid parameter: "token"');var t=this.context,r=t.orgName,a=t.appName,n={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/sdk/users/").concat(this.user,"/token/expires"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+e,"Content-Type":"application/json"}};return p.vF.debug("Call getTokenExpireTimestamp",e),s.RD.call(this,n,h.jz.SDK_INTERNAL)}function W(e){var t=this;return new Promise((function(r,a){if(!e.queue)throw Error('Invalid parameter: "specified"');var o=n.dO.call(t).error;if(o)return Promise.reject(o);(function e(t){var n=this,o=t.count||20;Q.call(this,{count:o,isGroup:!!t.isGroup,queue:t.queue,start:t.start,format:t.format,success:function(a){if(a.msgs.length>=o||a.is_last){var i=a.msgs.splice(0,o).reverse();t.success&&t.success(i),r(i)}else e.call(n,I(I({},t),{start:null}))},fail:function(e){a(e),t.fail&&t.fail(e)}})}).call(t,e),p.vF.debug("Call fetchHistoryMessages",e)}))}function Q(e){var t=this,r=e.queue,a=this.mr_cache[r]||(this.mr_cache[r]={msgs:[]}),n=this.context.userId,c=e.start||-1,l=e.count||20;if(a.msgs.length>=l||a.is_last)"function"==typeof e.success&&e.success(a);else{a&&a.next_key&&(c=a.next_key),e.start&&(c=e.start);var p={queue:r+(e.isGroup?"@conference.easemob.com":"@easemob.com"),start:c,end:-1},f=this.context,m=f.orgName,v=f.appName,g={url:"".concat(this.apiUrl,"/").concat(m,"/").concat(v,"/users/").concat(n,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"},data:JSON.stringify(p),success:function(r){return E(t,void 0,void 0,(function(){var t,n,o,i,s,c,l=this;return C(this,(function(p){switch(p.label){case 0:if(t=null==r?void 0:r.data,!r.data.msgs)return"function"==typeof e.success&&e.success(a),a.is_last=!0,a.next_key="",[2];n=t.msgs,o=n.length,a.is_last=t.is_last,a.next_key=t.next_key,i=function(t){return E(l,void 0,void 0,(function(){var r,a,n,o,i;return C(this,(function(s){switch(s.label){case 0:for(r=[],t=d().atob(t),a=0,n=t.length;a<n;++a)r.push(t.charCodeAt(a));return o=(o=this.context.root.lookup("easemob.pb.Meta")).decode(r),i={errorCode:0,reason:""},1!==o.ns?[3,2]:[4,u.Ay.call(this,o,i,!0,e.format)];case 1:return[2,s.sent()];case 2:return[2]}}))}))},s=0,p.label=1;case 1:return s<o?[4,i(n[s].msg)]:[3,4];case 2:(c=p.sent())&&a.msgs.push(c),p.label=3;case 3:return s++,[3,1];case 4:return"function"==typeof e.success&&e.success(a),[2]}}))}))},error:function(e){if(e.error&&e.error_description){var r=i.A.create({type:o.C.WEBIM_CONNCTION_AJAX_ERROR,message:"fetch history messages error",data:e});t.onError&&t.onError(r)}}};s.RD.call(this,g,h.jz.GET_HISTORY_MSG).catch((function(t){"function"==typeof e.fail&&e.fail(t)}))}}function X(e){var t=this;return new Promise((function(r,a){var o=e.targetId,i=e.cursor,c=void 0===i?-1:i,l=e.pageSize,f=void 0===l?20:l,m=e.chatType,v=e.searchDirection,g=e.searchOptions,y=void 0===g?{}:g,T=y.msgTypes,I=void 0===T?[]:T,b=y.startTime,S=void 0===b?null:b,j=y.endTime,R=void 0===j?null:j,_=y.from,k=void 0===_?null:_;if("string"!=typeof o||""===o)return a(N('"Invalid parameter": "targetId"'));if(k&&"string"!=typeof k)return a(N('"Invalid parameter": "searchOptions.from"'));if(I&&!Array.isArray(I))return a(N('"Invalid parameter": "searchOptions.msgTypes"'));if(S&&"number"!=typeof S)return a(N('"Invalid parameter": "searchOptions.startTime"'));if(R&&"number"!=typeof R)return a(N('"Invalid parameter": "searchOptions.endTime"'));var O=n.dO.call(t).error;if(O)return a(O);var w=t.context,A=w.orgName,P=w.appName,U=w.userId,x="singleChat"===e.chatType?"@easemob.com":"@conference.easemob.com",z={queue:"".concat(o).concat(x),start:c,pull_number:f,is_positive:"down"===v,msgType:I.join(",")||"",end:-1,startTime:S,endTime:R,userId:"singleChat"===m?null:k},F={url:"".concat(t.apiUrl,"/").concat(A,"/").concat(P,"/users/").concat(U,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+t.token,"Content-Type":"application/json"},data:JSON.stringify(z),success:function(a){return E(t,void 0,void 0,(function(){var t,n,o,i,s,c,l,p,h=this;return C(this,(function(f){switch(f.label){case 0:t=null==a?void 0:a.data,n=t.msgs||[],o=function(e){return E(h,void 0,void 0,(function(){var t,r,a,n,o;return C(this,(function(i){switch(i.label){case 0:for(t=[],e=d().atob(e),r=0,a=e.length;r<a;++r)t.push(e.charCodeAt(r));return n=(n=this.context.root.lookup("easemob.pb.Meta")).decode(t),o={errorCode:0,reason:""},1!==n.ns?[3,2]:[4,u.Ay.call(this,n,o,!0,!0)];case 1:return[2,i.sent()];case 2:return[2]}}))}))},i=[],s=0,f.label=1;case 1:return s<n.length?[4,o(n[s].msg)]:[3,4];case 2:(c=f.sent())&&i.push(c),f.label=3;case 3:return s++,[3,1];case 4:return t.msgs=i,l={cursor:t.next_key,messages:i,isLast:t.is_last},null===(p=e.success)||void 0===p||p.call(e,l),r(l),[2]}}))}))},error:e.fail};s.RD.call(t,F,h.jz.REST_FETCHHISTORYMESSAGE).catch((function(e){a(e)})),p.vF.debug("Call getHistoryMessages",e)}))}function Y(e){var t,r,a=this,c=n.dO.call(this).error;if(c)return Promise.reject(c);var u=null==e?void 0:e.option,l=null!==(t=null==e?void 0:e.pageNum)&&void 0!==t?t:1,d=null!==(r=null==e?void 0:e.pageSize)&&void 0!==r?r:20,f=[];try{f=function(e,t,r){var a;if(!e||"object"!==T(e))throw N('"Invalid parameter": "option"');if(!Array.isArray(e.keywordList))throw N('"Invalid parameter": "keywordList"');var n=e.keywordList.map((function(e){return"".concat(null!=e?e:"").trim()})).filter((function(e){return e.length>0}));if(0===n.length)throw N('"Invalid parameter": "keywordList"');if(n.length>j)throw N('"Invalid parameter": "keywordList exceeds max count 5"');if(n.some((function(e){return e.length<1||e.length>R})))throw N('"Invalid parameter": "keywordList item length exceeds 150"');if(void 0!==e.conversationId&&("string"!=typeof e.conversationId||""===e.conversationId.trim()))throw N('"Invalid parameter": "conversationId"');if(void 0!==e.conversationType&&!["singleChat","groupChat","chatRoom"].includes(e.conversationType))throw N('"Invalid parameter": "conversationType"');if(void 0===e.conversationId!=(void 0===e.conversationType))throw N('"Invalid parameter": "conversationId and conversationType must be used together"');if(void 0!==e.startTime&&void 0===e.endTime||void 0===e.startTime&&void 0!==e.endTime)throw N('"Invalid parameter": "startTime/endTime"');if(void 0!==e.startTime&&("number"!=typeof e.startTime||"number"!=typeof e.endTime||e.endTime<e.startTime))throw N('"Invalid parameter": "startTime/endTime"');if("number"!=typeof t||t<1)throw N('"Invalid parameter": "pageNum"');if("number"!=typeof r||r<1||r>100)throw N('"Invalid parameter": "pageSize"');if(e.msgTypes&&!Array.isArray(e.msgTypes))throw N('"Invalid parameter": "msgTypes"');if(null===(a=e.msgTypes)||void 0===a?void 0:a.some((function(e){return _.has(e)})))throw N('"Invalid parameter": "msgTypes contains unsupported type"');return n}(u,l,d)}catch(t){return p.vF.error("searchMessages parameter validation failed",{params:e,error:t}),Promise.reject(t)}var m=this.context,v=m.orgName,g=m.appName,y=m.accessToken,I=function(e,t,r,a,n){var o=function(e,t){var r,a=null!==(r=e.keywordListMatchType)&&void 0!==r?r:"or",n={searchMode:"default"};return 1===t.length?n.keyword=t[0]:(n.keywords=t,n.keywordMatch="and"===a?"all":"any"),{data:n,normalizedKeywordList:t}}(e,t).data;return e.conversationId&&("singleChat"===e.conversationType?o.participantPairs=[{userId1:n,userId2:e.conversationId}]:"groupChat"===e.conversationType?o.groupIds=[e.conversationId]:"chatRoom"===e.conversationType?o.chatroomIds=[e.conversationId]:o.conversationId=e.conversationId),e.msgTypes&&e.msgTypes.length>0&&(o.contentType=e.msgTypes.filter((function(e){return e in b})).map((function(e){return b[e]})).join(",")),"number"==typeof e.startTime&&"number"==typeof e.endTime&&(o.startTime=e.startTime,o.endTime=e.endTime),e.searchScope&&(o.searchExt=e.searchScope),o.sort="relevance:desc",o.highlightEnable=!0,o.page=r,o.size=a,o}(u,f,l,d,this.user),E={url:"".concat(this.apiUrl,"/").concat(v,"/").concat(g,"/users/").concat(this.user,"/messages/search/get"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+y,"Content-Type":"application/json",Accept:"application/json; charset=utf-8"},data:JSON.stringify({data:I})};return p.vF.debug("Call searchMessages",e),s.RD.call(this,E,h.jz.REST_SEARCH_MESSAGES).then((function(t){var r,n,s=(null==t?void 0:t.data)||{},c=(null==s?void 0:s.data)&&"object"===T(s.data)?s.data:s,u=c.pagination||{},p=Array.isArray(c.items)?c.items:Array.isArray(c.list)?c.list:[];Array.isArray(c.items)||Array.isArray(c.list)||k("searchMessages response items/list is invalid",{params:e,responseData:c,rawResponse:t});var h=[];p.forEach((function(t,r){try{h.push(O.call(a,t))}catch(a){throw k("searchMessages failed to map response item",{params:e,index:r,item:t,error:a}),i.A.create({type:o.C.WEBIM_CONNCTION_AJAX_ERROR,message:"Failed to parse search result item",data:{index:r,item:t,error:a}})}}));var f={messages:h,pageNum:u.page||c.page||l,pageSize:d,totalPages:"number"==typeof u.totalPages?u.totalPages:-1,isLast:"number"!=typeof u.isFinished||1===u.isFinished,requestId:null===(r=null==s?void 0:s.meta)||void 0===r?void 0:r.requestId,timestamp:(null===(n=null==s?void 0:s.meta)||void 0===n?void 0:n.timestamp)||Date.now()};return"number"!=typeof u.page&&void 0!==u.page&&k("searchMessages pagination.page is invalid",{params:e,pagination:u,rawResponse:t}),f}))}function Z(e,t){return E(this,void 0,void 0,(function(){var r,a,o,i,c,u,l;return C(this,(function(d){switch(d.label){case 0:if(r=n.dO.call(this).error)return[2,Promise.reject(r)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call addContact",e,t),a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=a.jid,l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/users/").concat(this.user,"/contacts/apply?resource=").concat(u.clientResource),type:"POST",dataType:"json",data:JSON.stringify({usernames:[e],reason:t}),headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"}},[4,s.RD.call(this,l,h.jz.ROSTER_ADD)];case 1:return d.sent(),[2]}}))}))}var $=ee;function ee(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u;return C(this,(function(l){switch(l.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call deleteContact",e),r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=r.jid,u={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/contacts/users/").concat(e,"?resource=").concat(c.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,u,h.jz.ROSTER_REMOVE)];case 1:return l.sent(),[2]}}))}))}function te(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u;return C(this,(function(l){switch(l.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call acceptInvitation",e),r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=r.jid,u={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/contacts/accept/users/").concat(e,"?resource=").concat(c.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,u,h.jz.ROSTER_ACCEPT)];case 1:return l.sent(),[2]}}))}))}var re=te;function ae(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u;return C(this,(function(l){switch(l.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call declineInvitation",e),r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=r.jid,u={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/contacts/decline/users/").concat(e,"?resource=").concat(c.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,u,h.jz.ROSTER_DECLINE)];case 1:return l.sent(),[2]}}))}))}var ne=ae;function oe(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d;return C(this,(function(f){switch(f.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(r=e.name,a=[],"string"==typeof r){if(""===r)throw Error('"Invalid parameter": "name"');a=[r]}else{if(!Array.isArray(r))throw Error('"Invalid parameter": "name"');a=r}return p.vF.debug("Call addToBlockList",e),o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=o.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/sdk/user/").concat(this.user,"/blocks?resource=").concat(l.clientResource),type:"POST",dataType:"json",data:JSON.stringify({usernames:a}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.RD.call(this,d,h.jz.ROSTER_BAN).then((function(e){return{type:e.type,data:{userIds:(null==e?void 0:e.data)||[]}}}))];case 1:return[2,f.sent()]}}))}))}var ie=oe,se=oe;function ce(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d;return C(this,(function(f){switch(f.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(r=e.name,a=[],"string"==typeof r){if(""===r)throw Error('"Invalid parameter": "name"');a=[r]}else{if(!Array.isArray(r))throw Error('"Invalid parameter": "name"');a=r}return p.vF.debug("Call removeFromBlockList",e),o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=o.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/sdk/user/").concat(this.user,"/blocks?resource=").concat(l.clientResource),type:"DELETE",dataType:"json",data:JSON.stringify({usernames:a}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.RD.call(this,d,h.jz.ROSTER_ALLOW)];case 1:return f.sent(),[2]}}))}))}var ue=ce,le=ce;function de(e){var t=this,r=(null==e?void 0:e.ext)||"";if("string"!=typeof r)throw Error('"Invalid parameter": "ext"',r);var a=this.getUniqueId(),n={id:a,to:e.to};this._msgHash[a]=I({},n);var o="";void 0!==e.chatType?o=e.chatType:void 0!==e.type&&(o="chat"===e.type?"singleChat":e.type);var i={id:a,type:"recall",chatType:o,ackId:e.mid,to:e.to,isChatThread:e.isChatThread||!1,metaExt:r,success:function(r){return E(t,void 0,void 0,(function(){var t,a,n,i,s,c,u,l,d;return C(this,(function(p){switch(p.label){case 0:return p.trys.push([0,5,,6]),"singleChat"!==o&&"groupChat"!==o?[3,4]:[4,null===(n=null===(a=this._localCache)||void 0===a?void 0:a.getInstance())||void 0===n?void 0:n.removeMsgByServerMsgId(e.mid)];case 1:return p.sent(),[4,null===(s=null===(i=this._localCache)||void 0===i?void 0:i.getInstance())||void 0===s?void 0:s.getConversationLastMessage(e.to,o)];case 2:return t=p.sent(),[4,null===(u=null===(c=this._localCache)||void 0===c?void 0:c.getInstance())||void 0===u?void 0:u.updateLocalConversation((0,v.u0)({conversationId:e.to,conversationType:o}),{lastMessageId:null==t?void 0:t.serverMsgId})];case 3:p.sent(),p.label=4;case 4:return null===(l=null==e?void 0:e.success)||void 0===l||l.call(e,r),[3,6];case 5:return p.sent(),null===(d=null==e?void 0:e.success)||void 0===d||d.call(e,r),[3,6];case 6:return[2]}}))}))},fail:e.fail};return p.vF.debug("Call recallMessage",e),this.mSync.send(i,this)}function pe(e){var t=e||{},r=t.messageId,a=t.modifiedMessage;if(p.vF.debug("Call modifyMessage",r,a),""===r)throw Error('Invalid parameter: "messageId"');return this.mSync.send(I({editMessageId:r},a))}function he(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d;return C(this,(function(p){switch(p.label){case 0:if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));return(t=n.dO.call(this).error)?[2,Promise.reject(t)]:(r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.reaction,u=e.messageId,l={msgId:u,message:c},d={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user),type:"POST",data:JSON.stringify(l),dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,d)]);case 1:return p.sent(),[2]}}))}))}function fe(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l;return C(this,(function(d){switch(d.label){case 0:if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reactionId: ".concat(e.reaction));return(t=n.dO.call(this).error)?[2,Promise.reject(t)]:(r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.messageId,u=e.reaction,l={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user,"?msgId=").concat(c,"&message=").concat(u),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,l)]);case 1:return d.sent(),[2]}}))}))}function me(e){if("string"!=typeof e.chatType||!e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.chatType,u=e.messageId,l={msgIdList:"string"==typeof u?[u]:u,msgType:"singleChat"===c?"chat":"groupchat",groupId:e.groupId||null},d={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user),type:"GET",data:l,dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return s.RD.call(this,d).then((function(e){var t=e.data;return null==t||t.forEach((function(e){null==e||e.reactionList.forEach((function(e){e.isAddedBySelf=e.state,delete e.state,delete e.reactionId}))})),e}))}var ve=me;function ge(e){if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.cursor,u=e.pageSize,l={msgId:e.messageId,message:e.reaction,currentPage:c||null,pageSize:u||20},d={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user,"/detail"),type:"GET",data:l,dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return s.RD.call(this,d).then((function(e){return e.data.isAddedBySelf=e.data.state,delete e.data.state,delete e.data.reactionId,e}))}function ye(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,p,h;return C(this,(function(f){switch(f.label){case 0:if("string"!=typeof e.reportType||!e.reportType)throw Error("Invalid parameter reportType: ".concat(e.reportType));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reportReason||!e.reportReason)throw Error("Invalid parameter messageId: ".concat(e.reportReason));return(t=n.dO.call(this).error)?[2,Promise.reject(t)]:(r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.reportType,u=e.reportReason,l=e.messageId,d={username:this.user,reportType:c,reportReason:u},p="".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/user/").concat(this.user,"/moderation/report/message/").concat(l),h={url:p,type:"POST",data:JSON.stringify(d),dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,h)]);case 1:return f.sent(),[2]}}))}))}function Te(e){var t;return E(this,void 0,void 0,(function(){var r,a,o,i,c,u,l,d,h;return C(this,(function(f){switch(f.label){case 0:if("string"!=typeof e.targetId||""===e.targetId)throw Error('"Invalid parameter targetId": '+e.targetId);if(!["singleChat","groupChat","chatRoom"].includes(e.chatType))throw Error('"Invalid parameter chatType": '+e.chatType);if(e.beforeTimeStamp&&("number"!=typeof e.beforeTimeStamp||e.beforeTimeStamp<0||(null===(t=e.beforeTimeStamp)||void 0===t?void 0:t.toString().length)>18))throw Error('"Invalid parameter beforeTimeStamp": '+e.beforeTimeStamp);if(e.messageIds&&!(Array.isArray(e.messageIds)&&e.messageIds.length>0&&e.messageIds.length<=20))throw Error('"Invalid parameter messageIds": '+e.messageIds);if(!e.messageIds&&!e.beforeTimeStamp)throw Error("messageIds or beforeTimeStamp field is required.");return(r=n.dO.call(this).error)?[2,Promise.reject(r)]:(a=this.context,o=a.orgName,i=a.appName,c=a.userId,u="singleChat"===e.chatType?"userId":"groupId",l="singleChat"===e.chatType?"chat":"group",d=e.messageIds?"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/message/roaming/").concat(l,"/user/").concat(c,"?").concat(u,"=").concat(e.targetId,"&msgIdList=").concat(e.messageIds,"&resource=").concat(this.clientResource):"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/message/roaming/").concat(l,"/user/").concat(c,"/time?").concat(u,"=").concat(e.targetId,"&delTime=").concat(e.beforeTimeStamp,"&&resource=").concat(this.clientResource),h={url:d,dataType:"json",type:"DELETE",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"}},p.vF.debug("Call removeHistoryMessages",e),[4,s.RD.call(this,h)]);case 1:return f.sent(),[2]}}))}))}function Ie(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));if((null==e?void 0:e.includeEmptyConversations)&&"boolean"!=typeof e.includeEmptyConversations)throw Error("Invalid parameter includeEmptyConversations: ".concat(e.includeEmptyConversations));var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||"",need_mark:!0,needEmptySession:(null==e?void 0:e.includeEmptyConversations)||!1},headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"}};return p.vF.debug("Call getServerConversations",e),new Promise((function(e,r){s.RD.call(t,u,h.jz.REST_FETCH_CONVERSATIONS).then((function(r){return E(t,void 0,void 0,(function(){var t,a,n=this;return C(this,(function(o){switch(o.label){case 0:return t=Ee.call(this,r),this._localCache?(a=t.data.conversations.map((function(e){return E(n,void 0,void 0,(function(){var t,r,a,n;return C(this,(function(o){switch(o.label){case 0:return[4,null===(r=null===(t=this._localCache)||void 0===t?void 0:t.getInstance())||void 0===r?void 0:r.storeMessage(e.lastMessage,m.q.SUCCESS,!0)];case 1:return o.sent(),[4,null===(n=null===(a=this._localCache)||void 0===a?void 0:a.getInstance())||void 0===n?void 0:n.updateLocalConversation((0,v.u0)({conversationId:e.conversationId,conversationType:e.conversationType}),{unReadCount:e.unReadCount})];case 2:return o.sent(),[2]}}))}))})),[4,Promise.all(a)]):[3,2];case 1:o.sent(),o.label=2;case 2:return e(t),[2]}}))}))})).catch((function(e){r(e)}))}))}function Ee(e){var t=this,r=e.data,a=r.cursor,n=r.channel_infos,o=[];null==n||n.forEach((function(e){var r=null;(null==e?void 0:e.meta)&&"{}"!==JSON.stringify(e.meta)&&(e.meta.payload=JSON.parse(e.meta.payload),"delivery"!==(r=f.h.call(t,e.meta)).type&&"read"!==r.type&&"channel"!==r.type&&(r.chatType=f.p[r.chatType]));var a={conversationId:e.session_to,conversationType:"chat"===e.session_type?"singleChat":"groupChat",isPinned:e.is_top,pinnedTime:e.is_top?e.update_top_status_time:0,unReadCount:e.unread_num,lastMessage:r};e.marks&&(a.marks=e.marks.map((function(e){return c.s[e]}))),o.push(a)}));var i={conversations:o,cursor:a||""};return{type:e.type,data:i}}function Ce(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));if((null==e?void 0:e.includeEmptyConversations)&&"boolean"!=typeof e.includeEmptyConversations)throw Error("Invalid parameter includeEmptyConversations: ".concat(e.includeEmptyConversations));var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||"",is_top:!0,need_mark:!0,needEmptySession:(null==e?void 0:e.includeEmptyConversations)||!1},headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"}};return p.vF.debug("Call getServerPinnedConversations",e),s.RD.call(this,u,h.jz.GET_SESSION_LIST).then((function(e){return Ee.call(t,e)}))}function be(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,f,m,v,g,y;return C(this,(function(T){if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(r=e.conversationId,a=e.conversationType,o=e.isPinned,i="singleChat"===a?"chat":"groupChat","string"!=typeof r||""===r)throw Error("Invalid parameter conversationId: ".concat(r));if(!["singleChat","groupChat"].includes(a))throw Error("Invalid parameter conversationType: ".concat(a));if("boolean"!=typeof o)throw Error("Invalid parameter isPinned: ".concat(o));return c=this.context,u=c.orgName,l=c.appName,d=c.accessToken,f=c.jid,m={type:i,to:r},v=o?"":"type=".concat(i,"&to=").concat(r,"&"),g="".concat(this.apiUrl,"/").concat(u,"/").concat(l,"/sdk/user/").concat(this.user,"/user_channel/top?").concat(v,"resource=").concat(f.clientResource),y={url:g,type:o?"POST":"DELETE",dataType:"json",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}},o&&(y.data=JSON.stringify(m)),p.vF.debug("Call pinConversation",e),[2,s.RD.call(this,y,h.jz.PIN_CONVERSATION).then((function(e){var t=e.type,r=e.data;return{type:t,data:{isPinned:r.is_top||!1,pinnedTime:r.is_top?r.update_top_status_time:0}}}))]}))}))}function Se(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,f;return C(this,(function(m){switch(m.label){case 0:if(t=e.userId,r=e.remark,a=n.dO.call(this).error)return[2,Promise.reject(a)];if("string"!=typeof t||""===t)throw Error('Invalid parameter: "userId"');if("string"!=typeof r)throw Error('Invalid parameter: "remark"');return p.vF.debug("Call setContactRemark",e),o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=o.jid,d="".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.context.userId,"/contacts/users/").concat(t,"?resource=").concat(l.clientResource),f={url:d,type:"PUT",data:JSON.stringify({remark:r}),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.RD.call(this,f,h.jz.ROSTER_SET_CONTACT_REMARK)];case 1:return m.sent(),[2]}}))}))}function je(){var e=n.dO.call(this).error;if(e)return Promise.reject(e);var t=this.context,r=t.orgName,a=t.appName,o=t.accessToken,i={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/users/").concat(this.user,"/contacts/users?needReturnRemark=true"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+o}};return p.vF.debug("Call getAllContacts"),s.RD.call(this,i,h.jz.ROSTER_GET_ALL_CONTACTS_REMARKS).then((function(e){var t=((null==e?void 0:e.entities)||[]).map((function(e){return{userId:e.username,remark:e.remark}}));return{type:e.type,data:t}}))}function Re(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);p.vF.debug("Call getContactsWithCursor",e);var r=e||{},a=r.pageSize,o=void 0===a?20:a,i=r.cursor,c=void 0===i?"":i;if(o&&"number"!=typeof o)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));var u=this.context,l=u.orgName,d=u.appName,f=u.accessToken,m={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/users/").concat(this.user,"/contacts?needReturnRemark=true&limit=").concat(o,"&cursor=").concat(c),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+f}};return s.RD.call(this,m,h.jz.ROSTER_GET_ALL_CONTACTS_REMARKS_FROM_SERVER_BY_PAGE).then((function(e){var t,r,a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.contacts)||[],n=(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.cursor)||"",o=a.map((function(e){return{userId:e.username,remark:e.remark}}));return{type:e.type,data:{cursor:n,contacts:o}}}))}function _e(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,u,l,d,m,v,g,y,T,I,E;return C(this,(function(C){switch(C.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(p.vF.debug("Call markConversation",e),a=(r=e||{}).conversations,o=void 0===a?[]:a,i=r.mark,u=r.isMarked,!Array.isArray(o))throw Error("Invalid parameter conversations");if(l=o.map((function(e){if(!e.conversationId||!["singleChat","groupChat"].includes(e.conversationType))throw Error("Invalid parameter conversations");return{to:e.conversationId,type:w[e.conversationType]}})),"boolean"!=typeof u)throw Error("Invalid parameter isMarked: ".concat(u));if("number"!=typeof i)throw Error("Invalid parameter mark: ".concat(i));return d=this.context,m=d.orgName,v=d.appName,g=d.accessToken,y=d.userId,T=d.jid,I={mark:c.s[i],targets:l},E={url:"".concat(this.apiUrl,"/").concat(m,"/").concat(v,"/sdk/user/").concat(y,"/user_channels/mark?resource=").concat(T.clientResource),dataType:"json",data:JSON.stringify(I),type:u?"Post":"Delete",headers:{Authorization:"Bearer "+g}},[4,s.RD.call(this,E,h.jz.MARK_CONVERSATION).then((function(e){var t,r=(null===(t=e.data)||void 0===t?void 0:t.ignore)||[];r&&Array.isArray(r)&&r.length>0&&p.vF.debug("markConversation has ignored conversations",r.map((function(e){return{conversationId:e.to,conversationType:f.p[e.type]}})))}))];case 1:return C.sent(),[2]}}))}))}function Ne(e){return E(this,void 0,void 0,(function(){var t,r;return C(this,(function(a){return p.vF.debug("Call addConversationMark",e),t=e.conversations,r=e.mark,[2,_e.call(this,{conversations:t,mark:r,isMarked:!0})]}))}))}function ke(e){return E(this,void 0,void 0,(function(){var t,r;return C(this,(function(a){return p.vF.debug("Call removeConversationMark",e),t=e.conversations,r=e.mark,[2,_e.call(this,{conversations:t,mark:r,isMarked:!1})]}))}))}function Oe(e){var t,r,a=this,o=n.dO.call(this).error;if(o)return Promise.reject(o);if(p.vF.debug("Call getServerConversationsByFilter",e),(null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));if("number"!=typeof(null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.mark))throw Error("Invalid parameter mark: ".concat(null===(r=null==e?void 0:e.filter)||void 0===r?void 0:r.mark));var i=this.context,u=i.orgName,l=i.appName,d=i.accessToken,f="".concat(this.apiUrl,"/").concat(u,"/").concat(l,"/sdk/user/").concat(this.user,"/user_channels/mark/search?"),m=e.pageSize,v=e.cursor,g=((null==e?void 0:e.filter)||{}).mark,y={url:f,type:"GET",dataType:"json",data:{limit:m||10,cursor:v||"",need_mark:!0,mark:c.s[g]},headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}};return s.RD.call(this,y,h.jz.GET_SESSION_LIST).then((function(e){return Ee.call(a,e)}))}function we(){var e=n.dO.call(this).error;if(e)return Promise.reject(e);p.vF.debug("Call getSelfIdsOnOtherPlatform");var t=this.context,r=t.orgName,a=t.appName,o=t.accessToken,i=t.userId,c=t.jid,u={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/users/").concat(i,"/resources"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+o,"Content-Type":"application/json"}};return s.RD.call(this,u,h.jz.USER_LOGGEDIN_OTHER_PLATFORM).then((function(e){var t,r=null===(t=e.data)||void 0===t?void 0:t.filter((function(e){return e.res!==c.clientResource})),a=null==r?void 0:r.map((function(e){return"".concat(i,"/").concat(e.res)}));return{type:e.type,data:a}}))}function Ae(){var e,t,r,a,o,i;return E(this,void 0,void 0,(function(){var c,u,l,d,f,m,v,g,y;return C(this,(function(T){switch(T.label){case 0:return(c=n.dO.call(this).error)?[2,Promise.reject(c)]:(p.vF.debug("Call deleteAllMessagesAndConversations"),u=this.context,l=u.orgName,d=u.appName,f=u.accessToken,m=u.userId,v=u.jid,g="".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/sdk/message/roaming/user/").concat(m,"/delete/all?resource=").concat(v.clientResource),y={url:g,type:"POST",dataType:"json",headers:{Authorization:"Bearer "+f,"Content-Type":"application/json"}},[4,s.RD.call(this,y,h.jz.REST_DELETE_MESSAGES_CONVERSATIONS)]);case 1:return T.sent(),null===(t=null===(e=this._localCache)||void 0===e?void 0:e.getInstance())||void 0===t||t.clearConversationMap(),[4,null===(a=null===(r=this._localCache)||void 0===r?void 0:r.getInstance())||void 0===a?void 0:a.clearStoreData("conversationList")];case 2:return T.sent(),[4,null===(i=null===(o=this._localCache)||void 0===o?void 0:o.getInstance())||void 0===i?void 0:i.clearStoreData("message")];case 3:return T.sent(),[2]}}))}))}function Pe(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,f,m,v,g,y,T;return C(this,(function(I){switch(I.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(p.vF.debug("Call setMessagePinStatus",e),a=(r=e||{}).conversationId,o=void 0===a?"":a,i=r.conversationType,c=r.messageId,u=r.isPinned,"string"!=typeof o||""===o)throw Error("Invalid parameter conversationId");if("string"!=typeof c||""===c)throw Error("Invalid parameter messageId");if("boolean"!=typeof u)throw Error("Invalid parameter isPinned");return l=this.context,d=l.orgName,f=l.appName,m=l.accessToken,v=l.userId,g=l.jid,y={to:o,type:w[i],pin_msg_id:c},T={url:"".concat(this.apiUrl,"/").concat(d,"/").concat(f,"/sdk/user/").concat(v,"/user_channel/pin?resource=").concat(g.clientResource),dataType:"json",data:JSON.stringify(y),type:u?"Post":"Delete",headers:{Authorization:"Bearer "+m}},[4,s.RD.call(this,T,h.jz.REST_PIN_MESSAGE)];case 1:return I.sent(),[2]}}))}))}function Ue(e){return E(this,void 0,void 0,(function(){var t,r,a,n;return C(this,(function(o){return p.vF.debug("Call pinMessage",e),r=(t=e||{}).conversationType,a=t.conversationId,n=t.messageId,[2,Pe.call(this,{conversationId:a,conversationType:r,messageId:n,isPinned:!0})]}))}))}function xe(e){return E(this,void 0,void 0,(function(){var t,r,a,n;return C(this,(function(o){return p.vF.debug("Call unpinMessage",e),r=(t=e||{}).conversationType,a=t.conversationId,n=t.messageId,[2,Pe.call(this,{conversationId:a,conversationType:r,messageId:n,isPinned:!1})]}))}))}function ze(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);p.vF.debug("Call getServerPinnedMessages",e);var a=e.conversationId,o=e.conversationType,i=e.pageSize,c=e.cursor;if("string"!=typeof a||""===a)throw Error("Invalid parameter conversationId");if(i&&"number"!=typeof i)throw Error("Invalid parameter pageSize: ".concat(i));if(c&&"string"!=typeof c)throw Error("Invalid parameter cursor: ".concat(c));var u=this.context,l=u.orgName,d=u.appName,m=u.accessToken,v={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/sdk/user/").concat(this.user,"/user_channel/pin"),type:"GET",dataType:"json",data:{to:a,type:w[o],limit:i||10,cursor:c||""},headers:{Authorization:"Bearer "+m,"Content-Type":"application/json"}};return s.RD.call(this,v,h.jz.GET_SESSION_LIST).then((function(e){return{type:0,data:{list:e.data.msg_infos.map((function(e){e.message.payload=JSON.parse(e.message.payload);var r=e.message,a=e.pin_opt_at,n=e.pin_operator;return{message:f.h.call(t,r,{formatChatType:!0}),pinTime:a,operatorId:n}})),cursor:e.data.cursor||""}}}))}function Fe(){var e=this;p.vF.debug("Call unbindPushToken");var t={deviceId:this.clientResource,deviceToken:"",notifierName:this.pushCertificateName};return y.B.call(this,t).then((function(t){return e.isRegisterPush=!1,t}))}function Le(e){if(!e||"string"!=typeof e.fileId||""===e.fileId)return Promise.reject(Error('Invalid parameter: "fileId"'));if(void 0!==e.currentUserId&&"string"!=typeof e.currentUserId)return Promise.reject(Error('Invalid parameter: "currentUserId"'));if(void 0!==e.audio){if("object"!==T(e.audio)||null===e.audio||Array.isArray(e.audio))return Promise.reject(Error('Invalid parameter: "audio"'));var t=e.audio,r=t.format,a=t.sampleRate,o=t.bitsPerSample,i=t.channels;if(void 0!==r&&"string"!=typeof r)return Promise.reject(Error('Invalid parameter: "audio.format"'));if(void 0!==a&&"number"!=typeof a)return Promise.reject(Error('Invalid parameter: "audio.sampleRate"'));if(void 0!==o&&"number"!=typeof o)return Promise.reject(Error('Invalid parameter: "audio.bitsPerSample"'));if(void 0!==i&&"number"!=typeof i)return Promise.reject(Error('Invalid parameter: "audio.channels"'))}var c=n.dO.call(this).error;if(c)return Promise.reject(c);var u=this.context,l=u.orgName,d=u.appName,h=u.accessToken,f=u.userId,m=e.currentUserId||f,v={data:I({fileId:e.fileId,username:m},e.audio?{audio:e.audio}:{})};if(!l||!d||!m)return Promise.reject(Error('Invalid parameter: "orgname", "appname" or "currentUserId"'));var g={url:"".concat(this.apiUrl,"/api/sdk/v1/").concat(l,"/").concat(d,"/speech/transcriptions"),type:"POST",dataType:"json",data:JSON.stringify(v),headers:{Authorization:"Bearer "+h,"Content-Type":"application/json",Accept:"application/json"}};return p.vF.debug("Call transcribeSpeech",v),s.RD.call(this,g).then((function(e){var t;return{type:0,data:{text:(null===(t=e.data)||void 0===t?void 0:t.text)||""}}}))}function Me(e){if(!e||!Ge(t=e.file)&&!qe(t))return Promise.reject(Error('Invalid parameter: "file"'));var t;if(void 0!==e.currentUserId&&"string"!=typeof e.currentUserId)return Promise.reject(Error('Invalid parameter: "currentUserId"'));if(void 0!==e.audio){if("object"!==T(e.audio)||null===e.audio||Array.isArray(e.audio))return Promise.reject(Error('Invalid parameter: "audio"'));var r=e.audio,a=r.format,i=r.sampleRate,s=r.bitsPerSample,c=r.channels;if(void 0!==a&&"string"!=typeof a)return Promise.reject(Error('Invalid parameter: "audio.format"'));if(void 0!==i&&"number"!=typeof i)return Promise.reject(Error('Invalid parameter: "audio.sampleRate"'));if(void 0!==s&&"number"!=typeof s)return Promise.reject(Error('Invalid parameter: "audio.bitsPerSample"'));if(void 0!==c&&"number"!=typeof c)return Promise.reject(Error('Invalid parameter: "audio.channels"'))}var u=n.dO.call(this).error;if(u)return Promise.reject(u);var l=this.context,d=l.orgName,h=l.appName,f=l.accessToken,m=l.userId,v=e.currentUserId||m;if(!d||!h||!v)return Promise.reject(Error('Invalid parameter: "orgname", "appname" or "currentUserId"'));var y="".concat(this.apiUrl,"/api/sdk/v1/").concat(d,"/").concat(h,"/speech/recognitions");if(Ge(e.file))return function(e){var t=new FormData,r=De(e.currentUserId,e.audio);return Object.keys(r).forEach((function(e){t.append(e,r[e])})),t.append("file",e.file),p.vF.debug("Call recognizeSpeech",{currentUserId:e.currentUserId,fileName:e.file.name,fileSize:e.file.size,audio:e.audio}),new Promise((function(r,a){var n=new XMLHttpRequest;n.timeout=g._h,n.ontimeout=function(){a({type:o.C.REQUEST_TIMEOUT,message:"Request Timeout",errorType:"timeout_error",xhr:n})},n.onerror=function(){a({type:o.C.REQUEST_UNKNOWN,message:"Request Unknown Error",errorType:"onerror",xhr:n})},n.onabort=function(){a({type:o.C.REQUEST_ABORT,message:"Request Abort",errorType:"onabort",xhr:n})},n.onreadystatechange=function(){var e,t;if(4===n.readyState){var i=Be(n.responseText);200!==n.status?a({type:n.status||o.C.REQUEST_UNKNOWN,data:i,message:(null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message)||(null==i?void 0:i.message)||"Request Error",xhr:n}):r({type:o.C.REQUEST_SUCCESS,data:{text:(null===(e=null==i?void 0:i.data)||void 0===e?void 0:e.text)||""}})}},n.open("POST",e.requestUrl),n.setRequestHeader("Authorization","Bearer "+e.accessToken),n.setRequestHeader("Accept","application/json"),n.send(t)}))}({file:e.file,currentUserId:v,audio:e.audio,requestUrl:y,accessToken:f});var I=Je();return qe(e.file)&&I?function(e){var t=De(e.currentUserId,e.audio);return p.vF.debug("Call recognizeSpeech",{currentUserId:e.currentUserId,filePath:e.file.filePath,fileName:e.file.name||e.file.filePath.split("?")[0].split("/").filter(Boolean).pop(),fileSize:e.file.size,audio:e.audio}),new Promise((function(r,a){e.platForm.global.uploadFile({url:e.requestUrl,filePath:e.file.filePath,name:"file",header:{"Content-Type":"multipart/form-data",Authorization:"Bearer "+e.accessToken,Accept:"application/json"},formData:t,success:function(e){var t,n,i=Be(e.data);200!==e.statusCode?a({type:e.statusCode||o.C.REQUEST_UNKNOWN,data:i,message:(null===(n=null==i?void 0:i.error)||void 0===n?void 0:n.message)||(null==i?void 0:i.message)||"Request Error"}):r({type:o.C.REQUEST_SUCCESS,data:{text:(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.text)||""}})},fail:function(e){a({type:o.C.REQUEST_UNKNOWN,message:"Request Unknown Error",errorType:"upload_fail",data:e})}})}))}({file:e.file,currentUserId:v,audio:e.audio,requestUrl:y,accessToken:f,platForm:I}):Promise.reject(Error('Invalid parameter: "file"'))}function De(e,t){var r={username:e};return void 0!==(null==t?void 0:t.format)&&(r["audio.format"]=t.format),void 0!==(null==t?void 0:t.sampleRate)&&(r["audio.sampleRate"]=String(t.sampleRate)),void 0!==(null==t?void 0:t.bitsPerSample)&&(r["audio.bitsPerSample"]=String(t.bitsPerSample)),void 0!==(null==t?void 0:t.channels)&&(r["audio.channels"]=String(t.channels)),r}function Be(e){if("string"==typeof e&&e)try{return JSON.parse(e)}catch(t){return e}return e}function Ge(e){return"undefined"!=typeof File&&e instanceof File}function qe(e){return"object"===T(e)&&null!==e&&!Array.isArray(e)&&"string"==typeof e.filePath&&""!==e.filePath}function Je(){var e,t=s.Wp.getEnvInfo();if("web"!==t.platform&&"node"!==t.platform&&"quick_app"!==t.platform&&"function"==typeof(null===(e=t.global)||void 0===e?void 0:e.uploadFile))return t}function Ke(e){var t,r=function(e){var t,r,a=Be(null==e?void 0:e.data),n=null===(t=null==a?void 0:a.error)||void 0===t?void 0:t.code;return{serviceCode:"string"==typeof n||"number"==typeof n?String(n):void 0,serviceMessage:null===(r=null==a?void 0:a.error)||void 0===r?void 0:r.message}}(e),a=r.serviceCode,n=r.serviceMessage;if("number"==typeof(null==e?void 0:e.type)&&!a)return{type:e.type,message:(null==e?void 0:e.message)||"Voice-to-text failed"};switch(a){case"4041001":return{type:o.C.FILE_NOT_FOUND,message:"File not found"};case"4001002":return{type:o.C.FILE_INVALID,message:"Invalid file"};case"5021001":return{type:o.C.WEBIM_UPLOADFILE_ERROR,message:"File upload failed"};case"4001003":return{type:o.C.FILE_DURATION_TOO_LONG,message:"Voice duration exceeds 60 seconds"};case"4031001":return{type:o.C.SERVICE_NOT_ENABLED,message:"Service not enabled"};case"4031002":return{type:o.C.MAX_LIMIT,message:"Beta service usage limit exceeded"};case"4001001":return"string"==typeof(t=n)&&t.toLowerCase().includes("uploaded file exceeds")?{type:o.C.FILE_TOO_LARGE,message:"File too large"}:{type:o.C.REQUEST_PARAMETER_ERROR,message:n||"Missing or invalid request parameter"};case"5021003":case"5001003":return{type:o.C.FILE_VOICE_TO_TEXT_FAILED,message:"Voice-to-text failed"};case"4011001":return{type:o.C.NO_PERMISSION,message:n||"Unauthorized or invalid token"};default:return{type:o.C.FILE_VOICE_TO_TEXT_FAILED,message:n||(null==e?void 0:e.message)||"Voice-to-text failed"}}}function Ve(e,t,r){void 0===r&&(r="");var a={type:e};return e===o.C.REQUEST_SUCCESS?(a.data={text:r},a):(void 0!==t&&(a.message=t),a)}function He(e){return!(void 0===e||"object"===T(e)&&null!==e&&!Array.isArray(e))||void 0!==(null==e?void 0:e.format)&&"string"!=typeof e.format||void 0!==(null==e?void 0:e.sampleRate)&&"number"!=typeof e.sampleRate||void 0!==(null==e?void 0:e.bitsPerSample)&&"number"!=typeof e.bitsPerSample||void 0!==(null==e?void 0:e.channels)&&"number"!=typeof e.channels}function We(e,t){if(!e||"audio"!==e.type)return Promise.reject(Ve(o.C.FILE_INVALID,"Invalid file"));if(He(t))return Promise.reject(Ve(o.C.FILE_INVALID,"Invalid file"));if(!e.url)return Promise.reject(Ve(o.C.FILE_NOT_FOUND,"File not found"));var r=function(e){if(e){var t=e.split("#")[0].split("?")[0].split("/").filter(Boolean);return t[t.length-1]}}(e.url);return r?Le.call(this,I({fileId:r},t?{audio:t}:{})).then((function(e){var t;return Ve(e.type,e.message,(null===(t=e.data)||void 0===t?void 0:t.text)||"")})).catch((function(e){var t=Ke(e);throw Ve(t.type,t.message)})):Promise.reject(Ve(o.C.FILE_INVALID,"Invalid file"))}function Qe(e,t){return He(t)?Promise.reject(Ve(o.C.FILE_INVALID,"Invalid file")):Ge(e)||qe(e)&&Je()?Me.call(this,I({file:e},t?{audio:t}:{})).then((function(e){var t;return Ve(e.type,e.message,(null===(t=e.data)||void 0===t?void 0:t.text)||"")})).catch((function(e){var t=Ke(e);throw Ve(t.type,t.message)})):Promise.reject(Ve(o.C.FILE_INVALID,"Invalid file"))}function Xe(e){void 0===e&&(e="*");var t=this.context,r=t.orgName,a=t.appName,n=t.accessToken,o=t.userId,i={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/users/").concat(o,"/token/rtc?channelName=").concat(e),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+n,"Content-Type":"application/json"}};return s.RD.call(this,i).then((function(e){return{type:e.type,data:{appId:(null==e?void 0:e.app_id)||"",RTCToken:(null==e?void 0:e.rtc_token)||"",channelName:(null==e?void 0:e.channel_name)||"",RTCUId:(null==e?void 0:e.rtcUid)||0,expire:(null==e?void 0:e.expires_in)||0}}}))}function Ye(e){if(!Array.isArray(e)||0===e.length)throw Error("Invalid parameter RTCUIds: "+e);var t=this.context,r=t.orgName,a=t.appName,n=t.accessToken,o={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/rtc_mapper/batch/get"),type:"POST",dataType:"json",data:JSON.stringify({data:e}),headers:{Authorization:"Bearer "+n,"Content-Type":"application/json"}};return s.RD.call(this,o).then((function(e){return{type:e.type,data:e.data||{}}}))}var Ze=a},4490:function(e,t,r){var a=r(6518),n=r(9504),o=r(4376),i=n([].reverse),s=[1,2];a({target:"Array",proto:!0,forced:String(s)===String(s.reverse())},{reverse:function(){return o(this)&&(this.length=this.length),i(this)}})},6034:function(e,t,r){var a=r(6518),n=r(2357).values;a({target:"Object",stat:!0},{values:function(e){return n(e)}})}},function(e){var t=e(e.s=3352);return t.default}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[77],{706:function(e,t,r){var a=r(350).PROPER,n=r(9039),o=r(7452);e.exports=function(e){return n((function(){return!!o[e]()||"​…᠎"!=="​…᠎"[e]()||a&&o[e].name!==e}))}},2762:function(e,t,r){var a=r(6518),n=r(3802).trim;a({target:"String",proto:!0,forced:r(706)("trim")},{trim:function(){return n(this)}})},3352:function(e,t,r){r.d(t,{default:function(){return Ye}});var a={};r.r(a),r.d(a,{acceptContactInvite:function(){return te},acceptInvitation:function(){return ee},addContact:function(){return Y},addConversationMark:function(){return _e},addReaction:function(){return pe},addToBlackList:function(){return ne},addUsersToBlacklist:function(){return oe},addUsersToBlocklist:function(){return ie},declineContactInvite:function(){return ae},declineInvitation:function(){return re},deleteAllMessagesAndConversations:function(){return we},deleteContact:function(){return $},deleteConversation:function(){return B},deleteReaction:function(){return he},deleteSession:function(){return D},fetchHistoryMessages:function(){return H},fetchUserInfoById:function(){return J},getAllContacts:function(){return Se},getBlacklist:function(){return w},getBlocklist:function(){return A},getContacts:function(){return U},getContactsWithCursor:function(){return je},getConversationlist:function(){return L},getHistoryMessages:function(){return Q},getRTCToken:function(){return Qe},getReactionDetail:function(){return ve},getReactionList:function(){return fe},getReactionlist:function(){return me},getRoster:function(){return P},getSelfIdsOnOtherPlatform:function(){return Oe},getServerConversations:function(){return Te},getServerConversationsByFilter:function(){return ke},getServerPinnedConversations:function(){return Ee},getServerPinnedMessages:function(){return xe},getSessionList:function(){return F},getTokenExpireTimestamp:function(){return V},getUserIdByRTCUIds:function(){return Xe},modifyMessage:function(){return de},pinConversation:function(){return Ce},pinMessage:function(){return Pe},recallMessage:function(){return le},removeConversationMark:function(){return Ne},removeFromBlackList:function(){return se},removeHistoryMessages:function(){return ye},removeRoster:function(){return Z},removeUserFromBlackList:function(){return ce},removeUserFromBlocklist:function(){return ue},reportMessage:function(){return ge},searchMessages:function(){return X},setContactRemark:function(){return be},unbindPushToken:function(){return ze},unpinMessage:function(){return Ue},updateCurrentUserNick:function(){return K},updateOwnUserInfo:function(){return G},updateUserInfo:function(){return q},uploadPushToken:function(){return z},uploadToken:function(){return x},voiceFileToText:function(){return We},voiceMessageToText:function(){return He}}),r(2675),r(9463),r(2259),r(8706),r(2008),r(1629),r(4423),r(4346),r(3792),r(8598),r(2062),r(4490),r(5086),r(6910),r(4554),r(9089),r(739),r(3288),r(2010),r(9085),r(9432),r(6099),r(6034),r(3362),r(8781),r(1415),r(1699),r(7764),r(2762),r(3500),r(2953);var n=r(1156),o=r(8093),i=r(3484),s=r(4269),c=r(4865),u=r(8579),l=r(3887),d=r.n(l),p=r(7968),h=r(3603),f=r(8211),m=r(1274),v=r(9254),g=r(4331),y=r(6981);function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}var I=function(){return I=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},I.apply(this,arguments)},E=function(e,t,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))},C=function(e,t){var r,a,n,o,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((n=(n=i.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},b={txt:"text",img:"image",video:"video",file:"file",loc:"location",custom:"custom",combine:"combine"},S={text:"txt",image:"img",video:"video",file:"file",location:"loc",custom:"custom"},j=5,R=new Set(["txt","img","video","file","loc","custom","combine"]);function _(e){return i.A.create({type:o.C.REQUEST_PARAMETER_ERROR,message:e})}function N(e,t){p.vF.error(e,t)}function k(e){var t,r,a,n=f.p[e.conversationType],o=S[e.contentType]||e.contentType,i=function(e,t){return"groupchat"===t.conversationType||"chatroom"===t.conversationType?t.receiverId:t.senderId!==e?t.senderId:t.receiverId}(this.context.userId,e),c={id:"".concat(e.messageId),conversationId:i,chatType:n,from:e.senderId,to:e.receiverId,ext:e.ext||{},time:new Date(e.sentTime).getTime()},l=e.content||{},d="string"==typeof e.text?e.text:void 0;switch(o){case"txt":a=I(I({},c),{type:"txt",msg:l.message||e.text||""}),Array.isArray(e.translations)&&e.translations.length>0&&(a.translations={translations:e.translations.map((function(e){return{text:e.text,to:e.code}}))});break;case"img":var p=l.url||l.remotePath||"",h=l.secret||l.secretKey||"",m=this.useOwnUploadFun?p:u.zK.call(this,{remotePath:p,secretKey:h});a=I(I({},c),{type:"img",url:m||"",width:(null===(t=l.size)||void 0===t?void 0:t.width)||l.width||0,height:(null===(r=l.size)||void 0===r?void 0:r.height)||l.height||0,secret:h,thumb:this.useOwnUploadFun?l.thumb||"":l.thumb?s.Wp.formatAttachUrl.call(this,l.thumb):m?"".concat(m,"&thumbnail=true"):"",thumb_secret:l.thumb_secret||l.thumbnailSecretKey||h||"",file_length:l.file_length||l.fileLength||0,filetype:l.filetype||"",file:{},isGif:"sub_gif"===l.subType||1===l.subType});break;case"video":p=l.url||l.remotePath||"",h=l.secret||l.secretKey||"",m=this.useOwnUploadFun?p:u.zK.call(this,{remotePath:p,secretKey:h}),a=I(I({},c),{type:"video",url:m||"",secret:h||"",thumb:l.thumb?s.Wp.formatAttachUrl.call(this,l.thumb):s.Wp.formatAttachUrl.call(this,l.thumbnailRemotePath||""),thumb_secret:l.thumb_secret||l.thumbnailSecretKey||"",filename:l.filename||l.displayName||"",length:l.length||l.duration||0,file:{},file_length:l.file_length||l.fileLength||0,filetype:l.filetype||""});break;case"file":p=l.url||l.remotePath||"",h=l.secret||l.secretKey||"",m=this.useOwnUploadFun?p:u.zK.call(this,{remotePath:p,secretKey:h}),a=I(I({},c),{type:"file",url:m||"",secret:h||"",file:{},filename:l.filename||l.displayName||"",length:l.length||l.duration||0,file_length:l.file_length||l.fileLength||0,filetype:l.filetype||""});break;case"loc":a=I(I({},c),{type:"loc",buildingName:l.buildingName||"",addr:l.addr||l.address||"",lat:l.lat||l.latitude||0,lng:l.lng||l.longitude||0});break;case"custom":a=I(I({},c),{type:"custom",customEvent:l.customEvent||"",customExts:l.customExts||{},params:l.params||{}});break;default:a=I(I({},c),{type:o})}if(void 0!==d&&(a.text=d),e.highlight&&"object"===T(e.highlight)){for(var v=[],g=0,y=Object.values(e.highlight);g<y.length;g++){var E=y[g];Array.isArray(E)&&v.push.apply(v,E)}v.length>0&&(a.highlight=v)}return a}var O={singleChat:"chat",chatRoom:"chatroom",groupChat:"groupchat"};function w(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c={url:this.apiUrl+"/"+a+"/"+o+"/users/"+this.user+"/blocks/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+i},success:function(t){var r={};t.data.forEach((function(e){r[e]={name:e}})),"function"==typeof(null==e?void 0:e.success)&&e.success(t)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return p.vF.debug("Call getBlocklist"),s.RD.call(this,c,h.jz.GET_BLACK_LIST)}var A=w,P=U;function U(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u={url:this.apiUrl+"/"+o+"/"+i+"/users/"+this.user+"/contacts/users",dataType:"json",type:"GET",headers:{Authorization:"Bearer "+c},success:function(r){var a=[];r.data.forEach((function(e){a.push({name:e,subscription:"both",jid:t.context.jid})})),"function"==typeof(null==e?void 0:e.success)&&e.success(a)},error:function(t){"function"==typeof(null==e?void 0:e.error)&&e.error(t)}};return p.vF.debug("Call getContacts"),s.RD.call(this,u,h.jz.GET_CONTACTS)}function x(e){return p.vF.debug("Call uploadPushToken"),y.B.call(this,e)}var z=x;function F(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/user_channels"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return p.vF.debug("Call getSessionList"),s.RD.call(this,c)}function L(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=!!(e&&"number"==typeof e.pageNum&&"number"==typeof e.pageSize&&e.pageNum>0&&e.pageSize>0),l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/users/").concat(this.user,"/user_channels").concat(u?"/page":""),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return u&&(l.data={pageNum:e.pageNum,pageSize:e.pageSize}),p.vF.debug("Call getConversationlist"),s.RD.call(this,l,h.jz.GET_SESSION_LIST).then((function(e){return M.call(t,e)}))}function M(e){var t=this,r=e.data.channel_infos;return null==r||r.forEach((function(e){e.meta&&"{}"!==JSON.stringify(e.meta)?(e.meta.payload=JSON.parse(e.meta.payload),e.lastMessage=f.h.call(t,e.meta,{formatCustomExts:!1})):e.lastMessage=e.meta,delete e.meta})),e}function D(e){if(e&&"string"!=typeof e.channel)throw Error("Invalid parameter channel: ".concat(e.channel));if(e&&"singleChat"!==e.chatType&&"groupChat"!==e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(e&&"boolean"!=typeof e.deleteRoam)throw Error("Invalid parameter deleteRoam: ".concat(e.deleteRoam));var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r,a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=a.jid;r="singleChat"===e.chatType?"chat":"groupChat";var l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/user/").concat(this.user,"/user_channel?resource=").concat(u.clientResource),dataType:"json",type:"DELETE",data:JSON.stringify({channel:e.channel,type:r,delete_roam:e.deleteRoam}),headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"},success:e.success,error:e.error};return p.vF.debug("Call deleteSession",e),s.RD.call(this,l,h.jz.DELETE_SESSION)}var B=D;function G(e,t){var r=n.dO.call(this).error;if(r)return Promise.reject(r);var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=["nickname","avatarurl","mail","phone","gender","sign","birth","ext"],l={},d=s.Wp.getEnvInfo();if("wx"===d.platform||"qq"===d.platform)if("string"==typeof e&&void 0!==t){if(!u.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");l[e]=t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");u.forEach((function(t){u.includes(t)&&void 0!==e[t]&&(l[t]=e[t])}))}else if("string"==typeof e){if(!u.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");l=e+"="+t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");var f=[];u.forEach((function(t){if(u.includes(t)&&void 0!==e[t]){var r=encodeURIComponent(t),a=encodeURIComponent(e[t]);f.push(r+"="+a)}})),l=f.join("&")}var m={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/metadata/user/").concat(this.user),type:"PUT",data:l,dataType:"json",headers:{Authorization:"Bearer "+c,"Content-Type":"application/x-www-form-urlencoded"}};return p.vF.debug("Call updateOwnUserInfo",e),s.RD.call(this,m,h.jz.UPDATE_USER_INFO)}var q=G;function J(e,t){var r=n.dO.call(this).error;if(r)return Promise.reject(r);var a,o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=[];if("string"==typeof e)l=[e];else{if("[object Array]"!==Object.prototype.toString.call(e))throw new Error("illegal params");l=e}a="string"==typeof t?[t]:t&&"[object Array]"===Object.prototype.toString.call(t)?t:["nickname","avatarurl","mail","phone","gender","sign","birth","ext"];var d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/metadata/user/get"),type:"POST",data:JSON.stringify({targets:l,properties:a}),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return p.vF.debug("Call fetchUserInfoById",e),s.RD.call(this,d,h.jz.GET_USER_INFO)}function K(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user),type:"PUT",dataType:"json",data:JSON.stringify({nickname:e}),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return p.vF.debug("Call updateCurrentUserNick",e),s.RD.call(this,c)}function V(e){if("string"!=typeof e||""===e)throw Error('Invalid parameter: "token"');var t=this.context,r=t.orgName,a=t.appName,n={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/sdk/users/").concat(this.user,"/token/expires"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+e,"Content-Type":"application/json"}};return p.vF.debug("Call getTokenExpireTimestamp",e),s.RD.call(this,n,h.jz.SDK_INTERNAL)}function H(e){var t=this;return new Promise((function(r,a){if(!e.queue)throw Error('Invalid parameter: "specified"');var o=n.dO.call(t).error;if(o)return Promise.reject(o);(function e(t){var n=this,o=t.count||20;W.call(this,{count:o,isGroup:!!t.isGroup,queue:t.queue,start:t.start,format:t.format,success:function(a){if(a.msgs.length>=o||a.is_last){var i=a.msgs.splice(0,o).reverse();t.success&&t.success(i),r(i)}else e.call(n,I(I({},t),{start:null}))},fail:function(e){a(e),t.fail&&t.fail(e)}})}).call(t,e),p.vF.debug("Call fetchHistoryMessages",e)}))}function W(e){var t=this,r=e.queue,a=this.mr_cache[r]||(this.mr_cache[r]={msgs:[]}),n=this.context.userId,c=e.start||-1,l=e.count||20;if(a.msgs.length>=l||a.is_last)"function"==typeof e.success&&e.success(a);else{a&&a.next_key&&(c=a.next_key),e.start&&(c=e.start);var p={queue:r+(e.isGroup?"@conference.easemob.com":"@easemob.com"),start:c,end:-1},f=this.context,m=f.orgName,v=f.appName,g={url:"".concat(this.apiUrl,"/").concat(m,"/").concat(v,"/users/").concat(n,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"},data:JSON.stringify(p),success:function(r){return E(t,void 0,void 0,(function(){var t,n,o,i,s,c,l=this;return C(this,(function(p){switch(p.label){case 0:if(t=null==r?void 0:r.data,!r.data.msgs)return"function"==typeof e.success&&e.success(a),a.is_last=!0,a.next_key="",[2];n=t.msgs,o=n.length,a.is_last=t.is_last,a.next_key=t.next_key,i=function(t){return E(l,void 0,void 0,(function(){var r,a,n,o,i;return C(this,(function(s){switch(s.label){case 0:for(r=[],t=d().atob(t),a=0,n=t.length;a<n;++a)r.push(t.charCodeAt(a));return o=(o=this.context.root.lookup("easemob.pb.Meta")).decode(r),i={errorCode:0,reason:""},1!==o.ns?[3,2]:[4,u.Ay.call(this,o,i,!0,e.format)];case 1:return[2,s.sent()];case 2:return[2]}}))}))},s=0,p.label=1;case 1:return s<o?[4,i(n[s].msg)]:[3,4];case 2:(c=p.sent())&&a.msgs.push(c),p.label=3;case 3:return s++,[3,1];case 4:return"function"==typeof e.success&&e.success(a),[2]}}))}))},error:function(e){if(e.error&&e.error_description){var r=i.A.create({type:o.C.WEBIM_CONNCTION_AJAX_ERROR,message:"fetch history messages error",data:e});t.onError&&t.onError(r)}}};s.RD.call(this,g,h.jz.GET_HISTORY_MSG).catch((function(t){"function"==typeof e.fail&&e.fail(t)}))}}function Q(e){var t=this;return new Promise((function(r,a){var o=e.targetId,i=e.cursor,c=void 0===i?-1:i,l=e.pageSize,f=void 0===l?20:l,m=e.chatType,v=e.searchDirection,g=e.searchOptions,y=void 0===g?{}:g,T=y.msgTypes,I=void 0===T?[]:T,b=y.startTime,S=void 0===b?null:b,j=y.endTime,R=void 0===j?null:j,N=y.from,k=void 0===N?null:N;if("string"!=typeof o||""===o)return a(_('"Invalid parameter": "targetId"'));if(k&&"string"!=typeof k)return a(_('"Invalid parameter": "searchOptions.from"'));if(I&&!Array.isArray(I))return a(_('"Invalid parameter": "searchOptions.msgTypes"'));if(S&&"number"!=typeof S)return a(_('"Invalid parameter": "searchOptions.startTime"'));if(R&&"number"!=typeof R)return a(_('"Invalid parameter": "searchOptions.endTime"'));var O=n.dO.call(t).error;if(O)return a(O);var w=t.context,A=w.orgName,P=w.appName,U=w.userId,x="singleChat"===e.chatType?"@easemob.com":"@conference.easemob.com",z={queue:"".concat(o).concat(x),start:c,pull_number:f,is_positive:"down"===v,msgType:I.join(",")||"",end:-1,startTime:S,endTime:R,userId:"singleChat"===m?null:k},F={url:"".concat(t.apiUrl,"/").concat(A,"/").concat(P,"/users/").concat(U,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+t.token,"Content-Type":"application/json"},data:JSON.stringify(z),success:function(a){return E(t,void 0,void 0,(function(){var t,n,o,i,s,c,l,p,h=this;return C(this,(function(f){switch(f.label){case 0:t=null==a?void 0:a.data,n=t.msgs||[],o=function(e){return E(h,void 0,void 0,(function(){var t,r,a,n,o;return C(this,(function(i){switch(i.label){case 0:for(t=[],e=d().atob(e),r=0,a=e.length;r<a;++r)t.push(e.charCodeAt(r));return n=(n=this.context.root.lookup("easemob.pb.Meta")).decode(t),o={errorCode:0,reason:""},1!==n.ns?[3,2]:[4,u.Ay.call(this,n,o,!0,!0)];case 1:return[2,i.sent()];case 2:return[2]}}))}))},i=[],s=0,f.label=1;case 1:return s<n.length?[4,o(n[s].msg)]:[3,4];case 2:(c=f.sent())&&i.push(c),f.label=3;case 3:return s++,[3,1];case 4:return t.msgs=i,l={cursor:t.next_key,messages:i,isLast:t.is_last},null===(p=e.success)||void 0===p||p.call(e,l),r(l),[2]}}))}))},error:e.fail};s.RD.call(t,F,h.jz.REST_FETCHHISTORYMESSAGE).catch((function(e){a(e)})),p.vF.debug("Call getHistoryMessages",e)}))}function X(e){var t,r,a=this,c=n.dO.call(this).error;if(c)return Promise.reject(c);var u=null==e?void 0:e.option,l=null!==(t=null==e?void 0:e.pageNum)&&void 0!==t?t:1,d=null!==(r=null==e?void 0:e.pageSize)&&void 0!==r?r:20,f=[];try{f=function(e,t,r){var a;if(!e||"object"!==T(e))throw _('"Invalid parameter": "option"');if(!Array.isArray(e.keywordList))throw _('"Invalid parameter": "keywordList"');var n=e.keywordList.map((function(e){return"".concat(null!=e?e:"").trim()})).filter((function(e){return e.length>0}));if(0===n.length)throw _('"Invalid parameter": "keywordList"');if(n.length>j)throw _('"Invalid parameter": "keywordList exceeds max count 5"');if(void 0!==e.conversationId&&("string"!=typeof e.conversationId||""===e.conversationId.trim()))throw _('"Invalid parameter": "conversationId"');if(void 0!==e.conversationType&&!["singleChat","groupChat","chatRoom"].includes(e.conversationType))throw _('"Invalid parameter": "conversationType"');if(void 0===e.conversationId!=(void 0===e.conversationType))throw _('"Invalid parameter": "conversationId and conversationType must be used together"');if(void 0!==e.startTime&&void 0===e.endTime||void 0===e.startTime&&void 0!==e.endTime)throw _('"Invalid parameter": "startTime/endTime"');if(void 0!==e.startTime&&("number"!=typeof e.startTime||"number"!=typeof e.endTime||e.endTime<e.startTime))throw _('"Invalid parameter": "startTime/endTime"');if("number"!=typeof t||t<1)throw _('"Invalid parameter": "pageNum"');if("number"!=typeof r||r<1||r>100)throw _('"Invalid parameter": "pageSize"');if(e.msgTypes&&!Array.isArray(e.msgTypes))throw _('"Invalid parameter": "msgTypes"');if(null===(a=e.msgTypes)||void 0===a?void 0:a.some((function(e){return!R.has(e)})))throw _('"Invalid parameter": "msgTypes contains unsupported type"');return n}(u,l,d)}catch(t){return p.vF.error("searchMessages parameter validation failed",{params:e,error:t}),Promise.reject(t)}var m=this.context,v=m.orgName,g=m.appName,y=m.accessToken,I=function(e,t,r,a,n){var o=function(e,t){var r,a=null!==(r=e.keywordListMatchType)&&void 0!==r?r:"or",n={searchMode:"default"};return 1===t.length?n.keyword=t[0]:(n.keywords=t,n.keywordMatch="and"===a?"all":"any"),{data:n,normalizedKeywordList:t}}(e,t).data;return e.conversationId&&("singleChat"===e.conversationType?o.participantPairs=[{userId1:n,userId2:e.conversationId}]:"groupChat"===e.conversationType?o.groupIds=[e.conversationId]:"chatRoom"===e.conversationType?o.chatroomIds=[e.conversationId]:o.conversationId=e.conversationId),e.msgTypes&&e.msgTypes.length>0&&(o.contentType=e.msgTypes.filter((function(e){return e in b})).map((function(e){return b[e]})).join(",")),"number"==typeof e.startTime&&"number"==typeof e.endTime&&(o.startTime=e.startTime,o.endTime=e.endTime),e.searchScope&&(o.searchExt=e.searchScope),o.sort="relevance:desc",o.highlightEnable=!0,o.page=r,o.size=a,o}(u,f,l,d,this.user),E={url:"".concat(this.apiUrl,"/").concat(v,"/").concat(g,"/users/").concat(this.user,"/messages/search/get"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+y,"Content-Type":"application/json",Accept:"application/json; charset=utf-8"},data:JSON.stringify({data:I})};return p.vF.debug("Call searchMessages",e),s.RD.call(this,E,h.jz.REST_SEARCH_MESSAGES).then((function(t){var r,n,s=(null==t?void 0:t.data)||{},c=(null==s?void 0:s.data)&&"object"===T(s.data)?s.data:s,u=c.pagination||{},p=Array.isArray(c.items)?c.items:Array.isArray(c.list)?c.list:[];Array.isArray(c.items)||Array.isArray(c.list)||N("searchMessages response items/list is invalid",{params:e,responseData:c,rawResponse:t});var h=[];p.forEach((function(t,r){try{h.push(k.call(a,t))}catch(a){throw N("searchMessages failed to map response item",{params:e,index:r,item:t,error:a}),i.A.create({type:o.C.WEBIM_CONNCTION_AJAX_ERROR,message:"Failed to parse search result item",data:{index:r,item:t,error:a}})}}));var f={messages:h,pageNum:u.page||c.page||l,pageSize:d,totalPages:"number"==typeof u.totalPages?u.totalPages:-1,isLast:"number"!=typeof u.isFinished||1===u.isFinished,requestId:null===(r=null==s?void 0:s.meta)||void 0===r?void 0:r.requestId,timestamp:(null===(n=null==s?void 0:s.meta)||void 0===n?void 0:n.timestamp)||Date.now()};return"number"!=typeof u.page&&void 0!==u.page&&N("searchMessages pagination.page is invalid",{params:e,pagination:u,rawResponse:t}),f}))}function Y(e,t){return E(this,void 0,void 0,(function(){var r,a,o,i,c,u,l;return C(this,(function(d){switch(d.label){case 0:if(r=n.dO.call(this).error)return[2,Promise.reject(r)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call addContact",e,t),a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u=a.jid,l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/users/").concat(this.user,"/contacts/apply?resource=").concat(u.clientResource),type:"POST",dataType:"json",data:JSON.stringify({usernames:[e],reason:t}),headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"}},[4,s.RD.call(this,l,h.jz.ROSTER_ADD)];case 1:return d.sent(),[2]}}))}))}var Z=$;function $(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u;return C(this,(function(l){switch(l.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call deleteContact",e),r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=r.jid,u={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/contacts/users/").concat(e,"?resource=").concat(c.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,u,h.jz.ROSTER_REMOVE)];case 1:return l.sent(),[2]}}))}))}function ee(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u;return C(this,(function(l){switch(l.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call acceptInvitation",e),r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=r.jid,u={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/contacts/accept/users/").concat(e,"?resource=").concat(c.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,u,h.jz.ROSTER_ACCEPT)];case 1:return l.sent(),[2]}}))}))}var te=ee;function re(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u;return C(this,(function(l){switch(l.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if("string"!=typeof e||""===e)throw Error('"Invalid parameter": "to"');return p.vF.debug("Call declineInvitation",e),r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=r.jid,u={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/users/").concat(this.user,"/contacts/decline/users/").concat(e,"?resource=").concat(c.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,u,h.jz.ROSTER_DECLINE)];case 1:return l.sent(),[2]}}))}))}var ae=re;function ne(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d;return C(this,(function(f){switch(f.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(r=e.name,a=[],"string"==typeof r){if(""===r)throw Error('"Invalid parameter": "name"');a=[r]}else{if(!Array.isArray(r))throw Error('"Invalid parameter": "name"');a=r}return p.vF.debug("Call addToBlockList",e),o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=o.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/sdk/user/").concat(this.user,"/blocks?resource=").concat(l.clientResource),type:"POST",dataType:"json",data:JSON.stringify({usernames:a}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.RD.call(this,d,h.jz.ROSTER_BAN).then((function(e){return{type:e.type,data:{userIds:(null==e?void 0:e.data)||[]}}}))];case 1:return[2,f.sent()]}}))}))}var oe=ne,ie=ne;function se(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d;return C(this,(function(f){switch(f.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(r=e.name,a=[],"string"==typeof r){if(""===r)throw Error('"Invalid parameter": "name"');a=[r]}else{if(!Array.isArray(r))throw Error('"Invalid parameter": "name"');a=r}return p.vF.debug("Call removeFromBlockList",e),o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=o.jid,d={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/sdk/user/").concat(this.user,"/blocks?resource=").concat(l.clientResource),type:"DELETE",dataType:"json",data:JSON.stringify({usernames:a}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.RD.call(this,d,h.jz.ROSTER_ALLOW)];case 1:return f.sent(),[2]}}))}))}var ce=se,ue=se;function le(e){var t=this,r=(null==e?void 0:e.ext)||"";if("string"!=typeof r)throw Error('"Invalid parameter": "ext"',r);var a=this.getUniqueId(),n={id:a,to:e.to};this._msgHash[a]=I({},n);var o="";void 0!==e.chatType?o=e.chatType:void 0!==e.type&&(o="chat"===e.type?"singleChat":e.type);var i={id:a,type:"recall",chatType:o,ackId:e.mid,to:e.to,isChatThread:e.isChatThread||!1,metaExt:r,success:function(r){return E(t,void 0,void 0,(function(){var t,a,n,i,s,c,u,l,d;return C(this,(function(p){switch(p.label){case 0:return p.trys.push([0,5,,6]),"singleChat"!==o&&"groupChat"!==o?[3,4]:[4,null===(n=null===(a=this._localCache)||void 0===a?void 0:a.getInstance())||void 0===n?void 0:n.removeMsgByServerMsgId(e.mid)];case 1:return p.sent(),[4,null===(s=null===(i=this._localCache)||void 0===i?void 0:i.getInstance())||void 0===s?void 0:s.getConversationLastMessage(e.to,o)];case 2:return t=p.sent(),[4,null===(u=null===(c=this._localCache)||void 0===c?void 0:c.getInstance())||void 0===u?void 0:u.updateLocalConversation((0,v.u0)({conversationId:e.to,conversationType:o}),{lastMessageId:null==t?void 0:t.serverMsgId})];case 3:p.sent(),p.label=4;case 4:return null===(l=null==e?void 0:e.success)||void 0===l||l.call(e,r),[3,6];case 5:return p.sent(),null===(d=null==e?void 0:e.success)||void 0===d||d.call(e,r),[3,6];case 6:return[2]}}))}))},fail:e.fail};return p.vF.debug("Call recallMessage",e),this.mSync.send(i,this)}function de(e){var t=e||{},r=t.messageId,a=t.modifiedMessage;if(p.vF.debug("Call modifyMessage",r,a),""===r)throw Error('Invalid parameter: "messageId"');return this.mSync.send(I({editMessageId:r},a))}function pe(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d;return C(this,(function(p){switch(p.label){case 0:if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));return(t=n.dO.call(this).error)?[2,Promise.reject(t)]:(r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.reaction,u=e.messageId,l={msgId:u,message:c},d={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user),type:"POST",data:JSON.stringify(l),dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,d)]);case 1:return p.sent(),[2]}}))}))}function he(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l;return C(this,(function(d){switch(d.label){case 0:if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reactionId: ".concat(e.reaction));return(t=n.dO.call(this).error)?[2,Promise.reject(t)]:(r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.messageId,u=e.reaction,l={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user,"?msgId=").concat(c,"&message=").concat(u),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,l)]);case 1:return d.sent(),[2]}}))}))}function fe(e){if("string"!=typeof e.chatType||!e.chatType)throw Error("Invalid parameter chatType: ".concat(e.chatType));if(!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.chatType,u=e.messageId,l={msgIdList:"string"==typeof u?[u]:u,msgType:"singleChat"===c?"chat":"groupchat",groupId:e.groupId||null},d={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user),type:"GET",data:l,dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return s.RD.call(this,d).then((function(e){var t=e.data;return null==t||t.forEach((function(e){null==e||e.reactionList.forEach((function(e){e.isAddedBySelf=e.state,delete e.state,delete e.reactionId}))})),e}))}var me=fe;function ve(e){if("string"!=typeof e.reaction||!e.reaction)throw Error("Invalid parameter reaction: ".concat(e.reaction));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));var t=n.dO.call(this).error;if(t)return Promise.reject(t);var r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.cursor,u=e.pageSize,l={msgId:e.messageId,message:e.reaction,currentPage:c||null,pageSize:u||20},d={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/reaction/user/").concat(this.user,"/detail"),type:"GET",data:l,dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return s.RD.call(this,d).then((function(e){return e.data.isAddedBySelf=e.data.state,delete e.data.state,delete e.data.reactionId,e}))}function ge(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,p,h;return C(this,(function(f){switch(f.label){case 0:if("string"!=typeof e.reportType||!e.reportType)throw Error("Invalid parameter reportType: ".concat(e.reportType));if("string"!=typeof e.messageId||!e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.reportReason||!e.reportReason)throw Error("Invalid parameter messageId: ".concat(e.reportReason));return(t=n.dO.call(this).error)?[2,Promise.reject(t)]:(r=this.context,a=r.orgName,o=r.appName,i=r.accessToken,c=e.reportType,u=e.reportReason,l=e.messageId,d={username:this.user,reportType:c,reportReason:u},p="".concat(this.apiUrl,"/").concat(a,"/").concat(o,"/user/").concat(this.user,"/moderation/report/message/").concat(l),h={url:p,type:"POST",data:JSON.stringify(d),dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,s.RD.call(this,h)]);case 1:return f.sent(),[2]}}))}))}function ye(e){var t;return E(this,void 0,void 0,(function(){var r,a,o,i,c,u,l,d,h;return C(this,(function(f){switch(f.label){case 0:if("string"!=typeof e.targetId||""===e.targetId)throw Error('"Invalid parameter targetId": '+e.targetId);if(!["singleChat","groupChat","chatRoom"].includes(e.chatType))throw Error('"Invalid parameter chatType": '+e.chatType);if(e.beforeTimeStamp&&("number"!=typeof e.beforeTimeStamp||e.beforeTimeStamp<0||(null===(t=e.beforeTimeStamp)||void 0===t?void 0:t.toString().length)>18))throw Error('"Invalid parameter beforeTimeStamp": '+e.beforeTimeStamp);if(e.messageIds&&!(Array.isArray(e.messageIds)&&e.messageIds.length>0&&e.messageIds.length<=20))throw Error('"Invalid parameter messageIds": '+e.messageIds);if(!e.messageIds&&!e.beforeTimeStamp)throw Error("messageIds or beforeTimeStamp field is required.");return(r=n.dO.call(this).error)?[2,Promise.reject(r)]:(a=this.context,o=a.orgName,i=a.appName,c=a.userId,u="singleChat"===e.chatType?"userId":"groupId",l="singleChat"===e.chatType?"chat":"group",d=e.messageIds?"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/message/roaming/").concat(l,"/user/").concat(c,"?").concat(u,"=").concat(e.targetId,"&msgIdList=").concat(e.messageIds,"&resource=").concat(this.clientResource):"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/message/roaming/").concat(l,"/user/").concat(c,"/time?").concat(u,"=").concat(e.targetId,"&delTime=").concat(e.beforeTimeStamp,"&&resource=").concat(this.clientResource),h={url:d,dataType:"json",type:"DELETE",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"}},p.vF.debug("Call removeHistoryMessages",e),[4,s.RD.call(this,h)]);case 1:return f.sent(),[2]}}))}))}function Te(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));if((null==e?void 0:e.includeEmptyConversations)&&"boolean"!=typeof e.includeEmptyConversations)throw Error("Invalid parameter includeEmptyConversations: ".concat(e.includeEmptyConversations));var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||"",need_mark:!0,needEmptySession:(null==e?void 0:e.includeEmptyConversations)||!1},headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"}};return p.vF.debug("Call getServerConversations",e),new Promise((function(e,r){s.RD.call(t,u,h.jz.REST_FETCH_CONVERSATIONS).then((function(r){return E(t,void 0,void 0,(function(){var t,a,n=this;return C(this,(function(o){switch(o.label){case 0:return t=Ie.call(this,r),this._localCache?(a=t.data.conversations.map((function(e){return E(n,void 0,void 0,(function(){var t,r,a,n;return C(this,(function(o){switch(o.label){case 0:return[4,null===(r=null===(t=this._localCache)||void 0===t?void 0:t.getInstance())||void 0===r?void 0:r.storeMessage(e.lastMessage,m.q.SUCCESS,!0)];case 1:return o.sent(),[4,null===(n=null===(a=this._localCache)||void 0===a?void 0:a.getInstance())||void 0===n?void 0:n.updateLocalConversation((0,v.u0)({conversationId:e.conversationId,conversationType:e.conversationType}),{unReadCount:e.unReadCount})];case 2:return o.sent(),[2]}}))}))})),[4,Promise.all(a)]):[3,2];case 1:o.sent(),o.label=2;case 2:return e(t),[2]}}))}))})).catch((function(e){r(e)}))}))}function Ie(e){var t=this,r=e.data,a=r.cursor,n=r.channel_infos,o=[];null==n||n.forEach((function(e){var r=null;(null==e?void 0:e.meta)&&"{}"!==JSON.stringify(e.meta)&&(e.meta.payload=JSON.parse(e.meta.payload),"delivery"!==(r=f.h.call(t,e.meta)).type&&"read"!==r.type&&"channel"!==r.type&&(r.chatType=f.p[r.chatType]));var a={conversationId:e.session_to,conversationType:"chat"===e.session_type?"singleChat":"groupChat",isPinned:e.is_top,pinnedTime:e.is_top?e.update_top_status_time:0,unReadCount:e.unread_num,lastMessage:r};e.marks&&(a.marks=e.marks.map((function(e){return c.s[e]}))),o.push(a)}));var i={conversations:o,cursor:a||""};return{type:e.type,data:i}}function Ee(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);if((null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));if((null==e?void 0:e.includeEmptyConversations)&&"boolean"!=typeof e.includeEmptyConversations)throw Error("Invalid parameter includeEmptyConversations: ".concat(e.includeEmptyConversations));var a=this.context,o=a.orgName,i=a.appName,c=a.accessToken,u={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/sdk/user/").concat(this.user,"/user_channels/list?"),type:"GET",dataType:"json",data:{limit:(null==e?void 0:e.pageSize)||20,cursor:(null==e?void 0:e.cursor)||"",is_top:!0,need_mark:!0,needEmptySession:(null==e?void 0:e.includeEmptyConversations)||!1},headers:{Authorization:"Bearer "+c,"Content-Type":"application/json"}};return p.vF.debug("Call getServerPinnedConversations",e),s.RD.call(this,u,h.jz.GET_SESSION_LIST).then((function(e){return Ie.call(t,e)}))}function Ce(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,f,m,v,g,y;return C(this,(function(T){if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(r=e.conversationId,a=e.conversationType,o=e.isPinned,i="singleChat"===a?"chat":"groupChat","string"!=typeof r||""===r)throw Error("Invalid parameter conversationId: ".concat(r));if(!["singleChat","groupChat"].includes(a))throw Error("Invalid parameter conversationType: ".concat(a));if("boolean"!=typeof o)throw Error("Invalid parameter isPinned: ".concat(o));return c=this.context,u=c.orgName,l=c.appName,d=c.accessToken,f=c.jid,m={type:i,to:r},v=o?"":"type=".concat(i,"&to=").concat(r,"&"),g="".concat(this.apiUrl,"/").concat(u,"/").concat(l,"/sdk/user/").concat(this.user,"/user_channel/top?").concat(v,"resource=").concat(f.clientResource),y={url:g,type:o?"POST":"DELETE",dataType:"json",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}},o&&(y.data=JSON.stringify(m)),p.vF.debug("Call pinConversation",e),[2,s.RD.call(this,y,h.jz.PIN_CONVERSATION).then((function(e){var t=e.type,r=e.data;return{type:t,data:{isPinned:r.is_top||!1,pinnedTime:r.is_top?r.update_top_status_time:0}}}))]}))}))}function be(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,f;return C(this,(function(m){switch(m.label){case 0:if(t=e.userId,r=e.remark,a=n.dO.call(this).error)return[2,Promise.reject(a)];if("string"!=typeof t||""===t)throw Error('Invalid parameter: "userId"');if("string"!=typeof r)throw Error('Invalid parameter: "remark"');return p.vF.debug("Call setContactRemark",e),o=this.context,i=o.orgName,c=o.appName,u=o.accessToken,l=o.jid,d="".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.context.userId,"/contacts/users/").concat(t,"?resource=").concat(l.clientResource),f={url:d,type:"PUT",data:JSON.stringify({remark:r}),dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}},[4,s.RD.call(this,f,h.jz.ROSTER_SET_CONTACT_REMARK)];case 1:return m.sent(),[2]}}))}))}function Se(){var e=n.dO.call(this).error;if(e)return Promise.reject(e);var t=this.context,r=t.orgName,a=t.appName,o=t.accessToken,i={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/users/").concat(this.user,"/contacts/users?needReturnRemark=true"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+o}};return p.vF.debug("Call getAllContacts"),s.RD.call(this,i,h.jz.ROSTER_GET_ALL_CONTACTS_REMARKS).then((function(e){var t=((null==e?void 0:e.entities)||[]).map((function(e){return{userId:e.username,remark:e.remark}}));return{type:e.type,data:t}}))}function je(e){var t=n.dO.call(this).error;if(t)return Promise.reject(t);p.vF.debug("Call getContactsWithCursor",e);var r=e||{},a=r.pageSize,o=void 0===a?20:a,i=r.cursor,c=void 0===i?"":i;if(o&&"number"!=typeof o)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));var u=this.context,l=u.orgName,d=u.appName,f=u.accessToken,m={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/users/").concat(this.user,"/contacts?needReturnRemark=true&limit=").concat(o,"&cursor=").concat(c),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+f}};return s.RD.call(this,m,h.jz.ROSTER_GET_ALL_CONTACTS_REMARKS_FROM_SERVER_BY_PAGE).then((function(e){var t,r,a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.contacts)||[],n=(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.cursor)||"",o=a.map((function(e){return{userId:e.username,remark:e.remark}}));return{type:e.type,data:{cursor:n,contacts:o}}}))}function Re(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,u,l,d,m,v,g,y,T,I,E;return C(this,(function(C){switch(C.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(p.vF.debug("Call markConversation",e),a=(r=e||{}).conversations,o=void 0===a?[]:a,i=r.mark,u=r.isMarked,!Array.isArray(o))throw Error("Invalid parameter conversations");if(l=o.map((function(e){if(!e.conversationId||!["singleChat","groupChat"].includes(e.conversationType))throw Error("Invalid parameter conversations");return{to:e.conversationId,type:O[e.conversationType]}})),"boolean"!=typeof u)throw Error("Invalid parameter isMarked: ".concat(u));if("number"!=typeof i)throw Error("Invalid parameter mark: ".concat(i));return d=this.context,m=d.orgName,v=d.appName,g=d.accessToken,y=d.userId,T=d.jid,I={mark:c.s[i],targets:l},E={url:"".concat(this.apiUrl,"/").concat(m,"/").concat(v,"/sdk/user/").concat(y,"/user_channels/mark?resource=").concat(T.clientResource),dataType:"json",data:JSON.stringify(I),type:u?"Post":"Delete",headers:{Authorization:"Bearer "+g}},[4,s.RD.call(this,E,h.jz.MARK_CONVERSATION).then((function(e){var t,r=(null===(t=e.data)||void 0===t?void 0:t.ignore)||[];r&&Array.isArray(r)&&r.length>0&&p.vF.debug("markConversation has ignored conversations",r.map((function(e){return{conversationId:e.to,conversationType:f.p[e.type]}})))}))];case 1:return C.sent(),[2]}}))}))}function _e(e){return E(this,void 0,void 0,(function(){var t,r;return C(this,(function(a){return p.vF.debug("Call addConversationMark",e),t=e.conversations,r=e.mark,[2,Re.call(this,{conversations:t,mark:r,isMarked:!0})]}))}))}function Ne(e){return E(this,void 0,void 0,(function(){var t,r;return C(this,(function(a){return p.vF.debug("Call removeConversationMark",e),t=e.conversations,r=e.mark,[2,Re.call(this,{conversations:t,mark:r,isMarked:!1})]}))}))}function ke(e){var t,r,a=this,o=n.dO.call(this).error;if(o)return Promise.reject(o);if(p.vF.debug("Call getServerConversationsByFilter",e),(null==e?void 0:e.pageSize)&&"number"!=typeof e.pageSize)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));if((null==e?void 0:e.cursor)&&"string"!=typeof e.cursor)throw Error("Invalid parameter cursor: ".concat(e.cursor));if("number"!=typeof(null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.mark))throw Error("Invalid parameter mark: ".concat(null===(r=null==e?void 0:e.filter)||void 0===r?void 0:r.mark));var i=this.context,u=i.orgName,l=i.appName,d=i.accessToken,f="".concat(this.apiUrl,"/").concat(u,"/").concat(l,"/sdk/user/").concat(this.user,"/user_channels/mark/search?"),m=e.pageSize,v=e.cursor,g=((null==e?void 0:e.filter)||{}).mark,y={url:f,type:"GET",dataType:"json",data:{limit:m||10,cursor:v||"",need_mark:!0,mark:c.s[g]},headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}};return s.RD.call(this,y,h.jz.GET_SESSION_LIST).then((function(e){return Ie.call(a,e)}))}function Oe(){var e=n.dO.call(this).error;if(e)return Promise.reject(e);p.vF.debug("Call getSelfIdsOnOtherPlatform");var t=this.context,r=t.orgName,a=t.appName,o=t.accessToken,i=t.userId,c=t.jid,u={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/users/").concat(i,"/resources"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+o,"Content-Type":"application/json"}};return s.RD.call(this,u,h.jz.USER_LOGGEDIN_OTHER_PLATFORM).then((function(e){var t,r=null===(t=e.data)||void 0===t?void 0:t.filter((function(e){return e.res!==c.clientResource})),a=null==r?void 0:r.map((function(e){return"".concat(i,"/").concat(e.res)}));return{type:e.type,data:a}}))}function we(){var e,t,r,a,o,i;return E(this,void 0,void 0,(function(){var c,u,l,d,f,m,v,g,y;return C(this,(function(T){switch(T.label){case 0:return(c=n.dO.call(this).error)?[2,Promise.reject(c)]:(p.vF.debug("Call deleteAllMessagesAndConversations"),u=this.context,l=u.orgName,d=u.appName,f=u.accessToken,m=u.userId,v=u.jid,g="".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/sdk/message/roaming/user/").concat(m,"/delete/all?resource=").concat(v.clientResource),y={url:g,type:"POST",dataType:"json",headers:{Authorization:"Bearer "+f,"Content-Type":"application/json"}},[4,s.RD.call(this,y,h.jz.REST_DELETE_MESSAGES_CONVERSATIONS)]);case 1:return T.sent(),null===(t=null===(e=this._localCache)||void 0===e?void 0:e.getInstance())||void 0===t||t.clearConversationMap(),[4,null===(a=null===(r=this._localCache)||void 0===r?void 0:r.getInstance())||void 0===a?void 0:a.clearStoreData("conversationList")];case 2:return T.sent(),[4,null===(i=null===(o=this._localCache)||void 0===o?void 0:o.getInstance())||void 0===i?void 0:i.clearStoreData("message")];case 3:return T.sent(),[2]}}))}))}function Ae(e){return E(this,void 0,void 0,(function(){var t,r,a,o,i,c,u,l,d,f,m,v,g,y,T;return C(this,(function(I){switch(I.label){case 0:if(t=n.dO.call(this).error)return[2,Promise.reject(t)];if(p.vF.debug("Call setMessagePinStatus",e),a=(r=e||{}).conversationId,o=void 0===a?"":a,i=r.conversationType,c=r.messageId,u=r.isPinned,"string"!=typeof o||""===o)throw Error("Invalid parameter conversationId");if("string"!=typeof c||""===c)throw Error("Invalid parameter messageId");if("boolean"!=typeof u)throw Error("Invalid parameter isPinned");return l=this.context,d=l.orgName,f=l.appName,m=l.accessToken,v=l.userId,g=l.jid,y={to:o,type:O[i],pin_msg_id:c},T={url:"".concat(this.apiUrl,"/").concat(d,"/").concat(f,"/sdk/user/").concat(v,"/user_channel/pin?resource=").concat(g.clientResource),dataType:"json",data:JSON.stringify(y),type:u?"Post":"Delete",headers:{Authorization:"Bearer "+m}},[4,s.RD.call(this,T,h.jz.REST_PIN_MESSAGE)];case 1:return I.sent(),[2]}}))}))}function Pe(e){return E(this,void 0,void 0,(function(){var t,r,a,n;return C(this,(function(o){return p.vF.debug("Call pinMessage",e),r=(t=e||{}).conversationType,a=t.conversationId,n=t.messageId,[2,Ae.call(this,{conversationId:a,conversationType:r,messageId:n,isPinned:!0})]}))}))}function Ue(e){return E(this,void 0,void 0,(function(){var t,r,a,n;return C(this,(function(o){return p.vF.debug("Call unpinMessage",e),r=(t=e||{}).conversationType,a=t.conversationId,n=t.messageId,[2,Ae.call(this,{conversationId:a,conversationType:r,messageId:n,isPinned:!1})]}))}))}function xe(e){var t=this,r=n.dO.call(this).error;if(r)return Promise.reject(r);p.vF.debug("Call getServerPinnedMessages",e);var a=e.conversationId,o=e.conversationType,i=e.pageSize,c=e.cursor;if("string"!=typeof a||""===a)throw Error("Invalid parameter conversationId");if(i&&"number"!=typeof i)throw Error("Invalid parameter pageSize: ".concat(i));if(c&&"string"!=typeof c)throw Error("Invalid parameter cursor: ".concat(c));var u=this.context,l=u.orgName,d=u.appName,m=u.accessToken,v={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/sdk/user/").concat(this.user,"/user_channel/pin"),type:"GET",dataType:"json",data:{to:a,type:O[o],limit:i||10,cursor:c||""},headers:{Authorization:"Bearer "+m,"Content-Type":"application/json"}};return s.RD.call(this,v,h.jz.GET_SESSION_LIST).then((function(e){return{type:0,data:{list:e.data.msg_infos.map((function(e){e.message.payload=JSON.parse(e.message.payload);var r=e.message,a=e.pin_opt_at,n=e.pin_operator;return{message:f.h.call(t,r,{formatChatType:!0}),pinTime:a,operatorId:n}})),cursor:e.data.cursor||""}}}))}function ze(){var e=this;p.vF.debug("Call unbindPushToken");var t={deviceId:this.clientResource,deviceToken:"",notifierName:this.pushCertificateName};return y.B.call(this,t).then((function(t){return e.isRegisterPush=!1,t}))}function Fe(e){if(!e||"string"!=typeof e.fileId||""===e.fileId)return Promise.reject(Error('Invalid parameter: "fileId"'));if(void 0!==e.currentUserId&&"string"!=typeof e.currentUserId)return Promise.reject(Error('Invalid parameter: "currentUserId"'));if(void 0!==e.audio){if("object"!==T(e.audio)||null===e.audio||Array.isArray(e.audio))return Promise.reject(Error('Invalid parameter: "audio"'));var t=e.audio,r=t.format,a=t.sampleRate,o=t.bitsPerSample,i=t.channels;if(void 0!==r&&"string"!=typeof r)return Promise.reject(Error('Invalid parameter: "audio.format"'));if(void 0!==a&&"number"!=typeof a)return Promise.reject(Error('Invalid parameter: "audio.sampleRate"'));if(void 0!==o&&"number"!=typeof o)return Promise.reject(Error('Invalid parameter: "audio.bitsPerSample"'));if(void 0!==i&&"number"!=typeof i)return Promise.reject(Error('Invalid parameter: "audio.channels"'))}var c=n.dO.call(this).error;if(c)return Promise.reject(c);var u=this.context,l=u.orgName,d=u.appName,h=u.accessToken,f=u.userId,m=e.currentUserId||f,v={data:I({fileId:e.fileId,username:m},e.audio?{audio:e.audio}:{})};if(!l||!d||!m)return Promise.reject(Error('Invalid parameter: "orgname", "appname" or "currentUserId"'));var g={url:"".concat(this.apiUrl,"/api/sdk/v1/").concat(l,"/").concat(d,"/speech/transcriptions"),type:"POST",dataType:"json",data:JSON.stringify(v),headers:{Authorization:"Bearer "+h,"Content-Type":"application/json",Accept:"application/json"}};return p.vF.debug("Call transcribeSpeech",v),s.RD.call(this,g).then((function(e){var t;return{type:0,data:{text:(null===(t=e.data)||void 0===t?void 0:t.text)||""}}}))}function Le(e){if(!e||!Be(t=e.file)&&!Ge(t))return Promise.reject(Error('Invalid parameter: "file"'));var t;if(void 0!==e.currentUserId&&"string"!=typeof e.currentUserId)return Promise.reject(Error('Invalid parameter: "currentUserId"'));if(void 0!==e.audio){if("object"!==T(e.audio)||null===e.audio||Array.isArray(e.audio))return Promise.reject(Error('Invalid parameter: "audio"'));var r=e.audio,a=r.format,i=r.sampleRate,s=r.bitsPerSample,c=r.channels;if(void 0!==a&&"string"!=typeof a)return Promise.reject(Error('Invalid parameter: "audio.format"'));if(void 0!==i&&"number"!=typeof i)return Promise.reject(Error('Invalid parameter: "audio.sampleRate"'));if(void 0!==s&&"number"!=typeof s)return Promise.reject(Error('Invalid parameter: "audio.bitsPerSample"'));if(void 0!==c&&"number"!=typeof c)return Promise.reject(Error('Invalid parameter: "audio.channels"'))}var u=n.dO.call(this).error;if(u)return Promise.reject(u);var l=this.context,d=l.orgName,h=l.appName,f=l.accessToken,m=l.userId,v=e.currentUserId||m;if(!d||!h||!v)return Promise.reject(Error('Invalid parameter: "orgname", "appname" or "currentUserId"'));var y="".concat(this.apiUrl,"/api/sdk/v1/").concat(d,"/").concat(h,"/speech/recognitions");if(Be(e.file))return function(e){var t=new FormData,r=Me(e.currentUserId,e.audio);return Object.keys(r).forEach((function(e){t.append(e,r[e])})),t.append("file",e.file),p.vF.debug("Call recognizeSpeech",{currentUserId:e.currentUserId,fileName:e.file.name,fileSize:e.file.size,audio:e.audio}),new Promise((function(r,a){var n=new XMLHttpRequest;n.timeout=g._h,n.ontimeout=function(){a({type:o.C.REQUEST_TIMEOUT,message:"Request Timeout",errorType:"timeout_error",xhr:n})},n.onerror=function(){a({type:o.C.REQUEST_UNKNOWN,message:"Request Unknown Error",errorType:"onerror",xhr:n})},n.onabort=function(){a({type:o.C.REQUEST_ABORT,message:"Request Abort",errorType:"onabort",xhr:n})},n.onreadystatechange=function(){var e,t;if(4===n.readyState){var i=De(n.responseText);200!==n.status?a({type:n.status||o.C.REQUEST_UNKNOWN,data:i,message:(null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message)||(null==i?void 0:i.message)||"Request Error",xhr:n}):r({type:o.C.REQUEST_SUCCESS,data:{text:(null===(e=null==i?void 0:i.data)||void 0===e?void 0:e.text)||""}})}},n.open("POST",e.requestUrl),n.setRequestHeader("Authorization","Bearer "+e.accessToken),n.setRequestHeader("Accept","application/json"),n.send(t)}))}({file:e.file,currentUserId:v,audio:e.audio,requestUrl:y,accessToken:f});var I=qe();return Ge(e.file)&&I?function(e){var t=Me(e.currentUserId,e.audio);return p.vF.debug("Call recognizeSpeech",{currentUserId:e.currentUserId,filePath:e.file.filePath,fileName:e.file.name||e.file.filePath.split("?")[0].split("/").filter(Boolean).pop(),fileSize:e.file.size,audio:e.audio}),new Promise((function(r,a){e.platForm.global.uploadFile({url:e.requestUrl,filePath:e.file.filePath,name:"file",header:{"Content-Type":"multipart/form-data",Authorization:"Bearer "+e.accessToken,Accept:"application/json"},formData:t,success:function(e){var t,n,i=De(e.data);200!==e.statusCode?a({type:e.statusCode||o.C.REQUEST_UNKNOWN,data:i,message:(null===(n=null==i?void 0:i.error)||void 0===n?void 0:n.message)||(null==i?void 0:i.message)||"Request Error"}):r({type:o.C.REQUEST_SUCCESS,data:{text:(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.text)||""}})},fail:function(e){a({type:o.C.REQUEST_UNKNOWN,message:"Request Unknown Error",errorType:"upload_fail",data:e})}})}))}({file:e.file,currentUserId:v,audio:e.audio,requestUrl:y,accessToken:f,platForm:I}):Promise.reject(Error('Invalid parameter: "file"'))}function Me(e,t){var r={username:e};return void 0!==(null==t?void 0:t.format)&&(r["audio.format"]=t.format),void 0!==(null==t?void 0:t.sampleRate)&&(r["audio.sampleRate"]=String(t.sampleRate)),void 0!==(null==t?void 0:t.bitsPerSample)&&(r["audio.bitsPerSample"]=String(t.bitsPerSample)),void 0!==(null==t?void 0:t.channels)&&(r["audio.channels"]=String(t.channels)),r}function De(e){if("string"==typeof e&&e)try{return JSON.parse(e)}catch(t){return e}return e}function Be(e){return"undefined"!=typeof File&&e instanceof File}function Ge(e){return"object"===T(e)&&null!==e&&!Array.isArray(e)&&"string"==typeof e.filePath&&""!==e.filePath}function qe(){var e,t=s.Wp.getEnvInfo();if("web"!==t.platform&&"node"!==t.platform&&"quick_app"!==t.platform&&"function"==typeof(null===(e=t.global)||void 0===e?void 0:e.uploadFile))return t}function Je(e){var t,r=function(e){var t,r,a=De(null==e?void 0:e.data),n=null===(t=null==a?void 0:a.error)||void 0===t?void 0:t.code;return{serviceCode:"string"==typeof n||"number"==typeof n?String(n):void 0,serviceMessage:null===(r=null==a?void 0:a.error)||void 0===r?void 0:r.message}}(e),a=r.serviceCode,n=r.serviceMessage;if("number"==typeof(null==e?void 0:e.type)&&!a)return{type:e.type,message:(null==e?void 0:e.message)||"Voice-to-text failed"};switch(a){case"4041001":return{type:o.C.FILE_NOT_FOUND,message:"File not found"};case"4001002":return{type:o.C.FILE_INVALID,message:"Invalid file"};case"5021001":return{type:o.C.WEBIM_UPLOADFILE_ERROR,message:"File upload failed"};case"4001003":return{type:o.C.FILE_DURATION_TOO_LONG,message:"Voice duration exceeds 60 seconds"};case"4031001":return{type:o.C.SERVICE_NOT_ENABLED,message:"Service not enabled"};case"4031002":return{type:o.C.MAX_LIMIT,message:"Beta service usage limit exceeded"};case"4001001":return"string"==typeof(t=n)&&t.toLowerCase().includes("uploaded file exceeds")?{type:o.C.FILE_TOO_LARGE,message:"File too large"}:{type:o.C.REQUEST_PARAMETER_ERROR,message:n||"Missing or invalid request parameter"};case"5021003":case"5001003":return{type:o.C.FILE_VOICE_TO_TEXT_FAILED,message:"Voice-to-text failed"};case"4011001":return{type:o.C.NO_PERMISSION,message:n||"Unauthorized or invalid token"};default:return{type:o.C.FILE_VOICE_TO_TEXT_FAILED,message:n||(null==e?void 0:e.message)||"Voice-to-text failed"}}}function Ke(e,t,r){void 0===r&&(r="");var a={type:e};return e===o.C.REQUEST_SUCCESS?(a.data={text:r},a):(void 0!==t&&(a.message=t),a)}function Ve(e){return!(void 0===e||"object"===T(e)&&null!==e&&!Array.isArray(e))||void 0!==(null==e?void 0:e.format)&&"string"!=typeof e.format||void 0!==(null==e?void 0:e.sampleRate)&&"number"!=typeof e.sampleRate||void 0!==(null==e?void 0:e.bitsPerSample)&&"number"!=typeof e.bitsPerSample||void 0!==(null==e?void 0:e.channels)&&"number"!=typeof e.channels}function He(e,t){if(!e||"audio"!==e.type)return Promise.reject(Ke(o.C.FILE_INVALID,"Invalid file"));if(Ve(t))return Promise.reject(Ke(o.C.FILE_INVALID,"Invalid file"));if(!e.url)return Promise.reject(Ke(o.C.FILE_NOT_FOUND,"File not found"));var r=function(e){if(e){var t=e.split("#")[0].split("?")[0].split("/").filter(Boolean);return t[t.length-1]}}(e.url);return r?Fe.call(this,I({fileId:r},t?{audio:t}:{})).then((function(e){var t;return Ke(e.type,e.message,(null===(t=e.data)||void 0===t?void 0:t.text)||"")})).catch((function(e){var t=Je(e);throw Ke(t.type,t.message)})):Promise.reject(Ke(o.C.FILE_INVALID,"Invalid file"))}function We(e,t){return Ve(t)?Promise.reject(Ke(o.C.FILE_INVALID,"Invalid file")):Be(e)||Ge(e)&&qe()?Le.call(this,I({file:e},t?{audio:t}:{})).then((function(e){var t;return Ke(e.type,e.message,(null===(t=e.data)||void 0===t?void 0:t.text)||"")})).catch((function(e){var t=Je(e);throw Ke(t.type,t.message)})):Promise.reject(Ke(o.C.FILE_INVALID,"Invalid file"))}function Qe(e){void 0===e&&(e="*");var t=this.context,r=t.orgName,a=t.appName,n=t.accessToken,o=t.userId,i={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/users/").concat(o,"/token/rtc?channelName=").concat(e),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+n,"Content-Type":"application/json"}};return s.RD.call(this,i).then((function(e){return{type:e.type,data:{appId:(null==e?void 0:e.app_id)||"",RTCToken:(null==e?void 0:e.rtc_token)||"",channelName:(null==e?void 0:e.channel_name)||"",RTCUId:(null==e?void 0:e.rtcUid)||0,expire:(null==e?void 0:e.expires_in)||0}}}))}function Xe(e){if(!Array.isArray(e)||0===e.length)throw Error("Invalid parameter RTCUIds: "+e);var t=this.context,r=t.orgName,a=t.appName,n=t.accessToken,o={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(a,"/rtc_mapper/batch/get"),type:"POST",dataType:"json",data:JSON.stringify({data:e}),headers:{Authorization:"Bearer "+n,"Content-Type":"application/json"}};return s.RD.call(this,o).then((function(e){return{type:e.type,data:e.data||{}}}))}var Ye=a},4490:function(e,t,r){var a=r(6518),n=r(9504),o=r(4376),i=n([].reverse),s=[1,2];a({target:"Array",proto:!0,forced:String(s)===String(s.reverse())},{reverse:function(){return o(this)&&(this.length=this.length),i(this)}})},6034:function(e,t,r){var a=r(6518),n=r(2357).values;a({target:"Object",stat:!0},{values:function(e){return n(e)}})}},function(e){var t=e(e.s=3352);return t.default}])}));
package/group/group.d.ts CHANGED
@@ -326,6 +326,7 @@ export interface GroupApi {
326
326
  * Invites users into a group.
327
327
  * Creates a group instance "inviteNeedConfirm:true", the invited users will receive "operation: 'inviteToJoin'" in the callback of onGroupEvent.
328
328
  * Creates a group instance "inviteNeedConfirm:false", the invited users will receive "operation: 'directJoined'" in the callback of onGroupEvent.
329
+ * When inviting multiple users, the request can partially succeed. Check the `result` of each item in the returned `data` array. A failed item has `result: false` and includes the failure reason in `reason`.
329
330
  *
330
331
  * ```typescript
331
332
  * connection.inviteUsersToGroup({groupId: 'groupId', users: ['user1', 'user2']})
@@ -20,6 +20,8 @@ export type MessagePriority =
20
20
  export interface ChannelMsgBody extends ChannelMsgSetParameters {
21
21
  /** The message ID. */
22
22
  id: string;
23
+ /** The ID of the last read message. */
24
+ mid?: string;
23
25
  /** Whether it's group chat. */
24
26
  group?: string;
25
27
  /** The message type. */
@@ -45,6 +47,8 @@ export interface ChannelParameters {
45
47
  export interface CreateChannelMsgParameters {
46
48
  /** The message type. */
47
49
  type: 'channel';
50
+ /** The ID of the last read message. */
51
+ mid?: string;
48
52
  /** The session type. */
49
53
  chatType: ChatType;
50
54
  /** The receipt. */
@@ -15,6 +15,8 @@ import { SendMsgResult } from '../types/indexApi';
15
15
  export type MiniCoreOptions = {
16
16
  /** Whether DNS is enabled or not. It is enabled by default. The private cloud should be turned off */
17
17
  isHttpDNS?: boolean;
18
+ /** Whether to enable attachment MD5 precheck. Defaults to `false`. DNS config takes precedence when provided. */
19
+ enableMd5Check?: boolean;
18
20
  /** The URL of the specified message server. This command is used when DNS is not enabled. Usually this API is used for specific customers and need to contact account manager to get it. */
19
21
  url?: string;
20
22
  /** The URL of the specified REST server. This command is used when DNS is not enabled. Usually this API is used for specific customers and need to contact account manager to get it. */