@tencentcloud/chat
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 20.6 kB
JavaScript
let e=4,t=11,s=12,o=20,n=23,i=27;class r{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let u={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT0:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT0:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT0:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT0:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},c={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},m="CHINA",a={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=m){this.CURRENT=u.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",GRP_SEARCH:"group_search",GRP_MEMBER_SEARCH:"group_member_search",USER_SEARCH:"user_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic"}},l=(new r(0,Math.pow(2,1)).toString(),new r(0,Math.pow(2,2)).toString(),new r(0,Math.pow(2,3)).toString(),new r(0,Math.pow(2,4)).toString(),new r(0,Math.pow(2,6)).toString(),new r(0,Math.pow(2,7)).toString(),new r(0,Math.pow(2,9)).toString(),new r(0,Math.pow(2,10)).toString(),new r(0,Math.pow(2,11)).toString(),new r(0,Math.pow(2,13)).toString(),new r(0,Math.pow(2,15)).toString(),new r(Math.pow(2,6)).toString(),new r(Math.pow(2,7)).toString(),new r(Math.pow(2,8)).toString(),new r(Math.pow(2,9)).toString(),new r(Math.pow(2,10)).toString(),new r(Math.pow(2,16)).toString(),new r(Math.pow(2,20)).toString(),a.HOST.setCurrent(m),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)),g="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||l,h=(g&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),d="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),p="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),_="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,w="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,S=g&&"object"==typeof wx.miniapp,y=g||h||d||p||f||w||_,T="undefined"==typeof window&&!y&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,M="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),A="undefined"!=typeof uni?!y:"undefined"!=typeof window&&!y&&!M,I=(h?qq:d?tt:p?swan:f?my:g?wx:w?uni:_&&jd,A&&window&&window.navigator&&window.navigator.userAgent||""),E=/(micromessenger|webbrowser)/i.test(I),P=function(){let e="WEB";return E?e="WEB":h?e="QQ_MP":d?e="TT_MP":p?e="BAIDU_MP":f?e="ALI_MP":g?e=S?"DONUT_NATIVE_APP":"WX_MP":w?e="UNI_NATIVE_APP":T?e="NS_NATIVE_APP":M&&(e="RN_NATIVE_APP"),c[e]}(),C=(!function(){var e=I.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){var e,t,s=I.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);s&&(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e)&&t&&parseFloat(s[1]+"."+s[2])}(),/MSIE/.test(I)||-1<I.indexOf("Trident")&&-1<I.indexOf("rv:11.0")),N,v,b=(!function(){var e=/MSIE\s(\d+)\.\d/.exec(I),e=e&&parseFloat(e[1]);!e&&/Trident\/7.0/i.test(I)&&/rv:11.0/.test(I)}(),N="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{},function(){}),D=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],U=D.length;for(;U--;)v=D[U],console[v]||(N[v]=b);var O=N;let L="C2C",R="GROUP",q=function(){return(new Date).getTime()+0},F=Object.prototype.hasOwnProperty,x=function(e){return"map"===Y(e)},B=function(e){return"set"===Y(e)},k=function(e){return"file"===Y(e)},G=function(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"==typeof e&&e.constructor===Number)},j=function(e){return"string"==typeof e},$=function(e){if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t},K=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===Y(e)},V=function(e){return K(e)&&0<e.length},W=function(e){return void 0===e},H=function(e){return K(e)||null!==e&&"object"==typeof e},Y=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},z=(Date.now||(Date.now=function(){return(new Date).getTime()}),function(s,r,o,i){if(!H(s)||!H(r))return 0;let n=0;var a,m=Object.keys(r);for(let e=0,t=m.length;e<t;e++)if(a=m[e],!(W(r[a])||o&&o.includes(a)))if(H(s[a])&&H(r[a]))n+=z(s[a],r[a],o,i);else{if(i&&i.includes(r[a]))continue;s[a]!==r[a]&&(s[a]=r[a],n+=1)}return n});function J(){return!C&&!y}let Q=0;function X(){return J()?"%c Chat %c":"Chat"}function Z(){(e=new Date).setTime(q());var e;return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}let ee={arguments2String(s){let r="";if(1===s.length)r=s[0];else for(let e=0,t=s.length;e<t;e++){if(H(s[e]))try{r+=s[e]instanceof Error?JSON.stringify(s[e],["message","code"]):JSON.stringify(s[e])}catch(e){r+=e?e.message:"";break}else r+=s[e];r+=" "}return r},_exec(e,t){J()?O[e](X(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",Z(),t):O[e](`${X()} ${Z()} `+t)},d:function(){var e;Q<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;Q<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;Q<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;Q<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;Q<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;Q<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+Q+" to "+e),Q=e},getLevel:function(){return Q}},te=function(e){return{code:0,data:e||{}}};class se extends Error{constructor(e){super();var{code:e,message:t,data:s}=e;this.code=e,t?this.message=t:this._getErrMsg&&(this.message=this._getErrMsg(this.code)),this.data=s||{}}}let oe=2805,ne=2903,ie=3122,re=3153,ue="error",ce=null,me=function(e,t=!1){if(e instanceof se)return t&&null!==ce&&ce.emit(ue,e),Promise.reject(e);if(e instanceof Error){let e=new se({code:ne});return t&&null!==ce&&ce.emit(ue,e),Promise.reject(e)}return W(e)||W(e.code)?Promise.reject(new se({code:ne})):(e=new se(e),t&&null!==ce&&ce.emit(ue,e),Promise.reject(e))},ae="query",le="query_grp",ge="query_grp_member",he="query_user",de={info:4,warning:5,error:6},pe={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},fe={login:4,plugin_search:16,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16,tui_key_features:16};class _e{constructor(e){this._n="SSOLogData",this.eventType=fe[e]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=e,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=q()}static bindEventStatModule(e){_e.prototype._eventStatModule=e}static bindNetMonitorModule(e){_e.prototype._netMonitorModule=e}updateTimeStamp(){this.timestamp=q()}start(e){return this._startts=e,this}end(e=!1){if(!this._sentFlag){if(this._netMonitorModule){let e=this._netMonitorModule.getNetworkType();this.setNetworkType(e)}var t=q();0===this.costTime&&(this.costTime=t-this._startts),this.setMoreMessage(`startts:${this._startts} endts:`+t),e?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(t){if(t instanceof Error){if(!this._sentFlag){let e=!0;if(e=this._netMonitorModule?this._netMonitorModule.isOnline():e)t.code&&this.setCode(t.code),t.message&&this.setMoreMessage(t.message);else{let e=oe;this.setCode(e)}this.setLevel("error")}}else ee.w(this._n+".setError value not instanceof Error, please check!");return this}setCode(e){return W(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),G(e)?this.code=e:ee.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return W(e)||this._sentFlag||(G(e)&&(this.message=e.toString()),j(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return W(e)||this._sentFlag||(this.level=de[e]),this}setMoreMessage(e){return function(e){if(null==e)return 1;if("boolean"!=typeof e){if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if($(e)){for(var t in e)if(F.call(e,t))return;return 1}return(x(e)||B(e)||k(e))&&0===e.size}}(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return W(e)?ee.w(this._n+".setNetworkType value is undefined, please check!"):(e=pe[e.toLowerCase()],W(e)||(this.networkType=e)),this}getStartTs(){return this._startts}setUIPlatform(e){return this.uiPlatform=e,this}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}let we=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class Se{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime="",this.infoSequence="",this.lastInfoTime="",this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:"",lastSequence:"",fromAccount:"",messageForShow:""},this.nextMessageSeq="",this.memberNum="",this.memberCount="",this.maxMemberNum="",this.maxMemberCount="",this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}set memberNum(e){}set maxMemberNum(e){}get memberNum(){return this.memberCount}get maxMemberNum(){return this.maxMemberCount}_initGroup(e){for(var t in e)we.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}updateGroup(e){e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);e=JSON.parse(JSON.stringify(e));if(e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),W(e.muteAllMembers)||("On"===e.muteAllMembers?e.muteAllMembers=!0:e.muteAllMembers=!1),e.groupCustomField){var o=this.groupCustomField,t=e.groupCustomField;if(K(o)&&K(t)){let r=!1;t.forEach(({key:t,value:e})=>{var s=o.find(e=>e.key===t);s?s.value!==e&&(s.value=e,r=!0):(o.push({key:t,value:e}),r=!0)})}}W(e.memberNum)||(this.memberCount=e.memberNum),W(e.maxMemberNum)||(this.maxMemberCount=e.maxMemberNum),W(e.isSupportTopic)||(this.isSupportTopic=G(e.isSupportTopic)?1===e.isSupportTopic:e.isSupportTopic),z(this,e,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),K(e.members)&&0<e.members.length&&e.members.forEach(e=>{e.userID===this.selfInfo.userID&&z(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:r,readedSequence:o,excludedUnreadSequenceList:i}){e={nameCard:e,joinTime:t,role:s,messageRemindType:r,readedSequence:o,excludedUnreadSequenceList:i};z(this.selfInfo,{...e},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}let ye="Message",Te="User",Me="Group",Ae="GroupMember",Ie={[ye]:ae,[Te]:he,[Me]:le,[Ae]:ge};class Ee extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(s).isLoggedIn()}isOversea(){return this._m.get(s).isOversea()}isPrivateNetWork(){var e=this._m.get(s);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(s).getFileDownloadProxy()}getDownloadFileAuthKey(){return this._m.get(s).getDownloadFileAuthKey()}getMyUserID(){return this._m.get(s).getUserID()}getMyTinyID(){return this._m.get(s).getTinyID()}getSDKAppID(){return this._m.get(s).getSDKAppID()}isIntl(){return this._m.get(s).isIntl()}isUsingChatCore(){return this._m.get(s).isUsingChatCore()}isDevMode(){return this._m.get(s).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return P}getCloudConfig(e){return this._m.get(n).getCloudConfig(e)}emitOEvt(e,t){this._m.getOEmitInst().emit(e,t)}emitIEvt(e,t){this._m.getIEmitInst().emit(e,t)}getIEmitInst(){return this._m.getIEmitInst()}req(e){return this._m.get(o).req(e)}canIUse(e){return this._m.get(i).canIUse(e)}getErrMsg(e,t,s){return this._m.getErrMsg(e,t,s)}warn(e,t,s){e=this.getErrMsg(e,t,s);e&&ee.w(e)}noUse(e){var t=ie;return me({code:t,message:this.getErrMsg(t,e)})}}{constructor(e){super(e),this._n="CSModule"}searchCloudMessages(e){return this.search(ye,e)}searchCloudUsers(e){return this.search(Te,e)}searchCloudGroups(e){return this.search(Me,e)}searchCloudGroupMembers(e){return this.search(Ae,e)}search(n,s){let e=`searchCloud${n}s`,a=this._n+"."+e;if(!s)return me({code:re,message:this.getErrMsg(re,e)});var t=s["keywordList"],r=V(t);let o=s.count;if(s.count&&(o=parseInt(o)),n===ye&&!r&&!V(s.senderUserIDList)&&!V(s.messageTypeList)||n!==ye&&!r)throw ee.e(`[${e}] Missing required params: "keywordList".`),new Error("Params validate failed.");let m=Date.now(),u=new _e(e),c=`keywordList:${t} keywordListMatchType:${s.keywordListMatchType} cursor:${s.cursor} count:`+o;return ee.l(a+" "+c),this.req({P:Ie[n],data:this._genParams(n,s)}).then(e=>{var{code:r,message:o}=e.data;if(0!==r){let e=r,t=(60020===r?e="SearchUnable":n!==ye&&27003===r?e="SearchParamsError":n!==ye&&60018===r&&(e="SearchOverLimit"),this.getErrMsg(e)||o),s=new se({code:r,message:t});return u.setMessage(c).setError(s).end(),me(s)}this.get(i).isCSPluginEnabled();var{cursor:o="",totalCount:r}=e.data,t=`totalCount:${r} cost:`+(t=m,Date.now()-t)+" ms",t=(ee.l(a+` ok. cursor:${o} `+t),u.setMessage(c+" "+t).end(),this._genRes(n,s,e.data));return te({searchResultList:t,cursor:o,totalCount:r})}).catch(e=>(u.setMessage(c).setError(e).end(),me(e)))}_genParams(e,t){let{count:s,...r}=t;var o;return s&&(r.count=parseInt(s)),e===ye?this._genMsgParams(r):({keywordList:t,keywordListMatchType:o}=t,r.keywords=t,r.keywordMatchType="and"===o?1:0,e===Te?this._genUserParams(r):r)}_genMsgParams(e){let{conversationID:t,timePosition:s,timePeriod:r,...o}=e;return W(t)||(e=t,j(e)&&e.slice(0,3)===L&&(o.account=t.replace(L,"")),e=t,j(e)&&e.slice(0,5)===R&&(o.groupID=t.replace(R,""))),G(r)&&0<r&&(G(s)&&0<s?o.startTime=s-r:o.startTime=Math.floor(q()/1e3)-r),o.startTime&&o.startTime<0&&(o.startTime=void 0),G(s)&&0<s&&(o.endTime=s),o}_genUserParams(e){let{miniBirthday:t,maxBirthday:s,...r}=e;return G(t)&&(r.miniBirthday=parseInt(t),G(s)||(r.maxBirthday=4294967295)),G(s)&&(r.maxBirthday=parseInt(s)),r}_genRes(e,t,s){switch(e){case ye:return this._genMsgRes(s.searchResult,!t.conversationID);case Te:return this._genUserRes(s.userList);case Me:return this._genGrpRes(s.groupList);case Ae:return this._genMemberRes(s.groupMemberList);default:return[]}}_genMsgRes(e,n){let a=this.get(t);return K(e)&&0!==e.length?e.map(({groupID:t,userID:e,messageCount:s,messageList:r=[]})=>{var o=t?""+R+t:""+L+e,i={conversationID:o,messageCount:s,messageList:[]};if(!(n&&1<s)){s=r.filter(e=>!!e);if(0<s.length){let e=a.onRoamingMessage(s,o,!1);t&&e.reverse(),i.messageList=e,i.messageCount=e.length}}return i}):[]}_genUserRes(s){var r=this.get(e)._profileHandler;if(!K(s))return[];var o=[];for(let e=0,t=s.length;e<t;e++){var{userID:i,profileItems:n}=s[e];"@TLS#NOT_FOUND"!==i&&""!==i&&(i=r._update(i,r._getLatestProfileFromResponse(i,n))["latestProfile"],o.push(i))}return o}_genGrpRes(s){if(!K(s))return[];var r=[];for(let e=0,t=s.length;e<t;e++)s[e]&&s[e].groupID&&r.push(new Se(s[e]));return r}_genMemberRes(s){if(!K(s))return[];var r=new Map;for(let e=0,t=s.length;e<t;e++)if(s[e]&&s[e].userID&&s[e].groupID){var{groupID:o,name:i,type:n,avatar:a,nick:m,userID:u,nameCard:c,memberAvatar:l=""}=s[e],i={groupID:o,name:i,type:n,avatar:a},n={userID:u,nick:m,nameCard:c,avatar:l};if(r.has(o)){let e=r.get(o);e.memberList.push(n),r.set(o,e)}else r.set(o,{groupInfo:i,memberList:[n]})}return[...r.values()]}}export{Ee as default};