@tencentcloud/chat
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -1,1 +0,1 @@ | ||
'use strict';const e={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};let t,s;t="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const r=function(){},i=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let n=i.length;for(;n--;)s=i[n],console[s]||(t[s]=r);var o=t;class a{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(){const 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 d={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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"}}},u={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},l="CHINA",p={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=l){this.CURRENT=d.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GROUP:"group_open_http_svc",GROUP_AVCHATROOM:"group_open_avchatroom_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"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",MESSAGE_SEARCH:"message_search"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}};new a(0,Math.pow(2,0)).toString(),new a(0,Math.pow(2,1)).toString(),new a(0,Math.pow(2,2)).toString(),new a(0,Math.pow(2,3)).toString(),new a(0,Math.pow(2,4)).toString(),new a(0,Math.pow(2,6)).toString(),new a(0,Math.pow(2,7)).toString(),new a(0,Math.pow(2,9)).toString(),new a(0,Math.pow(2,10)).toString(),new a(0,Math.pow(2,11)).toString(),new a(0,Math.pow(2,13)).toString(),new a(0,Math.pow(2,15)).toString(),new a(Math.pow(2,16)).toString();const c="sns";p.HOST.setCurrent(l);const h="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),_="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),M="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,y="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=h||_||f||m||g||y||M,F=("undefined"!=typeof uni||"undefined"!=typeof window)&&!w;_?qq:f?tt:m?swan:g?my:h?wx:y?uni:!M||jd;const T=F&&window&&window.navigator&&window.navigator.userAgent||"",I=/(micromessenger|webbrowser)/i.test(T),A=/AppleWebKit\/([\d.]+)/i.exec(T);A&&parseFloat(A.pop());const D=function(){let e="WEB";return I?e="WEB":_?e="QQ_MP":f?e="TT_MP":m?e="BAIDU_MP":g?e="ALI_MP":h?e="WX_MP":y&&(e="UNI_NATIVE_APP"),u[e]}();!function(){const e=T.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){const e=T.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);t&&s&&parseFloat(e[1]+"."+e[2])}(),function(){const e=T.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}();const L=/MSIE/.test(T)||T.indexOf("Trident")>-1&&T.indexOf("rv:11.0")>-1;!function(){const e=/MSIE\s(\d+)\.\d/.exec(T);let t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(T)&&/rv:11.0/.test(T)&&(t=11)}(),function(){const e=T.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}();const k="C2C",S="AllowType_Type_AllowAny",N="AdminForbid_Type_None",v="Add_Type_Single",b="Add_Type_Both",E="Delete_Type_Single",G="Delete_Type_Both",U="Pendency_Type_Both",C="Pendency_Type_ComeIn",P="Pendency_Type_SendOut",O="Response_Action_Agree",$="Response_Action_AgreeAndAdd",q="CheckResult_Type_Both",R="CheckResult_Type_Single";const x=function(){return(new Date).getTime()+0},H="Tag_Profile_IM_Nick",W="Tag_Profile_IM_Gender",B="Tag_Profile_IM_BirthDay",j="Tag_Profile_IM_Location",K="Tag_Profile_IM_SelfSignature",Y="Tag_Profile_IM_AllowType",J="Tag_Profile_IM_Language",V="Tag_Profile_IM_Image",z="Tag_Profile_IM_MsgSettings",Q="Tag_Profile_IM_AdminForbidType",X="Tag_Profile_IM_Level",Z="Tag_Profile_IM_Role",ee="Tag_SNS_IM_Group",te="Tag_SNS_IM_Remark",se="Tag_SNS_IM_AddSource",re="Tag_SNS_IM_AddWording",ie="Tag_SNS_IM_AddTime",ne={UNKNOWN:"Gender_Type_Unknown",FEMALE:"Gender_Type_Female",MALE:"Gender_Type_Male"},oe={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},ae={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},de=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)},ue=function(e){return"string"==typeof e},le=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===he(e)},pe=function(e){return void 0===e},ce=function(e){return e instanceof Error},he=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()};Date.now||(Date.now=function(){return(new Date).getTime()});const _e=function(e){if(0===e.length)return 0;let t=0,s="",r=0,i=1;const n="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";for(;void 0!==e[t];)s=e[t++],i=s.charCodeAt[t]<=255?1:!1===n?3:2,r+=i;return r},fe=function(e,t){for(const s in e)if(e[s]===t)return!0;return!1};function me(){return!L&&!w}let ge=0;function Me(){return me()?"%c Chat %c":"Chat"}function ye(){const e=function(){const e=new Date;return e.setTime(x()),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 we={arguments2String(e){let t="";if(1===e.length)t=e[0];else for(let i=0,n=e.length;i<n;i++)r=e[i],le(r)||function(e){return null!==e&&"object"==typeof e}(r)?ce(e[i])?t+=(s=e[i],JSON.stringify(s,["message","code"])):t+=JSON.stringify(e[i]):t+=e[i],t+=" ";var s,r;return t},_exec(e,t){me()?o[e](Me(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",ye(),t):o[e](`${Me()} ${ye()} ${t}`)},d:function(){if(ge<=-1){const e=this.arguments2String(arguments);this._exec("debug",e)}},l:function(){if(ge<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},log:function(){if(ge<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},i:function(){if(ge<=1){const e=this.arguments2String(arguments);this._exec("info",e)}},w:function(){if(ge<=2){const e=this.arguments2String(arguments);this._exec("warn",e)}},e:function(){if(ge<=3){const e=this.arguments2String(arguments);this._exec("error",e)}},setLevel:function(e){e<4&&this._exec("log","set level from "+ge+" to "+e),ge=e},getLevel:function(){return ge}},Fe=Object.prototype.hasOwnProperty;function Te(e){if(null==e)return!0;if("boolean"==typeof e)return!1;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(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s}(e)){for(const t in e)if(Fe.call(e,t))return!1;return!0}return!("map"!==he(e)&&!function(e){return"set"===he(e)}(e)&&!function(e){return"file"===he(e)}(e))&&0===e.size}class Ie{constructor(e){Te(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",this.time=e.time||0,this.source=e.source||"",this.wording=e.wording||"",this.type=e.type||"")}}const Ae=function(e){return{code:0,data:e||{}}};class De extends Error{constructor(e){super();const{code:t,message:s,data:r}=e;this.code=t,this.message=s||this._getErrorMessage(this.code),this.data=r||{}}}const Le=2700,ke=2701,Se=2710,Ne=2711,ve=2716,be=2805,Ee=2903,Ge=3122,Ue=3123,Ce="onMessageModified",Pe="onFriendListUpdated",Oe="onFriendGroupListUpdated",$e="onFriendApplicationListUpdated",qe="error";let Re=null;const xe=function(e){return Promise.resolve(Ae(e))},He=function(e,t=!1){if(e instanceof De)return t&&null!==Re&&Re.emit(qe,e),Promise.reject(e);if(e instanceof Error){const e=new De({code:Ee});return t&&null!==Re&&Re.emit(qe,e),Promise.reject(e)}if(pe(e)||pe(e.code))return Promise.reject(new De({code:Ee}));const s=new De(e);return t&&null!==Re&&Re.emit(qe,s),Promise.reject(s)},We="friend_get",Be="friend_get_specified",je="friend_check",Ke="friend_delete",Ye="friend_add",Je="friend_update",Ve="friend_response",ze="pendency_get",Qe="pendency_delete",Xe="pendency_report",Ze="group_get",et="group_add",st="group_delete",rt="group_update",it={info:4,warning:5,error:6},nt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},ot={login:4};class at{constructor(e){this._n="SSOLogData",this.eventType=ot[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=x()}static bindEventStatModule(e){at.prototype._eventStatModule=e}updateTimeStamp(){this.timestamp=x()}start(e){return this._startts=e,this}end(e=!1){if(this._sentFlag)return;const t=x();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,t,s){if(!(e instanceof Error))return we.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;if(this.setNetworkType(s),t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=be;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return pe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),de(e)?this.code=e:we.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return pe(e)||this._sentFlag||(de(e)&&(this.message=e.toString()),ue(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return pe(e)||this._sentFlag||(this.level=it[e]),this}setMoreMessage(e){return Te(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){if(pe(e))we.w(this._n+".setNetworkType value is undefined, please check!");else{const t=nt[e.toLowerCase()];pe(t)||(this.networkType=t)}return this}getStartTs(){return this._startts}setUIPlatform(e){this.uiPlatform=e}}class dt{constructor(e){this._snsModule=e,this._n="FriendApplicationHandler",this._startTime=0,this._maxLimited=100,this._currentSequence=0,this._friendApplicationMap=new Map,this._unreadCount=0}getLocalFriendApplicationList(){return{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}}_onFriendApplicationListUpdated(){this._snsModule.emitOuterEvent($e,{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount})}onFriendApplicationRead(){this._unreadCount=0,this._onFriendApplicationListUpdated()}onFriendApplicationAdded(e,t){if(Te(e))return;let s="";s=t===this._snsModule.getMyUserID()?P:C;let r=!1;e.forEach(e=>{const t=`${e.userID}_${s}`;s!==C||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,new Ie({...e,type:s})),r=!0}),r&&this._onFriendApplicationListUpdated()}onFriendApplicationDeleted(e){Te(e)||(this._startTime=0,this._currentSequence=0,this.getFriendApplicationList())}getFriendApplicationList(){const e=this._n+".getFriendApplicationList",t=new at("getFriendApplicationList");return this._snsModule.request({protocolName:ze,requestData:{applicationType:U,fromAccount:this._snsModule.getMyUserID(),maxLimited:this._maxLimited,startTime:this._startTime,lastSequence:this._currentSequence}}).then(s=>{const{resultList:r,unreadCount:i,startTime:n,currentSequence:o}=s.data;this._startTime=n,this._currentSequence=o,this._unreadCount=i;const a=`applicationCount:${le(r)?r.length:0} unreadCount:${i} startTime:${n} currentSequence:${o}`;t.setNetworkType(this._snsModule.getNetworkType()).setMessage(a).end(),we.i(`${e} ok. ${a}`),this._friendApplicationMap.clear(),le(r)&&r.forEach(e=>{const{userID:t,type:s}=e,r=new Ie(e);this._friendApplicationMap.set(`${t}_${s}`,r)}),this._onFriendApplicationListUpdated()}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" failed. error:",s),He(s)))}deleteFriendApplication(e){const t=this._n+".deleteFriendApplication",{userID:s,type:r}=e;let i=r;if((!i||i!==P&&i!==C)&&(i=C),!this._friendApplicationMap.has(`${s}_${i}`))return He({code:ve});const n=new at("deleteFriendApplication");n.setMessage(`userID:${s} type:${i}`);return this._snsModule.request({protocolName:Qe,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:[s],type:i}}).then(e=>{const{resultList:r}=e.data,{to:o,resultCode:a,resultInfo:d}=r[0];return n.setNetworkType(this._snsModule.getNetworkType()).setMoreMessage("resultList:"+JSON.stringify(r)).end(),we.i(`${t} ok. userID:${s} type:${i}`),0===a?Ae():He({userID:o,code:a,message:d})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}acceptFriendApplication(e){const t=this._n+".acceptFriendApplication",{userID:s,remark:r,tag:i,type:n}=e;let o=n;(!o||o!==O&&o!==$)&&(o=$);const a=new at("acceptFriendApplication");a.setMessage(`userID:${s} type:${o}`);return this._snsModule.request({protocolName:Ve,requestData:{fromAccount:this._snsModule.getMyUserID(),responseFriendItem:[{userID:s,remark:r,tag:i,action:o}]}}).then(e=>{a.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:r}=e.data,{resultCode:i,resultInfo:n}=r[0];if(0!==i)return He({code:i,message:n});we.i(`${t} ok. userID:${s} type:${o}`)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}refuseFriendApplication(e){const t=this._n+".refuseFriendApplication",{userID:s}=e,r=new at("refuseFriendApplication");r.setMessage("userID:"+s);return this._snsModule.request({protocolName:Ve,requestData:{fromAccount:this._snsModule.getMyUserID(),responseFriendItem:[{userID:s,action:"Response_Action_Reject"}]}}).then(e=>{r.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:i}=e.data,{resultCode:n,resultInfo:o}=i[0];if(0!==n)return He({code:n,message:o});we.i(`${t} ok. userID:${s}`)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}_onFriendApplicationProcessed(e){if(0===e.length)return;let t=!1;e.forEach(e=>{const s=`${e.to}_${C}`;this._friendApplicationMap.has(s)&&(this._friendApplicationMap.delete(s),this._unreadCount-=1,t=!0)}),this._unreadCount<0&&(this._unreadCount=0),t&&this._onFriendApplicationListUpdated()}setFriendApplicationRead(){const e=this._n+".setFriendApplicationRead",t=new at("setFriendApplicationRead");var s,r;return this._snsModule.request({protocolName:Xe,requestData:{fromAccount:this._snsModule.getMyUserID(),latestTimeStamp:(s=x()/1e3,r=0,Math.round(Number(s)*Math.pow(10,r))/Math.pow(10,r))}}).then(s=>{t.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(e+" ok"),this._unreadCount=0}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" failed. error:",s),He(s)))}reset(){this._startIndex=0,this._maxLimited=100,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}}class ut{constructor(e){Te(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.gender=e.gender||"",this.birthday=e.birthday||0,this.location=e.location||"",this.selfSignature=e.selfSignature||"",this.allowType=e.allowType||S,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||N,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Te(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(e){let t=!0,s="";if(Te(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){const t=e.profileCustomField.length;let s=null;for(let r=0;r<t;r++){if(s=e.profileCustomField[r],!ue(s.key)||-1===s.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!ue(s.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if("profileCustomField"===r)continue;if(Te(e[r])&&!ue(e[r])&&!de(e[r])){s="key:"+r+", invalid value:"+e[r],t=!1;continue}switch(r){case"nick":ue(e[r])||(s="nick must be a string",t=!1),_e(e[r])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${_e(e[r])} bytes`,t=!1);break;case"gender":fe(ne,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":de(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":ue(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":ue(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":fe(ae,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":de(e.language)||(s="language must be a number",t=!1);break;case"avatar":ue(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":fe(oe,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":de(e.level)||(s="level must be a number",t=!1);break;case"role":de(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:s}}}class lt{constructor(e,t){this.userID=e,this.remark="",this.groupList=[],this.source="",this.addTime=0,this.friendCustomField=[],this.timestamp=0;const s={},r=[];if(s.userID=e,!Te(t)){let e="",i="";for(let n=0,o=t.length;n<o;n++)if(e=t[n].tag,i=t[n].value,e.indexOf("Tag_SNS_Custom")>-1)this.friendCustomField.push({key:e,value:i});else if(e.indexOf("Tag_Profile_Custom")>-1)r.push({key:e,value:i});else switch(e){case H:s.nick=i;break;case W:s.gender=i;break;case B:s.birthday=i;break;case j:s.location=i;break;case K:s.selfSignature=i;break;case Y:s.allowType=i;break;case J:s.language=i;break;case V:s.avatar=i;break;case z:s.messageSettings=i;break;case Q:s.adminForbidType=i;break;case X:s.level=i;break;case Z:s.role=i;break;case te:this.remark=i;break;case ie:this.addTime=i;break;case ee:this.groupList=JSON.parse(JSON.stringify(i));break;case se:this.source=i;break;case re:break;default:we.l("snsProfileItem unknown tag->",t[n].tag)}}this.profile=new ut({...s,profileCustomField:r})}validate(e){let t=!0,s="";if(Te(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){const t=e.profileCustomField.length;let s=null;for(let r=0;r<t;r++){if(s=e.profileCustomField[r],!ue(s.key)||-1===s.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!ue(s.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if("profileCustomField"===r)continue;if(Te(e[r])&&!ue(e[r])&&!de(e[r])){s="key:"+r+", invalid value:"+e[r],t=!1;continue}switch(r){case"nick":ue(e[r])||(s="nick must be a string",t=!1),_e(e[r])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${_e(e[r])} bytes`,t=!1);break;case"gender":fe(ne,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":de(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":ue(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":ue(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":fe(ae,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":de(e.language)||(s="language must be a number",t=!1);break;case"avatar":ue(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":fe(oe,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":de(e.level)||(s="level must be a number",t=!1);break;case"role":de(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:s}}update(e){let t="",s="";const r=[];this.friendCustomField.forEach(e=>{r.push(e.key)});for(let i=0,n=e.length;i<n;i++)if(t=e[i].tag,s=e[i].value,t.indexOf("Tag_SNS_Custom")>-1)r.indexOf(t)>-1?this.friendCustomField.forEach(e=>{e.key===t&&(e.value=s)}):this.friendCustomField.push({key:t,value:s});else if(t.indexOf("Tag_Profile_Custom")>-1){let e=!1;this.profile.profileCustomField.forEach(r=>{r.key===t&&(r.value=s,e=!0)}),e||this.profile.profileCustomField.push({key:t,value:s})}else switch(t){case H:this.profile.nick=s;break;case W:this.profile.gender=s;break;case B:this.profile.birthday=s;break;case j:this.profile.location=s;break;case K:this.profile.selfSignature=s;break;case Y:this.profile.allowType=s;break;case J:this.profile.language=s;break;case V:this.profile.avatar=s;break;case z:this.profile.messageSettings=s;break;case Q:this.profile.adminForbidType=s;break;case X:this.profile.level=s;break;case Z:this.profile.role=s;break;case te:this.remark=s;break;case ie:this.addTime=s;break;case ee:this.groupList=JSON.parse(JSON.stringify(s));break;case se:this.source=s;break;case re:break;default:we.d("snsProfileItem unkown tag->",e[i].tag)}this.timestamp=Date.now(),r.length=0}updateProfile(e){this.profile=JSON.parse(JSON.stringify(e)),this.timestamp=Date.now()}addToGroupList(e){-1===this.groupList.indexOf(e)&&(this.groupList.push(e),this.count=this.groupList.length)}removeFromGroupList(e){const t=this.groupList.indexOf(e);t>-1&&(this.groupList.splice(t,1),this.count=this.groupList.length)}}const pt=4,ct=11,ht=12,_t=15,ft=20,mt=23,gt=27,Mt=29;class yt{constructor(e){this._snsModule=e,this._n="FriendHandler",this._friendMap=new Map,this._startIndex=0,this._standardSequence=0,this._customSequence=0,this._expirationTime=18e4}getLocalFriendList(){return[...this._friendMap.values()]}getFriendRemark(e){return this._friendMap.has(e)?this._friendMap.get(e).remark:""}onFriendProfileModified(e){const{dataList:t}=e;if(Te(t))return;const s=this._snsModule.getModule(ct);t.forEach(e=>{const{userID:t,profileList:r}=e;if(this.isMyFriend(t)){we.l(`${this._n}.onFriendProfileModified. friend account:${t}, profileList:${JSON.stringify(r)}`);const e=this._friendMap.get(t);e.update(r),s.modifyMessageSentByPeer({conversationID:`${k}${t}`,latestNick:e.profile.nick,latestAvatar:e.profile.avatar})}}),this._onFriendListUpdated()}onFriendAdded(e){0!==e.length&&(we.l(`${this._n}.onFriendAdded userIDList:${e}`),e.forEach(e=>{this._friendMap.set(e,new lt(e))}),this.getFriendProfile({userIDList:e}).then(t=>{e.forEach(e=>{const t=this._friendMap.get(e);t.groupList.length>0&&this._snsModule.updateWhenFriendAdded({nameList:t.groupList,userID:e})}),this._onFriendListUpdated()}))}onFriendDeleted(e){0!==e.length&&(we.l(`${this._n}.onFriendDeleted userIDList:${e}`),e.forEach(e=>{const t=this._friendMap.get(e);t.groupList.length>0&&this._snsModule.updateWhenFriendDeleted({nameList:t.groupList,userID:e}),this._friendMap.delete(e)}),this._onFriendListUpdated())}_onFriendListUpdated(){this._snsModule.emitOuterEvent(Pe);this._snsModule.getModule(ct).checkAndPatchRemark()}getFriendProfile(e){const t=this._n+".getFriendProfile",{userIDList:s}=e,r=[],i=[],n=[];if(s.forEach(e=>{if(this._friendMap.has(e)){const t=this._friendMap.get(e);Date.now()-t.timestamp<this._expirationTime?i.push(t):n.push(e)}else r.push({userID:e,code:Le,message:this._snsModule.getErrorMessage(Le)})}),0===n.length)return we.i(t+" newUserIDList is empty"),xe({friendList:i,failureUserIDList:r});const o=new at("getFriendProfile");o.setMessage("userIDList:"+n),we.i(`${t} userIDList:${n}`);return this._snsModule.request({protocolName:Be,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:n}}).then(e=>{o.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(t+" ok");const{resultList:s}=e.data;return s.forEach(e=>{const{to:t,resultCode:s,resultInfo:n,tagValueList:o}=e;if(pe(s)||0===s){let e;this._friendMap.has(t)?(e=this._friendMap.get(t),e.update(o)):(e=new lt(t,o),this._friendMap.set(t,e)),i.push(e)}else r.push({userID:t,code:s,message:n})}),Ae({friendList:i,failureUserIDList:r})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}isMyFriend(e){return this._friendMap.has(e)}pagingGetFriendList(){const e=this._n+".getFriendList",t=new at("getFriendList"),s=Date.now();this._snsModule.request({protocolName:We,requestData:{fromAccount:this._snsModule.getMyUserID(),startIndex:this._startIndex,standardSequence:this._standardSequence,customSequence:this._customSequence}}).then(r=>{const{friendCount:i,resultList:n,nextStartIndex:o,standardSequence:a,customSequence:d,completeFlag:u}=r.data;this._startIndex=o,this._standardSequence=a,this._customSequence=d;const l=`friendCount:${i} nextStartIndex:${o} standardSequence:${a} customSequence:${d} completeFlag:${u} cost ${Date.now()-s} ms`;t.setNetworkType(this._snsModule.getNetworkType()).setMessage(l).end(),we.i(e+" ok.",l),Te(n)||n.forEach(e=>{const{to:t,tagValueList:s}=e;this._friendMap.set(t,new lt(t,s))}),0===u?this.pagingGetFriendList():(this._snsModule.emitOuterEvent(Pe),this._pagingGetFriendProfile())}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" failed. error:",s),He(s)))}_pagingGetFriendProfile(){const e=[...this._friendMap.keys()],t=this._snsModule.getModule(pt),s=e.length,r=s<=100?1:Math.ceil(s/100);we.l(`${this._n}._pagingGetFriendProfile friendCount:${s} pageCount:${r}`);for(let i=0;i<r;i++)t.getUserProfile({userIDList:e.slice(100*i,100*(i+1))}).then(e=>{e.data.forEach(e=>{const t=this._friendMap.get(e.userID);t&&t.updateProfile(e)}),this._onFriendListUpdated()})}addFriend(e){const t=this._n+".addFriend";if(this._friendMap.has(e.to))return He({code:ke});if(e.wording&&!1===this._snsModule.filterProfanity("wording",e))return He({code:Ue});const{to:s,source:r,type:i,wording:n,remark:o,groupName:a}=e;let d=i;(!d||d!==v&&d!==b)&&(d=b);const u=new at("addFriend");u.setMessage(`to:${s} source:${r} type:${d}`);return this._snsModule.request({protocolName:Ye,requestData:{fromAccount:this._snsModule.getMyUserID(),addFriendItem:[{to:s,source:r,wording:n,remark:o,groupName:a}],type:d}}).then(e=>{const{resultList:s}=e.data;u.setNetworkType(this._snsModule.getNetworkType()).setMoreMessage("resultList:"+JSON.stringify(s)).end();const{to:r,resultCode:i,resultInfo:n}=s[0];return we.i(`${t} ok. to:${r} type:${d} code:${i}`),pe(i)||0===i?Ae({userID:r,code:0}):30539===i?Ae({userID:r,code:i,message:this._snsModule.getErrorMessage(i)}):He({userID:r,code:i,message:this._snsModule.getErrorMessage(i)||n})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}deleteFriend(e){const t=this._n+".deleteFriend",{userIDList:s,type:r}=e;var i;s.length>1e3&&(we.w(`${t} ${i=1e3,"the length of userIDList cannot exceed "+i}`),s.length=1e3);const n=[],o=[],a=[];if(s.forEach(e=>{this._friendMap.has(e)?a.push(e):n.push({userID:e,code:Le,message:this._snsModule.getErrorMessage(Le)})}),0===a.length)return xe({successUserIDList:o,failureUserIDList:n});let d=r;(!d||d!==E&&d!==G)&&(d=G);const u=new at("deleteFriend");u.setMessage(`userIDList:${a} type:${d}`);return this._snsModule.request({protocolName:Ke,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:a,type:d}}).then(e=>{u.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(t+" ok");const{resultList:s}=e.data;return Te(s)||s.forEach(e=>{const{to:t,resultCode:s,resultInfo:r}=e;pe(s)||0===s?o.push({userID:t}):n.push({userID:t,code:s,message:r})}),Ae({successUserIDList:o,failureUserIDList:n})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),we.w(t+" error:",e),He(e)))}updateFriend(e){const{userID:t,remark:s,friendCustomField:r}=e;if(!this._friendMap.has(t))return He({code:Le});const i=this._n+".updateFriend",n=new at("updateFriend");n.setMessage(`userID:${t} remark:${s} friendCustomField:${r}`);const o=[];pe(s)||o.push({tag:te,value:s}),le(r)&&r.length>0&&r.forEach(e=>{o.push({tag:e.key,value:e.value})});return this._snsModule.request({protocolName:Je,requestData:{fromAccount:this._snsModule.getMyUserID(),updateItem:[{to:t,snsItem:o}]}}).then(e=>{n.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(i+" ok");const{resultList:t}=e.data,{to:o,resultCode:a,resultInfo:d}=t[0];if(pe(a)||0===a){const e=this._friendMap.get(o);return e&&(pe(s)||(e.remark=s),le(r)&&r.length>0&&function(e,t){if(!le(e)||!le(t))return!1;let s=!1;t.forEach(({key:t,value:r})=>{const i=e.find(e=>e.key===t);i?i.value!==r&&(i.value=r,s=!0):(e.push({key:t,value:r}),s=!0)})}(e.friendCustomField,r),this._onFriendListUpdated()),Ae(e)}return He({code:a,message:d})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),we.w(i+" failed. error:",e),He(e)))}checkFriend(e){const t=this._n+".checkFriend",{userIDList:s,type:r}=e;let i=r;(!i||i!==R&&i!==q)&&(i=q);const n=new at("checkFriend");n.setMessage(`userIDList:${s} type:${i}`);return this._snsModule.request({protocolName:je,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:s,type:i}}).then(e=>{n.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(`${t} ok. userIDList:${s} type:${i}`);const r=[],o=[],{resultList:a}=e.data;return le(a)&&a.forEach(e=>{const{to:t,relation:s,resultCode:i,resultInfo:n}=e;pe(i)||0===i?r.push({userID:t,code:0,relation:s}):o.push({userID:t,code:i,message:n})}),Ae({successUserIDList:r,failureUserIDList:o})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}updateWhenAddedToFriendGroup(e){const{name:t,userIDList:s}=e;we.l(`${this._n}.updateWhenAddedToFriendGroup groupName:${t} userIDList:${s}`),t&&!Te(s)&&s.forEach(e=>{if(this._friendMap.has(e)){this._friendMap.get(e).addToGroupList(t)}})}updateWhenRemovedFromFriendGroup(e){const{name:t,userIDList:s}=e;we.l(`${this._n}.updateWhenRemovedFromFriendGroup groupName:${t} userIDList:${s}`),t&&!Te(s)&&s.forEach(e=>{if(this._friendMap.has(e)){this._friendMap.get(e).removeFromGroupList(t)}})}reset(){this._friendMap.clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}}class wt{constructor(e){Te(e)||(this.name=e.name||"",this.userIDList=e.userIDList||[],this.count=this.userIDList.length||0)}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}class Ft{constructor(e){this._snsModule=e,this._n="FriendGroupHandler",this._friendGroupMap=new Map}getLocalFriendGroupList(){return[...this._friendGroupMap.values()]}_emitFriendGroupListUpdated(){const e=[...this._friendGroupMap.values()];this._snsModule.emitOuterEvent(Oe,e)}getFriendGroupList(){const e=this._n+".getFriendGroupList",t=new at("getFriendGroupList");return this._snsModule.request({protocolName:Ze,requestData:{fromAccount:this._snsModule.getMyUserID()}}).then(s=>{t.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:r}=s.data;Te(r)?we.i(e+" ok. friend group count:0"):(we.i(`${e} ok. friend group count:${r.length}`),this._friendGroupMap.clear(),r.forEach(e=>{const t=new wt(e);this._friendGroupMap.set(e.name,t)}),this._emitFriendGroupListUpdated())}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" error:",s),He(s)))}createFriendGroup(e){const t=this._n+".createFriendGroup",{name:s,userIDList:r}=e;if(this._friendGroupMap.has(s))return He({code:Se});const i=new at("createFriendGroup");return i.setMessage(`name:${s} userIDList:${r}`),this._snsModule.request({protocolName:et,requestData:{fromAccount:this._snsModule.getMyUserID(),groupName:[s],userIDList:le(r)?r:void 0}}).then(e=>{i.setNetworkType(this._snsModule.getNetworkType()).end(),we.l(`${t} ok. name:${s} userIDList:${r}`);const{resultList:n}=e.data,o=[],a=[];n&&n.forEach(e=>{const{to:t,resultCode:s,resultInfo:r}=e;if(pe(s)||0===s)o.push(t);else{const t={userID:e.to,code:s,message:r};a.push(t)}});const d=new wt({name:s,userIDList:o});return this._friendGroupMap.set(s,d),this._snsModule.updateWhenAddedToFriendGroup({name:s,userIDList:o}),this._emitFriendGroupListUpdated(),Ae({friendGroup:d,failureUserIDList:a})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}deleteFriendGroup(e){const t=this._n+".deleteFriendGroup",{name:s}=e;if(!this._friendGroupMap.has(s))return He({code:Ne});const r=new at("deleteFriendGroup");r.setMessage("name:"+s);return this._snsModule.request({protocolName:st,requestData:{fromAccount:this._snsModule.getMyUserID(),nameList:[s]}}).then(e=>{r.setNetworkType(this._snsModule.getNetworkType()).end(),we.l(`${t} ok. name:${s}`);const i=this._friendGroupMap.get(s);return i&&(this._snsModule.updateWhenRemovedFromFriendGroup({name:s,userIDList:i.userIDList}),this._friendGroupMap.delete(s),i.userIDList.length=0),this._emitFriendGroupListUpdated(),Ae(i)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}renameFriendGroup(e){const t=this._n+".renameFriendGroup",{oldName:s,newName:r}=e;if(!this._friendGroupMap.has(s))return He({code:Ne});const i=new at("renameFriendGroup");i.setMessage(`oldName:${s} newName:${r}`);return this._snsModule.request({protocolName:rt,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,newName:r}}).then(()=>{if(i.setNetworkType(this._snsModule.getNetworkType()).end(),we.l(`${t} ok. oldName:${s} newName:${r}`),this._friendGroupMap.has(s)){const e=this._friendGroupMap.get(s);return e.name=r,this._friendGroupMap.delete(s),this._friendGroupMap.set(r,e),this._snsModule.updateWhenRemovedFromFriendGroup({name:s,userIDList:e.userIDList}),this._snsModule.updateWhenAddedToFriendGroup({name:r,userIDList:e.userIDList}),this._emitFriendGroupListUpdated(),Ae(e)}return Ae()}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}addToFriendGroup(e){const t=this._n+".addToFriendGroup",{name:s,userIDList:r}=e;if(!this._friendGroupMap.has(s))return this._onFriendGroupNotExist(s);const i=new at("addToFriendGroup");i.setMessage(`name:${s} userIDList:${r}`),we.l(`${t} name:${s} userIDList:${r}`);return this._snsModule.request({protocolName:rt,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,updateGroupItem:r.filter(e=>this._snsModule.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Add"}))}}).then(e=>(i.setNetworkType(this._snsModule.getNetworkType()).end(),this._onFriendGroupUpdated(s,e))).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}removeFromFriendGroup(e){const t=this._n+".removeFromFriendGroup",{name:s,userIDList:r}=e;if(!this._friendGroupMap.has(s))return this._onFriendGroupNotExist(s);const i=new at("removeFromFriendGroup");i.setMessage(`name:${s} userIDList:${r}`),we.l(`${t} name:${s} userIDList:${r}`);return this._snsModule.request({protocolName:rt,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,updateGroupItem:r.filter(e=>this._snsModule.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Delete"}))}}).then(e=>(i.setNetworkType(this._snsModule.getNetworkType()).end(),this._onFriendGroupUpdated(s,e))).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}_onFriendGroupUpdated(e,t){const{resultList:s}=t.data,r=this._friendGroupMap.get(e),i=[],n=[],o=[];return le(s)&&s.forEach(e=>{const{to:t,resultCode:s,resultInfo:a,type:d}=e;0===s?"Update_Type_Add"===d?r&&(r.addToUserIDList(t),n.push(t)):"Update_Type_Delete"===d&&r&&(r.removeFromUserIDList(t),o.push(t)):i.push({to:e.to,code:s,message:a})}),we.l(`${this._n}._onFriendGroupUpdated name:${e} userIDList:${r.userIDList}`),n.length>0&&this._snsModule.updateWhenAddedToFriendGroup({name:e,userIDList:n}),o.length>0&&this._snsModule.updateWhenRemovedFromFriendGroup({name:e,userIDList:o}),Ae({friendGroup:r,failureUserIDList:i})}updateWhenFriendAdded(e){const{nameList:t,userID:s}=e;we.l(`${this._n}.updateWhenFriendAdded userID:${s} nameList:${t}`),Te(t)||t.forEach(e=>{if(this._friendGroupMap.has(e)){this._friendGroupMap.get(e).addToUserIDList(s)}})}updateWhenFriendDeleted(e){const{nameList:t,userID:s}=e;we.l(`${this._n}.updateWhenFriendDeleted userID:${s} nameList:${t}`),Te(t)||t.forEach(e=>{if(this._friendGroupMap.has(e)){this._friendGroupMap.get(e).removeFromUserIDList(s)}})}reset(){this._friendGroupMap.clear()}}class Tt extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.getModule(ht).isLoggedIn()}isOversea(){return this._m.getModule(ht).isOversea()}isPrivateNetWork(){return this._m.getModule(ht).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(ht).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(ht).getUserID()}getMyTinyID(){return this._m.getModule(ht).getTinyID()}getSDKAppID(){return this._m.getModule(ht).getSDKAppID()}isIntl(){return this._m.getModule(ht).isIntl()}isDevMode(){return this._m.getModule(ht).isDevMode()}getModule(e){return this._m.getModule(e)}getPlatform(){return D}getNetworkType(){return this._m.getModule(_t).getNetworkType()}probeNetwork(e){return this._m.getModule(_t).probe(e)}getCloudConfig(e){return this._m.getModule(mt).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.getModule(ht).getTinyID()+"-"+e.random}filterModifiedMessage(e){if(Te(e))return;const t=e.filter(e=>!0===e.isModified);t.length>0&&this.emitOuterEvent(Ce,t)}filterUnmodifiedMessage(e){if(Te(e))return[];return e.filter(e=>!1===e.isModified)}request(e){return this._m.getModule(ft).request(e)}canIUse(e){return this._m.getModule(gt).canIUse(e)}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}outputWarning(e,t,s){const r=this.getErrorMessage(e,t,s);r&&we.w(r)}cannotUseCommercialAbility(e){const t=Ge;return He({code:t,message:this.getErrorMessage(t,e)})}}{constructor(t){super(t),this._n="SnsModule",this._friendHandler=new yt(this),this._friendApplicationHandler=new dt(this),this._friendGroupHandler=new Ft(this);this.getInnerEmitterInstance().on(e.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._friendHandler.pagingGetFriendList(),this._friendGroupHandler.getFriendGroupList(),this._friendApplicationHandler.getFriendApplicationList()}onRelationChainModified(e){const{dataList:t}=e;if(Te(t))return;const s=[],r=[],i=[],n=[];let o=!1,a="";t.forEach(e=>{if(3!==e.pushType&&4!==e.pushType||!e.from||(a=e.from),e.friendAddAccount&&(s.push(...e.friendAddAccount),n.push(...e.friendAddAccount)),e.friendDelAccount&&r.push(...e.friendDelAccount),e.friendApplicationAdded&&i.push(...e.friendApplicationAdded),e.friendApplicationDeletedUserIDList&&n.push(...e.friendApplicationDeletedUserIDList),e.reportTime&&7===e.pushType&&(o=!0),e.friendUpInfo){const t={dataList:[]};e.friendUpInfo.forEach(e=>{t.dataList.push({userID:e.friendAccount,profileList:[...e.sns]})}),this.onFriendProfileModified(t)}}),o&&this._friendApplicationHandler.onFriendApplicationRead(),this._friendApplicationHandler.onFriendApplicationAdded(i,a),this._friendApplicationHandler.onFriendApplicationDeleted(n),this._friendHandler.onFriendAdded(s),this._friendHandler.onFriendDeleted(r)}isMyFriend(e){return this._friendHandler.isMyFriend(e)}filterProfanity(e,t){const s=this.getModule(Mt);if(!s)return!0;const{isAllowedToSend:r,modifiedText:i}=s.filterText(t[e],c);return!0===r&&(t[e]=i,!0)}onFriendProfileModified(e){this._friendHandler.onFriendProfileModified(e)}getLocalFriendList(e=!0){const t=this._friendHandler.getLocalFriendList();return e?xe(t):t}getFriendRemark(e){return this._friendHandler.getFriendRemark(e)}getFriendList(){return this._friendHandler.pagingGetFriendList()}addFriend(e){return this._friendHandler.addFriend(e)}deleteFriend(e){return this._friendHandler.deleteFriend(e)}checkFriend(e){return this._friendHandler.checkFriend(e)}getFriendProfile(e){return this._friendHandler.getFriendProfile(e)}updateFriend(e){return this._friendHandler.updateFriend(e)}updateWhenAddedToFriendGroup(e){this._friendHandler.updateWhenAddedToFriendGroup(e)}updateWhenRemovedFromFriendGroup(e){this._friendHandler.updateWhenRemovedFromFriendGroup(e)}getLocalFriendApplicationList(){const e=this._friendApplicationHandler.getLocalFriendApplicationList();return xe(e)}deleteFriendApplication(e){return this._friendApplicationHandler.deleteFriendApplication(e)}refuseFriendApplication(e){return this._friendApplicationHandler.refuseFriendApplication(e)}acceptFriendApplication(e){return this._friendApplicationHandler.acceptFriendApplication(e)}setFriendApplicationRead(e){return this._friendApplicationHandler.setFriendApplicationRead(e)}getLocalFriendGroupList(){const e=this._friendGroupHandler.getLocalFriendGroupList();return xe(e)}createFriendGroup(e){return this._friendGroupHandler.createFriendGroup(e)}deleteFriendGroup(e){return this._friendGroupHandler.deleteFriendGroup(e)}addToFriendGroup(e){return this._friendGroupHandler.addToFriendGroup(e)}removeFromFriendGroup(e){return this._friendGroupHandler.removeFromFriendGroup(e)}renameFriendGroup(e){return this._friendGroupHandler.renameFriendGroup(e)}onAddToFriendGroup(e){return this._friendGroupHandler.onAddToFriendGroup(e)}updateWhenFriendAdded(e){this._friendGroupHandler.updateWhenFriendAdded(e)}updateWhenFriendDeleted(e){this._friendGroupHandler.updateWhenFriendDeleted(e)}reset(){we.l(this._n+".reset"),this._friendHandler.reset(),this._friendGroupHandler.reset(),this._friendApplicationHandler.reset()}}export{Tt as default}; | ||
'use strict';const e={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};let t,s;t="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const r=function(){},i=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let n=i.length;for(;n--;)s=i[n],console[s]||(t[s]=r);var o=t;class a{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(){const 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 d={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:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},u={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},l="CHINA",p={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=l){this.CURRENT=d.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GROUP:"group_open_http_svc",GROUP_AVCHATROOM:"group_open_avchatroom_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"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",MESSAGE_SEARCH:"message_search"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}};new a(0,Math.pow(2,0)).toString(),new a(0,Math.pow(2,1)).toString(),new a(0,Math.pow(2,2)).toString(),new a(0,Math.pow(2,3)).toString(),new a(0,Math.pow(2,4)).toString(),new a(0,Math.pow(2,6)).toString(),new a(0,Math.pow(2,7)).toString(),new a(0,Math.pow(2,9)).toString(),new a(0,Math.pow(2,10)).toString(),new a(0,Math.pow(2,11)).toString(),new a(0,Math.pow(2,13)).toString(),new a(0,Math.pow(2,15)).toString(),new a(Math.pow(2,16)).toString();const c="sns";p.HOST.setCurrent(l);const h="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),_="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),M="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,y="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=h||_||f||m||g||y||M,F=("undefined"!=typeof uni||"undefined"!=typeof window)&&!w;_?qq:f?tt:m?swan:g?my:h?wx:y?uni:!M||jd;const T=F&&window&&window.navigator&&window.navigator.userAgent||"",A=/(micromessenger|webbrowser)/i.test(T),I=/AppleWebKit\/([\d.]+)/i.exec(T);I&&parseFloat(I.pop());const D=function(){let e="WEB";return A?e="WEB":_?e="QQ_MP":f?e="TT_MP":m?e="BAIDU_MP":g?e="ALI_MP":h?e="WX_MP":y&&(e="UNI_NATIVE_APP"),u[e]}();!function(){const e=T.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){const e=T.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);t&&s&&parseFloat(e[1]+"."+e[2])}(),function(){const e=T.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}();const L=/MSIE/.test(T)||T.indexOf("Trident")>-1&&T.indexOf("rv:11.0")>-1;!function(){const e=/MSIE\s(\d+)\.\d/.exec(T);let t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(T)&&/rv:11.0/.test(T)&&(t=11)}(),function(){const e=T.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}();const k="C2C",S="AllowType_Type_AllowAny",N="AdminForbid_Type_None",v="Add_Type_Single",b="Add_Type_Both",E="Delete_Type_Single",G="Delete_Type_Both",U="Pendency_Type_Both",C="Pendency_Type_ComeIn",P="Pendency_Type_SendOut",O="Response_Action_Agree",$="Response_Action_AgreeAndAdd",q="CheckResult_Type_Both",R="CheckResult_Type_Single";const x=function(){return(new Date).getTime()+0},H="Tag_Profile_IM_Nick",W="Tag_Profile_IM_Gender",B="Tag_Profile_IM_BirthDay",j="Tag_Profile_IM_Location",K="Tag_Profile_IM_SelfSignature",Y="Tag_Profile_IM_AllowType",J="Tag_Profile_IM_Language",V="Tag_Profile_IM_Image",z="Tag_Profile_IM_MsgSettings",Q="Tag_Profile_IM_AdminForbidType",X="Tag_Profile_IM_Level",Z="Tag_Profile_IM_Role",ee="Tag_SNS_IM_Group",te="Tag_SNS_IM_Remark",se="Tag_SNS_IM_AddSource",re="Tag_SNS_IM_AddWording",ie="Tag_SNS_IM_AddTime",ne={UNKNOWN:"Gender_Type_Unknown",FEMALE:"Gender_Type_Female",MALE:"Gender_Type_Male"},oe={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},ae={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},de=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)},ue=function(e){return"string"==typeof e},le=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===he(e)},pe=function(e){return void 0===e},ce=function(e){return e instanceof Error},he=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()};Date.now||(Date.now=function(){return(new Date).getTime()});const _e=function(e){if(0===e.length)return 0;let t=0,s="",r=0,i=1;const n="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";for(;void 0!==e[t];)s=e[t++],i=s.charCodeAt[t]<=255?1:!1===n?3:2,r+=i;return r},fe=function(e,t){for(const s in e)if(e[s]===t)return!0;return!1};function me(){return!L&&!w}let ge=0;function Me(){return me()?"%c Chat %c":"Chat"}function ye(){const e=function(){const e=new Date;return e.setTime(x()),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 we={arguments2String(e){let t="";if(1===e.length)t=e[0];else for(let i=0,n=e.length;i<n;i++)r=e[i],le(r)||function(e){return null!==e&&"object"==typeof e}(r)?ce(e[i])?t+=(s=e[i],JSON.stringify(s,["message","code"])):t+=JSON.stringify(e[i]):t+=e[i],t+=" ";var s,r;return t},_exec(e,t){me()?o[e](Me(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",ye(),t):o[e](`${Me()} ${ye()} ${t}`)},d:function(){if(ge<=-1){const e=this.arguments2String(arguments);this._exec("debug",e)}},l:function(){if(ge<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},log:function(){if(ge<=0){const e=this.arguments2String(arguments);this._exec("log",e)}},i:function(){if(ge<=1){const e=this.arguments2String(arguments);this._exec("info",e)}},w:function(){if(ge<=2){const e=this.arguments2String(arguments);this._exec("warn",e)}},e:function(){if(ge<=3){const e=this.arguments2String(arguments);this._exec("error",e)}},setLevel:function(e){e<4&&this._exec("log","set level from "+ge+" to "+e),ge=e},getLevel:function(){return ge}},Fe=Object.prototype.hasOwnProperty;function Te(e){if(null==e)return!0;if("boolean"==typeof e)return!1;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(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s}(e)){for(const t in e)if(Fe.call(e,t))return!1;return!0}return!("map"!==he(e)&&!function(e){return"set"===he(e)}(e)&&!function(e){return"file"===he(e)}(e))&&0===e.size}class Ae{constructor(e){Te(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",this.time=e.time||0,this.source=e.source||"",this.wording=e.wording||"",this.type=e.type||"")}}const Ie=function(e){return{code:0,data:e||{}}};class De extends Error{constructor(e){super();const{code:t,message:s,data:r}=e;this.code=t,this.message=s||this._getErrorMessage(this.code),this.data=r||{}}}const Le=2700,ke=2701,Se=2710,Ne=2711,ve=2716,be=2805,Ee=2903,Ge=3122,Ue=3123,Ce="onMessageModified",Pe="onFriendListUpdated",Oe="onFriendGroupListUpdated",$e="onFriendApplicationListUpdated",qe="error";let Re=null;const xe=function(e){return Promise.resolve(Ie(e))},He=function(e,t=!1){if(e instanceof De)return t&&null!==Re&&Re.emit(qe,e),Promise.reject(e);if(e instanceof Error){const e=new De({code:Ee});return t&&null!==Re&&Re.emit(qe,e),Promise.reject(e)}if(pe(e)||pe(e.code))return Promise.reject(new De({code:Ee}));const s=new De(e);return t&&null!==Re&&Re.emit(qe,s),Promise.reject(s)},We="friend_get",Be="friend_get_specified",je="friend_check",Ke="friend_delete",Ye="friend_add",Je="friend_update",Ve="friend_response",ze="pendency_get",Qe="pendency_delete",Xe="pendency_report",Ze="group_get",et="group_add",st="group_delete",rt="group_update",it={info:4,warning:5,error:6},nt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},ot={login:4};class at{constructor(e){this._n="SSOLogData",this.eventType=ot[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=x()}static bindEventStatModule(e){at.prototype._eventStatModule=e}updateTimeStamp(){this.timestamp=x()}start(e){return this._startts=e,this}end(e=!1){if(this._sentFlag)return;const t=x();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,t,s){if(!(e instanceof Error))return we.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;if(this.setNetworkType(s),t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=be;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return pe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),de(e)?this.code=e:we.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return pe(e)||this._sentFlag||(de(e)&&(this.message=e.toString()),ue(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return pe(e)||this._sentFlag||(this.level=it[e]),this}setMoreMessage(e){return Te(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){if(pe(e))we.w(this._n+".setNetworkType value is undefined, please check!");else{const t=nt[e.toLowerCase()];pe(t)||(this.networkType=t)}return this}getStartTs(){return this._startts}setUIPlatform(e){this.uiPlatform=e}}class dt{constructor(e){this._snsModule=e,this._n="FriendApplicationHandler",this._startTime=0,this._maxLimited=100,this._currentSequence=0,this._friendApplicationMap=new Map,this._unreadCount=0}getLocalFriendApplicationList(){return{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}}_onFriendApplicationListUpdated(){this._snsModule.emitOuterEvent($e,{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount})}onFriendApplicationRead(){this._unreadCount=0,this._onFriendApplicationListUpdated()}onFriendApplicationAdded(e,t){if(Te(e))return;let s="";s=t===this._snsModule.getMyUserID()?P:C;let r=!1;e.forEach(e=>{const t=`${e.userID}_${s}`;s!==C||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,new Ae({...e,type:s})),r=!0}),r&&this._onFriendApplicationListUpdated()}onFriendApplicationDeleted(e){Te(e)||(this._startTime=0,this._currentSequence=0,this.getFriendApplicationList())}getFriendApplicationList(){const e=this._n+".getFriendApplicationList",t=new at("getFriendApplicationList");return this._snsModule.request({protocolName:ze,requestData:{applicationType:U,fromAccount:this._snsModule.getMyUserID(),maxLimited:this._maxLimited,startTime:this._startTime,lastSequence:this._currentSequence}}).then(s=>{const{resultList:r,unreadCount:i,startTime:n,currentSequence:o}=s.data;this._startTime=n,this._currentSequence=o,this._unreadCount=i;const a=`applicationCount:${le(r)?r.length:0} unreadCount:${i} startTime:${n} currentSequence:${o}`;t.setNetworkType(this._snsModule.getNetworkType()).setMessage(a).end(),we.i(`${e} ok. ${a}`),this._friendApplicationMap.clear(),le(r)&&r.forEach(e=>{const{userID:t,type:s}=e,r=new Ae(e);this._friendApplicationMap.set(`${t}_${s}`,r)}),this._onFriendApplicationListUpdated()}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" failed. error:",s),He(s)))}deleteFriendApplication(e){const t=this._n+".deleteFriendApplication",{userID:s,type:r}=e;let i=r;if((!i||i!==P&&i!==C)&&(i=C),!this._friendApplicationMap.has(`${s}_${i}`))return He({code:ve});const n=new at("deleteFriendApplication");n.setMessage(`userID:${s} type:${i}`);return this._snsModule.request({protocolName:Qe,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:[s],type:i}}).then(e=>{const{resultList:r}=e.data,{to:o,resultCode:a,resultInfo:d}=r[0];return n.setNetworkType(this._snsModule.getNetworkType()).setMoreMessage("resultList:"+JSON.stringify(r)).end(),we.i(`${t} ok. userID:${s} type:${i}`),0===a?Ie():He({userID:o,code:a,message:d})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}acceptFriendApplication(e){const t=this._n+".acceptFriendApplication",{userID:s,remark:r,tag:i,type:n}=e;let o=n;(!o||o!==O&&o!==$)&&(o=$);const a=new at("acceptFriendApplication");a.setMessage(`userID:${s} type:${o}`);return this._snsModule.request({protocolName:Ve,requestData:{fromAccount:this._snsModule.getMyUserID(),responseFriendItem:[{userID:s,remark:r,tag:i,action:o}]}}).then(e=>{a.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:r}=e.data,{resultCode:i,resultInfo:n}=r[0];if(0!==i)return He({code:i,message:n});we.i(`${t} ok. userID:${s} type:${o}`)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}refuseFriendApplication(e){const t=this._n+".refuseFriendApplication",{userID:s}=e,r=new at("refuseFriendApplication");r.setMessage("userID:"+s);return this._snsModule.request({protocolName:Ve,requestData:{fromAccount:this._snsModule.getMyUserID(),responseFriendItem:[{userID:s,action:"Response_Action_Reject"}]}}).then(e=>{r.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:i}=e.data,{resultCode:n,resultInfo:o}=i[0];if(0!==n)return He({code:n,message:o});we.i(`${t} ok. userID:${s}`)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}_onFriendApplicationProcessed(e){if(0===e.length)return;let t=!1;e.forEach(e=>{const s=`${e.to}_${C}`;this._friendApplicationMap.has(s)&&(this._friendApplicationMap.delete(s),this._unreadCount-=1,t=!0)}),this._unreadCount<0&&(this._unreadCount=0),t&&this._onFriendApplicationListUpdated()}setFriendApplicationRead(){const e=this._n+".setFriendApplicationRead",t=new at("setFriendApplicationRead");var s,r;return this._snsModule.request({protocolName:Xe,requestData:{fromAccount:this._snsModule.getMyUserID(),latestTimeStamp:(s=x()/1e3,r=0,Math.round(Number(s)*Math.pow(10,r))/Math.pow(10,r))}}).then(s=>{t.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(e+" ok"),this._unreadCount=0}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" failed. error:",s),He(s)))}reset(){this._startIndex=0,this._maxLimited=100,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}}class ut{constructor(e){Te(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.gender=e.gender||"",this.birthday=e.birthday||0,this.location=e.location||"",this.selfSignature=e.selfSignature||"",this.allowType=e.allowType||S,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||N,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Te(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(e){let t=!0,s="";if(Te(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){const t=e.profileCustomField.length;let s=null;for(let r=0;r<t;r++){if(s=e.profileCustomField[r],!ue(s.key)||-1===s.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!ue(s.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if("profileCustomField"===r)continue;if(Te(e[r])&&!ue(e[r])&&!de(e[r])){s="key:"+r+", invalid value:"+e[r],t=!1;continue}switch(r){case"nick":ue(e[r])||(s="nick must be a string",t=!1),_e(e[r])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${_e(e[r])} bytes`,t=!1);break;case"gender":fe(ne,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":de(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":ue(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":ue(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":fe(ae,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":de(e.language)||(s="language must be a number",t=!1);break;case"avatar":ue(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":fe(oe,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":de(e.level)||(s="level must be a number",t=!1);break;case"role":de(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:s}}}class lt{constructor(e,t){this.userID=e,this.remark="",this.groupList=[],this.source="",this.addTime=0,this.friendCustomField=[],this.timestamp=0;const s={},r=[];if(s.userID=e,!Te(t)){let e="",i="";for(let n=0,o=t.length;n<o;n++)if(e=t[n].tag,i=t[n].value,e.indexOf("Tag_SNS_Custom")>-1)this.friendCustomField.push({key:e,value:i});else if(e.indexOf("Tag_Profile_Custom")>-1)r.push({key:e,value:i});else switch(e){case H:s.nick=i;break;case W:s.gender=i;break;case B:s.birthday=i;break;case j:s.location=i;break;case K:s.selfSignature=i;break;case Y:s.allowType=i;break;case J:s.language=i;break;case V:s.avatar=i;break;case z:s.messageSettings=i;break;case Q:s.adminForbidType=i;break;case X:s.level=i;break;case Z:s.role=i;break;case te:this.remark=i;break;case ie:this.addTime=i;break;case ee:this.groupList=JSON.parse(JSON.stringify(i));break;case se:this.source=i;break;case re:break;default:we.l("snsProfileItem unknown tag->",t[n].tag)}}this.profile=new ut({...s,profileCustomField:r})}validate(e){let t=!0,s="";if(Te(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){const t=e.profileCustomField.length;let s=null;for(let r=0;r<t;r++){if(s=e.profileCustomField[r],!ue(s.key)||-1===s.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!ue(s.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if("profileCustomField"===r)continue;if(Te(e[r])&&!ue(e[r])&&!de(e[r])){s="key:"+r+", invalid value:"+e[r],t=!1;continue}switch(r){case"nick":ue(e[r])||(s="nick must be a string",t=!1),_e(e[r])>500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${_e(e[r])} bytes`,t=!1);break;case"gender":fe(ne,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":de(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":ue(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":ue(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":fe(ae,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":de(e.language)||(s="language must be a number",t=!1);break;case"avatar":ue(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":fe(oe,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":de(e.level)||(s="level must be a number",t=!1);break;case"role":de(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:s}}update(e){let t="",s="";const r=[];this.friendCustomField.forEach(e=>{r.push(e.key)});for(let i=0,n=e.length;i<n;i++)if(t=e[i].tag,s=e[i].value,t.indexOf("Tag_SNS_Custom")>-1)r.indexOf(t)>-1?this.friendCustomField.forEach(e=>{e.key===t&&(e.value=s)}):this.friendCustomField.push({key:t,value:s});else if(t.indexOf("Tag_Profile_Custom")>-1){let e=!1;this.profile.profileCustomField.forEach(r=>{r.key===t&&(r.value=s,e=!0)}),e||this.profile.profileCustomField.push({key:t,value:s})}else switch(t){case H:this.profile.nick=s;break;case W:this.profile.gender=s;break;case B:this.profile.birthday=s;break;case j:this.profile.location=s;break;case K:this.profile.selfSignature=s;break;case Y:this.profile.allowType=s;break;case J:this.profile.language=s;break;case V:this.profile.avatar=s;break;case z:this.profile.messageSettings=s;break;case Q:this.profile.adminForbidType=s;break;case X:this.profile.level=s;break;case Z:this.profile.role=s;break;case te:this.remark=s;break;case ie:this.addTime=s;break;case ee:this.groupList=JSON.parse(JSON.stringify(s));break;case se:this.source=s;break;case re:break;default:we.d("snsProfileItem unkown tag->",e[i].tag)}this.timestamp=Date.now(),r.length=0}updateProfile(e){this.profile=JSON.parse(JSON.stringify(e)),this.timestamp=Date.now()}addToGroupList(e){-1===this.groupList.indexOf(e)&&(this.groupList.push(e),this.count=this.groupList.length)}removeFromGroupList(e){const t=this.groupList.indexOf(e);t>-1&&(this.groupList.splice(t,1),this.count=this.groupList.length)}}const pt=4,ct=11,ht=12,_t=15,ft=20,mt=23,gt=27,Mt=29;class yt{constructor(e){this._snsModule=e,this._n="FriendHandler",this._friendMap=new Map,this._startIndex=0,this._standardSequence=0,this._customSequence=0,this._expirationTime=18e4}getLocalFriendList(){return[...this._friendMap.values()]}getFriendRemark(e){return this._friendMap.has(e)?this._friendMap.get(e).remark:""}onFriendProfileModified(e){const{dataList:t}=e;if(Te(t))return;const s=this._snsModule.getModule(ct);t.forEach(e=>{const{userID:t,profileList:r}=e;if(this.isMyFriend(t)){we.l(`${this._n}.onFriendProfileModified. friend account:${t}, profileList:${JSON.stringify(r)}`);const e=this._friendMap.get(t);e.update(r),s.modifyMessageSentByPeer({conversationID:`${k}${t}`,latestNick:e.profile.nick,latestAvatar:e.profile.avatar})}}),this._onFriendListUpdated()}onFriendAdded(e){0!==e.length&&(we.l(`${this._n}.onFriendAdded userIDList:${e}`),e.forEach(e=>{this._friendMap.set(e,new lt(e))}),this.getFriendProfile({userIDList:e}).then(t=>{e.forEach(e=>{const t=this._friendMap.get(e);t.groupList.length>0&&this._snsModule.updateWhenFriendAdded({nameList:t.groupList,userID:e})}),this._onFriendListUpdated()}))}onFriendDeleted(e){0!==e.length&&(we.l(`${this._n}.onFriendDeleted userIDList:${e}`),e.forEach(e=>{const t=this._friendMap.get(e);t.groupList.length>0&&this._snsModule.updateWhenFriendDeleted({nameList:t.groupList,userID:e}),this._friendMap.delete(e)}),this._onFriendListUpdated())}_onFriendListUpdated(){this._snsModule.emitOuterEvent(Pe);this._snsModule.getModule(ct).checkAndPatchRemark()}getFriendProfile(e){const t=this._n+".getFriendProfile",{userIDList:s}=e,r=[],i=[],n=[];if(s.forEach(e=>{if(this._friendMap.has(e)){const t=this._friendMap.get(e);Date.now()-t.timestamp<this._expirationTime?i.push(t):n.push(e)}else r.push({userID:e,code:Le,message:this._snsModule.getErrorMessage(Le)})}),0===n.length)return we.i(t+" newUserIDList is empty"),xe({friendList:i,failureUserIDList:r});const o=new at("getFriendProfile");o.setMessage("userIDList:"+n),we.i(`${t} userIDList:${n}`);return this._snsModule.request({protocolName:Be,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:n}}).then(e=>{o.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(t+" ok");const{resultList:s}=e.data;return s.forEach(e=>{const{to:t,resultCode:s,resultInfo:n,tagValueList:o}=e;if(pe(s)||0===s){let e;this._friendMap.has(t)?(e=this._friendMap.get(t),e.update(o)):(e=new lt(t,o),this._friendMap.set(t,e)),i.push(e)}else r.push({userID:t,code:s,message:n})}),Ie({friendList:i,failureUserIDList:r})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}isMyFriend(e){return this._friendMap.has(e)}pagingGetFriendList(){const e=this._n+".getFriendList",t=new at("getFriendList"),s=Date.now();this._snsModule.request({protocolName:We,requestData:{fromAccount:this._snsModule.getMyUserID(),startIndex:this._startIndex,standardSequence:this._standardSequence,customSequence:this._customSequence}}).then(r=>{const{friendCount:i,resultList:n,nextStartIndex:o,standardSequence:a,customSequence:d,completeFlag:u}=r.data;this._startIndex=o,this._standardSequence=a,this._customSequence=d;const l=`friendCount:${i} nextStartIndex:${o} standardSequence:${a} customSequence:${d} completeFlag:${u} cost ${Date.now()-s} ms`;t.setNetworkType(this._snsModule.getNetworkType()).setMessage(l).end(),we.i(e+" ok.",l),Te(n)||n.forEach(e=>{const{to:t,tagValueList:s}=e;this._friendMap.set(t,new lt(t,s))}),0===u?this.pagingGetFriendList():(this._snsModule.emitOuterEvent(Pe),this._pagingGetFriendProfile())}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" failed. error:",s),He(s)))}_pagingGetFriendProfile(){const e=[...this._friendMap.keys()],t=this._snsModule.getModule(pt),s=e.length,r=s<=100?1:Math.ceil(s/100);we.l(`${this._n}._pagingGetFriendProfile friendCount:${s} pageCount:${r}`);for(let i=0;i<r;i++)t.getUserProfile({userIDList:e.slice(100*i,100*(i+1))}).then(e=>{e.data.forEach(e=>{const t=this._friendMap.get(e.userID);t&&t.updateProfile(e)}),this._onFriendListUpdated()})}addFriend(e){const t=this._n+".addFriend";if(this._friendMap.has(e.to))return He({code:ke});if(e.wording&&!1===this._snsModule.filterProfanity("wording",e))return He({code:Ue});const{to:s,source:r,type:i,wording:n,remark:o,groupName:a}=e;let d=i;(!d||d!==v&&d!==b)&&(d=b);const u=new at("addFriend");u.setMessage(`to:${s} source:${r} type:${d}`);return this._snsModule.request({protocolName:Ye,requestData:{fromAccount:this._snsModule.getMyUserID(),addFriendItem:[{to:s,source:r,wording:n,remark:o,groupName:a}],type:d}}).then(e=>{const{resultList:s}=e.data;u.setNetworkType(this._snsModule.getNetworkType()).setMoreMessage("resultList:"+JSON.stringify(s)).end();const{to:r,resultCode:i,resultInfo:n}=s[0];return we.i(`${t} ok. to:${r} type:${d} code:${i}`),pe(i)||0===i?Ie({userID:r,code:0}):30539===i?Ie({userID:r,code:i,message:this._snsModule.getErrorMessage(i)}):He({userID:r,code:i,message:this._snsModule.getErrorMessage(i)||n})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}deleteFriend(e){const t=this._n+".deleteFriend",{userIDList:s,type:r}=e;var i;s.length>1e3&&(we.w(`${t} ${i=1e3,"the length of userIDList cannot exceed "+i}`),s.length=1e3);const n=[],o=[],a=[];if(s.forEach(e=>{this._friendMap.has(e)?a.push(e):n.push({userID:e,code:Le,message:this._snsModule.getErrorMessage(Le)})}),0===a.length)return xe({successUserIDList:o,failureUserIDList:n});let d=r;(!d||d!==E&&d!==G)&&(d=G);const u=new at("deleteFriend");u.setMessage(`userIDList:${a} type:${d}`);return this._snsModule.request({protocolName:Ke,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:a,type:d}}).then(e=>{u.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(t+" ok");const{resultList:s}=e.data;return Te(s)||s.forEach(e=>{const{to:t,resultCode:s,resultInfo:r}=e;pe(s)||0===s?o.push({userID:t}):n.push({userID:t,code:s,message:r})}),Ie({successUserIDList:o,failureUserIDList:n})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),we.w(t+" error:",e),He(e)))}updateFriend(e){const{userID:t,remark:s,friendCustomField:r}=e;if(!this._friendMap.has(t))return He({code:Le});const i=this._n+".updateFriend",n=new at("updateFriend");n.setMessage(`userID:${t} remark:${s} friendCustomField:${r}`);const o=[];pe(s)||o.push({tag:te,value:s}),le(r)&&r.length>0&&r.forEach(e=>{o.push({tag:e.key,value:e.value})});return this._snsModule.request({protocolName:Je,requestData:{fromAccount:this._snsModule.getMyUserID(),updateItem:[{to:t,snsItem:o}]}}).then(e=>{n.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(i+" ok");const{resultList:t}=e.data,{to:o,resultCode:a,resultInfo:d}=t[0];if(pe(a)||0===a){const e=this._friendMap.get(o);return e&&(pe(s)||(e.remark=s),le(r)&&r.length>0&&function(e,t){if(!le(e)||!le(t))return!1;let s=!1;t.forEach(({key:t,value:r})=>{const i=e.find(e=>e.key===t);i?i.value!==r&&(i.value=r,s=!0):(e.push({key:t,value:r}),s=!0)})}(e.friendCustomField,r),this._onFriendListUpdated()),Ie(e)}return He({code:a,message:d})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),we.w(i+" failed. error:",e),He(e)))}checkFriend(e){const t=this._n+".checkFriend",{userIDList:s,type:r}=e;let i=r;(!i||i!==R&&i!==q)&&(i=q);const n=new at("checkFriend");n.setMessage(`userIDList:${s} type:${i}`);return this._snsModule.request({protocolName:je,requestData:{fromAccount:this._snsModule.getMyUserID(),userIDList:s,type:i}}).then(e=>{n.setNetworkType(this._snsModule.getNetworkType()).end(),we.i(`${t} ok. userIDList:${s} type:${i}`);const r=[],o=[],{resultList:a}=e.data;return le(a)&&a.forEach(e=>{const{to:t,relation:s,resultCode:i,resultInfo:n}=e;pe(i)||0===i?r.push({userID:t,code:0,relation:s}):o.push({userID:t,code:i,message:n})}),Ie({successUserIDList:r,failureUserIDList:o})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}updateWhenAddedToFriendGroup(e){const{name:t,userIDList:s}=e;we.l(`${this._n}.updateWhenAddedToFriendGroup groupName:${t} userIDList:${s}`),t&&!Te(s)&&s.forEach(e=>{if(this._friendMap.has(e)){this._friendMap.get(e).addToGroupList(t)}})}updateWhenRemovedFromFriendGroup(e){const{name:t,userIDList:s}=e;we.l(`${this._n}.updateWhenRemovedFromFriendGroup groupName:${t} userIDList:${s}`),t&&!Te(s)&&s.forEach(e=>{if(this._friendMap.has(e)){this._friendMap.get(e).removeFromGroupList(t)}})}reset(){this._friendMap.clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}}class wt{constructor(e){Te(e)||(this.name=e.name||"",this.userIDList=e.userIDList||[],this.count=this.userIDList.length||0)}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}class Ft{constructor(e){this._snsModule=e,this._n="FriendGroupHandler",this._friendGroupMap=new Map}getLocalFriendGroupList(){return[...this._friendGroupMap.values()]}_emitFriendGroupListUpdated(){const e=[...this._friendGroupMap.values()];this._snsModule.emitOuterEvent(Oe,e)}getFriendGroupList(){const e=this._n+".getFriendGroupList",t=new at("getFriendGroupList");return this._snsModule.request({protocolName:Ze,requestData:{fromAccount:this._snsModule.getMyUserID()}}).then(s=>{t.setNetworkType(this._snsModule.getNetworkType()).end();const{resultList:r}=s.data;Te(r)?we.i(e+" ok. friend group count:0"):(we.i(`${e} ok. friend group count:${r.length}`),this._friendGroupMap.clear(),r.forEach(e=>{const t=new wt(e);this._friendGroupMap.set(e.name,t)}),this._emitFriendGroupListUpdated())}).catch(s=>(this._snsModule.probeNetwork().then(([e,r])=>{t.setError(s,e,r).end()}),we.w(e+" error:",s),He(s)))}createFriendGroup(e){const t=this._n+".createFriendGroup",{name:s,userIDList:r}=e;if(this._friendGroupMap.has(s))return He({code:Se});const i=new at("createFriendGroup");return i.setMessage(`name:${s} userIDList:${r}`),this._snsModule.request({protocolName:et,requestData:{fromAccount:this._snsModule.getMyUserID(),groupName:[s],userIDList:le(r)?r:void 0}}).then(e=>{i.setNetworkType(this._snsModule.getNetworkType()).end(),we.l(`${t} ok. name:${s} userIDList:${r}`);const{resultList:n}=e.data,o=[],a=[];n&&n.forEach(e=>{const{to:t,resultCode:s,resultInfo:r}=e;if(pe(s)||0===s)o.push(t);else{const t={userID:e.to,code:s,message:r};a.push(t)}});const d=new wt({name:s,userIDList:o});return this._friendGroupMap.set(s,d),this._snsModule.updateWhenAddedToFriendGroup({name:s,userIDList:o}),this._emitFriendGroupListUpdated(),Ie({friendGroup:d,failureUserIDList:a})}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}deleteFriendGroup(e){const t=this._n+".deleteFriendGroup",{name:s}=e;if(!this._friendGroupMap.has(s))return He({code:Ne});const r=new at("deleteFriendGroup");r.setMessage("name:"+s);return this._snsModule.request({protocolName:st,requestData:{fromAccount:this._snsModule.getMyUserID(),nameList:[s]}}).then(e=>{r.setNetworkType(this._snsModule.getNetworkType()).end(),we.l(`${t} ok. name:${s}`);const i=this._friendGroupMap.get(s);return i&&(this._snsModule.updateWhenRemovedFromFriendGroup({name:s,userIDList:i.userIDList}),this._friendGroupMap.delete(s),i.userIDList.length=0),this._emitFriendGroupListUpdated(),Ie(i)}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}renameFriendGroup(e){const t=this._n+".renameFriendGroup",{oldName:s,newName:r}=e;if(!this._friendGroupMap.has(s))return He({code:Ne});const i=new at("renameFriendGroup");i.setMessage(`oldName:${s} newName:${r}`);return this._snsModule.request({protocolName:rt,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,newName:r}}).then(()=>{if(i.setNetworkType(this._snsModule.getNetworkType()).end(),we.l(`${t} ok. oldName:${s} newName:${r}`),this._friendGroupMap.has(s)){const e=this._friendGroupMap.get(s);return e.name=r,this._friendGroupMap.delete(s),this._friendGroupMap.set(r,e),this._snsModule.updateWhenRemovedFromFriendGroup({name:s,userIDList:e.userIDList}),this._snsModule.updateWhenAddedToFriendGroup({name:r,userIDList:e.userIDList}),this._emitFriendGroupListUpdated(),Ie(e)}return Ie()}).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}addToFriendGroup(e){const t=this._n+".addToFriendGroup",{name:s,userIDList:r}=e;if(!this._friendGroupMap.has(s))return this._onFriendGroupNotExist(s);const i=new at("addToFriendGroup");i.setMessage(`name:${s} userIDList:${r}`),we.l(`${t} name:${s} userIDList:${r}`);return this._snsModule.request({protocolName:rt,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,updateGroupItem:r.filter(e=>this._snsModule.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Add"}))}}).then(e=>(i.setNetworkType(this._snsModule.getNetworkType()).end(),this._onFriendGroupUpdated(s,e))).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}removeFromFriendGroup(e){const t=this._n+".removeFromFriendGroup",{name:s,userIDList:r}=e;if(!this._friendGroupMap.has(s))return this._onFriendGroupNotExist(s);const i=new at("removeFromFriendGroup");i.setMessage(`name:${s} userIDList:${r}`),we.l(`${t} name:${s} userIDList:${r}`);return this._snsModule.request({protocolName:rt,requestData:{fromAccount:this._snsModule.getMyUserID(),oldName:s,updateGroupItem:r.filter(e=>this._snsModule.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Delete"}))}}).then(e=>(i.setNetworkType(this._snsModule.getNetworkType()).end(),this._onFriendGroupUpdated(s,e))).catch(e=>(this._snsModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),we.w(t+" failed. error:",e),He(e)))}_onFriendGroupUpdated(e,t){const{resultList:s}=t.data,r=this._friendGroupMap.get(e),i=[],n=[],o=[];return le(s)&&s.forEach(e=>{const{to:t,resultCode:s,resultInfo:a,type:d}=e;0===s?"Update_Type_Add"===d?r&&(r.addToUserIDList(t),n.push(t)):"Update_Type_Delete"===d&&r&&(r.removeFromUserIDList(t),o.push(t)):i.push({to:e.to,code:s,message:a})}),we.l(`${this._n}._onFriendGroupUpdated name:${e} userIDList:${r.userIDList}`),n.length>0&&this._snsModule.updateWhenAddedToFriendGroup({name:e,userIDList:n}),o.length>0&&this._snsModule.updateWhenRemovedFromFriendGroup({name:e,userIDList:o}),Ie({friendGroup:r,failureUserIDList:i})}updateWhenFriendAdded(e){const{nameList:t,userID:s}=e;we.l(`${this._n}.updateWhenFriendAdded userID:${s} nameList:${t}`),Te(t)||t.forEach(e=>{if(this._friendGroupMap.has(e)){this._friendGroupMap.get(e).addToUserIDList(s)}})}updateWhenFriendDeleted(e){const{nameList:t,userID:s}=e;we.l(`${this._n}.updateWhenFriendDeleted userID:${s} nameList:${t}`),Te(t)||t.forEach(e=>{if(this._friendGroupMap.has(e)){this._friendGroupMap.get(e).removeFromUserIDList(s)}})}reset(){this._friendGroupMap.clear()}}class Tt extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.getModule(ht).isLoggedIn()}isOversea(){return this._m.getModule(ht).isOversea()}isPrivateNetWork(){return this._m.getModule(ht).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(ht).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(ht).getUserID()}getMyTinyID(){return this._m.getModule(ht).getTinyID()}getSDKAppID(){return this._m.getModule(ht).getSDKAppID()}isIntl(){return this._m.getModule(ht).isIntl()}isDevMode(){return this._m.getModule(ht).isDevMode()}getModule(e){return this._m.getModule(e)}getPlatform(){return D}getNetworkType(){return this._m.getModule(_t).getNetworkType()}probeNetwork(e){return this._m.getModule(_t).probe(e)}getCloudConfig(e){return this._m.getModule(mt).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.getModule(ht).getTinyID()+"-"+e.random}filterModifiedMessage(e){if(Te(e))return;const t=e.filter(e=>!0===e.isModified);t.length>0&&this.emitOuterEvent(Ce,t)}filterUnmodifiedMessage(e){if(Te(e))return[];return e.filter(e=>!1===e.isModified)}request(e){return this._m.getModule(ft).request(e)}canIUse(e){return this._m.getModule(gt).canIUse(e)}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}outputWarning(e,t,s){const r=this.getErrorMessage(e,t,s);r&&we.w(r)}cannotUseCommercialAbility(e){const t=Ge;return He({code:t,message:this.getErrorMessage(t,e)})}}{constructor(t){super(t),this._n="SnsModule",this._friendHandler=new yt(this),this._friendApplicationHandler=new dt(this),this._friendGroupHandler=new Ft(this);this.getInnerEmitterInstance().on(e.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._friendHandler.pagingGetFriendList(),this._friendGroupHandler.getFriendGroupList(),this._friendApplicationHandler.getFriendApplicationList()}onRelationChainModified(e){const{dataList:t}=e;if(Te(t))return;const s=[],r=[],i=[],n=[];let o=!1,a="";t.forEach(e=>{if(3!==e.pushType&&4!==e.pushType||!e.from||(a=e.from),e.friendAddAccount&&(s.push(...e.friendAddAccount),n.push(...e.friendAddAccount)),e.friendDelAccount&&r.push(...e.friendDelAccount),e.friendApplicationAdded&&i.push(...e.friendApplicationAdded),e.friendApplicationDeletedUserIDList&&n.push(...e.friendApplicationDeletedUserIDList),e.reportTime&&7===e.pushType&&(o=!0),e.friendUpInfo){const t={dataList:[]};e.friendUpInfo.forEach(e=>{t.dataList.push({userID:e.friendAccount,profileList:[...e.sns]})}),this.onFriendProfileModified(t)}}),o&&this._friendApplicationHandler.onFriendApplicationRead(),this._friendApplicationHandler.onFriendApplicationAdded(i,a),this._friendApplicationHandler.onFriendApplicationDeleted(n),this._friendHandler.onFriendAdded(s),this._friendHandler.onFriendDeleted(r)}isMyFriend(e){return this._friendHandler.isMyFriend(e)}filterProfanity(e,t){const s=this.getModule(Mt);if(!s)return!0;const{isAllowedToSend:r,modifiedText:i}=s.filterText(t[e],c);return!0===r&&(t[e]=i,!0)}onFriendProfileModified(e){this._friendHandler.onFriendProfileModified(e)}getLocalFriendList(e=!0){const t=this._friendHandler.getLocalFriendList();return e?xe(t):t}getFriendRemark(e){return this._friendHandler.getFriendRemark(e)}getFriendList(){return this._friendHandler.pagingGetFriendList()}addFriend(e){return this._friendHandler.addFriend(e)}deleteFriend(e){return this._friendHandler.deleteFriend(e)}checkFriend(e){return this._friendHandler.checkFriend(e)}getFriendProfile(e){return this._friendHandler.getFriendProfile(e)}updateFriend(e){return this._friendHandler.updateFriend(e)}updateWhenAddedToFriendGroup(e){this._friendHandler.updateWhenAddedToFriendGroup(e)}updateWhenRemovedFromFriendGroup(e){this._friendHandler.updateWhenRemovedFromFriendGroup(e)}getLocalFriendApplicationList(){const e=this._friendApplicationHandler.getLocalFriendApplicationList();return xe(e)}deleteFriendApplication(e){return this._friendApplicationHandler.deleteFriendApplication(e)}refuseFriendApplication(e){return this._friendApplicationHandler.refuseFriendApplication(e)}acceptFriendApplication(e){return this._friendApplicationHandler.acceptFriendApplication(e)}setFriendApplicationRead(e){return this._friendApplicationHandler.setFriendApplicationRead(e)}getLocalFriendGroupList(){const e=this._friendGroupHandler.getLocalFriendGroupList();return xe(e)}createFriendGroup(e){return this._friendGroupHandler.createFriendGroup(e)}deleteFriendGroup(e){return this._friendGroupHandler.deleteFriendGroup(e)}addToFriendGroup(e){return this._friendGroupHandler.addToFriendGroup(e)}removeFromFriendGroup(e){return this._friendGroupHandler.removeFromFriendGroup(e)}renameFriendGroup(e){return this._friendGroupHandler.renameFriendGroup(e)}onAddToFriendGroup(e){return this._friendGroupHandler.onAddToFriendGroup(e)}updateWhenFriendAdded(e){this._friendGroupHandler.updateWhenFriendAdded(e)}updateWhenFriendDeleted(e){this._friendGroupHandler.updateWhenFriendDeleted(e)}reset(){we.l(this._n+".reset"),this._friendHandler.reset(),this._friendGroupHandler.reset(),this._friendApplicationHandler.reset()}}export{Tt as default}; |
@@ -1,1 +0,1 @@ | ||
'use strict';var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,i,o,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var r=new s(i,o||t,a),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],r]:t._events[l].push(r):(t._events[l]=r,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function r(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),r.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},r.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,o=i.length,a=new Array(o);s<o;s++)a[s]=i[s].fn;return a},r.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},r.prototype.emit=function(t,e,i,s,o,a){var r=n?n+t:t;if(!this._events[r])return!1;var l,g,c=this._events[r],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,s),!0;case 5:return c.fn.call(c.context,e,i,s,o),!0;case 6:return c.fn.call(c.context,e,i,s,o,a),!0}for(g=1,l=new Array(u-1);g<u;g++)l[g-1]=arguments[g];c.fn.apply(c.context,l)}else{var h,d=c.length;for(g=0;g<d;g++)switch(c[g].once&&this.removeListener(t,c[g].fn,void 0,!0),u){case 1:c[g].fn.call(c[g].context);break;case 2:c[g].fn.call(c[g].context,e);break;case 3:c[g].fn.call(c[g].context,e,i);break;case 4:c[g].fn.call(c[g].context,e,i,s);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c[g].fn.apply(c[g].context,l)}}return!0},r.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},r.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},r.prototype.removeListener=function(t,e,i,s){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var r=this._events[o];if(r.fn)r.fn!==e||s&&!r.once||i&&r.context!==i||a(this,o);else{for(var l=0,g=[],c=r.length;l<c;l++)(r[l].fn!==e||s&&!r[l].once||i&&r[l].context!==i)&&g.push(r[l]);g.length?this._events[o]=1===g.length?g[0]:g:a(this,o)}return this},r.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=n,r.EventEmitter=r,t.exports=r}));const e=2,n=11,i=12,s=15,o=20,a=23,r=27,l="onMessageModified",g="error";class c{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&(this.low===t.low&&this.high===t.high)}toString(){const t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"}}},h={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},d="CHINA",_={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=d){this.CURRENT=u.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GROUP:"group_open_http_svc",GROUP_AVCHATROOM:"group_open_avchatroom_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"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",MESSAGE_SEARCH:"message_search"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}};new c(0,Math.pow(2,0)).toString(),new c(0,Math.pow(2,1)).toString(),new c(0,Math.pow(2,2)).toString(),new c(0,Math.pow(2,3)).toString(),new c(0,Math.pow(2,4)).toString(),new c(0,Math.pow(2,6)).toString(),new c(0,Math.pow(2,7)).toString(),new c(0,Math.pow(2,9)).toString(),new c(0,Math.pow(2,10)).toString(),new c(0,Math.pow(2,11)).toString(),new c(0,Math.pow(2,13)).toString(),new c(0,Math.pow(2,15)).toString(),new c(Math.pow(2,16)).toString(),_.HOST.setCurrent(d);const m="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),I="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),v="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),p="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,M="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,S=m||I||f||v||p||M||D,y=("undefined"!=typeof uni||"undefined"!=typeof window)&&!S;I?qq:f?tt:v?swan:p?my:m?wx:M?uni:!D||jd;const w=y&&window&&window.navigator&&window.navigator.userAgent||"",C=/(micromessenger|webbrowser)/i.test(w),T=/AppleWebKit\/([\d.]+)/i.exec(w);T&&parseFloat(T.pop());const E=function(){let t="WEB";return C?t="WEB":I?t="QQ_MP":f?t="TT_MP":v?t="BAIDU_MP":p?t="ALI_MP":m?t="WX_MP":M&&(t="UNI_NATIVE_APP"),h[t]}();!function(){const t=w.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){const t=w.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const e=t[1]&&parseFloat(t[1]),n=t[2]&&parseFloat(t[2]);e&&n&&parseFloat(t[1]+"."+t[2])}(),function(){const t=w.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}();const L=/MSIE/.test(w)||w.indexOf("Trident")>-1&&w.indexOf("rv:11.0")>-1;!function(){const t=/MSIE\s(\d+)\.\d/.exec(w);let e=t&&parseFloat(t[1]);!e&&/Trident\/7.0/i.test(w)&&/rv:11.0/.test(w)&&(e=11)}(),function(){const t=w.match(/TBS\/(\d+)/i);if(t&&t[1])t[1]}();const A="TIMCustomElem",O="High",N="C2C",$="GROUP",U="@TIM#SYSTEM";let P,R;P="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const H=function(){},x=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let b=x.length;for(;b--;)R=x[b],console[R]||(P[R]=H);var F=P;const q=function(){const t=new Date;return t.setTime((new Date).getTime()+0),t};let j=0;function G(){return z()?"%c Chat %c":"Chat"}function k(){const t=q();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const B={arguments2String(t){let e="";if(1===t.length)e=t[0];else for(let n=0,i=t.length;n<i;n++)K(t[n])?Y(t[n])?e+=W(t[n]):e+=JSON.stringify(t[n]):e+=t[n],e+=" ";return e},_exec(t,e){z()?F[t](G(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",k(),e):F[t](`${G()} ${k()} ${e}`)},d:function(){if(j<=-1){const t=this.arguments2String(arguments);this._exec("debug",t)}},l:function(){if(j<=0){const t=this.arguments2String(arguments);this._exec("log",t)}},log:function(){if(j<=0){const t=this.arguments2String(arguments);this._exec("log",t)}},i:function(){if(j<=1){const t=this.arguments2String(arguments);this._exec("info",t)}},w:function(){if(j<=2){const t=this.arguments2String(arguments);this._exec("warn",t)}},e:function(){if(j<=3){const t=this.arguments2String(arguments);this._exec("error",t)}},setLevel:function(t){t<4&&this._exec("log","set level from "+j+" to "+t),j=t},getLevel:function(){return j}},J=function(t){return void 0===t},K=function(t){return function(t){return"function"==typeof Array.isArray?Array.isArray(t):"array"===V(t)}(t)||function(t){return null!==t&&"object"==typeof t}(t)},Y=function(t){return t instanceof Error},V=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};Date.now||(Date.now=function(){return(new Date).getTime()});const W=function(t){return JSON.stringify(t,["message","code"])};function z(){return!L&&!S}const X=Object.prototype.hasOwnProperty;function Q(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(function(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return e===n}(t)){for(const e in t)if(X.call(t,e))return!1;return!0}return!("map"!==V(t)&&!function(t){return"set"===V(t)}(t)&&!function(t){return"file"===V(t)}(t))&&0===t.size}class Z extends Error{constructor(t){super();const{code:e,message:n,data:i}=t;this.code=e,this.message=n||this._getErrorMessage(this.code),this.data=i||{}}}const et=2903,nt=3122,it=8010,st=8011,ot=8020,at=8021;let rt=null;const lt=function(t,e=!1){if(t instanceof Z)return e&&null!==rt&&rt.emit(g,t),Promise.reject(t);if(t instanceof Error){const t=new Z({code:et});return e&&null!==rt&&rt.emit(g,t),Promise.reject(t)}if(J(t)||J(t.code))return Promise.reject(new Z({code:et}));const n=new Z(t);return e&&null!==rt&&rt.emit(g,n),Promise.reject(n)};const gt="newInvitationReceived",ct="ts_invitee_accepted",ut="ts_invitee_rejected",ht="ts_invitation_cancelled",dt="ts_invitation_timeout",_t="ts_invitation_modified",mt=1,It=2,ft=3,vt=4,pt=5;class Dt{constructor(t){this._n="RemoteSignalingHandler",this._signalingModule=t}onNewMessageList(t){const e=this._signalingModule.filterMessageList(t);e.length>0&&e.forEach(t=>{const e=this.getPayloadData(t);e&&this._handleActionType(e,t)})}onMessageModified(t){const e=this._signalingModule.filterMessageList(t);e.length>0&&e.forEach(t=>{const e=this.getPayloadData(t);e&&this._onInvitationModified(e,t)})}getPayloadData(t){const e=this._n+".getPayloadData",{data:n}=t.payload;try{return JSON.parse(n)}catch(i){return B.e(`${e} JSON parse error. signalingData:${n}`),null}}_handleActionType(t,e){const{actionType:n}=t;switch(n){case mt:this._onNewInvitationReceived(t,e);break;case vt:this._onInviteeRejected(t);break;case ft:this._onInviteeAccepted(t);break;case It:this._onInvitationCancelled(t);break;case pt:this._onInvitationTimeout(t)}}_createDefaultEmitData(t){const{inviteID:e,inviter:n,groupID:i,data:s}=t;return{inviteID:e,inviter:n,groupID:i,data:s||""}}_onNewInvitationReceived(t,e){const n=this._n+"._onNewInvitationReceived",{inviteID:i,inviteeList:s,groupID:o}=t,a=this._signalingModule.getMyUserID(),r=s.includes(a),l=Math.round(t.timeout-((new Date).getTime()-1e3*e.time)/1e3);if(B.l(`${n} myselfIncluded:${r} groupID:${o} timeout:${l}s signalObj:${JSON.stringify(t)}`),o&&r||!o){const n=this._signalingModule.getInviteInfo(i);if(n&&n===t)return;n||this._signalingModule.setInviteInfo(i,{...t,message:e}),this._signalingModule.emitEvent(gt,{...this._createDefaultEmitData(t),inviteeList:s}),this._signalingModule.startTimer({...t,timeout:l})}}_onInviteeRejected(t){const e=this._n+"._onInviteeRejected",{inviteID:n,inviter:i,groupID:s}=t,o=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${o} inviter:${i} groupID:${s}`),(s&&o||!s)&&(this._signalingModule.updateInviteInfo(t),this._signalingModule.emitEvent(ut,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInviteeAccepted(t){const e=this._n+"._onInviteeAccepted",{inviteID:n,inviter:i,groupID:s}=t,o=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${o} inviter:${i} groupID:${s}`),(s&&o||!s)&&(this._signalingModule.updateInviteInfo(t),this._signalingModule.emitEvent(ct,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInvitationCancelled(t){const e=this._n+"._onInvitationCancelled",{inviteID:n,inviter:i,groupID:s}=t,o=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${o} inviter:${i} groupID:${s}`),(s&&o||!s)&&(this._signalingModule.deleteInviteInfo(n),this._signalingModule.emitEvent(ht,this._createDefaultEmitData(t)))}_onInvitationTimeout(t){const e=this._n+"._onInvitationTimeout",{inviteID:n,inviter:i,groupID:s,inviteeList:o}=t,a=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${a} inviter:${i} groupID:${s} data:${t.data}`),(s&&a||!s)&&(this._signalingModule.updateInviteInfo(t),this._signalingModule.emitEvent(dt,{...this._createDefaultEmitData(t),inviteeList:o,isSelfTimeout:!1}))}_onInvitationModified(t,e){const n=this._n+"._onInvitationModified",{inviteID:i,data:s}=t;B.l(`${n} inviteID:${i} data:${s}`),this._signalingModule.setInviteInfo(i,{...t,message:e}),this._signalingModule.emitEvent(_t,{inviteID:i,data:s})}}const Mt=function(t){if(t<0||t>53)return NaN;const e=0|1073741824*Math.random();return t>30?e+1073741824*(0|Math.random()*(1<<t-30)):e>>>30-t},St=function(t,e){let n=t.toString(16),i=e-n.length,s="0";for(;i>0;i>>>=1,s+=s)1&i&&(n=s+n);return n};class yt{constructor(t){this._n="LocalSignalingHandler",this._signalingModule=t}generateInviteID(){const t=function(){const t=Mt,e=St;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)}();return B.l(`${this._n}.generateInviteID inviteID:${t}`),t}createInviteInfo(t){const e=this.generateInviteID(),n=this.createInviteCustomData({...t,inviteID:e}),{groupID:i,inviteeList:s}=n,o=i||s[0];return{customData:n,message:this.createSignalingMessage(n,o),inviteID:e}}_createDefaultCustomData(t){const{data:e="",inviteID:n="",groupID:i=""}=t;return{businessID:1,timeout:0,data:e,inviteID:n,groupID:i}}createInviteCustomData(t){const{userID:e,timeout:n=0,groupID:i=""}=t,s=this._signalingModule.getMyUserID(),o={...this._createDefaultCustomData(t),actionType:mt,inviter:s,inviteeList:i?t.inviteeList:[e],timeout:n};return B.l(`${this._n}.createInviteCustomData customData:${JSON.stringify(o)}`),o}createCancelCustomData(t){const e=this._n+".createCancelCustomData",{inviteID:n}=t;let i;const s=this._signalingModule.getMyUserID(),{inviteeList:o,groupID:a,inviter:r}=this._signalingModule.getInviteInfo(n);return r===s?i={...this._createDefaultCustomData(t),actionType:It,groupID:a,inviter:s,inviteeList:o}:B.e(`${e} unmatched inviter:${r} and my userID:${s}`),B.l(`${e} customData:${JSON.stringify(i)}`),i}createAcceptCustomData(t){const e=this._n+".createAcceptCustomData",{inviteID:n}=t;let i;const s=this._signalingModule.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._signalingModule.getInviteInfo(n);return r.includes(s)?i={...this._createDefaultCustomData(t),actionType:ft,groupID:a,inviter:o,inviteeList:[s]}:B.e(`${e} userID:${s} not in inviteeList. inviteID:${n} groupID:${a}`),B.l(`${e} customData:${JSON.stringify(i)}`),i}createRejectCustomData(t){const e=this._n+".createRejectCustomData",{inviteID:n}=t;let i;const s=this._signalingModule.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._signalingModule.getInviteInfo(n);return r.includes(s)?i={...this._createDefaultCustomData(t),actionType:vt,groupID:a,inviter:o,inviteeList:[s]}:B.e(`${e} userID:${s} not in inviteeList. inviteID:${n} groupID:${a}`),B.l(`${e} customData:${JSON.stringify(i)}`),i}createTimeoutCustomData(t){const e=this._n+".createTimeoutCustomData",{inviteeList:n,inviter:i,isInviter:s=!1}=t,o=this._signalingModule.getMyUserID(),a={...this._createDefaultCustomData(t),actionType:pt,inviter:i,inviteeList:s?n:[o]};return B.l(`${e} customData:${JSON.stringify(a)}`),a}createSignalingMessage(t,n){const{groupID:i,inviter:s}=t,o=this._signalingModule.getModule(e),a={to:n||i||s,conversationType:i?$:N,priority:O,payload:{data:JSON.stringify(t)}},r=o.createCustomMessage(a);return B.d(`${this._n}.createSignalingMessage. message:${JSON.stringify(r)}`),r}}class wt{constructor(t){this._n="HistorySignalingHandler",this._signalingModule=t,this.EXPIRED_TIME=3e4,this.COUNT=20,this._signalingMap=new Map,this._signalingRelatedToMeMap=new Map}getHistorySignaling(){const t=this._signalingModule.getModule(n).getLocalConversationList();Q(t)||this._getSignalingList(t).then(t=>{this._handleSignalingList(t)})}_getSignalingList(t){const e=this._getValidConversationList(t),n=this._createPromiseList(e);return Q(n)?Promise.resolve([]):this._concurrentGetMessageList(n).then(t=>{let e=new Map;return t.forEach(t=>{const{signalingList:n}=t,i=this._getSignalingRelatedToMeMap(n);e=new Map([...e,...i])}),this._sortSignaling(e)})}_handleSignalingList(t){Q(t)||(B.d(`${this._n}._handleSignalingList signalingList:${JSON.stringify(t)}`),this._signalingModule.onNewMessageList(t))}_isSignalingNotExpired(t,e){return t[e]&&1e3*t[e]>(new Date).getTime()-this.EXPIRED_TIME}_getValidConversationList(t){const e=[];for(let n=0;n<t.length;n++){const{type:i,unreadCount:s,lastMessage:o}=t[n],a=this._isSignalingNotExpired(o,"lastTime");i!==U&&s>0&&a&&e.push(t[n])}return e}_createPromiseList(t){const e=[];for(let i=0;i<t.length;i++){const s=t[i],{conversationID:o,unreadCount:a,type:r}=s,l=r===N?a:this.COUNT;this._signalingMap.set(o,{needMessageCount:l,signalingList:[]});const g=this._signalingModule.getModule(n).getMessageList({conversationID:o});e.push(g)}return e}_concurrentGetMessageList(t){const e=[];return Promise.all(t).then(t=>{for(let n=0;n<t.length;n++){const{code:i,data:s}=t[n];if(0!==i||0===s.messageList.length)continue;this._handleMessageList(s.messageList);const o=this._relayGetMessageList(s);o&&e.push(o)}return e.length>0?this._concurrentGetMessageList(e):this._signalingMap})}_relayGetMessageList(t){const{messageList:e,nextReqMessageID:i,isCompleted:s}=t,o=e.length;if(0===o)return null;const{conversationID:a,conversationType:r}=e[0],{needMessageCount:l}=this._signalingMap.get(a),g=r===$,c=0===l||s,u=this._isSignalingNotExpired(e[o-1],"time");if(g||c||!u)return null;return this._signalingModule.getModule(n).getMessageList({conversationID:a,nextReqMessageID:i,count:l})}_handleMessageList(t){const e=t.length,{conversationID:n}=t[0],{needMessageCount:i,signalingList:s}=this._signalingMap.get(n),o=i-e>0?i-e:0,a=[];for(let l=0;l<t.length;l++){const e=t[l];this._isSignalingNotExpired(e,"time")&&a.push(e)}const r=this._signalingModule.filterMessageList(a);this._signalingMap.set(n,{needMessageCount:o,signalingList:s.concat(r)})}_getSignalingRelatedToMeMap(t){for(let e=0;e<t.length;e++){const n=t[e];this._saveSignalingRelatedToMe(n)}return this._signalingRelatedToMeMap}_saveSignalingRelatedToMe(t){const e=this._signalingModule.getRemoteSignalingHandler().getPayloadData(t)||{},{actionType:n="",inviteID:i="",inviteeList:s=[]}=e,o=this._signalingModule.getMyUserID();switch(n){case mt:s.includes(o)&&this._signalingRelatedToMeMap.set(i,{...e,messageList:[t]});break;case vt:case ft:this.updateHistoryInviteInfo(t);break;case It:this.deleteHistoryInviteInfo(i);break;case pt:this.updateHistoryInviteInfo(t)}}deleteHistoryInviteInfo(t){this._signalingRelatedToMeMap.has(t)&&this._signalingRelatedToMeMap.delete(t)}updateHistoryInviteInfo(t){const e=this._signalingModule.getRemoteSignalingHandler().getPayloadData(t)||{},{inviteID:n="",inviteeList:i=[]}=e;if(this._signalingRelatedToMeMap.has(n)){const{inviteeList:e,messageList:s}=this._signalingRelatedToMeMap.get(n);for(let t=0;t<i.length;t++){const n=i[t];e.includes(n)&&e.splice(e.indexOf(n),1)}0===e.length?this.deleteHistoryInviteInfo(n):s.push(t)}else this.deleteHistoryInviteInfo(n)}_sortSignaling(t){let e=[];t.forEach(t=>{e=[...e,...t.messageList]});return e.sort((function(t,e){return(t.time?t.time:0)-(e.time?e.time:0)}))}reset(){this._signalingMap.clear(),this._signalingRelatedToMeMap.clear()}}class Ct{constructor(t,e){this.businessID=t.businessID||1,this.inviteID=t.inviteID,this.groupID=t.groupID||"",this.inviter=t.inviter||"",this.inviteeList=t.inviteeList||[],this.data=t.data||"",this.actionType=t.actionType||mt,this.timeout=t.timeout||0}}const Tt={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};class Et extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.getModule(i).isLoggedIn()}isOversea(){return this._m.getModule(i).isOversea()}isPrivateNetWork(){return this._m.getModule(i).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(i).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(i).getUserID()}getMyTinyID(){return this._m.getModule(i).getTinyID()}getSDKAppID(){return this._m.getModule(i).getSDKAppID()}isIntl(){return this._m.getModule(i).isIntl()}isDevMode(){return this._m.getModule(i).isDevMode()}getModule(t){return this._m.getModule(t)}getPlatform(){return E}getNetworkType(){return this._m.getModule(s).getNetworkType()}probeNetwork(t){return this._m.getModule(s).probe(t)}getCloudConfig(t){return this._m.getModule(a).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(t){return this._m.getModule(i).getTinyID()+"-"+t.random}filterModifiedMessage(t){if(Q(t))return;const e=t.filter(t=>!0===t.isModified);e.length>0&&this.emitOuterEvent(l,e)}filterUnmodifiedMessage(t){if(Q(t))return[];return t.filter(t=>!1===t.isModified)}request(t){return this._m.getModule(o).request(t)}canIUse(t){return this._m.getModule(r).canIUse(t)}getErrorMessage(t,e,n){return this._m.getErrorMessage(t,e,n)}outputWarning(t,e,n){const i=this.getErrorMessage(t,e,n);i&&B.w(i)}cannotUseCommercialAbility(t){const e=nt;return lt({code:e,message:this.getErrorMessage(e,t)})}}{constructor(e){super(e),this._n="SignalingModule",this._inviteInfoMap=new Map,this._outerEmitter=new t,this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(...t){const e=[t[0],{name:t[0],data:t[1]}];this._outerEmitter._emit.apply(this._outerEmitter,[...e])}.bind(this),this._canIUseSignaling=!1,this._isHandling=!1,this._remoteSignalingHandler=new Dt(this),this._localSignalingHandler=new yt(this),this._historySignalingHandler=new wt(this),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1,this.getInnerEmitterInstance().on(Tt.C2C_UNREAD_HANDLE_COMPLETED,this.onC2CUnreadHandleCompleted,this),this.getInnerEmitterInstance().on(Tt.CONV_SYNC_COMPLETED,this.onConvSyncCompleted,this)}onC2CUnreadHandleCompleted(){this._isC2CUnreadHandleCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onConvSyncCompleted(){this._isConvSyncCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onReady(){B.l(this._n+".onReady"),this._isSyncCompleted=!0,this._historySignalingHandler.getHistorySignaling()}onNewMessageList(t){return this._remoteSignalingHandler.onNewMessageList(t)}onMessageModified(t){return this._remoteSignalingHandler.onMessageModified(t)}hasInviteInfo(t){return this._inviteInfoMap.has(t)}getInviteInfo(t){return this._inviteInfoMap.get(t)}setInviteInfo(t,e){const{message:n,...i}=e;B.l(`${this._n}.setInviteInfo inviteID:${t} data:${JSON.stringify(i)}`),this._inviteInfoMap.set(t,{...i,message:n})}deleteInviteInfo(t){this.hasInviteInfo(t)&&(B.l(`${this._n}.deleteInviteInfo inviteID:${t}.`),this._inviteInfoMap.delete(t))}updateInviteInfo(t){const e=this._n+".updateInviteInfo",{inviteID:n,inviter:i,inviteeList:s,groupID:o}=t;if(B.l(`${e} inviteID:${n} inviter:${i} groupID:${o}`),o&&this.hasInviteInfo(n)){const t=s[0],{inviteeList:i}=this.getInviteInfo(n);i.includes(t)&&(i.splice(i.indexOf(t),1),B.l(`${e} remove ${t}. localInviteeList.length:${i.length}`)),0===i.length&&this.deleteInviteInfo(n)}else this.deleteInviteInfo(n)}getLocalSignalingHandler(){return this._localSignalingHandler}getRemoteSignalingHandler(){return this._remoteSignalingHandler}canIUseSignaling(){return this._canIUseSignaling}emitEvent(t,e){this._outerEmitter.emit(t,e)}addSignalingListener(t,e,n){this._canIUseSignaling||(this._canIUseSignaling=!0),this._outerEmitter.on(t,e,n)}removeSignalingListener(t,e,n){this._outerEmitter.off(t,e,n),0===this._outerEmitter.eventNames().length&&(this._canIUseSignaling=!1)}invite(t){const e=this._n+".invite",{message:n,customData:i,inviteID:s}=this._localSignalingHandler.createInviteInfo(t);return B.l(`${e} options:${JSON.stringify(t)} inviteID:${s}`),this.sendSignaling(n,t).then(t=>t&&0===t.code?(this.setInviteInfo(s,{...i,message:n}),this.startTimer({...i,inviteID:s}),{...t,inviteID:s}):t).catch(t=>lt(t))}inviteSync(t,e,n){const i=this._n+".inviteSync",{message:s,customData:o,inviteID:a}=this._localSignalingHandler.createInviteInfo(t);return B.l(`${i} options:${JSON.stringify(t)} inviteID:${a}`),this.sendSignaling(s,t).then(t=>{if(t&&0===t.code)return this.setInviteInfo(a,{...o,message:s}),this.startTimer({...o,inviteID:a}),e&&e({inviteID:a}),{inviteID:a};n&&n(0===t.code,t.message||"")}).catch(t=>(n&&n(t.code,t.message),lt(t))),a}_handleImResponse(t,e,n){e&&0===e.code&&(this._isHandling=!1,n?this.deleteInviteInfo(t.inviteID):this.updateInviteInfo(t))}cancel(t){const e=this._n+".cancel";if(B.l(`${e} options:${JSON.stringify(t)}`),!this.hasInviteInfo(t.inviteID)||this._isHandling)return lt({code:ot});this._isHandling=!0;const n=this._localSignalingHandler.createCancelCustomData(t);if(!n)return this._isHandling=!1,lt({code:st});const{groupID:i,inviteeList:s}=n,o=i||s[0],a=this._localSignalingHandler.createSignalingMessage(n,o);return this.sendSignaling(a,t).then(e=>(this._handleImResponse(n,e,!0),0===e.code?{...e,inviteID:t.inviteID}:e)).catch(t=>lt(t))}accept(t){const e=this._n+".accept";if(B.l(`${e} options:${JSON.stringify(t)}`),!this.hasInviteInfo(t.inviteID)||this._isHandling)return lt({code:it});this._isHandling=!0;const n=this._localSignalingHandler.createAcceptCustomData(t);if(!n)return this._isHandling=!1,lt({code:st});const i=this._localSignalingHandler.createSignalingMessage(n);return this.sendSignaling(i,t).then(e=>(this._handleImResponse(n,e),0===e.code?{...e,inviteID:t.inviteID}:e)).catch(t=>lt(t))}reject(t){const e=this._n+".reject";if(B.l(`${e} options:${JSON.stringify(t)}`),!this.hasInviteInfo(t.inviteID)||this._isHandling)return lt({code:it});this._isHandling=!0;const n=this._localSignalingHandler.createRejectCustomData(t);if(!n)return this._isHandling=!1,lt({code:st});const i=this._localSignalingHandler.createSignalingMessage(n);return this.sendSignaling(i,t).then(e=>(this._handleImResponse(n,e,!0),0===e.code?{...e,inviteID:t.inviteID}:e)).catch(t=>lt(t))}getSignalingInfo(t){const e=this._n+".getSignalingInfo",{ID:n,from:i,to:s}=t,o=this._filterSignalingMessage(t);let a=null;if(o){const e=this._remoteSignalingHandler.getPayloadData(t);a=new Ct(e)}const r=o?"actionType:"+a.actionType:"";return B.l(`${e} messageID:${n} from:${i} to:${s}${r} isSignaling:${o}`),a}modifyInvitation(t){const{inviteID:n,data:i}=t;if(!this.hasInviteInfo(t.inviteID)||this._isHandling)return lt({code:it});this._isHandling=!0;const{message:s,...o}=this.getInviteInfo(n),a=s.payload.data;o.data=i,s.payload.data=JSON.stringify(o);return this.getModule(e).modifyRemoteMessage(s).then(t=>(this.setInviteInfo(n,{...o,message:s}),this._isHandling=!1,t)).catch(t=>(this._isHandling=!1,s.payload.data=a,lt(t)))}_genMessageControlInfo(t={}){const{data:e="",onlineUserOnly:n,inviteID:i="",offlinePushInfo:s,actionType:o}=t;let a={_onlineOnlyFlag:!1};i&&this.getInviteInfo(i)&&(a=this.getInviteInfo(i).message);const r={onlineUserOnly:a._onlineOnlyFlag||n||!1,offlinePushInfo:s,messageControlInfo:{excludedFromContentModeration:!0,excludedFromUnreadCount:!1,excludedFromLastMessage:!1}};if(o===pt){const t=!!e.match(/excludeTimeoutSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=t,r.messageControlInfo.excludedFromLastMessage=t,r}const l=!!e.match(/excludeFromHistoryMessage/),g=!!e.match(/excludeOriginalSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=l||g,r.messageControlInfo.excludedFromLastMessage=l||g,r}sendSignaling(t,n){return this.getModule(e).sendMessageInstance(t,this._genMessageControlInfo(n)).catch(t=>(this._isHandling=!1,lt({code:at})))}filterMessageList(t){return t.filter(t=>this._filterSignalingMessage(t))}_filterSignalingMessage(t){let e=!1;if(t.type&&t.type===A){const{cloudCustomData:n="",payload:{data:i=""}}=t,s=n.match(/"type":"tsignaling"/),o=i.match(/inviteID/),a=i.match(/actionType/);e=s||o&&a}return!!e}startTimer(t){const e=this._n+".startTimer",{timeout:n,inviteID:i,inviter:s,groupID:o}=t,a=s===this.getMyUserID();if(B.l(`${e} timeout:${n} isInviter:${a} groupID:${o}`),n<=0)return;const r=a?n+5:n;let l=1;const g=setInterval(()=>{const n=this._hasLocalInviteInfo(t,a);l<r&&n?++l:(n&&this._sendTimeoutNotice(i,a),B.l(e+" end."),clearInterval(g))},1e3)}_hasLocalInviteInfo(t,e){const{inviteID:n,groupID:i}=t;if(!this.hasInviteInfo(n))return!1;const s=this._n+"._hasLocalInviteInfo",{inviteeList:o}=this.getInviteInfo(n);return B.l(`${s} inviteID:${n} inviteeList:${o} groupID:${i}`),!i||(e?o.length>0:o.length>0&&o.includes(this.getMyUserID()))}_getReceiver(t,e){const{groupID:n,inviteeList:i,inviter:s}=e;return t?n||i[0]:n||s}_sendTimeoutNotice(t,e){const n=this.getInviteInfo(t),i=this._getReceiver(e,n);B.l(`${this._n}._sendTimeoutNotice inviteID:${t} to:${i} isInviter:${e}`);const s=this._localSignalingHandler.createTimeoutCustomData({...n,isInviter:e}),o=this._localSignalingHandler.createSignalingMessage(s,i);return this.sendSignaling(o,s).then(n=>{if(n&&0===n.code){const{data:n,groupID:i,inviteeList:a,inviter:r}=s;this.emitEvent(dt,{data:n,groupID:i,inviteID:t,inviteeList:a,inviter:r,isSelfTimeout:!0,message:o}),e?this.deleteInviteInfo(t):this.updateInviteInfo(s)}})}reset(){B.l(this._n+".reset"),this._inviteInfoMap.clear(),this._canIUseSignaling=!1,this._isHandling=!1,this._historySignalingHandler.reset(),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1}}export{Et as default}; | ||
'use strict';var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,i,o,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var r=new s(i,o||t,a),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],r]:t._events[l].push(r):(t._events[l]=r,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function r(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),r.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},r.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,o=i.length,a=new Array(o);s<o;s++)a[s]=i[s].fn;return a},r.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},r.prototype.emit=function(t,e,i,s,o,a){var r=n?n+t:t;if(!this._events[r])return!1;var l,g,c=this._events[r],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,s),!0;case 5:return c.fn.call(c.context,e,i,s,o),!0;case 6:return c.fn.call(c.context,e,i,s,o,a),!0}for(g=1,l=new Array(u-1);g<u;g++)l[g-1]=arguments[g];c.fn.apply(c.context,l)}else{var h,d=c.length;for(g=0;g<d;g++)switch(c[g].once&&this.removeListener(t,c[g].fn,void 0,!0),u){case 1:c[g].fn.call(c[g].context);break;case 2:c[g].fn.call(c[g].context,e);break;case 3:c[g].fn.call(c[g].context,e,i);break;case 4:c[g].fn.call(c[g].context,e,i,s);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c[g].fn.apply(c[g].context,l)}}return!0},r.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},r.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},r.prototype.removeListener=function(t,e,i,s){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var r=this._events[o];if(r.fn)r.fn!==e||s&&!r.once||i&&r.context!==i||a(this,o);else{for(var l=0,g=[],c=r.length;l<c;l++)(r[l].fn!==e||s&&!r[l].once||i&&r[l].context!==i)&&g.push(r[l]);g.length?this._events[o]=1===g.length?g[0]:g:a(this,o)}return this},r.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=n,r.EventEmitter=r,t.exports=r}));const e=2,n=11,i=12,s=15,o=20,a=23,r=27,l="onMessageModified",g="error";class c{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&(this.low===t.low&&this.high===t.high)}toString(){const t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}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:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},h={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},d="CHINA",_={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=d){this.CURRENT=u.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GROUP:"group_open_http_svc",GROUP_AVCHATROOM:"group_open_avchatroom_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"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",MESSAGE_SEARCH:"message_search"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}};new c(0,Math.pow(2,0)).toString(),new c(0,Math.pow(2,1)).toString(),new c(0,Math.pow(2,2)).toString(),new c(0,Math.pow(2,3)).toString(),new c(0,Math.pow(2,4)).toString(),new c(0,Math.pow(2,6)).toString(),new c(0,Math.pow(2,7)).toString(),new c(0,Math.pow(2,9)).toString(),new c(0,Math.pow(2,10)).toString(),new c(0,Math.pow(2,11)).toString(),new c(0,Math.pow(2,13)).toString(),new c(0,Math.pow(2,15)).toString(),new c(Math.pow(2,16)).toString(),_.HOST.setCurrent(d);const m="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),I="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),v="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),p="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,M="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,S=m||I||f||v||p||M||D,y=("undefined"!=typeof uni||"undefined"!=typeof window)&&!S;I?qq:f?tt:v?swan:p?my:m?wx:M?uni:!D||jd;const w=y&&window&&window.navigator&&window.navigator.userAgent||"",C=/(micromessenger|webbrowser)/i.test(w),T=/AppleWebKit\/([\d.]+)/i.exec(w);T&&parseFloat(T.pop());const E=function(){let t="WEB";return C?t="WEB":I?t="QQ_MP":f?t="TT_MP":v?t="BAIDU_MP":p?t="ALI_MP":m?t="WX_MP":M&&(t="UNI_NATIVE_APP"),h[t]}();!function(){const t=w.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){const t=w.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const e=t[1]&&parseFloat(t[1]),n=t[2]&&parseFloat(t[2]);e&&n&&parseFloat(t[1]+"."+t[2])}(),function(){const t=w.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}();const A=/MSIE/.test(w)||w.indexOf("Trident")>-1&&w.indexOf("rv:11.0")>-1;!function(){const t=/MSIE\s(\d+)\.\d/.exec(w);let e=t&&parseFloat(t[1]);!e&&/Trident\/7.0/i.test(w)&&/rv:11.0/.test(w)&&(e=11)}(),function(){const t=w.match(/TBS\/(\d+)/i);if(t&&t[1])t[1]}();const L="TIMCustomElem",O="High",N="C2C",$="GROUP",U="@TIM#SYSTEM";let P,R;P="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const H=function(){},x=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let b=x.length;for(;b--;)R=x[b],console[R]||(P[R]=H);var F=P;const q=function(){const t=new Date;return t.setTime((new Date).getTime()+0),t};let j=0;function G(){return z()?"%c Chat %c":"Chat"}function k(){const t=q();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const B={arguments2String(t){let e="";if(1===t.length)e=t[0];else for(let n=0,i=t.length;n<i;n++)K(t[n])?Y(t[n])?e+=W(t[n]):e+=JSON.stringify(t[n]):e+=t[n],e+=" ";return e},_exec(t,e){z()?F[t](G(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",k(),e):F[t](`${G()} ${k()} ${e}`)},d:function(){if(j<=-1){const t=this.arguments2String(arguments);this._exec("debug",t)}},l:function(){if(j<=0){const t=this.arguments2String(arguments);this._exec("log",t)}},log:function(){if(j<=0){const t=this.arguments2String(arguments);this._exec("log",t)}},i:function(){if(j<=1){const t=this.arguments2String(arguments);this._exec("info",t)}},w:function(){if(j<=2){const t=this.arguments2String(arguments);this._exec("warn",t)}},e:function(){if(j<=3){const t=this.arguments2String(arguments);this._exec("error",t)}},setLevel:function(t){t<4&&this._exec("log","set level from "+j+" to "+t),j=t},getLevel:function(){return j}},J=function(t){return void 0===t},K=function(t){return function(t){return"function"==typeof Array.isArray?Array.isArray(t):"array"===V(t)}(t)||function(t){return null!==t&&"object"==typeof t}(t)},Y=function(t){return t instanceof Error},V=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};Date.now||(Date.now=function(){return(new Date).getTime()});const W=function(t){return JSON.stringify(t,["message","code"])};function z(){return!A&&!S}const X=Object.prototype.hasOwnProperty;function Q(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(function(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return e===n}(t)){for(const e in t)if(X.call(t,e))return!1;return!0}return!("map"!==V(t)&&!function(t){return"set"===V(t)}(t)&&!function(t){return"file"===V(t)}(t))&&0===t.size}class Z extends Error{constructor(t){super();const{code:e,message:n,data:i}=t;this.code=e,this.message=n||this._getErrorMessage(this.code),this.data=i||{}}}const et=2903,nt=3122,it=8010,st=8011,ot=8020;let at=null;const rt=function(t,e=!1){if(t instanceof Z)return e&&null!==at&&at.emit(g,t),Promise.reject(t);if(t instanceof Error){const t=new Z({code:et});return e&&null!==at&&at.emit(g,t),Promise.reject(t)}if(J(t)||J(t.code))return Promise.reject(new Z({code:et}));const n=new Z(t);return e&&null!==at&&at.emit(g,n),Promise.reject(n)};const lt="newInvitationReceived",gt="ts_invitee_accepted",ct="ts_invitee_rejected",ut="ts_invitation_cancelled",ht="ts_invitation_timeout",dt="ts_invitation_modified",_t=1,mt=2,It=3,ft=4,vt=5;class pt{constructor(t){this._n="RemoteSignalingHandler",this._signalingModule=t}onNewMessageList(t){const e=this._signalingModule.filterMessageList(t);e.length>0&&e.forEach(t=>{const e=this.getPayloadData(t);e&&this._handleActionType(e,t)})}onMessageModified(t){const e=this._signalingModule.filterMessageList(t);e.length>0&&e.forEach(t=>{const e=this.getPayloadData(t);e&&this._onInvitationModified(e,t)})}getPayloadData(t){const e=this._n+".getPayloadData",{data:n}=t.payload;try{return JSON.parse(n)}catch(i){return B.e(`${e} JSON parse error. signalingData:${n}`),null}}_handleActionType(t,e){const{actionType:n}=t;switch(n){case _t:this._onNewInvitationReceived(t,e);break;case ft:this._onInviteeRejected(t);break;case It:this._onInviteeAccepted(t);break;case mt:this._onInvitationCancelled(t);break;case vt:this._onInvitationTimeout(t)}}_createDefaultEmitData(t){const{inviteID:e,inviter:n,groupID:i,data:s}=t;return{inviteID:e,inviter:n,groupID:i,data:s||""}}_onNewInvitationReceived(t,e){const n=this._n+"._onNewInvitationReceived",{inviteID:i,inviteeList:s,groupID:o}=t,a=this._signalingModule.getMyUserID(),r=s.includes(a),l=Math.round(t.timeout-((new Date).getTime()-1e3*e.time)/1e3);if(B.l(`${n} myselfIncluded:${r} groupID:${o} timeout:${l}s signalObj:${JSON.stringify(t)}`),o&&r||!o){const n=this._signalingModule.getInviteInfo(i);if(n&&n===t)return;n||this._signalingModule.setInviteInfo(i,{...t,message:e}),this._signalingModule.emitEvent(lt,{...this._createDefaultEmitData(t),inviteeList:s}),this._signalingModule.startTimer({...t,timeout:l})}}_onInviteeRejected(t){const e=this._n+"._onInviteeRejected",{inviteID:n,inviter:i,groupID:s}=t,o=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${o} inviter:${i} groupID:${s}`),(s&&o||!s)&&(this._signalingModule.updateInviteInfo(t),this._signalingModule.emitEvent(ct,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInviteeAccepted(t){const e=this._n+"._onInviteeAccepted",{inviteID:n,inviter:i,groupID:s}=t,o=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${o} inviter:${i} groupID:${s}`),(s&&o||!s)&&(this._signalingModule.updateInviteInfo(t),this._signalingModule.emitEvent(gt,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInvitationCancelled(t){const e=this._n+"._onInvitationCancelled",{inviteID:n,inviter:i,groupID:s}=t,o=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${o} inviter:${i} groupID:${s}`),(s&&o||!s)&&(this._signalingModule.deleteInviteInfo(n),this._signalingModule.emitEvent(ut,this._createDefaultEmitData(t)))}_onInvitationTimeout(t){const e=this._n+"._onInvitationTimeout",{inviteID:n,inviter:i,groupID:s,inviteeList:o}=t,a=this._signalingModule.hasInviteInfo(n);B.l(`${e} inviteID:${n} hasInviteID:${a} inviter:${i} groupID:${s} data:${t.data}`),(s&&a||!s)&&(this._signalingModule.updateInviteInfo(t),this._signalingModule.emitEvent(ht,{...this._createDefaultEmitData(t),inviteeList:o,isSelfTimeout:!1}))}_onInvitationModified(t,e){const n=this._n+"._onInvitationModified",{inviteID:i,data:s}=t;B.l(`${n} inviteID:${i} data:${s}`),this._signalingModule.setInviteInfo(i,{...t,message:e}),this._signalingModule.emitEvent(dt,{inviteID:i,data:s})}}const Dt=function(t){if(t<0||t>53)return NaN;const e=0|1073741824*Math.random();return t>30?e+1073741824*(0|Math.random()*(1<<t-30)):e>>>30-t},Mt=function(t,e){let n=t.toString(16),i=e-n.length,s="0";for(;i>0;i>>>=1,s+=s)1&i&&(n=s+n);return n};class St{constructor(t){this._n="LocalSignalingHandler",this._signalingModule=t}generateInviteID(){const t=function(){const t=Dt,e=Mt;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)}();return B.l(`${this._n}.generateInviteID inviteID:${t}`),t}createInviteInfo(t){const e=this.generateInviteID(),n=this.createInviteCustomData({...t,inviteID:e}),{groupID:i,inviteeList:s}=n,o=i||s[0];return{customData:n,message:this.createSignalingMessage(n,o),inviteID:e}}_createDefaultCustomData(t){const{data:e="",inviteID:n="",groupID:i=""}=t;return{businessID:1,timeout:0,data:e,inviteID:n,groupID:i}}createInviteCustomData(t){const{userID:e,timeout:n=0,groupID:i=""}=t,s=this._signalingModule.getMyUserID(),o={...this._createDefaultCustomData(t),actionType:_t,inviter:s,inviteeList:i?t.inviteeList:[e],timeout:n};return B.l(`${this._n}.createInviteCustomData customData:${JSON.stringify(o)}`),o}createCancelCustomData(t){const e=this._n+".createCancelCustomData",{inviteID:n}=t;let i;const s=this._signalingModule.getMyUserID(),{inviteeList:o,groupID:a,inviter:r}=this._signalingModule.getInviteInfo(n);return r===s?i={...this._createDefaultCustomData(t),actionType:mt,groupID:a,inviter:s,inviteeList:o}:B.e(`${e} unmatched inviter:${r} and my userID:${s}`),B.l(`${e} customData:${JSON.stringify(i)}`),i}createAcceptCustomData(t){const e=this._n+".createAcceptCustomData",{inviteID:n}=t;let i;const s=this._signalingModule.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._signalingModule.getInviteInfo(n);return r.includes(s)?i={...this._createDefaultCustomData(t),actionType:It,groupID:a,inviter:o,inviteeList:[s]}:B.e(`${e} userID:${s} not in inviteeList. inviteID:${n} groupID:${a}`),B.l(`${e} customData:${JSON.stringify(i)}`),i}createRejectCustomData(t){const e=this._n+".createRejectCustomData",{inviteID:n}=t;let i;const s=this._signalingModule.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._signalingModule.getInviteInfo(n);return r.includes(s)?i={...this._createDefaultCustomData(t),actionType:ft,groupID:a,inviter:o,inviteeList:[s]}:B.e(`${e} userID:${s} not in inviteeList. inviteID:${n} groupID:${a}`),B.l(`${e} customData:${JSON.stringify(i)}`),i}createTimeoutCustomData(t){const e=this._n+".createTimeoutCustomData",{inviteeList:n,inviter:i,isInviter:s=!1}=t,o=this._signalingModule.getMyUserID(),a={...this._createDefaultCustomData(t),actionType:vt,inviter:i,inviteeList:s?n:[o]};return B.l(`${e} customData:${JSON.stringify(a)}`),a}createSignalingMessage(t,n){const{groupID:i,inviter:s}=t,o=this._signalingModule.getModule(e),a={to:n||i||s,conversationType:i?$:N,priority:O,payload:{data:JSON.stringify(t)}},r=o.createCustomMessage(a);return B.d(`${this._n}.createSignalingMessage. message:${JSON.stringify(r)}`),r}}class yt{constructor(t){this._n="HistorySignalingHandler",this._signalingModule=t,this.EXPIRED_TIME=3e4,this.COUNT=20,this._signalingMap=new Map,this._signalingRelatedToMeMap=new Map}getHistorySignaling(){const t=this._signalingModule.getModule(n).getLocalConversationList();Q(t)||this._getSignalingList(t).then(t=>{this._handleSignalingList(t)})}_getSignalingList(t){const e=this._getValidConversationList(t),n=this._createPromiseList(e);return Q(n)?Promise.resolve([]):this._concurrentGetMessageList(n).then(t=>{let e=new Map;return t.forEach(t=>{const{signalingList:n}=t,i=this._getSignalingRelatedToMeMap(n);e=new Map([...e,...i])}),this._sortSignaling(e)})}_handleSignalingList(t){Q(t)||(B.d(`${this._n}._handleSignalingList signalingList:${JSON.stringify(t)}`),this._signalingModule.onNewMessageList(t))}_isSignalingNotExpired(t,e){return t[e]&&1e3*t[e]>(new Date).getTime()-this.EXPIRED_TIME}_getValidConversationList(t){const e=[];for(let n=0;n<t.length;n++){const{type:i,unreadCount:s,lastMessage:o}=t[n],a=this._isSignalingNotExpired(o,"lastTime");i!==U&&s>0&&a&&e.push(t[n])}return e}_createPromiseList(t){const e=[];for(let i=0;i<t.length;i++){const s=t[i],{conversationID:o,unreadCount:a,type:r}=s,l=r===N?a:this.COUNT;this._signalingMap.set(o,{needMessageCount:l,signalingList:[]});const g=this._signalingModule.getModule(n).getMessageList({conversationID:o});e.push(g)}return e}_concurrentGetMessageList(t){const e=[];return Promise.all(t).then(t=>{for(let n=0;n<t.length;n++){const{code:i,data:s}=t[n];if(0!==i||0===s.messageList.length)continue;this._handleMessageList(s.messageList);const o=this._relayGetMessageList(s);o&&e.push(o)}return e.length>0?this._concurrentGetMessageList(e):this._signalingMap})}_relayGetMessageList(t){const{messageList:e,nextReqMessageID:i,isCompleted:s}=t,o=e.length;if(0===o)return null;const{conversationID:a,conversationType:r}=e[0],{needMessageCount:l}=this._signalingMap.get(a),g=r===$,c=0===l||s,u=this._isSignalingNotExpired(e[o-1],"time");if(g||c||!u)return null;return this._signalingModule.getModule(n).getMessageList({conversationID:a,nextReqMessageID:i,count:l})}_handleMessageList(t){const e=t.length,{conversationID:n}=t[0],{needMessageCount:i,signalingList:s}=this._signalingMap.get(n),o=i-e>0?i-e:0,a=[];for(let l=0;l<t.length;l++){const e=t[l];this._isSignalingNotExpired(e,"time")&&a.push(e)}const r=this._signalingModule.filterMessageList(a);this._signalingMap.set(n,{needMessageCount:o,signalingList:s.concat(r)})}_getSignalingRelatedToMeMap(t){for(let e=0;e<t.length;e++){const n=t[e];this._saveSignalingRelatedToMe(n)}return this._signalingRelatedToMeMap}_saveSignalingRelatedToMe(t){const e=this._signalingModule.getRemoteSignalingHandler().getPayloadData(t)||{},{actionType:n="",inviteID:i="",inviteeList:s=[]}=e,o=this._signalingModule.getMyUserID();switch(n){case _t:s.includes(o)&&this._signalingRelatedToMeMap.set(i,{...e,messageList:[t]});break;case ft:case It:this.updateHistoryInviteInfo(t);break;case mt:this.deleteHistoryInviteInfo(i);break;case vt:this.updateHistoryInviteInfo(t)}}deleteHistoryInviteInfo(t){this._signalingRelatedToMeMap.has(t)&&this._signalingRelatedToMeMap.delete(t)}updateHistoryInviteInfo(t){const e=this._signalingModule.getRemoteSignalingHandler().getPayloadData(t)||{},{inviteID:n="",inviteeList:i=[]}=e;if(this._signalingRelatedToMeMap.has(n)){const{inviteeList:e,messageList:s}=this._signalingRelatedToMeMap.get(n);for(let t=0;t<i.length;t++){const n=i[t];e.includes(n)&&e.splice(e.indexOf(n),1)}0===e.length?this.deleteHistoryInviteInfo(n):s.push(t)}else this.deleteHistoryInviteInfo(n)}_sortSignaling(t){let e=[];t.forEach(t=>{e=[...e,...t.messageList]});return e.sort((function(t,e){return(t.time?t.time:0)-(e.time?e.time:0)}))}reset(){this._signalingMap.clear(),this._signalingRelatedToMeMap.clear()}}class wt{constructor(t,e){this.businessID=t.businessID||1,this.inviteID=t.inviteID,this.groupID=t.groupID||"",this.inviter=t.inviter||"",this.inviteeList=t.inviteeList||[],this.data=t.data||"",this.actionType=t.actionType||_t,this.timeout=t.timeout||0}}const Ct={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};class Tt extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.getModule(i).isLoggedIn()}isOversea(){return this._m.getModule(i).isOversea()}isPrivateNetWork(){return this._m.getModule(i).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(i).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(i).getUserID()}getMyTinyID(){return this._m.getModule(i).getTinyID()}getSDKAppID(){return this._m.getModule(i).getSDKAppID()}isIntl(){return this._m.getModule(i).isIntl()}isDevMode(){return this._m.getModule(i).isDevMode()}getModule(t){return this._m.getModule(t)}getPlatform(){return E}getNetworkType(){return this._m.getModule(s).getNetworkType()}probeNetwork(t){return this._m.getModule(s).probe(t)}getCloudConfig(t){return this._m.getModule(a).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(t){return this._m.getModule(i).getTinyID()+"-"+t.random}filterModifiedMessage(t){if(Q(t))return;const e=t.filter(t=>!0===t.isModified);e.length>0&&this.emitOuterEvent(l,e)}filterUnmodifiedMessage(t){if(Q(t))return[];return t.filter(t=>!1===t.isModified)}request(t){return this._m.getModule(o).request(t)}canIUse(t){return this._m.getModule(r).canIUse(t)}getErrorMessage(t,e,n){return this._m.getErrorMessage(t,e,n)}outputWarning(t,e,n){const i=this.getErrorMessage(t,e,n);i&&B.w(i)}cannotUseCommercialAbility(t){const e=nt;return rt({code:e,message:this.getErrorMessage(e,t)})}}{constructor(e){super(e),this._n="SignalingModule",this._inviteInfoMap=new Map,this._outerEmitter=new t,this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(...t){const e=[t[0],{name:t[0],data:t[1]}];this._outerEmitter._emit.apply(this._outerEmitter,[...e])}.bind(this),this._canIUseSignaling=!1,this._isHandling=!1,this._remoteSignalingHandler=new pt(this),this._localSignalingHandler=new St(this),this._historySignalingHandler=new yt(this),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1,this.getInnerEmitterInstance().on(Ct.C2C_UNREAD_HANDLE_COMPLETED,this.onC2CUnreadHandleCompleted,this),this.getInnerEmitterInstance().on(Ct.CONV_SYNC_COMPLETED,this.onConvSyncCompleted,this)}onC2CUnreadHandleCompleted(){this._isC2CUnreadHandleCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onConvSyncCompleted(){this._isConvSyncCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onReady(){B.l(this._n+".onReady"),this._isSyncCompleted=!0,this._historySignalingHandler.getHistorySignaling()}onNewMessageList(t){return this._remoteSignalingHandler.onNewMessageList(t)}onMessageModified(t){return this._remoteSignalingHandler.onMessageModified(t)}hasInviteInfo(t){return this._inviteInfoMap.has(t)}getInviteInfo(t){return this._inviteInfoMap.get(t)}setInviteInfo(t,e){const{message:n,...i}=e;B.l(`${this._n}.setInviteInfo inviteID:${t} data:${JSON.stringify(i)}`),this._inviteInfoMap.set(t,{...i,message:n})}deleteInviteInfo(t){this.hasInviteInfo(t)&&(B.l(`${this._n}.deleteInviteInfo inviteID:${t}.`),this._inviteInfoMap.delete(t))}updateInviteInfo(t){const e=this._n+".updateInviteInfo",{inviteID:n,inviter:i,inviteeList:s,groupID:o}=t;if(B.l(`${e} inviteID:${n} inviter:${i} groupID:${o}`),o&&this.hasInviteInfo(n)){const t=s[0],{inviteeList:i}=this.getInviteInfo(n);i.includes(t)&&(i.splice(i.indexOf(t),1),B.l(`${e} remove ${t}. localInviteeList.length:${i.length}`)),0===i.length&&this.deleteInviteInfo(n)}else this.deleteInviteInfo(n)}getLocalSignalingHandler(){return this._localSignalingHandler}getRemoteSignalingHandler(){return this._remoteSignalingHandler}canIUseSignaling(){return this._canIUseSignaling}emitEvent(t,e){this._outerEmitter.emit(t,e)}addSignalingListener(t,e,n){this._canIUseSignaling||(this._canIUseSignaling=!0),this._outerEmitter.on(t,e,n)}removeSignalingListener(t,e,n){this._outerEmitter.off(t,e,n),0===this._outerEmitter.eventNames().length&&(this._canIUseSignaling=!1)}invite(t){const e=this._n+".invite",{message:n,customData:i,inviteID:s}=this._localSignalingHandler.createInviteInfo(t);return B.l(`${e} options:${JSON.stringify(t)} inviteID:${s}`),this.sendSignaling(n,t).then(t=>t&&0===t.code?(this.setInviteInfo(s,{...i,message:n}),this.startTimer({...i,inviteID:s}),{...t,inviteID:s}):t).catch(t=>rt(t))}inviteSync(t,e,n){const i=this._n+".inviteSync",{message:s,customData:o,inviteID:a}=this._localSignalingHandler.createInviteInfo(t);return B.l(`${i} options:${JSON.stringify(t)} inviteID:${a}`),this.sendSignaling(s,t).then(t=>{if(t&&0===t.code)return this.setInviteInfo(a,{...o,message:s}),this.startTimer({...o,inviteID:a}),e&&e({inviteID:a}),{inviteID:a};n&&n(0===t.code,t.message||"")}).catch(t=>(n&&n(t.code,t.message),rt(t))),a}_handleImResponse(t,e,n){e&&0===e.code&&(this._isHandling=!1,n?this.deleteInviteInfo(t.inviteID):this.updateInviteInfo(t))}cancel(t){const e=this._n+".cancel";if(B.l(`${e} options:${JSON.stringify(t)}`),!this.hasInviteInfo(t.inviteID)||this._isHandling)return rt({code:ot});this._isHandling=!0;const n=this._localSignalingHandler.createCancelCustomData(t);if(!n)return this._isHandling=!1,rt({code:st});const{groupID:i,inviteeList:s}=n,o=i||s[0],a=this._localSignalingHandler.createSignalingMessage(n,o);return this.sendSignaling(a,t).then(e=>(this._handleImResponse(n,e,!0),0===e.code?{...e,inviteID:t.inviteID}:e)).catch(t=>rt(t))}accept(t){const e=this._n+".accept";if(B.l(`${e} options:${JSON.stringify(t)}`),!this.hasInviteInfo(t.inviteID)||this._isHandling)return rt({code:it});this._isHandling=!0;const n=this._localSignalingHandler.createAcceptCustomData(t);if(!n)return this._isHandling=!1,rt({code:st});const i=this._localSignalingHandler.createSignalingMessage(n);return this.sendSignaling(i,t).then(e=>(this._handleImResponse(n,e),0===e.code?{...e,inviteID:t.inviteID}:e)).catch(t=>rt(t))}reject(t){const e=this._n+".reject";if(B.l(`${e} options:${JSON.stringify(t)}`),!this.hasInviteInfo(t.inviteID)||this._isHandling)return rt({code:it});this._isHandling=!0;const n=this._localSignalingHandler.createRejectCustomData(t);if(!n)return this._isHandling=!1,rt({code:st});const i=this._localSignalingHandler.createSignalingMessage(n);return this.sendSignaling(i,t).then(e=>(this._handleImResponse(n,e,!0),0===e.code?{...e,inviteID:t.inviteID}:e)).catch(t=>rt(t))}getSignalingInfo(t){const e=this._n+".getSignalingInfo",{ID:n,from:i,to:s}=t,o=this._filterSignalingMessage(t);let a=null;if(o){const e=this._remoteSignalingHandler.getPayloadData(t);a=new wt(e)}const r=o?"actionType:"+a.actionType:"";return B.l(`${e} messageID:${n} from:${i} to:${s} ${r} isSignaling:${o}`),a}modifyInvitation(t){const{inviteID:n,data:i}=t;if(!this.hasInviteInfo(t.inviteID)||this._isHandling)return rt({code:it});this._isHandling=!0;const{message:s,...o}=this.getInviteInfo(n),a=s.payload.data;o.data=i,s.payload.data=JSON.stringify(o);return this.getModule(e).modifyRemoteMessage(s).then(t=>(this.setInviteInfo(n,{...o,message:s}),this._isHandling=!1,t)).catch(t=>(this._isHandling=!1,s.payload.data=a,rt(t)))}_genMessageControlInfo(t={}){const{data:e="",onlineUserOnly:n,inviteID:i="",offlinePushInfo:s,actionType:o}=t;let a={_onlineOnlyFlag:!1};i&&this.getInviteInfo(i)&&(a=this.getInviteInfo(i).message);const r={onlineUserOnly:a._onlineOnlyFlag||n||!1,offlinePushInfo:s,messageControlInfo:{excludedFromContentModeration:!0,excludedFromUnreadCount:!1,excludedFromLastMessage:!1}};if(o===vt){const t=!!e.match(/excludeTimeoutSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=t,r.messageControlInfo.excludedFromLastMessage=t,r}const l=!!e.match(/excludeFromHistoryMessage/),g=!!e.match(/excludeOriginalSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=l||g,r.messageControlInfo.excludedFromLastMessage=l||g,r}sendSignaling(t,n){return this.getModule(e).sendMessageInstance(t,this._genMessageControlInfo(n)).catch(t=>(this._isHandling=!1,rt(t)))}filterMessageList(t){return t.filter(t=>this._filterSignalingMessage(t))}_filterSignalingMessage(t){let e=!1;if(t.type&&t.type===L){const{cloudCustomData:n="",payload:{data:i=""}}=t,s=n.match(/"type":"tsignaling"/),o=i.match(/inviteID/),a=i.match(/actionType/);e=s||o&&a}return!!e}startTimer(t){const e=this._n+".startTimer",{timeout:n,inviteID:i,inviter:s,groupID:o}=t,a=s===this.getMyUserID();if(B.l(`${e} timeout:${n} isInviter:${a} groupID:${o}`),n<=0)return;const r=a?n+5:n;let l=1;const g=setInterval(()=>{const n=this._hasLocalInviteInfo(t,a);l<r&&n?++l:(n&&this._sendTimeoutNotice(i,a),B.l(e+" end."),clearInterval(g))},1e3)}_hasLocalInviteInfo(t,e){const{inviteID:n,groupID:i}=t;if(!this.hasInviteInfo(n))return!1;const s=this._n+"._hasLocalInviteInfo",{inviteeList:o}=this.getInviteInfo(n);return B.l(`${s} inviteID:${n} inviteeList:${o} groupID:${i}`),!i||(e?o.length>0:o.length>0&&o.includes(this.getMyUserID()))}_getReceiver(t,e){const{groupID:n,inviteeList:i,inviter:s}=e;return t?n||i[0]:n||s}_sendTimeoutNotice(t,e){const n=this.getInviteInfo(t),i=this._getReceiver(e,n);B.l(`${this._n}._sendTimeoutNotice inviteID:${t} to:${i} isInviter:${e}`);const s=this._localSignalingHandler.createTimeoutCustomData({...n,isInviter:e}),o=this._localSignalingHandler.createSignalingMessage(s,i);return this.sendSignaling(o,s).then(n=>{if(n&&0===n.code){const{data:n,groupID:i,inviteeList:a,inviter:r}=s;this.emitEvent(ht,{data:n,groupID:i,inviteID:t,inviteeList:a,inviter:r,isSelfTimeout:!0,message:o}),e?this.deleteInviteInfo(t):this.updateInviteInfo(s)}})}reset(){B.l(this._n+".reset"),this._inviteInfoMap.clear(),this._canIUseSignaling=!1,this._isHandling=!1,this._historySignalingHandler.reset(),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1}}export{Tt as default}; |
{ | ||
"name": "@tencentcloud/chat", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Tencent Cloud Chat SDK for Web", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1408040
7600