jiuyiUniapp/service/node_modules/@tencentcloud/chat/modules/cloud-search-module.js

1 line
20 KiB
JavaScript

"use strict";const 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}}const 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",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",BACKUP:"wss://wss.my-imcloud.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",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",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",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",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",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",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",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&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),g=(l&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),h="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),d="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),p="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,_="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=l&&"object"==typeof wx.miniapp,S=l||g||h||d||p||_||f,T="undefined"==typeof window&&!S&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,y="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),M="undefined"!=typeof uni?!S:"undefined"!=typeof window&&!S&&!y,I=(g?qq:h?tt:d?swan:p?my:l?wx:_?uni:f&&jd,M&&window&&window.navigator&&window.navigator.userAgent||""),A=/(micromessenger|webbrowser)/i.test(I),E=function(){let e="WEB";return A?e="WEB":g?e="QQ_MP":h?e="TT_MP":d?e="BAIDU_MP":p?e="ALI_MP":l?e=w?"DONUT_NATIVE_APP":"WX_MP":_?e="UNI_NATIVE_APP":T?e="NS_NATIVE_APP":y&&(e="RN_NATIVE_APP"),c[e]}(),P=(!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"));let N,v;!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:{};const C=function(){},b=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let D=b.length;for(;D--;)v=b[D],console[v]||(N[v]=C);var U=N;const O="C2C",L="GROUP",R=function(){return(new Date).getTime()+0},q=Object.prototype.hasOwnProperty,F=function(e){return"map"===Y(e)},x=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)},B=function(e){return"string"==typeof e},j=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},$=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===Y(e)},V=function(e){return $(e)&&0<e.length},H=function(e){return void 0===e},K=function(e){return $(e)||null!==e&&"object"==typeof e},Y=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},W=(Date.now||(Date.now=function(){return(new Date).getTime()}),function(s,r,o,n){if(!K(s)||!K(r))return 0;let i=0;var u,a=Object.keys(r);for(let e=0,t=a.length;e<t;e++)if(u=a[e],!(H(r[u])||o&&o.includes(u)))if(K(s[u])&&K(r[u]))i+=W(s[u],r[u],o,n);else{if(n&&n.includes(r[u]))continue;s[u]!==r[u]&&(s[u]=r[u],i+=1)}return i});function z(){return!P&&!S}let J=0;function Q(){return z()?"%c Chat %c":"Chat"}function X(){const e=function(){const e=new Date;return e.setTime(R()),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())}const Z={arguments2String(s){let r="";if(1===s.length)r=s[0];else for(let e=0,t=s.length;e<t;e++){if(K(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){z()?U[e](Q(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",X(),t):U[e](`${Q()} ${X()} `+t)},d:function(){var e;J<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;J<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;J<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;J<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;J<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;J<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+J+" to "+e),J=e},getLevel:function(){return J}},ee=function(e){return{code:0,data:e||{}}};class te 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||{}}}const se=2805,oe=2903,ne=3122,ie=3153,re="error";let ue=null;const ce=function(e,t=!1){if(e instanceof te)return t&&null!==ue&&ue.emit(re,e),Promise.reject(e);if(e instanceof Error){const e=new te({code:oe});return t&&null!==ue&&ue.emit(re,e),Promise.reject(e)}if(H(e)||H(e.code))return Promise.reject(new te({code:oe}));e=new te(e);return t&&null!==ue&&ue.emit(re,e),Promise.reject(e)},me="query",ae="query_grp",le="query_grp_member",ge="query_user",he={info:4,warning:5,error:6},de={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},pe={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 fe{constructor(e){this._n="SSOLogData",this.eventType=pe[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=R()}static bindEventStatModule(e){fe.prototype._eventStatModule=e}static bindNetMonitorModule(e){fe.prototype._netMonitorModule=e}updateTimeStamp(){this.timestamp=R()}start(e){return this._startts=e,this}end(e=!1){if(!this._sentFlag){if(this._netMonitorModule){const e=this._netMonitorModule.getNetworkType();this.setNetworkType(e)}var t=R();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(e){if(!(e instanceof Error))return Z.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let t=!0;if(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=se;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return H(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),G(e)?this.code=e:Z.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return H(e)||this._sentFlag||(G(e)&&(this.message=e.toString()),B(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return H(e)||this._sentFlag||(this.level=he[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(j(e)){for(const t in e)if(q.call(e,t))return;return 1}return(F(e)||x(e)||k(e))&&0===e.size}}(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return H(e)?Z.w(this._n+".setNetworkType value is undefined, please check!"):(e=de[e.toLowerCase()],H(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}}const _e=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class we{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(const t in e)_e.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);const t=JSON.parse(JSON.stringify(e));if(t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),H(t.muteAllMembers)||("On"===t.muteAllMembers?t.muteAllMembers=!0:t.muteAllMembers=!1),t.groupCustomField){var o=this.groupCustomField;if(e=t.groupCustomField,$(o)&&$(e)){let r=!1;e.forEach(({key:t,value:e})=>{const s=o.find(e=>e.key===t);s?s.value!==e&&(s.value=e,r=!0):(o.push({key:t,value:e}),r=!0)})}}H(t.memberNum)||(this.memberCount=t.memberNum),H(t.maxMemberNum)||(this.maxMemberCount=t.maxMemberNum),H(t.isSupportTopic)||(this.isSupportTopic=G(t.isSupportTopic)?1===t.isSupportTopic:t.isSupportTopic),W(this,t,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),$(t.members)&&0<t.members.length&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&W(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:r,readedSequence:o,excludedUnreadSequenceList:n}){e={nameCard:e,joinTime:t,role:s,messageRemindType:r,readedSequence:o,excludedUnreadSequenceList:n};W(this.selfInfo,{...e},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}const Se="Message",Te="User",ye="Group",Me="GroupMember",Ie={[Se]:me,[Te]:ge,[ye]:ae,[Me]:le};class Ae extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(s).isLoggedIn()}isOversea(){return this._m.get(s).isOversea()}isPrivateNetWork(){const e=this._m.get(s);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(s).getFileDownloadProxy()}getDowloadFileAuthKey(){return this._m.get(s).getDowloadFileAuthKey()}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 E}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&&Z.w(e)}noUse(e){var t=ne;return ce({code:t,message:this.getErrMsg(t,e)})}}{constructor(e){super(e),this._n="CSModule"}searchCloudMessages(e){return this.search(Se,e)}searchCloudUsers(e){return this.search(Te,e)}searchCloudGroups(e){return this.search(ye,e)}searchCloudGroupMembers(e){return this.search(Me,e)}search(o,n){const e=`searchCloud${o}s`,u=this._n+"."+e;if(!n)return ce({code:ie,message:this.getErrMsg(ie,e)});var t=n["keywordList"],s=V(t);let r=n.count;if(n.count&&(r=parseInt(r)),o===Se&&!s&&!V(n.senderUserIDList)&&!V(n.messageTypeList)||o!==Se&&!s)throw Z.e(`[${e}] Missing required params: "keywordList".`),new Error("Params validate failed.");const a=Date.now(),m=new fe(e),c=`keywordList:${t} keywordListMatchType:${n.keywordListMatchType} cursor:${n.cursor} count:`+r;return Z.l(u+" "+c),this.req({P:Ie[o],data:this._genParams(o,n)}).then(t=>{var{code:s,message:r}=t.data;if(0!==s){let e=s;60020===s?e="SearchUnable":o!==Se&&27003===s?e="SearchParamsError":o!==Se&&60018===s&&(e="SearchOverLimit");const t=this.getErrMsg(e)||r,u=new te({code:s,message:t});return m.setMessage(c).setError(u).end(),ce(u)}this.get(i).isCSPluginEnabled();var{cursor:r="",totalCount:s}=t.data,e=`totalCount:${s} cost:`+(e=a,Date.now()-e+" ms"),e=(Z.l(u+` ok. cursor:${r} `+e),m.setMessage(c+" "+e).end(),this._genRes(o,n,t.data));return ee({searchResultList:e,cursor:r,totalCount:s})}).catch(e=>(m.setMessage(c).setError(e).end(),ce(e)))}_genParams(e,t){const{count:s,...r}=t;if(s&&(r.count=parseInt(s)),e===Se)return this._genMsgParams(r);var{keywordList:t,keywordListMatchType:o}=t;return r.keywords=t,r.keywordMatchType="and"===o?1:0,e===Te?this._genUserParams(r):r}_genMsgParams(e){const{conversationID:t,timePosition:s,timePeriod:r,...o}=e;return H(t)||(e=t,B(e)&&e.slice(0,3)===O&&(o.account=t.replace(O,"")),e=t,B(e)&&e.slice(0,5)===L&&(o.groupID=t.replace(L,""))),G(r)&&0<r&&(G(s)&&0<s?o.startTime=s-r:o.startTime=Math.floor(R()/1e3)-r),o.startTime&&o.startTime<0&&(o.startTime=void 0),G(s)&&0<s&&(o.endTime=s),o}_genUserParams(e){const{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 Se:return this._genMsgRes(s.searchResult,!t.conversationID);case Te:return this._genUserRes(s.userList);case ye:return this._genGrpRes(s.groupList);case Me:return this._genMemberRes(s.groupMemberList);default:return[]}}_genMsgRes(e,i){const u=this.get(t);return $(e)&&0!==e.length?e.map(({groupID:e,userID:t,messageCount:s,messageList:r=[]})=>{const o=e?""+L+e:""+O+t,n={conversationID:o,messageCount:s,messageList:[]};if(i&&1<s)return n;s=r.filter(e=>!!e);if(0<s.length){const t=u.onRoamingMessage(s,o,!1);e&&t.reverse(),n.messageList=t,n.messageCount=t.length}return n}):[]}_genUserRes(s){const r=this.get(e)._profileHandler;if(!$(s))return[];const o=[];for(let e=0,t=s.length;e<t;e++){var{userID:n,profileItems:i}=s[e];"@TLS#NOT_FOUND"!==n&&""!==n&&(n=r._update(n,r._getLatestProfileFromResponse(n,i))["latestProfile"],o.push(n))}return o}_genGrpRes(s){if(!$(s))return[];const r=[];for(let e=0,t=s.length;e<t;e++)s[e]&&s[e].groupID&&r.push(new we(s[e]));return r}_genMemberRes(s){if(!$(s))return[];const 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:n,type:i,avatar:u,nick:a,userID:m,nameCard:c}=s[e],n={groupID:o,name:n,type:i,avatar:u},i={userID:m,nick:a,nameCard:c};if(r.has(o)){const s=r.get(o);s.memberList.push(i),r.set(o,s)}else r.set(o,{groupInfo:n,memberList:[i]})}return[...r.values()]}}export{Ae as default};