!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()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[564],{7479:function(e,t,r){r.r(t),r.d(t,{acceptContactInvite:function(){return X},acceptInvitation:function(){return L},addContact:function(){return x},addReaction:function(){return Y},addToBlackList:function(){return D},addUsersToBlacklist:function(){return K},addUsersToBlocklist:function(){return H},declineContactInvite:function(){return J},declineInvitation:function(){return G},deleteContact:function(){return z},deleteConversation:function(){return j},deleteReaction:function(){return $},deleteSession:function(){return R},fetchHistoryMessages:function(){return U},fetchUserInfoById:function(){return w},getAllContacts:function(){return le},getBlacklist:function(){return T},getBlocklist:function(){return S},getContacts:function(){return I},getContactsWithCursor:function(){return pe},getConversationlist:function(){return C},getHistoryMessages:function(){return Z},getReactionDetail:function(){return re},getReactionList:function(){return ee},getReactionlist:function(){return te},getRoster:function(){return E},getServerConversations:function(){return oe},getServerPinnedConversations:function(){return ie},getSessionList:function(){return A},getTokenExpireTimestamp:function(){return P},modifyMessage:function(){return V},pinConversation:function(){return ce},recallMessage:function(){return Q},removeFromBlackList:function(){return q},removeHistoryMessages:function(){return ne},removeRoster:function(){return B},removeUserFromBlackList:function(){return W},removeUserFromBlocklist:function(){return F},reportMessage:function(){return ae},setContactRemark:function(){return ue},updateCurrentUserNick:function(){return O},updateOwnUserInfo:function(){return N},updateUserInfo:function(){return b},uploadPushToken:function(){return _},uploadToken:function(){return k}}),r(9601),r(1539),r(8674),r(2526),r(1817),r(2165),r(6992),r(8783),r(3948),r(9554),r(4747),r(2222),r(7941),r(6699),r(3710),r(9714),r(9600),r(5069),r(561),r(9753),r(8309),r(1249);var a=r(3246),n=r(5531),o=r(7252),s=r(4370),i=r(8161),c=r(4188),u=r.n(c),l=r(7360),p=r(1595),h=r(4363),d=r(7288),f=r(9743),m=function(){return m=Object.assign||function(e){for(var t,r=1,a=arguments.length;r0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]0&&e.pageSize>0),f={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user,"/user_channels").concat(d?"/page":""),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e&&(null==e?void 0:e.success),error:e&&(null==e?void 0:e.error)};return d&&(f.data={pageNum:e.pageNum,pageSize:e.pageSize}),l.kg.debug("Call getConversationlist"),s.hj.call(this,f,p.fI.GET_SESSION_LIST).then((function(e){return function(e){var t=e.data.channel_infos;return null==t||t.forEach((function(e){e.meta&&"{}"!==JSON.stringify(e.meta)?(e.meta.payload=JSON.parse(e.meta.payload),e.lastMessage=(0,h.w)(e.meta)):e.lastMessage=e.meta,delete e.meta})),e}(e)}))}function R(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));if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r,i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,d=i.jid;r="singleChat"===e.chatType?"chat":"groupChat";var f={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/user/").concat(this.user,"/user_channel?resource=").concat(d.clientResource),dataType:"json",type:"DELETE",data:JSON.stringify({channel:e.channel,type:r,delete_roam:e.deleteRoam}),headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"},success:e.success,error:e.error};return l.kg.debug("Call deleteSession",e),s.hj.call(this,f,p.fI.DELETE_SESSION)}var j=R;function N(e,t){if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,d=["nickname","avatarurl","mail","phone","gender","sign","birth","ext"],f={};if("undefined"!=typeof wx||"undefined"!=typeof qq)if("string"==typeof e&&void 0!==t){if(!d.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");f[e]=t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");d.forEach((function(t){d.includes(t)&&void 0!==e[t]&&(f[t]=e[t])}))}else if("string"==typeof e){if(!d.includes(e))throw new Error("illegal key, only these keys: nickname, avatarurl, mail, phone, gender, sign, birth, ext are allowed");f=e+"="+t}else{if("[object Object]"!==Object.prototype.toString.call(e))throw new Error("illegal params");var m=[];d.forEach((function(t){if(d.includes(t)&&void 0!==e[t]){var r=encodeURIComponent(t),a=encodeURIComponent(e[t]);m.push(r+"="+a)}})),f=m.join("&")}var g={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/metadata/user/").concat(this.user),type:"PUT",data:f,dataType:"json",headers:{Authorization:"Bearer "+h,"Content-Type":"application/x-www-form-urlencoded"}};return l.kg.debug("Call updateOwnUserInfo",e),s.hj.call(this,g,p.fI.UPDATE_USER_INFO)}var b=N;function w(e,t){if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(r)}var i,c=this.context,u=c.orgName,h=c.appName,d=c.accessToken,f=[];if("string"==typeof e)f=[e];else{if("[object Array]"!==Object.prototype.toString.call(e))throw new Error("illegal params");f=e}i="string"==typeof t?[t]:t&&"[object Array]"===Object.prototype.toString.call(t)?t:["nickname","avatarurl","mail","phone","gender","sign","birth","ext"];var m={url:"".concat(this.apiUrl,"/").concat(u,"/").concat(h,"/metadata/user/get"),type:"POST",data:JSON.stringify({targets:f,properties:i}),dataType:"json",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}};return l.kg.debug("Call fetchUserInfoById",e),s.hj.call(this,m,p.fI.GET_USER_INFO)}function O(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,p={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/users/").concat(this.user),type:"PUT",dataType:"json",data:JSON.stringify({nickname:e}),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return l.kg.debug("Call updateCurrentUserNick",e),s.hj.call(this,p)}function P(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 l.kg.debug("Call getTokenExpireTimestamp",e),s.hj.call(this,n,p.fI.SDK_INTERNAL)}function U(e){var t=this;return new Promise((function(r,s){if(!e.queue)throw Error('Invalid parameter: "specified"');if(!a.XZ.call(t)){var i=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(i)}(function e(t){var a=this,n=t.count||20;M.call(this,{count:n,isGroup:!!t.isGroup,queue:t.queue,start:t.start,format:t.format,success:function(o){if(o.msgs.length>=n||o.is_last){var s=o.msgs.splice(0,n).reverse();t.success&&t.success(s),r(s)}else e.call(a,m(m({},t),{start:null}))},fail:function(e){s(e),t.fail&&t.fail(e)}})}).call(t,e),l.kg.debug("Call fetchHistoryMessages",e)}))}function M(e){var t=this,r=e.queue,a=this.mr_cache[r]||(this.mr_cache[r]={msgs:[]}),c=this.context.userId,l=e.start||-1,h=e.count||20;if(a.msgs.length>=h||a.is_last)"function"==typeof e.success&&e.success(a);else{a&&a.next_key&&(l=a.next_key),e.start&&(l=e.start);var d={queue:r+(e.isGroup?"@conference.easemob.com":"@easemob.com"),start:l,end:-1},f=this.context,m=f.orgName,v=f.appName,T={url:"".concat(this.apiUrl,"/").concat(m,"/").concat(v,"/users/").concat(c,"/messageroaming"),dataType:"json",type:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"},data:JSON.stringify(d),success:function(r){return g(t,void 0,void 0,(function(){var t,n,o,s,c,l,p=this;return y(this,(function(h){switch(h.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,s=function(t){return g(p,void 0,void 0,(function(){var r,a,n,o,s;return y(this,(function(c){switch(c.label){case 0:for(r=[],t=u().atob(t),a=0,n=t.length;a18))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 a.XZ.call(this)?(i=this.context,c=i.orgName,u=i.appName,p=i.userId,h="singleChat"===e.chatType?"userId":"groupId",d="singleChat"===e.chatType?"chat":"group",f=e.messageIds?"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/message/roaming/").concat(d,"/user/").concat(p,"?").concat(h,"=").concat(e.targetId,"&msgIdList=").concat(e.messageIds,"&resource=").concat(this.clientResource):"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/sdk/message/roaming/").concat(d,"/user/").concat(p,"/time?").concat(h,"=").concat(e.targetId,"&delTime=").concat(e.beforeTimeStamp,"&&resource=").concat(this.clientResource),m={url:f,dataType:"json",type:"DELETE",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json"}},l.kg.debug("Call removeHistoryMessages",e),[4,s.hj.call(this,m)]):(r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(r)]);case 1:return g.sent(),[2]}}))}))}function oe(e){var t=this;if(!a.XZ.call(this)){var r=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});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));var i=this.context,c=i.orgName,u=i.appName,h=i.accessToken,m={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/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)||""},headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"}};return l.kg.debug("Call getServerConversations",e),new Promise((function(e,r){s.hj.call(t,m,p.fI.GET_SESSION_LIST).then((function(r){return g(t,void 0,void 0,(function(){var t,a=this;return y(this,(function(n){switch(n.label){case 0:return t=se(r),this._localCache?[4,Promise.all(t.data.conversations.map((function(e){return g(a,void 0,void 0,(function(){var t,r,a=this;return y(this,(function(n){return null===(r=null===(t=this._localCache)||void 0===t?void 0:t.getInstance())||void 0===r||r.storeMessage(e.lastMessage,d.r.SUCCESS,!0).then((function(){var t,r;null===(r=null===(t=a._localCache)||void 0===t?void 0:t.getInstance())||void 0===r||r.updateLocalConversation((0,f.MQ)({conversationId:e.conversationId,conversationType:e.conversationType}),{unReadCount:e.unReadCount})})),[2]}))}))})))]:[3,2];case 1:return n.sent(),e(t),[2];case 2:return e(t),[2]}}))}))})).catch((function(e){r(e)}))}))}function se(e){var t=e.data,r=t.cursor,a=t.channel_infos,n=[];null==a||a.forEach((function(e){var t=null;(null==e?void 0:e.meta)&&"{}"!==JSON.stringify(e.meta)&&(e.meta.payload=JSON.parse(e.meta.payload),"delivery"!==(t=(0,h.w)(e.meta)).type&&"read"!==t.type&&"channel"!==t.type&&(t.chatType=v[t.chatType]));var r={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:t};n.push(r)}));var o={conversations:n,cursor:r||""};return{type:e.type,data:o}}function ie(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}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));var r=this.context,i=r.orgName,c=r.appName,u=r.accessToken,h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(c,"/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},headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"}};return l.kg.debug("Call getServerConversations",e),s.hj.call(this,h,p.fI.GET_SESSION_LIST).then((function(e){return se(e)}))}function ce(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d,f,m,g,v,T,S,E;return y(this,(function(y){if(!a.XZ.call(this))return t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(t)];if(r=e.conversationId,i=e.conversationType,c=e.isPinned,u="singleChat"===i?"chat":"groupChat","string"!=typeof r||""===r)throw Error("Invalid parameter conversationId: ".concat(r));if(!["singleChat","groupChat"].includes(i))throw Error("Invalid parameter conversationType: ".concat(i));if("boolean"!=typeof c)throw Error("Invalid parameter isPinned: ".concat(c));return h=this.context,d=h.orgName,f=h.appName,m=h.accessToken,g=h.jid,v={type:u,to:r},T=c?"":"type=".concat(u,"&to=").concat(r,"&"),S="".concat(this.apiUrl,"/").concat(d,"/").concat(f,"/sdk/user/").concat(this.user,"/user_channel/top?").concat(T,"resource=").concat(g.clientResource),E={url:S,type:c?"POST":"DELETE",dataType:"json",headers:{Authorization:"Bearer "+m,"Content-Type":"application/json"}},c&&(E.data=JSON.stringify(v)),l.kg.debug("Call pinConversation",e),[2,s.hj.call(this,E,p.fI.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 ue(e){return g(this,void 0,void 0,(function(){var t,r,i,c,u,h,d,f,m,g;return y(this,(function(y){switch(y.label){case 0:if(t=e.userId,r=e.remark,!a.XZ.call(this))return i=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),[2,Promise.reject(i)];if("string"!=typeof t||""===t)throw Error('Invalid parameter: "userId"');if("string"!=typeof r)throw Error('Invalid parameter: "remark"');return l.kg.debug("Call setContactRemark",e),c=this.context,u=c.orgName,h=c.appName,d=c.accessToken,f=c.jid,m="".concat(this.apiUrl,"/").concat(u,"/").concat(h,"/users/").concat(this.context.userId,"/contacts/users/").concat(t,"?resource=").concat(f.clientResource),g={url:m,type:"PUT",data:JSON.stringify({remark:r}),dataType:"json",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"}},[4,s.hj.call(this,g,p.fI.ROSTER_SET_CONTACT_REMARK)];case 1:return y.sent(),[2]}}))}))}function le(){if(!a.XZ.call(this)){var e=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(e)}var t=this.context,r=t.orgName,i=t.appName,c=t.accessToken,u={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(i,"/users/").concat(this.user,"/contacts/users?needReturnRemark=true"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+c}};return l.kg.debug("Call getAllContacts"),s.hj.call(this,u,p.fI.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 pe(e){if(!a.XZ.call(this)){var t=o.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}l.kg.debug("Call getContactsWithCursor",e);var r=e||{},i=r.pageSize,c=void 0===i?20:i,u=r.cursor,h=void 0===u?"":u;if(c&&"number"!=typeof c)throw Error("Invalid parameter pageSize: ".concat(e.pageSize));var d=this.context,f=d.orgName,m=d.appName,g=d.accessToken,y={url:"".concat(this.apiUrl,"/").concat(f,"/").concat(m,"/users/").concat(this.user,"/contacts?needReturnRemark=true&limit=").concat(c,"&cursor=").concat(h),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+g}};return s.hj.call(this,y,p.fI.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}}}))}},3246:function(e,t,r){r.d(t,{H7:function(){return u},XZ:function(){return i},_W:function(){return c}}),r(7941),r(9554),r(1539),r(4747),r(6699),r(2023);var a=r(5531),n=r(7252);function o(){var e=this.context.appName,t=this.context.orgName;return!(!e||!t)||(this.onError&&this.onError({type:a.E.WEBIM_CONNCTION_AUTH_ERROR,message:"appName or orgName is illegal"}),!1)}function s(){var e;if(!this.context.accessToken){var t=n.Z.create({type:a.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(t),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",t),!1}return!0}function i(){return s.call(this)&&o.call(this)}function c(e){var t=e.data,r=e.type;return{data:{status:Object.keys(t.errorKeys).length>0?"fail":"success",errorKeys:t.errorKeys,successKeys:t.successKeys},type:r}}function u(e){var t=e.data,r=void 0;return Object.keys(t.errorKeys).length>0&&Object.keys(t.errorKeys).forEach((function(e){var o=t.errorKeys[e];r=o.includes("is not part of you")?n.Z.create({type:a.E.NO_PERMISSION,message:o}):o.includes("size of metadata for this single chatroom exceeds the user defined limit")||o.includes("total size of chatroom metadata for this app exceeds the user defined limit")||o.includes("is exceeding maximum limit")?n.Z.create({type:a.E.MAX_LIMIT,message:o}):o.includes("is not Legal")?n.Z.create({type:a.E.REQUEST_PARAMETER_ERROR,message:o}):o.includes("Failed to update userMetadata. Concurrent updates not allowed")?n.Z.create({type:a.E.OPERATION_NOT_ALLOWED,message:o}):n.Z.create({type:a.E.WEBIM_CONNCTION_AJAX_ERROR,message:o})})),r}},5069:function(e,t,r){var a=r(2109),n=r(1702),o=r(3157),s=n([].reverse),i=[1,2];a({target:"Array",proto:!0,forced:String(i)===String(i.reverse())},{reverse:function(){return o(this)&&(this.length=this.length),s(this)}})}},function(e){return 7479,e(e.s=7479)}])}));