forked from nsjcy/frontEnd/nsjcy

Mr Ke
2020-05-15 e36d04fc335547bc293078a77924c94a31e99cdc
1
2
3
module.exports=function(){var e={},t={login:function(e,t,n){},syncMsgs:function(e,t){},getC2CHistoryMsgs:function(e,t,n){},syncGroupMsgs:function(e,t,n){},sendMsg:function(e,t,n){},logout:function(e,t){},setAutoRead:function(e,t,n){},getProfilePortrait:function(e,t,n){},setProfilePortrait:function(e,t,n){},applyAddFriend:function(e,t,n){},getPendency:function(e,t,n){},deletePendency:function(e,t,n){},responseFriend:function(e,t,n){},getAllFriend:function(e,t,n){},deleteFriend:function(e,t,n){},addBlackList:function(e,t,n){},getBlackList:function(e,t,n){},deleteBlackList:function(e,t,n){},uploadPic:function(e,t,n){},createGroup:function(e,t,n){},applyJoinGroup:function(e,t,n){},handleApplyJoinGroup:function(e,t,n){},deleteApplyJoinGroupPendency:function(e,t,n){},quitGroup:function(e,t,n){},getGroupPublicInfo:function(e,t,n){},getGroupInfo:function(e,t,n){},modifyGroupBaseInfo:function(e,t,n){},destroyGroup:function(e,t,n){},getJoinedGroupListHigh:function(e,t,n){},getGroupMemberInfo:function(e,t,n){},addGroupMember:function(e,t,n){},modifyGroupMember:function(e,t,n){},forbidSendMsg:function(e,t,n){},deleteGroupMember:function(e,t,n){},sendCustomGroupNotify:function(e,t,n){},Msg:function(e,t,n,o,r,i,s,u){},MsgStore:{sessMap:function(){return{}},sessCount:function(){return 0},sessByTypeId:function(e,t){return{}},delSessByTypeId:function(e,t){return!0},resetCookieAndSyncFlag:function(){},downloadMap:{}}};return function(t){var n={VERSION:"1.7.0",APPID:"537048168"},o=!0,r={FORMAL:{COMMON:"https://webim.tim.qq.com",PIC:"https://pic.tim.qq.com"},TEST:{COMMON:"https://test.tim.qq.com",PIC:"https://pic.tim.qq.com"}},i={},s={OPEN_IM:"openim",GROUP:"group_open_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat"},u={openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v1",group_open_long_polling_http_noauth_svc:"v1",imopenstat:"v4"},a={login:1,pic_up:3,apply_join_group:9,create_group:10,longpolling:18,send_group_msg:19,sendmsg:20},c={C2C:"C2C",GROUP:"GROUP"},l={C2C:1,GROUP:2},p={C2C:12e3,GROUP:8898},f={OK:"OK",FAIL:"FAIL"},g={TEXT:"TIMTextElem",FACE:"TIMFaceElem",IMAGE:"TIMImageElem",CUSTOM:"TIMCustomElem",SOUND:"TIMSoundElem",FILE:"TIMFileElem",LOCATION:"TIMLocationElem",GROUP_TIP:"TIMGroupTipElem"},d={ORIGIN:1,LARGE:2,SMALL:3},m={RAW_DATA:0,BASE64_DATA:1},I={BUSSINESS_ID:"10001",AUTH_KEY:"617574686b6579",SERVER_IP:"182.140.186.147"},M={SOUND:2106,FILE:2107},E={IMAGE:1,FILE:2,SHORT_VIDEO:3,SOUND:4},_={APP_VERSION:"2.1",SERVER_VERSION:1},y={C2C:1,GROUP_COMMON:3,GROUP_TIP:4,GROUP_SYSTEM:5,GROUP_TIP2:6,FRIEND_NOTICE:7,PROFILE_NOTICE:8,C2C_COMMON:9,C2C_EVENT:10},h={COMMON:0},C={READED:92},T={COMMON:0,LOVEMSG:1,TIP:2,REDPACKET:3},A={REDPACKET:1,COMMON:2,LOVEMSG:3},S={JOIN:1,QUIT:2,KICK:3,SET_ADMIN:4,CANCEL_ADMIN:5,MODIFY_GROUP_INFO:6,MODIFY_MEMBER_INFO:7},G={FACE_URL:1,NAME:2,OWNER:3,NOTIFICATION:4,INTRODUCTION:5},O={JOIN_GROUP_REQUEST:1,JOIN_GROUP_ACCEPT:2,JOIN_GROUP_REFUSE:3,KICK:4,DESTORY:5,CREATE:6,INVITED_JOIN_GROUP_REQUEST:7,QUIT:8,SET_ADMIN:9,CANCEL_ADMIN:10,REVOKE:11,READED:15,CUSTOM:255},F={FRIEND_ADD:1,FRIEND_DELETE:2,PENDENCY_ADD:3,PENDENCY_DELETE:4,BLACK_LIST_ADD:5,BLACK_LIST_DELETE:6,PENDENCY_REPORT:7,FRIEND_UPDATE:8},R={PROFILE_MODIFY:1},v={OK:0,SIGNATURE_EXPIRATION:11},N={INIT:-1,ON:0,RECONNECT:1,OFF:9999},P={GROUP_MSG:1,C2C_MSG:2,USER_HEAD:3,GROUP_HEAD:4},b={ING:14,STOP:15},L=N.INIT,U=!1,D=0,k=6e4,w=null,q=0,x=0,B=0,K=null,z=null,V=0,J=[],H=null,Y=null,X={sdkAppID:null,appIDAt3rd:null,accountType:null,identifier:null,tinyid:null,identifierNick:null,userSig:null,a2:null,contentType:"json",apn:1},Q={},W=0,j={},$=0,Z=[],ee=[],te=[],ne={downloadMap:{}},oe={"[惊讶]":0,"[撇嘴]":1,"[色]":2,"[发呆]":3,"[得意]":4,"[流泪]":5,"[害羞]":6,"[闭嘴]":7,"[睡]":8,"[大哭]":9,"[尴尬]":10,"[发怒]":11,"[调皮]":12,"[龇牙]":13,"[微笑]":14,"[难过]":15,"[酷]":16,"[冷汗]":17,"[抓狂]":18,"[吐]":19,"[偷笑]":20,"[可爱]":21,"[白眼]":22,"[傲慢]":23,"[饿]":24,"[困]":25,"[惊恐]":26,"[流汗]":27,"[憨笑]":28,"[大兵]":29,"[奋斗]":30,"[咒骂]":31,"[疑问]":32,"[嘘]":33,"[晕]":34},re={},ie=new function(){this.formatTimeStamp=function(e,t){if(!e)return 0;var n;t=t||"yyyy-MM-dd hh:mm:ss";var o=new Date(1e3*e),r={"M+":o.getMonth()+1,"d+":o.getDate(),"h+":o.getHours(),"m+":o.getMinutes(),"s+":o.getSeconds()};n=/(y+)/.test(t)?t.replace(RegExp.$1,(o.getFullYear()+"").substr(4-RegExp.$1.length)):t;for(var i in r)new RegExp("("+i+")").test(n)&&(n=n.replace(RegExp.$1,1==RegExp.$1.length?r[i]:("00"+r[i]).substr((""+r[i]).length)));return n},this.groupTypeEn2Ch=function(e){var t=null;switch(e){case"Public":t="公开群";break;case"ChatRoom":t="聊天室";break;case"Private":t="讨论组";break;case"AVChatRoom":t="直播聊天室";break;default:t=e}return t},this.groupTypeCh2En=function(e){var t=null;switch(e){case"公开群":t="Public";break;case"聊天室":t="ChatRoom";break;case"讨论组":t="Private";break;case"直播聊天室":t="AVChatRoom";break;default:t=e}return t},this.groupRoleEn2Ch=function(e){var t=null;switch(e){case"Member":t="成员";break;case"Admin":t="管理员";break;case"Owner":t="群主";break;default:t=e}return t},this.groupRoleCh2En=function(e){var t=null;switch(e){case"成员":t="Member";break;case"管理员":t="Admin";break;case"群主":t="Owner";break;default:t=e}return t},this.groupMsgFlagEn2Ch=function(e){var t=null;switch(e){case"AcceptAndNotify":t="接收并提示";break;case"AcceptNotNotify":t="接收不提示";break;case"Discard":t="屏蔽";break;default:t=e}return t},this.groupMsgFlagCh2En=function(e){var t=null;switch(e){case"接收并提示":t="AcceptAndNotify";break;case"接收不提示":t="AcceptNotNotify";break;case"屏蔽":t="Discard";break;default:t=e}return t},this.formatText2Html=function(e){var t=e;return t&&(t=this.xssFilter(t),t=t.replace(/ /g,"&nbsp;"),t=t.replace(/\n/g,"<br/>")),t},this.formatHtml2Text=function(e){var t=e;return t&&(t=t.replace(/&nbsp;/g," "),t=t.replace(/<br\/>/g,"\n")),t},this.getStrBytes=function(e){if(null==e||void 0===e)return 0;if("string"!=typeof e)return 0;var t,n,o,r=0;for(n=0,o=e.length;n<o;n++)t=e.charCodeAt(n),r+=t<=127?1:t<=2047?2:t<=65535?3:4;return r},this.xssFilter=function(e){return e=e.toString(),e=e.replace(/[<]/g,"&lt;"),e=e.replace(/[>]/g,"&gt;"),e=e.replace(/"/g,"&quot;")},this.trimStr=function(e){return e?(e=e.toString(),e.replace(/(^\s*)|(\s*$)/g,"")):""},this.validNumber=function(e){return e=e.toString(),e.match(/(^\d{1,8}$)/g)},this.getReturnError=function(e,t){return t||(t=-100),{ActionStatus:f.FAIL,ErrorCode:t,ErrorInfo:e+"["+t+"]"}},this.setCookie=function(e,t,n,o,r){var i=new Date;i.setTime(i.getTime()+1e3*n),document.cookie=e+"="+escape(t)+";expires="+i.toGMTString()},this.getCookie=function(e){var t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]*)(;|$)"));return null!=t?unescape(t[2]):null},this.delCookie=function(e){var t=new Date;t.setTime(t.getTime()-1);var n=this.getCookie(e);null!=n&&(document.cookie=e+"="+escape(n)+";expires="+t.toGMTString())},this.getQueryString=function(e){var t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),n=location.search.substr(1).match(t);return null!=n?unescape(n[2]):null}},se=new function(){var e=!0;this.setOn=function(t){e=t},this.getOn=function(){return e},this.error=function(t){try{e&&console.error(t)}catch(e){}},this.warn=function(t){try{e&&console.warn(t)}catch(e){}},this.info=function(t){try{e&&console.info(t)}catch(e){}},this.debug=function(t){try{e&&console.debug(t)}catch(e){}}},ue=function(e){return e||(e=new Date),Math.round(e.getTime()/1e3)},ae=function(){return $?$+=1:$=Math.round(1e7*Math.random()),$},ce=function(){return Math.round(4294967296*Math.random())},le=function(e,t,n,o,r,i,s){wx.request({url:t,data:n,dataType:"json",method:e,header:{"Content-Type":"application/json"},success:function(e){D=q=0,i&&i(e.data)},fail:function(e){setTimeout(function(){var e=ie.getReturnError("请求服务器失败,请检查你的网络是否正常",-2);s&&s(e)},16)}})},pe=function(e,t,n,o,r,i,s){le(e,t,JSON.stringify(n),0,0,function(e){var t=null;e&&(t=JSON.parse(e)),i&&i(t)},s)},fe=function(){return X.sdkAppID&&X.identifier},ge=function(e,t){if(!fe()){if(t){var n=ie.getReturnError("请登录",-4);e&&e(n)}return!1}return!0},de=function(){return o},me=function(e,t,o,i){var a=r;a=de()?r.FORMAL.COMMON:r.TEST.COMMON,e==s.PIC&&(a=de()?r.FORMAL.PIC:r.TEST.PIC);var c=a+"/"+u[e]+"/"+e+"/"+t+"?websdkappid="+n.APPID+"&v="+n.VERSION;if(fe()){if("login"==t)c+="&identifier="+encodeURIComponent(X.identifier)+"&usersig="+X.userSig;else if(X.tinyid&&X.a2)c+="&tinyid="+X.tinyid+"&a2="+X.a2;else if(i)return se.error("tinyid或a2为空["+e+"]["+t+"]"),i(ie.getReturnError("tinyid或a2为空["+e+"]["+t+"]",-5)),!1;c+="&contenttype="+X.contentType}return c+="&sdkappid="+X.sdkAppID+"&accounttype="+X.accountType+"&apn="+X.apn+"&reqtime="+ue()},Ie=function(e,t){var n=null;return H&&J[0]?n="http://"+J[0]+"/asn.com/stddownload_common_file?authkey="+H+"&bid="+I.BUSSINESS_ID+"&subbid="+X.sdkAppID+"&fileid="+e+"&filetype="+M.SOUND+"&openid="+t+"&ver=0":se.error("拼接语音下载url不报错:ip或者authkey为空"),n},Me=function(e,t,n){var o=null;return H&&J[0]?o="http://"+J[0]+"/asn.com/stddownload_common_file?authkey="+H+"&bid="+I.BUSSINESS_ID+"&subbid="+X.sdkAppID+"&fileid="+e+"&filetype="+M.FILE+"&openid="+t+"&ver=0&filename="+encodeURIComponent(n):se.error("拼接文件下载url不报错:ip或者authkey为空"),ne.downloadMap["uuid_"+e]=o,o},Ee=function(e,t,n,o,r,i,s){var u={From_Account:t,To_Account:r,os_platform:10,Timestamp:ue().toString(),Random:ce().toString(),request_info:[{busi_id:i,download_flag:o,type:s,uuid:e,version:_.SERVER_VERSION,auth_key:H,ip:J[0]}]};Et(u,function(e){0==e.error_code&&e.response_info&&(ne.downloadMap["uuid_"+u.uuid]=e.response_info.url),onAppliedDownloadUrl&&onAppliedDownloadUrl({uuid:u.uuid,url:e.response_info.url,maps:ne.downloadMap})},function(e){se.error("获取下载地址失败",u.uuid)})},_e=function(){for(var e in j){var t=j[e];t&&(t.abort(),j[W]=null)}W=0,j={}},ye=function(){_e(),X={sdkAppID:null,appIDAt3rd:null,accountType:null,identifier:null,identifierNick:null,userSig:null,contentType:"json",apn:1},Q={},$=0,B=0,K=null,te=[],At.clear(),w=null},he=function(e,t,n,r,i){return ye(),n&&(Q=n),0==Q.isAccessFormalEnv&&(se.error("请切换为正式环境"),o=Q.isAccessFormalEnv),0==Q.isLogOn&&se.setOn(Q.isLogOn),!e&&i?void i(ie.getReturnError("loginInfo is empty",-6)):!e.sdkAppID&&i?void i(ie.getReturnError("loginInfo.sdkAppID is empty",-7)):!e.accountType&&i?void i(ie.getReturnError("loginInfo.accountType is empty",-8)):(e.identifier&&(X.identifier=e.identifier.toString()),e.identifier&&!e.userSig&&i?void i(ie.getReturnError("loginInfo.userSig is empty",-9)):(e.userSig&&(X.userSig=e.userSig.toString()),X.sdkAppID=e.sdkAppID,X.accountType=e.accountType,void(X.identifier&&X.userSig?Te(function(e,n){At.init(t,function(t){r&&(t.identifierNick=e,t.headurl=n,r(t))},i)},i):At.init(t,r,i))))},Ce=function(e,t,o){if("longpolling"!=e||60008!=t&&91101!=t){var r=a[e];if(r){var i=ue(),s=null,u={Code:t,ErrMsg:o};if(X.a2?s=X.a2.substring(0,10)+"_"+i+"_"+ce():X.userSig&&(s=X.userSig.substring(0,10)+"_"+i+"_"+ce()),s){var c={UniqKey:s,EventId:r,ReportTime:i,MsgCmdErrorCode:u};if("login"==e){var l=[];l.push(c);It({EvtItems:l,MainVersion:n.VERSION,Version:"0"},function(e){l=null},function(e){l=null})}else if(te.push(c),te.length>=20){var p={EvtItems:te,MainVersion:n.VERSION,Version:"0"};It(p,function(e){te=[]},function(e){te=[]})}}}}},Te=function(e,t){_t.apiCall(s.OPEN_IM,"login",{State:"Online"},function(n){if(n.TinyId)X.tinyid=n.TinyId;else if(t)return void t(ie.getReturnError("TinyId is empty",-10));if(n.A2Key)X.a2=n.A2Key;else if(t)return void t(ie.getReturnError("A2Key is empty",-11));var o=["Tag_Profile_IM_Nick","Tag_Profile_IM_Image"],r={From_Account:X.identifier,To_Account:[X.identifier],LastStandardSequence:0,TagList:o};at(r,function(t){var n;if(t.UserProfileItem&&t.UserProfileItem.length>0)for(var o in t.UserProfileItem)for(var r in t.UserProfileItem[o].ProfileItem)switch(t.UserProfileItem[o].ProfileItem[r].Tag){case"Tag_Profile_IM_Nick":n=t.UserProfileItem[o].ProfileItem[r].Value,n&&(X.identifierNick=n);break;case"Tag_Profile_IM_Image":image=t.UserProfileItem[o].ProfileItem[r].Value,image&&(X.headurl=image)}e&&e(X.identifierNick,X.headurl)},t)},t)},Ae=function(e,t,n){if(!ge(n,!1))return ye(),void(t&&t({ActionStatus:f.OK,ErrorCode:0,ErrorInfo:"logout success"}));"all"==e?_t.apiCall(s.OPEN_IM,"logout",{},function(e){ye(),t&&t(e)},n):_t.apiCall(s.OPEN_IM,"longpollinglogout",{LongPollingId:w},function(e){ye(),t&&t(e)},n)},Se=function(e,t,n){if(ge(n,!0)){var o=null;switch(e.sess.type()){case c.C2C:o={From_Account:X.identifier,To_Account:e.sess.id().toString(),MsgTimeStamp:e.time,MsgSeq:e.seq,MsgRandom:e.random,MsgBody:[]};break;case c.GROUP:var r=e.getSubType();switch(o={GroupId:e.sess.id().toString(),From_Account:X.identifier,Random:e.random,MsgBody:[]},r){case T.COMMON:o.MsgPriority="COMMON";break;case T.REDPACKET:o.MsgPriority="REDPACKET";break;case T.LOVEMSG:o.MsgPriority="LOVEMSG";break;case T.TIP:se.error("不能主动发送群提示消息,subType="+r);break;default:return void se.error("发送群消息时,出现未知子消息类型:subType="+r)}}for(var i in e.elems){var u=e.elems[i],a=null,l=u.type;switch(l){case g.TEXT:a={Text:u.content.text};break;case g.FACE:a={Index:u.content.index,Data:u.content.data};break;case g.IMAGE:var p=[];for(var f in u.content.ImageInfoArray)p.push({Type:u.content.ImageInfoArray[f].type,Size:u.content.ImageInfoArray[f].size,Width:u.content.ImageInfoArray[f].width,Height:u.content.ImageInfoArray[f].height,URL:u.content.ImageInfoArray[f].url});a={UUID:u.content.UUID,ImageInfoArray:p};break;case g.SOUND:se.warn("web端暂不支持发送语音消息");continue;case g.LOCATION:se.warn("web端暂不支持发送地理位置消息");continue;case g.FILE:a={UUID:u.content.uuid,FileName:u.content.name,FileSize:u.content.size,DownloadFlag:u.content.downFlag};break;case g.CUSTOM:a={Data:u.content.data,Desc:u.content.desc,Ext:u.content.ext},l=g.CUSTOM;break;default:se.warn("web端暂不支持发送"+u.type+"消息");continue}e.PushInfoBoolean&&(o.OfflinePushInfo=e.PushInfo),o.MsgBody.push({MsgType:l,MsgContent:a})}e.sess.type()==c.C2C?_t.apiCall(s.OPEN_IM,"sendmsg",o,t,n):e.sess.type()==c.GROUP&&_t.apiCall(s.GROUP,"send_group_msg",o,t,n)}},Ge=function(e,t,n){(o||"undefined"==typeof stopPolling||1!=stopPolling)&&ge(n,!0)&&_t.apiCall(s.OPEN_IM,"longpolling",e,t,n,k,!0)},Oe=function(e,t,n,o){_t.apiCall(s.BIG_GROUP_LONG_POLLING,"get_msg",e,t,n,o)},Fe=function(e,t,n,o){ge(o,!0)&&_t.apiCall(s.OPEN_IM,"getmsg",{Cookie:e,SyncFlag:t},function(e){if(e.MsgList&&e.MsgList.length)for(var t in e.MsgList)Z.push(e.MsgList[t]);1==e.SyncFlag?Fe(e.Cookie,e.SyncFlag,n,o):(e.MsgList=Z,Z=[],n&&n(e))},o)},Re=function(e,t,n,o){if(ge(o,!0)){var r=[];for(var i in t){var u={To_Account:t[i].toAccount,LastedMsgTime:t[i].lastedMsgTime};r.push(u)}_t.apiCall(s.OPEN_IM,"msgreaded",{C2CMsgReaded:{Cookie:e,C2CMsgReadedItem:r}},n,o)}},ve=function(e,t,n){ge(n,!0)&&_t.apiCall(s.OPEN_IM,"deletemsg",e,t,n)},Ne=function(e,t,n){ge(n,!0)&&_t.apiCall(s.OPEN_IM,"getroammsg",e,function(o){var r=e.MaxCnt,i=o.Complete,s=o.MaxCnt,u=o.MsgKey,a=o.LastMsgTime;if(o.MsgList&&o.MsgList.length)for(var c in o.MsgList)ee.push(o.MsgList[c]);var l=null;0==i&&s<r&&(l={Peer_Account:e.Peer_Account,MaxCnt:r-s,LastMsgTime:a,MsgKey:u}),l?Ne(l,t,n):(o.MsgList=ee,ee=[],t&&t(o))},n)},Pe=function(e,t,n){if(ge(n,!0)){for(var o={Type:e.Type,Name:e.Name},r=[],i=0;i<e.MemberList.length;i++)r.push({Member_Account:e.MemberList[i]});o.MemberList=r,e.GroupId&&(o.GroupId=e.GroupId),e.Owner_Account&&(o.Owner_Account=e.Owner_Account),e.Introduction&&(o.Introduction=e.Introduction),e.Notification&&(o.Notification=e.Notification),e.MaxMemberCount&&(o.MaxMemberCount=e.MaxMemberCount),e.ApplyJoinOption&&(o.ApplyJoinOption=e.ApplyJoinOption),e.AppDefinedData&&(o.AppDefinedData=e.AppDefinedData),e.FaceUrl&&(o.FaceUrl=e.FaceUrl),_t.apiCall(s.GROUP,"create_group",o,t,n)}},be=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"create_group",e,t,n)},Le=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"modify_group_base_info",e,t,n)},Ue=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"apply_join_group",{GroupId:e.GroupId,ApplyMsg:e.ApplyMsg,UserDefinedField:e.UserDefinedField},t,n)},De=function(e,t,n){var o;o=ge(n,!1)?s.GROUP:s.BIG_GROUP,_t.apiCall(o,"apply_join_group",{GroupId:e.GroupId,ApplyMsg:e.ApplyMsg,UserDefinedField:e.UserDefinedField},function(o){if(o.JoinedStatus&&"JoinedSuccess"==o.JoinedStatus){if(!o.LongPollingKey)return void(n&&n(ie.getReturnError("The type of group is not AVChatRoom: groupid="+e.GroupId,-12)));At.setBigGroupLongPollingOn(!0),At.setBigGroupLongPollingKey(o.LongPollingKey),At.setBigGroupLongPollingMsgMap(e.GroupId,0),At.bigGroupLongPolling()}t&&t(o)},function(e){n&&n(e)})},ke=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"handle_apply_join_group",{GroupId:e.GroupId,Applicant_Account:e.Applicant_Account,HandleMsg:e.HandleMsg,Authentication:e.Authentication,MsgKey:e.MsgKey,ApprovalMsg:e.ApprovalMsg,UserDefinedField:e.UserDefinedField},t,function(e){if(10024==e.ErrorCode){if(t){var o={ActionStatus:f.OK,ErrorCode:0,ErrorInfo:"该申请已经被处理过"};t(o)}}else n&&n(e)})},we=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"quit_group",{GroupId:e.GroupId},t,n)},qe=function(e,t,n){var o;o=ge(n,!1)?s.GROUP:s.BIG_GROUP,_t.apiCall(o,"quit_group",{GroupId:e.GroupId},function(e){At.resetBigGroupLongPollingInfo(),t&&t(e)},n)},xe=function(e,t,n){_t.apiCall(s.GROUP,"search_group",e,t,n)},Be=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"get_group_public_info",{GroupIdList:e.GroupIdList,ResponseFilter:{GroupBasePublicInfoFilter:e.GroupBasePublicInfoFilter}},function(e){if(e.ErrorInfo="",e.GroupInfo)for(var o in e.GroupInfo){var r=e.GroupInfo[o].ErrorCode;r>0&&(e.ActionStatus=f.FAIL,e.GroupInfo[o].ErrorInfo="["+r+"]"+e.GroupInfo[o].ErrorInfo,e.ErrorInfo+=e.GroupInfo[o].ErrorInfo+"\n")}e.ActionStatus==f.FAIL?n&&n(e):t&&t(e)},n)},Ke=function(e,t,n){if(ge(n,!0)){var o={GroupIdList:e.GroupIdList,ResponseFilter:{GroupBaseInfoFilter:e.GroupBaseInfoFilter,MemberInfoFilter:e.MemberInfoFilter}};e.AppDefinedDataFilter_Group&&(o.ResponseFilter.AppDefinedDataFilter_Group=e.AppDefinedDataFilter_Group),e.AppDefinedDataFilter_GroupMember&&(o.ResponseFilter.AppDefinedDataFilter_GroupMember=e.AppDefinedDataFilter_GroupMember),_t.apiCall(s.GROUP,"get_group_info",o,t,n)}},ze=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"get_group_member_info",{GroupId:e.GroupId,Offset:e.Offset,Limit:e.Limit,MemberInfoFilter:e.MemberInfoFilter,MemberRoleFilter:e.MemberRoleFilter,AppDefinedDataFilter_GroupMember:e.AppDefinedDataFilter_GroupMember},t,n)},Ve=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"add_group_member",{GroupId:e.GroupId,Silence:e.Silence,MemberList:e.MemberList},t,n)},Je=function(e,t,n){if(ge(n,!0)){var o={};e.GroupId&&(o.GroupId=e.GroupId),e.Member_Account&&(o.Member_Account=e.Member_Account),e.Role&&(o.Role=e.Role),e.MsgFlag&&(o.MsgFlag=e.MsgFlag),e.ShutUpTime&&(o.ShutUpTime=e.ShutUpTime),e.NameCard&&(o.NameCard=e.NameCard),e.AppMemberDefinedData&&(o.AppMemberDefinedData=e.AppMemberDefinedData),_t.apiCall(s.GROUP,"modify_group_member_info",o,t,n)}},He=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"delete_group_member",{GroupId:e.GroupId,Silence:e.Silence,MemberToDel_Account:e.MemberToDel_Account,Reason:e.Reason},t,n)},Ye=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"destroy_group",{GroupId:e.GroupId},t,n)},Xe=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"change_group_owner",e,t,n)},Qe=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"get_joined_group_list",{Member_Account:e.Member_Account,Limit:e.Limit,Offset:e.Offset,GroupType:e.GroupType,ResponseFilter:{GroupBaseInfoFilter:e.GroupBaseInfoFilter,SelfInfoFilter:e.SelfInfoFilter}},t,n)},We=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"get_role_in_group",{GroupId:e.GroupId,User_Account:e.User_Account},t,n)},je=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"forbid_send_msg",{GroupId:e.GroupId,Members_Account:e.Members_Account,ShutUpTime:e.ShutUpTime},t,n)},$e=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"send_group_system_notification",e,t,n)},Ze=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"group_msg_get",{GroupId:e.GroupId,ReqMsgSeq:e.ReqMsgSeq,ReqMsgNumber:e.ReqMsgNumber},t,n)},et=function(e,t,n){ge(n,!0)&&_t.apiCall(s.GROUP,"msg_read_report",{GroupId:e.GroupId,MsgReadedSeq:e.MsgReadedSeq},t,n)},tt=function(e){var t=[];if(e.Fail_Account&&e.Fail_Account.length&&(t=e.Fail_Account),e.Invalid_Account&&e.Invalid_Account.length)for(var n in e.Invalid_Account)t.push(e.Invalid_Account[n]);if(t.length){e.ActionStatus=f.FAIL,e.ErrorCode=99999,e.ErrorInfo="";for(var o in t){var r=t[o];for(var i in e.ResultItem)if(e.ResultItem[i].To_Account==r){var s=e.ResultItem[i].ResultCode;e.ResultItem[i].ResultInfo="["+s+"]"+e.ResultItem[i].ResultInfo,e.ErrorInfo+=e.ResultItem[i].ResultInfo+"\n";break}}}return e},nt=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"friend_add",{From_Account:X.identifier,AddFriendItem:e.AddFriendItem},function(e){var o=tt(e);o.ActionStatus==f.FAIL?n&&n(o):t&&t(o)},n)},ot=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"friend_delete",{From_Account:X.identifier,To_Account:e.To_Account,DeleteType:e.DeleteType},function(e){var o=tt(e);o.ActionStatus==f.FAIL?n&&n(o):t&&t(o)},n)},rt=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"pendency_get",{From_Account:X.identifier,PendencyType:e.PendencyType,StartTime:e.StartTime,MaxLimited:e.MaxLimited,LastSequence:e.LastSequence},t,n)},it=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"pendency_delete",{From_Account:X.identifier,PendencyType:e.PendencyType,To_Account:e.To_Account},function(e){var o=tt(e);o.ActionStatus==f.FAIL?n&&n(o):t&&t(o)},n)},st=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"friend_response",{From_Account:X.identifier,ResponseFriendItem:e.ResponseFriendItem},function(e){var o=tt(e);o.ActionStatus==f.FAIL?n&&n(o):t&&t(o)},n)},ut=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"friend_get_all",{From_Account:X.identifier,TimeStamp:e.TimeStamp,StartIndex:e.StartIndex,GetCount:e.GetCount,LastStandardSequence:e.LastStandardSequence,TagList:e.TagList},t,n)},at=function(e,t,n){ge(n,!0)&&_t.apiCall(s.PROFILE,"portrait_get",{From_Account:X.identifier,To_Account:e.To_Account,TagList:e.TagList},function(e){var o=[];if(e.Fail_Account&&e.Fail_Account.length&&(o=e.Fail_Account),e.Invalid_Account&&e.Invalid_Account.length)for(var r in e.Invalid_Account)o.push(e.Invalid_Account[r]);if(o.length){e.ActionStatus=f.FAIL,e.ErrorCode=99999,e.ErrorInfo="";for(var i in o){var s=o[i];for(var u in e.UserProfileItem)if(e.UserProfileItem[u].To_Account==s){var a=e.UserProfileItem[u].ResultCode;e.UserProfileItem[u].ResultInfo="["+a+"]"+e.UserProfileItem[u].ResultInfo,e.ErrorInfo+="账号:"+s+","+e.UserProfileItem[u].ResultInfo+"\n";break}}}e.ActionStatus==f.FAIL?n&&n(e):t&&t(e)},n)},ct=function(e,t,n){ge(n,!0)&&_t.apiCall(s.PROFILE,"portrait_set",{From_Account:X.identifier,ProfileItem:e.ProfileItem},function(n){for(var o in e.ProfileItem){var r=e.ProfileItem[o];if("Tag_Profile_IM_Nick"==r.Tag){X.identifierNick=r.Value;break}}t&&t(n)},n)},lt=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"black_list_add",{From_Account:X.identifier,To_Account:e.To_Account},function(e){var o=tt(e);o.ActionStatus==f.FAIL?n&&n(o):t&&t(o)},n)},pt=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"black_list_delete",{From_Account:X.identifier,To_Account:e.To_Account},function(e){var o=tt(e);o.ActionStatus==f.FAIL?n&&n(o):t&&t(o)},n)},ft=function(e,t,n){ge(n,!0)&&_t.apiCall(s.FRIEND,"black_list_get",{From_Account:X.identifier,StartIndex:e.StartIndex,MaxLimited:e.MaxLimited,LastSequence:e.LastSequence},t,n)},gt=function(e,t,n){ge(n,!0)&&_t.apiCall(s.RECENT_CONTACT,"get",{From_Account:X.identifier,Count:e.Count},t,n)},dt=function(e,t,n){if(ge(n,!0)){var o;o=de()?"pic_up":"pic_up_test",_t.apiCall(s.PIC,o,{App_Version:_.APP_VERSION,From_Account:X.identifier,To_Account:e.To_Account,Seq:e.Seq,Timestamp:e.Timestamp,Random:e.Random,File_Str_Md5:e.File_Str_Md5,File_Size:e.File_Size,File_Type:e.File_Type,Server_Ver:_.SERVER_VERSION,Auth_Key:H,Busi_Id:e.Busi_Id,PkgFlag:e.PkgFlag,Slice_Offset:e.Slice_Offset,Slice_Size:e.Slice_Size,Slice_Data:e.Slice_Data},t,n)}},mt=function(e,t){ge(t,!0)&&_t.apiCall(s.OPEN_IM,"authkey",{},e,t)},It=function(e,t,n){ge(n,!0)&&_t.apiCall(s.IM_OPEN_STAT,"web_report",e,t,n)},Mt=function(e,t,n){ge(n,!0)&&_t.apiCall(s.OPEN_IM,"getlongpollingid",{},function(e){t&&t(e)},n)},Et=function(e,t,n){_t.apiCall(s.PIC,"apply_download",e,t,n)};!function(){i="wechat"}();var _t=new function(){var e=null;this.init=function(t,n,o){t&&(e=t)},this.callBack=function(t){e&&e(t)},this.clear=function(){e=null},this.apiCall=function(e,t,n,o,r,i,s){var u=me(e,t,0,r);0!=u&&pe("POST",u,n,0,0,function(i){var s=null,a="";"pic_up"==t&&(n.Slice_Data="");var c="\n request url: \n"+u+"\n request body: \n"+JSON.stringify(n)+"\n response: \n"+JSON.stringify(i);i.ActionStatus==f.OK?(se.info("["+e+"]["+t+"]success: "+c),o&&o(i),s=0,a=""):(s=i.ErrorCode,a=i.ErrorInfo,r&&(i.SrcErrorInfo=i.ErrorInfo,i.ErrorInfo="["+e+"]["+t+"]failed: "+c,"longpolling"==t&&60008==i.ErrorCode||se.error(i.ErrorInfo),r(i))),Ce(t,s,a)},function(e){r&&r(e),Ce(t,e.ErrorCode,e.ErrorInfo)})}},yt=function(e,t,n,o,r,i){this._impl={skey:yt.skey(e,t),type:e,id:t,name:n,icon:o,unread:0,isAutoRead:!1,time:r>=0?r:0,curMaxMsgSeq:i>=0?i:0,msgs:[],isFinished:1}};yt.skey=function(e,t){return e+t},yt.prototype.type=function(){return this._impl.type},yt.prototype.id=function(){return this._impl.id},yt.prototype.name=function(){return this._impl.name},yt.prototype.icon=function(){return this._impl.icon},yt.prototype.unread=function(e){if(void 0===e)return this._impl.unread;this._impl.unread=e},yt.prototype.isFinished=function(e){if(void 0===e)return this._impl.isFinished;this._impl.isFinished=e},yt.prototype.time=function(){return this._impl.time},yt.prototype.curMaxMsgSeq=function(e){if(void 0===e)return this._impl.curMaxMsgSeq;this._impl.curMaxMsgSeq=e},yt.prototype.msgCount=function(){return this._impl.msgs.length},yt.prototype.msg=function(e){return this._impl.msgs[e]},yt.prototype.msgs=function(){return this._impl.msgs},yt.prototype._impl_addMsg=function(e){this._impl.msgs.push(e),e.time>this._impl.time&&(this._impl.time=e.time),e.seq>this._impl.curMaxMsgSeq&&(this._impl.curMaxMsgSeq=e.seq),e.isSend||this._impl.isAutoRead||this._impl.unread++};var ht=function(e,t){this.toAccount=e,this.lastedMsgTime=t},Ct=function(e,t,n,o,r,i,s,u){this.sess=e,this.subType=s>=0?s:0,this.fromAccount=i,this.fromAccountNick=u||i,this.isSend=Boolean(t),this.seq=n>=0?n:ae(),this.random=o>=0?o:ce(),this.time=r>=0?r:ue(),this.elems=[]};Ct.prototype.getSession=function(){return this.sess},Ct.prototype.getType=function(){return this.subType},Ct.prototype.getSubType=function(){return this.subType},Ct.prototype.getFromAccount=function(){return this.fromAccount},Ct.prototype.getFromAccountNick=function(){return this.fromAccountNick},Ct.prototype.getIsSend=function(){return this.isSend},Ct.prototype.getSeq=function(){return this.seq},Ct.prototype.getTime=function(){return this.time},Ct.prototype.getRandom=function(){return this.random},Ct.prototype.getElems=function(){return this.elems},Ct.prototype.addText=function(e){this.addElem(new t.Msg.Elem(g.TEXT,e))},Ct.prototype.addFace=function(e){this.addElem(new t.Msg.Elem(g.FACE,e))},Ct.prototype.addImage=function(e){this.addElem(new t.Msg.Elem(g.IMAGE,e))},Ct.prototype.addLocation=function(e){this.addElem(new t.Msg.Elem(g.LOCATION,e))},Ct.prototype.addFile=function(e){this.addElem(new t.Msg.Elem(g.FILE,e))},Ct.prototype.addCustom=function(e){this.addElem(new t.Msg.Elem(g.CUSTOM,e))},Ct.prototype.addElem=function(e){this.elems.push(e)},Ct.prototype.toHtml=function(){var e="";for(var t in this.elems){e+=this.elems[t].toHtml()}return e},Ct.Elem=function(e,t){this.type=e,this.content=t},Ct.Elem.prototype.getType=function(){return this.type},Ct.Elem.prototype.getContent=function(){return this.content},Ct.Elem.prototype.toHtml=function(){return this.content.toHtml()},Ct.Elem.Text=function(e){this.text=ie.xssFilter(e)},Ct.Elem.Text.prototype.getText=function(){return this.text},Ct.Elem.Text.prototype.toHtml=function(){return this.text},Ct.Elem.Face=function(e,t){this.index=e,this.data=t},Ct.Elem.Face.prototype.getIndex=function(){return this.index},Ct.Elem.Face.prototype.getData=function(){return this.data},Ct.Elem.Face.prototype.toHtml=function(){var e=null,t=oe[this.data],n=re[t];return n&&n[1]&&(e=n[1]),e?"<img src='"+e+"'/>":this.data},Ct.Elem.Location=function(e,t,n){this.latitude=t,this.longitude=e,this.desc=n},Ct.Elem.Location.prototype.getLatitude=function(){return this.latitude},Ct.Elem.Location.prototype.getLongitude=function(){return this.longitude},Ct.Elem.Location.prototype.getDesc=function(){return this.desc},Ct.Elem.Location.prototype.toHtml=function(){return"经度="+this.longitude+",纬度="+this.latitude+",描述="+this.desc},Ct.Elem.Images=function(e){this.UUID=e,this.ImageInfoArray=[]},Ct.Elem.Images.prototype.addImage=function(e){this.ImageInfoArray.push(e)},Ct.Elem.Images.prototype.toHtml=function(){var e=this.getImage(d.SMALL),t=this.getImage(d.LARGE),n=this.getImage(d.ORIGIN);return t||(t=e),n||(n=e),"<img src='"+e.getUrl()+"#"+t.getUrl()+"#"+n.getUrl()+"' style='CURSOR: hand' id='"+this.getImageId()+"' bigImgUrl='"+t.getUrl()+"' onclick='imageClick(this)' />"},Ct.Elem.Images.prototype.getImageId=function(){return this.UUID},Ct.Elem.Images.prototype.getImage=function(e){for(var t in this.ImageInfoArray)if(this.ImageInfoArray[t].getType()==e)return this.ImageInfoArray[t];return null},Ct.Elem.Images.Image=function(e,t,n,o,r){this.type=e,this.size=t,this.width=n,this.height=o,this.url=r},Ct.Elem.Images.Image.prototype.getType=function(){return this.type},Ct.Elem.Images.Image.prototype.getSize=function(){return this.size},Ct.Elem.Images.Image.prototype.getWidth=function(){return this.width},Ct.Elem.Images.Image.prototype.getHeight=function(){return this.height},Ct.Elem.Images.Image.prototype.getUrl=function(){return this.url},Ct.Elem.Sound=function(e,t,n,o,r,i,s){this.uuid=e,this.second=t,this.size=n,this.senderId=o,this.receiverId=r,this.downFlag=i,this.busiId=s==c.C2C?2:1,void 0!==i&&void 0!==busiId?Ee(e,o,0,i,r,this.busiId,E.SOUND):this.downUrl=Ie(e,o)},Ct.Elem.Sound.prototype.getUUID=function(){return this.uuid},Ct.Elem.Sound.prototype.getSecond=function(){return this.second},Ct.Elem.Sound.prototype.getSize=function(){return this.size},Ct.Elem.Sound.prototype.getSenderId=function(){return this.senderId},Ct.Elem.Sound.prototype.getDownUrl=function(){return this.downUrl},Ct.Elem.Sound.prototype.toHtml=function(){return"ie"==i.type&&parseInt(i.ver)<=8?"[这是一条语音消息]demo暂不支持ie8(含)以下浏览器播放语音,语音URL:"+this.downUrl:'<audio id="uuid_'+this.uuid+'" src="'+this.downUrl+'" controls="controls" onplay="onChangePlayAudio(this)" preload="none"></audio>'},Ct.Elem.File=function(e,t,n,o,r,i,s){this.uuid=e,this.name=t,this.size=n,this.senderId=o,this.receiverId=r,this.downFlag=i,this.busiId=s==c.C2C?2:1,void 0!==i&&void 0!==busiId?Ee(e,o,0,i,r,this.busiId,E.FILE):this.downUrl=Me(e,o,t)},Ct.Elem.File.prototype.getUUID=function(){return this.uuid},Ct.Elem.File.prototype.getName=function(){return this.name},Ct.Elem.File.prototype.getSize=function(){return this.size},Ct.Elem.File.prototype.getSenderId=function(){return this.senderId},Ct.Elem.File.prototype.getDownUrl=function(){return this.downUrl},Ct.Elem.File.prototype.getDownFlag=function(){return this.downFlag},Ct.Elem.File.prototype.toHtml=function(){var e,t;return e=this.size,t="Byte",this.size>=1024&&(e=Math.round(this.size/1024),t="KB"),'<a href="javascript" onclick="webim.onDownFile("'+this.uuid+'")" title="点击下载文件" ><i class="glyphicon glyphicon-file">&nbsp;'+this.name+"("+e+t+")</i></a>"},Ct.Elem.GroupTip=function(e,t,n,o,r){this.opType=e,this.opUserId=t,this.groupId=n,this.groupName=o,this.userIdList=r||[],this.groupInfoList=[],this.memberInfoList=[],this.groupMemberNum=null},Ct.Elem.GroupTip.prototype.addGroupInfo=function(e){this.groupInfoList.push(e)},Ct.Elem.GroupTip.prototype.addMemberInfo=function(e){this.memberInfoList.push(e)},Ct.Elem.GroupTip.prototype.getOpType=function(){
return this.opType},Ct.Elem.GroupTip.prototype.getOpUserId=function(){return this.opUserId},Ct.Elem.GroupTip.prototype.getGroupId=function(){return this.groupId},Ct.Elem.GroupTip.prototype.getGroupName=function(){return this.groupName},Ct.Elem.GroupTip.prototype.getUserIdList=function(){return this.userIdList},Ct.Elem.GroupTip.prototype.getGroupInfoList=function(){return this.groupInfoList},Ct.Elem.GroupTip.prototype.getMemberInfoList=function(){return this.memberInfoList},Ct.Elem.GroupTip.prototype.getGroupMemberNum=function(){return this.groupMemberNum},Ct.Elem.GroupTip.prototype.setGroupMemberNum=function(e){return this.groupMemberNum=e},Ct.Elem.GroupTip.prototype.toHtml=function(){var e="[群提示消息]";switch(this.opType){case S.JOIN:e+=this.opUserId+"邀请了";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="加入该群";break;case S.QUIT:e+=this.opUserId+"主动退出该群";break;case S.KICK:e+=this.opUserId+"将";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="踢出该群";break;case S.SET_ADMIN:e+=this.opUserId+"将";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="设为管理员";break;case S.CANCEL_ADMIN:e+=this.opUserId+"取消";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="的管理员资格";break;case S.MODIFY_GROUP_INFO:e+=this.opUserId+"修改了群资料:";for(var t in this.groupInfoList){var n=this.groupInfoList[t].getType(),o=this.groupInfoList[t].getValue();switch(n){case G.FACE_URL:e+="群头像为"+o+"; ";break;case G.NAME:e+="群名称为"+o+"; ";break;case G.OWNER:e+="群主为"+o+"; ";break;case G.NOTIFICATION:e+="群公告为"+o+"; ";break;case G.INTRODUCTION:e+="群简介为"+o+"; ";break;default:e+="未知信息为:type="+n+",value="+o+"; "}}break;case S.MODIFY_MEMBER_INFO:e+=this.opUserId+"修改了群成员资料:";for(var t in this.memberInfoList){var r=this.memberInfoList[t].getUserId(),i=this.memberInfoList[t].getShutupTime();if(e+=r+": ",e+=null!=i&&void 0!==i?0==i?"取消禁言; ":"禁言"+i+"秒; ":" shutupTime为空",this.memberInfoList.length>10&&9==t){e+="等"+this.memberInfoList.length+"人";break}}break;case S.READED:Log.info("消息已读同步");break;default:e+="未知群提示消息类型:type="+this.opType}return e},Ct.Elem.GroupTip.GroupInfo=function(e,t){this.type=e,this.value=t},Ct.Elem.GroupTip.GroupInfo.prototype.getType=function(){return this.type},Ct.Elem.GroupTip.GroupInfo.prototype.getValue=function(){return this.value},Ct.Elem.GroupTip.MemberInfo=function(e,t){this.userId=e,this.shutupTime=t},Ct.Elem.GroupTip.MemberInfo.prototype.getUserId=function(){return this.userId},Ct.Elem.GroupTip.MemberInfo.prototype.getShutupTime=function(){return this.shutupTime},Ct.Elem.Custom=function(e,t,n){this.data=e,this.desc=t,this.ext=n},Ct.Elem.Custom.prototype.getData=function(){return this.data},Ct.Elem.Custom.prototype.getDesc=function(){return this.desc},Ct.Elem.Custom.prototype.getExt=function(){return this.ext},Ct.Elem.Custom.prototype.toHtml=function(){return this.data};var Tt=new function(){var t={},n=[];e={},this.cookie="",this.syncFlag=0;var o=function(e){for(var n in t)e(t[n])},r=function(t){var n=!1,o=t.sess._impl.skey,r=t.isSend+t.seq+t.random;return e[o]&&e[o][r]&&(n=!0),e[o]?e[o][r]={time:t.time}:(e[o]={},e[o][r]={time:t.time}),n};this.sessMap=function(){return t},this.sessCount=function(){return n.length},this.sessByTypeId=function(e,n){var o=yt.skey(e,n);return void 0===o||null==o?null:t[o]},this.delSessByTypeId=function(n,o){var r=yt.skey(n,o);return void 0!==r&&null!=r&&(t[r]&&(delete t[r],delete e[r]),!0)},this.resetCookieAndSyncFlag=function(){this.cookie="",this.syncFlag=0},this.setAutoRead=function(e,t,n){if(n&&o(function(e){e._impl.isAutoRead=!1}),e&&(e._impl.isAutoRead=t,t))if(e._impl.unread=0,e._impl.type==c.C2C){var r=[];r.push(new ht(e._impl.id,e._impl.time)),Re(Tt.cookie,r,function(e){se.info("[setAutoRead]: c2CMsgReaded success")},function(e){se.error("[setAutoRead}: c2CMsgReaded failed:"+e.ErrorInfo)})}else if(e._impl.type==c.GROUP){var i={GroupId:e._impl.id,MsgReadedSeq:e._impl.curMaxMsgSeq};et(i,function(e){se.info("groupMsgReaded success")},function(e){se.error("groupMsgReaded failed:"+e.ErrorInfo)})}},this.c2CMsgReaded=function(e,t,n){var o=[];o.push(new ht(e.To_Account,e.LastedMsgTime)),Re(Tt.cookie,o,function(e){t&&(se.info("c2CMsgReaded success"),t(e))},function(e){n&&(se.error("c2CMsgReaded failed:"+e.ErrorInfo),n(e))})},this.addSession=function(e){t[e._impl.skey]=e},this.delSession=function(e){delete t[e._impl.skey]},this.addMsg=function(e){if(r(e))return!1;var n=e.sess;return t[n._impl.skey]||this.addSession(n),n._impl_addMsg(e),!0},this.updateTimeline=function(){var e=new Array;o(function(t){e.push(t)}),e.sort(function(e,t){return t.time-e.time}),n=e}},At=new function(){var e=null,t=null,n={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,15:null,255:null},o={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null},r={1:null},i=null,s=!1,u=0,a=0,l=null,p=!1,d=0,m=90,I=null,M={},E=0,_={},h={};this.setLongPollingOn=function(e){s=e},this.getLongPollingOn=function(){return s},this.resetLongPollingInfo=function(){s=!1,u=0,a=0},this.setBigGroupLongPollingOn=function(e){p=e},this.setBigGroupLongPollingKey=function(e){I=e},this.resetBigGroupLongPollingInfo=function(){p=!1,d=0,I=null,M={}},this.setBigGroupLongPollingMsgMap=function(e,t){var n=M[e];n?(n=parseInt(n)+t,M[e]=n):M[e]=t},this.clear=function(){t=null,n={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,15:null,255:null},o={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null},r={1:null},e=null,s=!1,u=0,a=0,l=null,p=!1,d=0,I=null,M={},h={},J=[],H=null,Y=null};var v=function(e,t){mt(function(t){J=t.IpList,H=t.AuthKey,Y=t.ExpireTime,e&&e(t)},function(e){se.error("initIpAndAuthkey failed:"+e.ErrorInfo),t&&t(e)})},P=function(e,t){var n={Member_Account:X.identifier,Limit:1e3,Offset:0,GroupBaseInfoFilter:["NextMsgSeq"]};Qe(n,function(t){if(!t.GroupIdList||0==t.GroupIdList.length)return se.info("initMyGroupMaxSeqs: 目前还没有加入任何群组"),void(e&&e(t));for(var n=0;n<t.GroupIdList.length;n++){var o=t.GroupIdList[n].GroupId,r=t.GroupIdList[n].NextMsgSeq-1;_[o]=r}e&&e(t)},function(e){se.error("initMyGroupMaxSeqs failed:"+e.ErrorInfo),t&&t(e)})},x=function(e,t,n){E++;var o={GroupId:e,ReqMsgSeq:t,ReqMsgNumber:n};se.warn("第"+E+"次补齐群消息,参数="+JSON.stringify(o)),At.syncGroupMsgs(o)},B=function(e,t){var n=_[e];n?t>n&&(_[e]=t):_[e]=t},K=function(e,t){for(var n in e){var o=e[n];if(o.From_Account){var r=re(o,!1,!0);r&&t.push(r),B(o.ToGroupId,o.MsgSeq)}}return t},z=function(t,n){var o={},r=[];for(var i in n){var s=o[n[i].ToGroupId];s||(s=o[n[i].ToGroupId]={min:99999999,max:-1,msgs:[]}),n[i].NoticeSeq>a&&(se.warn("noticeSeq="+a+",msgNoticeSeq="+n[i].NoticeSeq),a=n[i].NoticeSeq),n[i].Event=t,o[n[i].ToGroupId].msgs.push(n[i]),n[i].MsgSeq<s.min&&(o[n[i].ToGroupId].min=n[i].MsgSeq),n[i].MsgSeq>s.max&&(o[n[i].ToGroupId].max=n[i].MsgSeq)}for(var u in o){var c=o[u].max-o[u].min+1,l=_[u];l?o[u].min-l>1||o[u].msgs.length<c?(se.warn("发起一次补齐群消息请求,curMaxMsgSeq="+l+", minMsgSeq="+o[u].min+", maxMsgSeq="+o[u].max+", msgs.length="+o[u].msgs.length+", tempCount="+c),x(u,o[u].max,o[u].max-l),B(u,o[u].max)):r=K(o[u].msgs,r):(se.warn("不存在该群的最大消息seq,群id="+u),o[u].msgs.length<c?(se.warn("发起一次补齐群消息请求,minMsgSeq="+o[u].min+", maxMsgSeq="+o[u].max+", msgs.length="+o[u].msgs.length+", tempCount="+c),x(u,o[u].max,c),B(u,o[u].max)):r=K(o[u].msgs,r))}r.length&&Tt.updateTimeline(),e&&r.length&&e(r)},V=function(t,n){var o={},r=[];for(var i in n){var s=o[n[i].ToGroupId];s||(s=o[n[i].ToGroupId]={min:99999999,max:-1,msgs:[]}),n[i].NoticeSeq>a&&(se.warn("noticeSeq="+a+",msgNoticeSeq="+n[i].NoticeSeq),a=n[i].NoticeSeq),n[i].Event=t,o[n[i].ToGroupId].msgs.push(n[i]),n[i].MsgSeq<s.min&&(o[n[i].ToGroupId].min=n[i].MsgSeq),n[i].MsgSeq>s.max&&(o[n[i].ToGroupId].max=n[i].MsgSeq)}for(var u in o){var c=o[u].max-o[u].min+1,l=_[u];l?o[u].min-l>1||o[u].msgs.length<c?(se.warn("发起一次补齐群消息请求,curMaxMsgSeq="+l+", minMsgSeq="+o[u].min+", maxMsgSeq="+o[u].max+", msgs.length="+o[u].msgs.length+", tempCount="+c),x(u,o[u].max,o[u].max-l),B(u,o[u].max)):r=K(o[u].msgs,r):(se.warn("不存在该群的最大消息seq,群id="+u),o[u].msgs.length<c?(se.warn("发起一次补齐群消息请求,minMsgSeq="+o[u].min+", maxMsgSeq="+o[u].max+", msgs.length="+o[u].msgs.length+", tempCount="+c),x(u,o[u].max,c),B(u,o[u].max)):r=K(o[u].msgs,r))}r.length&&Tt.updateTimeline(),e&&r.length&&e(r)},Q=function(e,t){for(var o in e){var r=e[o],i=r.MsgBody,s=i.ReportType;0==t&&r.NoticeSeq&&r.NoticeSeq>a&&(a=r.NoticeSeq);r.GroupInfo.To_Account;if(t){var u=r.ToGroupId+"_"+s+"_"+i.Operator_Account;if(h[u]){se.warn("收到重复的群系统消息:key="+u);continue}h[u]=!0}var c={SrcFlag:0,ReportType:s,GroupId:r.ToGroupId,GroupName:r.GroupInfo.GroupName,Operator_Account:i.Operator_Account,MsgTime:r.MsgTimeStamp,groupReportTypeMsg:i};switch(s){case O.JOIN_GROUP_REQUEST:c.RemarkInfo=i.RemarkInfo,c.MsgKey=i.MsgKey,c.Authentication=i.Authentication,c.UserDefinedField=r.UserDefinedField,c.From_Account=r.From_Account,c.MsgSeq=r.ClientSeq,c.MsgRandom=r.MsgRandom;break;case O.JOIN_GROUP_ACCEPT:case O.JOIN_GROUP_REFUSE:c.RemarkInfo=i.RemarkInfo;break;case O.KICK:case O.DESTORY:case O.CREATE:case O.INVITED_JOIN_GROUP_REQUEST:case O.QUIT:case O.SET_ADMIN:case O.CANCEL_ADMIN:case O.REVOKE:case O.READED:break;case O.CUSTOM:c.MsgSeq=r.MsgSeq,c.UserDefinedField=i.UserDefinedField;break;default:se.error("未知群系统消息类型:reportType="+s)}if(t)s==O.JOIN_GROUP_REQUEST&&n[s]&&n[s](c);else if(n[s])if(s==O.READED)for(var l=c.groupReportTypeMsg.GroupReadInfoArray,p=0,f=l.length;p<f;p++){var g=l[p];n[s](g)}else n[s](c)}},W=function(e,t){var n,r,i;for(var s in e){switch(n=e[s],r=n.PushType,0==t&&n.NoticeSeq&&n.NoticeSeq>a&&(a=n.NoticeSeq),i={Type:r},r){case F.FRIEND_ADD:i.Accounts=n.FriendAdd_Account;break;case F.FRIEND_DELETE:i.Accounts=n.FriendDel_Account;break;case F.PENDENCY_ADD:i.PendencyList=n.PendencyAdd;break;case F.PENDENCY_DELETE:i.Accounts=n.FrienPencydDel_Account;break;case F.BLACK_LIST_ADD:i.Accounts=n.BlackListAdd_Account;break;case F.BLACK_LIST_DELETE:i.Accounts=n.BlackListDel_Account;break;default:se.error("未知好友系统通知类型:friendNotice="+JSON.stringify(n))}t?r==F.PENDENCY_ADD&&o[r]&&o[r](i):o[r]&&o[r](i)}},j=function(e,t){var n,o,i;for(var s in e){switch(n=e[s],o=n.PushType,0==t&&n.NoticeSeq&&n.NoticeSeq>a&&(a=n.NoticeSeq),i={Type:o},o){case R.PROFILE_MODIFY:i.Profile_Account=n.Profile_Account,i.ProfileList=n.ProfileList;break;default:se.error("未知资料系统通知类型:profileNotice="+JSON.stringify(n))}t?o==R.PROFILE_MODIFY&&r[o]&&r[o](i):r[o]&&r[o](i)}},$=function(e){var t=e.MsgBody,o=t.ReportType,r=(e.GroupInfo.To_Account,{SrcFlag:1,ReportType:o,GroupId:e.ToGroupId,GroupName:e.GroupInfo.GroupName,Operator_Account:t.Operator_Account,MsgTime:e.MsgTimeStamp});switch(o){case O.JOIN_GROUP_REQUEST:r.RemarkInfo=t.RemarkInfo,r.MsgKey=t.MsgKey,r.Authentication=t.Authentication,r.UserDefinedField=e.UserDefinedField,r.From_Account=e.From_Account,r.MsgSeq=e.ClientSeq,r.MsgRandom=e.MsgRandom;break;case O.JOIN_GROUP_ACCEPT:case O.JOIN_GROUP_REFUSE:r.RemarkInfo=t.RemarkInfo;break;case O.KICK:case O.DESTORY:case O.CREATE:case O.INVITED_JOIN_GROUP_REQUEST:case O.QUIT:case O.SET_ADMIN:case O.CANCEL_ADMIN:case O.REVOKE:break;case O.CUSTOM:r.MsgSeq=e.MsgSeq,r.UserDefinedField=t.UserDefinedField;break;default:se.error("未知群系统消息类型:reportType="+o)}n[o]&&n[o](r)},Z=function(e){for(var t=0,n=e.length;t<n;t++)ee(e[t])},ee=function(e){var t=e.SubMsgType;switch(t){case C.READED:break;default:se.error("未知C2c系统消息:reportType="+reportType)}if(e.ReadC2cMsgNotify.UinPairReadArray&&onC2cEventCallbacks[t])for(var n=0,o=e.ReadC2cMsgNotify.UinPairReadArray.length;n<o;n++){var r=e.ReadC2cMsgNotify.UinPairReadArray[n];onC2cEventCallbacks[t](r)}};this.longPolling=function(e,t){function n(){Ge(o,function(e){for(var t in e.EventArray){var n=e.EventArray[t];switch(n.Event){case y.C2C:u=n.NotifySeq,se.warn("longpolling: received new c2c msg"),At.syncMsgs();break;case y.GROUP_COMMON:se.warn("longpolling: received new group msgs"),V(n.Event,n.GroupMsgArray);break;case y.GROUP_TIP:se.warn("longpolling: received new group tips"),V(n.Event,n.GroupTips);break;case y.GROUP_SYSTEM:se.warn("longpolling: received new group system msgs"),Q(n.GroupTips,!1);break;case y.FRIEND_NOTICE:se.warn("longpolling: received new friend system notice"),W(n.FriendListMod,!1);break;case y.PROFILE_NOTICE:se.warn("longpolling: received new profile system notice"),j(n.ProfileDataMod,!1);break;case y.C2C_COMMON:a=n.C2cMsgArray[0].NoticeSeq,se.warn("longpolling: received new c2c_common msg",a),z(n.Event,n.C2cMsgArray);break;case y.C2C_EVENT:a=n.C2cNotifyMsgArray[0].NoticeSeq,se.warn("longpolling: received new c2c_event msg"),Z(n.C2cNotifyMsgArray);break;default:se.error("longpolling收到未知新消息类型: Event="+n.Event)}}var o={ActionStatus:f.OK,ErrorCode:0};te(o)},function(e){te(e),t&&t(e)})}var o={Timeout:k/1e3,Cookie:{NotifySeq:u,NoticeSeq:a}};w?(o.Cookie.LongPollingId=w,n()):Mt(0,function(e){w=o.Cookie.LongPollingId=e.LongPollingId,k=e.Timeout>60?k:1e3*e.Timeout,n()})},this.bigGroupLongPolling=function(e,t){Oe({StartSeq:d,HoldTime:m,Key:I},function(t){var n=[];if(d=t.NextSeq,m=t.HoldTime,I=t.Key,t.RspMsgList&&t.RspMsgList.length>0){for(var o,r,i,s=0,u=t.RspMsgList.length-1;u>=0;u--)if(o=t.RspMsgList[u],!o.IsPlaceMsg&&o.From_Account&&o.MsgBody&&0!=o.MsgBody.length)switch(r=o.Event){case y.GROUP_COMMON:se.info("bigGroupLongPolling: return new group msg"),i=re(o,!1,!1),i&&n.push(i),s+=1;break;case y.GROUP_TIP:case y.GROUP_TIP2:se.info("bigGroupLongPolling: return new group tip"),(i=re(o,!1,!1))&&n.push(i);break;case y.GROUP_SYSTEM:se.info("bigGroupLongPolling: new group system msg"),$(o);break;default:se.error("bigGroupLongPolling收到未知新消息类型: Event="+r)}s>0&&(At.setBigGroupLongPollingMsgMap(o.ToGroupId,s),se.warn("current bigGroupLongPollingMsgMap: "+JSON.stringify(M)))}q=0;var a={ActionStatus:f.OK,ErrorCode:N.ON,ErrorInfo:"connection is ok..."};_t.callBack(a),e?e(n):l&&l(n),p&&At.bigGroupLongPolling()},function(e){if(60008!=e.ErrorCode&&(se.error(e.ErrorInfo),q++),91101!=e.ErrorCode&&(se.error("多实例登录,被kick"),i&&i()),q<10)p&&At.bigGroupLongPolling();else{var n={ActionStatus:f.FAIL,ErrorCode:N.OFF,ErrorInfo:"connection is off"};_t.callBack(n)}t&&t(e)},1e3*m)};var te=function(e){if(0==e.ErrorCode||60008==e.ErrorCode){D=0,U=!1;var t,n=!1;switch(L){case N.INIT:n=!0,L=N.ON,t="create connection successfully(INIT->ON)";break;case N.ON:t="connection is on...(ON->ON)";break;case N.RECONNECT:L=N.ON,t="connection is on...(RECONNECT->ON)";break;case N.OFF:n=!0,L=N.RECONNECT,t="reconnect successfully(OFF->RECONNECT)"}var o={ActionStatus:f.OK,ErrorCode:L,ErrorInfo:t};n&&_t.callBack(o),s&&At.longPolling()}else if(91101==e.ErrorCode)se.error("多实例登录,被kick"),i&&i();else if(D++,se.warn("longPolling接口第"+D+"次报错: "+e.ErrorInfo),D<=10)setTimeout(ne,100);else{L=N.OFF;var r={ActionStatus:f.FAIL,ErrorCode:N.OFF,ErrorInfo:"connection is off"};0==U&&_t.callBack(r),U=!0,se.warn("5000毫秒之后,SDK会发起新的longPolling请求..."),setTimeout(ne,5e3)}},z=function(t,n){var o=[],r=[];r=n;for(var i in r){var s,u,a,l=r[i];l.From_Account==X.identifier?(s=!0,u=l.To_Account,a=""):(s=!1,u=l.From_Account,a="");var p=Tt.sessByTypeId(c.C2C,u);p||(p=new yt(c.C2C,u,u,a,0,0));var f=new Ct(p,s,l.MsgSeq,l.MsgRandom,l.MsgTimeStamp,l.From_Account),d=null,m=null,I=null;for(var M in l.MsgBody){switch(d=l.MsgBody[M],I=d.MsgType){case g.TEXT:m=new Ct.Elem.Text(d.MsgContent.Text);break;case g.FACE:m=new Ct.Elem.Face(d.MsgContent.Index,d.MsgContent.Data);break;case g.IMAGE:m=new Ct.Elem.Images(d.MsgContent.UUID);for(var E in d.MsgContent.ImageInfoArray){var _=d.MsgContent.ImageInfoArray[E];m.addImage(new Ct.Elem.Images.Image(_.Type,_.Size,_.Width,_.Height,_.URL))}break;case g.SOUND:d.MsgContent?m=new Ct.Elem.Sound(d.MsgContent.UUID,d.MsgContent.Second,d.MsgContent.Size,l.From_Account,l.To_Account,d.MsgContent.Download_Flag,c.C2C):(I=g.TEXT,m=new Ct.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:m=new Ct.Elem.Location(d.MsgContent.Longitude,d.MsgContent.Latitude,d.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":I=g.FILE,d.MsgContent?m=new Ct.Elem.File(d.MsgContent.UUID,d.MsgContent.FileName,d.MsgContent.FileSize,l.From_Account,l.To_Account,d.MsgContent.Download_Flag,c.C2C):(I=g.TEXT,m=new Ct.Elem.Text("[文件消息下载地址解析出错]"));break;case g.CUSTOM:try{var y=JSON.parse(d.MsgContent.Data);if(y&&y.userAction&&y.userAction==b.ING)continue}catch(e){}I=g.CUSTOM,m=new Ct.Elem.Custom(d.MsgContent.Data,d.MsgContent.Desc,d.MsgContent.Ext);break;default:I=g.TEXT,m=new Ct.Elem.Text("web端暂不支持"+d.MsgType+"消息")}f.elems.push(new Ct.Elem(I,m))}f.elems.length>0&&Tt.addMsg(f)&&o.push(f)}o.length>0&&Tt.updateTimeline(),o.length>0&&e&&e(o)},ne=function(){s&&At.longPolling()},oe=function(e){for(var t in e){var n=e[t];switch(n.Event){case y.GROUP_SYSTEM:se.warn("handlerApplyJoinGroupSystemMsgs: handler new group system msg"),Q(n.GroupTips,!0);break;default:se.error("syncMsgs收到未知的群系统消息类型: Event="+n.Event)}}};this.syncMsgs=function(t,n){var o=[],r=[];Fe(Tt.cookie,Tt.syncFlag,function(n){2==n.SyncFlag&&(Tt.syncFlag=0),r=n.MsgList,Tt.cookie=n.Cookie;for(var i in r){var s,u,a,l=r[i];l.From_Account==X.identifier?(s=!0,u=l.To_Account,a=""):(s=!1,u=l.From_Account,a="");var p=Tt.sessByTypeId(c.C2C,u);p||(p=new yt(c.C2C,u,u,a,0,0));var f=new Ct(p,s,l.MsgSeq,l.MsgRandom,l.MsgTimeStamp,l.From_Account),d=null,m=null,I=null;for(var M in l.MsgBody){switch(d=l.MsgBody[M],I=d.MsgType){case g.TEXT:m=new Ct.Elem.Text(d.MsgContent.Text);break;case g.FACE:m=new Ct.Elem.Face(d.MsgContent.Index,d.MsgContent.Data);break;case g.IMAGE:m=new Ct.Elem.Images(d.MsgContent.UUID);for(var E in d.MsgContent.ImageInfoArray){var _=d.MsgContent.ImageInfoArray[E];m.addImage(new Ct.Elem.Images.Image(_.Type,_.Size,_.Width,_.Height,_.URL))}break;case g.SOUND:d.MsgContent?m=new Ct.Elem.Sound(d.MsgContent.UUID,d.MsgContent.Second,d.MsgContent.Size,l.From_Account,l.To_Account,d.MsgContent.Download_Flag,c.C2C):(I=g.TEXT,m=new Ct.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:m=new Ct.Elem.Location(d.MsgContent.Longitude,d.MsgContent.Latitude,d.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":I=g.FILE,d.MsgContent?m=new Ct.Elem.File(d.MsgContent.UUID,d.MsgContent.FileName,d.MsgContent.FileSize,l.From_Account,l.To_Account,d.MsgContent.Download_Flag,c.C2C):(I=g.TEXT,m=new Ct.Elem.Text("[文件消息下载地址解析出错]"));break;case g.CUSTOM:try{var y=JSON.parse(d.MsgContent.Data);if(y&&y.userAction&&y.userAction==b.ING)continue}catch(e){}I=g.CUSTOM,m=new Ct.Elem.Custom(d.MsgContent.Data,d.MsgContent.Desc,d.MsgContent.Ext);break;default:I=g.TEXT,m=new Ct.Elem.Text("web端暂不支持"+d.MsgType+"消息")}f.elems.push(new Ct.Elem(I,m))}f.elems.length>0&&Tt.addMsg(f)&&o.push(f)}oe(n.EventArray),o.length>0&&Tt.updateTimeline(),t?t(o):o.length>0&&e&&e(o)},function(e){se.error("getMsgs failed:"+e.ErrorInfo),n&&n(e)})},this.getC2CHistoryMsgs=function(e,t,n){if(!e.Peer_Account&&n)return void n(ie.getReturnError("Peer_Account is empty",-13));if(e.MaxCnt||(e.MaxCnt=15),e.MaxCnt<=0&&n)return void n(ie.getReturnError("MaxCnt should be greater than 0",-14));if(e.MaxCnt>15){if(n)return void n(ie.getReturnError("MaxCnt can not be greater than 15",-15))}else{null!=e.MsgKey&&void 0!==e.MsgKey||(e.MsgKey="");var o={Peer_Account:e.Peer_Account,MaxCnt:e.MaxCnt,LastMsgTime:e.LastMsgTime,MsgKey:e.MsgKey};Ne(o,function(n){var o=[],r=[];r=n.MsgList;var i=Tt.sessByTypeId(c.C2C,e.Peer_Account);i||(i=new yt(c.C2C,e.Peer_Account,e.Peer_Account,"",0,0));for(var s in r){var u,a=r[s];a.From_Account==X.identifier?(u=!0,a.To_Account,""):(u=!1,a.From_Account,"");var l=new Ct(i,u,a.MsgSeq,a.MsgRandom,a.MsgTimeStamp,a.From_Account),p=null,f=null,d=null;for(var m in a.MsgBody){switch(p=a.MsgBody[m],d=p.MsgType){case g.TEXT:f=new Ct.Elem.Text(p.MsgContent.Text);break;case g.FACE:f=new Ct.Elem.Face(p.MsgContent.Index,p.MsgContent.Data);break;case g.IMAGE:f=new Ct.Elem.Images(p.MsgContent.UUID);for(var I in p.MsgContent.ImageInfoArray){var M=p.MsgContent.ImageInfoArray[I];f.addImage(new Ct.Elem.Images.Image(M.Type,M.Size,M.Width,M.Height,M.URL))}break;case g.SOUND:p.MsgContent?f=new Ct.Elem.Sound(p.MsgContent.UUID,p.MsgContent.Second,p.MsgContent.Size,a.From_Account,a.To_Account,p.MsgContent.Download_Flag,c.C2C):(d=g.TEXT,f=new Ct.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:f=new Ct.Elem.Location(p.MsgContent.Longitude,p.MsgContent.Latitude,p.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":d=g.FILE,p.MsgContent?f=new Ct.Elem.File(p.MsgContent.UUID,p.MsgContent.FileName,p.MsgContent.FileSize,a.From_Account,a.To_Account,p.MsgContent.Download_Flag,c.C2C):(d=g.TEXT,f=new Ct.Elem.Text("[文件消息下载地址解析出错]"));break;case g.CUSTOM:d=g.CUSTOM,f=new Ct.Elem.Custom(p.MsgContent.Data,p.MsgContent.Desc,p.MsgContent.Ext);break;default:d=g.TEXT,f=new Ct.Elem.Text("web端暂不支持"+p.MsgType+"消息")}l.elems.push(new Ct.Elem(d,f))}Tt.addMsg(l),o.push(l)}if(Tt.updateTimeline(),t){var E={Complete:n.Complete,MsgCount:o.length,LastMsgTime:n.LastMsgTime,MsgKey:n.MsgKey,MsgList:o};i.isFinished(n.Complete),t(E)}},function(e){se.error("getC2CHistoryMsgs failed:"+e.ErrorInfo),n&&n(e)})}},this.syncGroupMsgs=function(t,n,o){if(t.ReqMsgSeq<=0){if(o){var r=ie.getReturnError("ReqMsgSeq must be greater than 0",-16);o(r)}}else{var i={GroupId:t.GroupId,ReqMsgSeq:t.ReqMsgSeq,ReqMsgNumber:t.ReqMsgNumber};Ze(i,function(t){var o=[],r=(t.GroupId,t.RspMsgList),i=t.IsFinished;if(null==r||void 0===r)return void(n&&n([]));for(var s=r.length-1;s>=0;s--){var u=r[s];if(!u.IsPlaceMsg&&u.From_Account&&u.MsgBody&&0!=u.MsgBody.length){var a=re(u,!0,!0,i);a&&o.push(a)}}o.length>0&&Tt.updateTimeline(),n?n(o):o.length>0&&e&&e(o)},function(e){se.error("getGroupMsgs failed:"+e.ErrorInfo),o&&o(e)})}};var re=function(e,n,o,r){if(e.IsPlaceMsg||!e.From_Account||!e.MsgBody||0==e.MsgBody.length)return null;var i,s,u,a=e.ToGroupId,l=a;e.GroupInfo&&e.GroupInfo.GroupName&&(l=e.GroupInfo.GroupName),u=e.From_Account,e.GroupInfo&&e.GroupInfo.From_AccountNick&&(u=e.GroupInfo.From_AccountNick),e.From_Account==X.identifier?(i=!0,e.From_Account,s=""):(i=!1,e.From_Account,s="");var p=Tt.sessByTypeId(c.GROUP,a);p||(p=new yt(c.GROUP,a,l,s,0,0)),void 0!==r&&p.isFinished(r||0);var f=T.COMMON;if(y.GROUP_TIP==e.Event||y.GROUP_TIP2==e.Event){f=T.TIP;var d=e.MsgBody;e.MsgBody=[],e.MsgBody.push({MsgType:g.GROUP_TIP,MsgContent:d})}else e.MsgPriority&&(e.MsgPriority==A.REDPACKET?f=T.REDPACKET:e.MsgPriority==A.LOVEMSG&&(f=T.LOVEMSG));var m=new Ct(p,i,e.MsgSeq,e.MsgRandom,e.MsgTimeStamp,e.From_Account,f,u),I=null,M=null,E=null;for(var _ in e.MsgBody){switch(I=e.MsgBody[_],E=I.MsgType){case g.TEXT:M=new Ct.Elem.Text(I.MsgContent.Text);break;case g.FACE:M=new Ct.Elem.Face(I.MsgContent.Index,I.MsgContent.Data);break;case g.IMAGE:M=new Ct.Elem.Images(I.MsgContent.UUID);for(var h in I.MsgContent.ImageInfoArray)M.addImage(new Ct.Elem.Images.Image(I.MsgContent.ImageInfoArray[h].Type,I.MsgContent.ImageInfoArray[h].Size,I.MsgContent.ImageInfoArray[h].Width,I.MsgContent.ImageInfoArray[h].Height,I.MsgContent.ImageInfoArray[h].URL));break;case g.SOUND:I.MsgContent?M=new Ct.Elem.Sound(I.MsgContent.UUID,I.MsgContent.Second,I.MsgContent.Size,e.From_Account,e.To_Account,I.MsgContent.Download_Flag,c.GROUP):(E=g.TEXT,M=new Ct.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:M=new Ct.Elem.Location(I.MsgContent.Longitude,I.MsgContent.Latitude,I.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":E=g.FILE;Me(I.MsgContent.UUID,e.From_Account,I.MsgContent.FileName);I.MsgContent?M=new Ct.Elem.File(I.MsgContent.UUID,I.MsgContent.FileName,I.MsgContent.FileSize,e.From_Account,e.To_Account,I.MsgContent.Download_Flag,c.GROUP):(E=g.TEXT,M=new Ct.Elem.Text("[文件消息]地址解析出错"));break;case g.GROUP_TIP:var C=I.MsgContent.OpType;if(M=new Ct.Elem.GroupTip(C,I.MsgContent.Operator_Account,a,e.GroupInfo.GroupName,I.MsgContent.List_Account),S.JOIN==C||S.QUIT==C)M.setGroupMemberNum(I.MsgContent.MemberNum);else if(S.MODIFY_GROUP_INFO==C){var O=!1,F={GroupId:a,GroupFaceUrl:null,GroupName:null,OwnerAccount:null,GroupNotification:null,GroupIntroduction:null},R=I.MsgContent.MsgGroupNewInfo;if(R.GroupFaceUrl){var v=new Ct.Elem.GroupTip.GroupInfo(G.FACE_URL,R.GroupFaceUrl);M.addGroupInfo(v),O=!0,F.GroupFaceUrl=R.GroupFaceUrl}if(R.GroupName){var N=new Ct.Elem.GroupTip.GroupInfo(G.NAME,R.GroupName);M.addGroupInfo(N),O=!0,F.GroupName=R.GroupName}if(R.Owner_Account){var P=new Ct.Elem.GroupTip.GroupInfo(G.OWNER,R.Owner_Account);M.addGroupInfo(P),O=!0,F.OwnerAccount=R.Owner_Account}if(R.GroupNotification){var b=new Ct.Elem.GroupTip.GroupInfo(G.NOTIFICATION,R.GroupNotification);M.addGroupInfo(b),O=!0,F.GroupNotification=R.GroupNotification}if(R.GroupIntroduction){var L=new Ct.Elem.GroupTip.GroupInfo(G.INTRODUCTION,R.GroupIntroduction);M.addGroupInfo(L),O=!0,F.GroupIntroduction=R.GroupIntroduction}0==n&&O&&t&&t(F)}else if(S.MODIFY_MEMBER_INFO==C){var U=I.MsgContent.MsgMemberInfo;for(var D in U){var k=U[D];M.addMemberInfo(new Ct.Elem.GroupTip.MemberInfo(k.User_Account,k.ShutupTime))}}break;case g.CUSTOM:E=g.CUSTOM,M=new Ct.Elem.Custom(I.MsgContent.Data,I.MsgContent.Desc,I.MsgContent.Ext);break;default:E=g.TEXT,M=new Ct.Elem.Text("web端暂不支持"+I.MsgType+"消息")}m.elems.push(new Ct.Elem(E,M))}return 0==o?m:Tt.addMsg(m)?m:null};this.init=function(u,a,c){if(u.onMsgNotify||se.warn("listeners.onMsgNotify is empty"),e=u.onMsgNotify,u.onBigGroupMsgNotify?l=u.onBigGroupMsgNotify:se.warn("listeners.onBigGroupMsgNotify is empty"),u.onC2cEventNotifys?onC2cEventCallbacks=u.onC2cEventNotifys:se.warn("listeners.onC2cEventNotifys is empty"),u.onGroupSystemNotifys?n=u.onGroupSystemNotifys:se.warn("listeners.onGroupSystemNotifys is empty"),u.onGroupInfoChangeNotify?t=u.onGroupInfoChangeNotify:se.warn("listeners.onGroupInfoChangeNotify is empty"),u.onFriendSystemNotifys?o=u.onFriendSystemNotifys:se.warn("listeners.onFriendSystemNotifys is empty"),u.onProfileSystemNotifys?r=u.onProfileSystemNotifys:se.warn("listeners.onProfileSystemNotifys is empty"),u.onKickedEventCall?i=u.onKickedEventCall:se.warn("listeners.onKickedEventCall is empty"),u.onAppliedDownloadUrl?onAppliedDownloadUrl=u.onAppliedDownloadUrl:se.warn("listeners.onAppliedDownloadUrl is empty"),X.identifier&&X.userSig)P(function(e){se.info("initMyGroupMaxSeqs success"),v(function(e){if(se.info("initIpAndAuthkey success"),a){se.info("login success(have login state))");var t={ActionStatus:f.OK,ErrorCode:0,ErrorInfo:"login success"};a(t)}At.setLongPollingOn(!0),s&&At.longPolling(a)},c)},c);else if(a){var p={ActionStatus:f.OK,ErrorCode:0,ErrorInfo:"login success(no login state)"};a(p)}},this.sendMsg=function(e,t,n){Se(e,function(o){if(e.sess.type()==c.C2C){if(!Tt.addMsg(e)){var r="sendMsg: addMsg failed!",i=ie.getReturnError(r,-17);return se.error(r),void(n&&n(i))}Tt.updateTimeline()}t&&t(o)},function(e){n&&n(e)})}},St=new function(){this.fileMd5=null;var e=function(e,t,n){function o(){var t=a*s,n=t+s>=e.size?e.size:t+s,o=i.call(e,t,n);r.readAsArrayBuffer(o)}var r=null;try{r=new FileReader}catch(e){if(n)return void n(ie.getReturnError("当前浏览器不支持FileReader",-18))}var i=File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice;if(!i&&n)return void n(ie.getReturnError("当前浏览器不支持FileAPI",-19));var s=2097152,u=Math.ceil(e.size/s),a=0,c=new SparkMD5;r.onload=function(e){for(var n="",r=new Uint8Array(e.target.result),i=r.byteLength,s=0;s<i;s++)n+=String.fromCharCode(r[s]);c.appendBinary(n),a++,a<u?o():(this.fileMd5=c.end(),t&&t(this.fileMd5))},o()};this.submitUploadFileForm=function(e,t,n){function o(e,t){var n=document.createElement("input");n.type="hidden",n.name=e,n.value=t,d.appendChild(n)}function r(){var e;try{e=JSON.parse(M.contentWindow.name)||{}}catch(t){e={}}e.ActionStatus?(M.src="about:blank",M.parentNode.removeChild(M),M=null,e.ActionStatus==f.OK?t&&t(e):n&&n(e)):setTimeout(r,100)}var i,s,u=e.formId,a=e.fileId,c=V++,l="uploadResultIframe_"+c,p=e.To_Account,g=e.businessType,d=document.getElementById(u);if(!d)return i="获取表单对象为空: formId="+u+"(formId非法)",s=ie.getReturnError(i,-20),void(n&&n(s));var I=document.getElementById(a);if(!I)return i="获取文件对象为空: fileId="+a+"(没有选择文件或者fileId非法)",s=ie.getReturnError(i,-21),void(n&&n(s));I.name="file";var M=document.createElement("iframe");M.name=l,M.id=l,M.style.display="none",document.body.appendChild(M);var E;E=de()?"pic_up":"pic_up_test";var y="https://pic.tim.qq.com/v4/openpic/"+E+"?tinyid="+X.tinyid+"&a2="+X.a2+"&sdkappid="+X.sdkAppID+"&accounttype="+X.accountType+"&contenttype=http";d.action=y,d.method="post",d.target=l,o("App_Version",_.APP_VERSION),o("From_Account",X.identifier),o("To_Account",p),o("Seq",ae().toString()),o("Timestamp",ue().toString()),o("Random",ce().toString()),o("Busi_Id",g),o("PkgFlag",m.RAW_DATA.toString()),o("Auth_Key",H),o("Server_Ver",_.SERVER_VERSION.toString()),o("File_Type",e.fileType),setTimeout(r,500),d.submit()},this.uploadFile=function(t,n,o){var r={init:function(e,t,n){var o=this;o.file=e.file,o.onProgressCallBack=e.onProgressCallBack,e.abortButton&&(e.abortButton.onclick=o.abortHandler),o.total=o.file.size,o.loaded=0,o.step=1105920,o.sliceSize=0,o.sliceOffset=0,o.timestamp=ue(),o.seq=ae(),o.random=ce(),o.fromAccount=X.identifier,o.toAccount=e.To_Account,o.fileMd5=e.fileMd5,o.businessType=e.businessType,o.fileType=e.fileType,o.cbOk=t,o.cbErr=n,o.reader=new FileReader,o.blobSlice=File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice,o.reader.onloadstart=o.onLoadStart,o.reader.onprogress=o.onProgress,o.reader.onabort=o.onAbort,o.reader.onerror=o.onerror,o.reader.onload=o.onLoad,o.reader.onloadend=o.onLoadEnd},upload:function(){r.readBlob(0)},onLoadStart:function(){},onProgress:function(e){var t=r;t.loaded+=e.loaded,t.onProgressCallBack&&t.onProgressCallBack(t.loaded,t.total)},onAbort:function(){},onError:function(){},onLoad:function(e){var t=r;if(e.target.readyState==FileReader.DONE){var n=e.target.result,o=n.indexOf(",");-1!=o&&(n=n.substr(o+1));var i={From_Account:t.fromAccount,To_Account:t.toAccount,Busi_Id:t.businessType,File_Type:t.fileType,File_Str_Md5:t.fileMd5,PkgFlag:m.BASE64_DATA,File_Size:t.total,Slice_Offset:t.sliceOffset,Slice_Size:t.sliceSize,Slice_Data:n,Seq:t.seq,Timestamp:t.timestamp,Random:t.random},s=function(e){if(0==e.IsFinish)t.loaded=e.Next_Offset,t.loaded<t.total?t.readBlob(t.loaded):t.loaded=t.total;else if(t.cbOk){var n={ActionStatus:e.ActionStatus,ErrorCode:e.ErrorCode,ErrorInfo:e.ErrorInfo,File_UUID:e.File_UUID,File_Size:e.Next_Offset,URL_INFO:e.URL_INFO,Download_Flag:e.Download_Flag};t.fileType==E.FILE&&(n.URL_INFO=Me(e.File_UUID,X.identifier,t.file.name)),t.cbOk(n)}x=0},u=function(e){x<20?(x++,setTimeout(function(){dt(i,s,u)},1e3)):t.cbErr(e)};dt(i,s,u)}},onLoadEnd:function(){},readBlob:function(e){var t,n=r,o=n.file,i=e+n.step;i>n.total?(i=n.total,n.sliceSize=i-e):n.sliceSize=n.step,n.sliceOffset=e,t=n.blobSlice.call(o,e,i),n.reader.readAsDataURL(t)},abortHandler:function(){var e=r;e.reader&&e.reader.abort()}};e(t.file,function(e){se.info("fileMd5: "+e),t.fileMd5=e,r.init(t,n,o),r.upload()},o)}};t.SESSION_TYPE=c,t.MSG_MAX_LENGTH=p,t.C2C_MSG_SUB_TYPE=h,t.GROUP_MSG_SUB_TYPE=T,t.MSG_ELEMENT_TYPE=g,t.GROUP_TIP_TYPE=S,t.IMAGE_TYPE=d,t.GROUP_SYSTEM_TYPE=O,t.FRIEND_NOTICE_TYPE=F,t.GROUP_TIP_MODIFY_GROUP_INFO_TYPE=G,t.BROWSER_INFO=i,t.Emotions=t.EmotionPicData=re,t.EmotionDataIndexs=t.EmotionPicDataIndex=oe,t.TLS_ERROR_CODE=v,t.CONNECTION_STATUS=N,t.UPLOAD_PIC_BUSSINESS_TYPE=P,t.RECENT_CONTACT_TYPE=l,t.UPLOAD_RES_TYPE=E,t.Tool=ie,t.Log=se,t.Msg=Ct,t.Session=yt,t.MsgStore={sessMap:function(){return Tt.sessMap()},sessCount:function(){return Tt.sessCount()},sessByTypeId:function(e,t){return Tt.sessByTypeId(e,t)},delSessByTypeId:function(e,t){return Tt.delSessByTypeId(e,t)},resetCookieAndSyncFlag:function(){return Tt.resetCookieAndSyncFlag()}},t.Resources=ne,t.login=t.init=function(e,t,n,o,r){_t.init(t.onConnNotify,o,r),t.jsonpCallback&&(z=t.jsonpCallback),he(e,t,n,o,r)},t.logout=t.offline=function(e,t){return Ae("instance",e,t)},
t.logoutAll=function(e,t){return Ae("all",e,t)},t.sendMsg=function(e,t,n){return At.sendMsg(e,t,n)},t.syncMsgs=function(e,t){return At.syncMsgs(e,t)},t.getC2CHistoryMsgs=function(e,t,n){return At.getC2CHistoryMsgs(e,t,n)},t.syncGroupMsgs=function(e,t,n){return At.syncGroupMsgs(e,t,n)},t.c2CMsgReaded=function(e,t,n){return Tt.c2CMsgReaded(e,t,n)},t.groupMsgReaded=function(e,t,n){return et(e,t,n)},t.setAutoRead=function(e,t,n){return Tt.setAutoRead(e,t,n)},t.createGroup=function(e,t,n){return Pe(e,t,n)},t.createGroupHigh=function(e,t,n){return be(e,t,n)},t.applyJoinGroup=function(e,t,n){return Ue(e,t,n)},t.handleApplyJoinGroupPendency=function(e,t,n){return ke(e,t,n)},t.deleteApplyJoinGroupPendency=function(e,t,n){return ve(e,t,n)},t.quitGroup=function(e,t,n){return we(e,t,n)},t.searchGroupByName=function(e,t,n){return xe(e,t,n)},t.getGroupPublicInfo=function(e,t,n){return Be(e,t,n)},t.getGroupInfo=function(e,t,n){return Ke(e,t,n)},t.modifyGroupBaseInfo=function(e,t,n){return Le(e,t,n)},t.getGroupMemberInfo=function(e,t,n){return ze(e,t,n)},t.addGroupMember=function(e,t,n){return Ve(e,t,n)},t.modifyGroupMember=function(e,t,n){return Je(e,t,n)},t.deleteGroupMember=function(e,t,n){return He(e,t,n)},t.destroyGroup=function(e,t,n){return Ye(e,t,n)},t.changeGroupOwner=function(e,t,n){return Xe(e,t,n)},t.getJoinedGroupListHigh=function(e,t,n){return Qe(e,t,n)},t.getRoleInGroup=function(e,t,n){return We(e,t,n)},t.forbidSendMsg=function(e,t,n){return je(e,t,n)},t.sendCustomGroupNotify=function(e,t,n){return $e(e,t,n)},t.applyJoinBigGroup=function(e,t,n){return De(e,t,n)},t.quitBigGroup=function(e,t,n){return qe(e,t,n)},t.getProfilePortrait=function(e,t,n){return at(e,t,n)},t.setProfilePortrait=function(e,t,n){return ct(e,t,n)},t.applyAddFriend=function(e,t,n){return nt(e,t,n)},t.getPendency=function(e,t,n){return rt(e,t,n)},t.deletePendency=function(e,t,n){return it(e,t,n)},t.responseFriend=function(e,t,n){return st(e,t,n)},t.getAllFriend=function(e,t,n){return ut(e,t,n)},t.deleteFriend=function(e,t,n){return ot(e,t,n)},t.addBlackList=function(e,t,n){return lt(e,t,n)},t.deleteBlackList=function(e,t,n){return pt(e,t,n)},t.getBlackList=function(e,t,n){return ft(e,t,n)},t.getRecentContactList=function(e,t,n){return gt(e,t,n)},t.uploadFile=t.uploadPic=function(e,t,n){return St.uploadFile(e,t,n)},t.submitUploadFileForm=function(e,t,n){return St.submitUploadFileForm(e,t,n)},t.uploadFileByBase64=t.uploadPicByBase64=function(e,t,n){var o={To_Account:e.toAccount,Busi_Id:e.businessType,File_Type:e.File_Type,File_Str_Md5:e.fileMd5,PkgFlag:m.BASE64_DATA,File_Size:e.totalSize,Slice_Offset:0,Slice_Size:e.totalSize,Slice_Data:e.base64Str,Seq:ae(),Timestamp:ue(),Random:ce()};return dt(o,t,n)},t.setJsonpLastRspData=function(e){K="string"==typeof e?JSON.parse(e):e},t.getLongPollingId=function(e,t,n){return Mt(0,t,n)},t.applyDownload=function(e,t,n){return Et(e,t,n)},t.onDownFile=function(e){window.open(ne.downloadMap["uuid_"+e])},t.checkLogin=function(e,t){return ge(e,t)}}(t),t}();