UNPKG

qn-im-sdk

Version:

QnzsIM SDK

3 lines (2 loc) 49.3 kB
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).qnImSdk={})}(this,function(e){var n,t,r,o=/*#__PURE__*/function(){function e(){this.events=void 0,this.events={}}var n=e.prototype;return n.emit=function(e,n){return this.events[e]&&this.events[e].forEach(function(e){return e(n)}),this},n.on=function(e,n){return this.events[e]?this.events[e].push(n):this.events[e]=[n],this},n.off=function(e,n){if(e&&"function"==typeof n){var t=this.events[e],r=t.findIndex(function(e){return e===n});t.splice(r,1)}else this.events[e]=[];return this},e}();function i(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function u(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return i(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},s.apply(null,arguments)}function a(e,n){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},a(e,n)}e.RequestFunc=void 0,(n=e.RequestFunc||(e.RequestFunc={})).INITSDK="InitSDK",n.LOGIN="Login",n.LOGOUT="Logout",n.GETLOGINSTATUS="GetLoginStatus",n.GETLOGINUSER="GetLoginUser",n.GETSELFUSERINFO="GetSelfUserInfo",n.CREATETEXTMESSAGE="CreateTextMessage",n.CREATETEXTATMESSAGE="CreateTextAtMessage",n.CREATEADVANCEDTEXTMESSAGE="CreateAdvancedTextMessage",n.CREATEIMAGEMESSAGEFROMBYURL="CreateImageMessageByURL",n.CREATESOUNDMESSAGEBYURL="CreateSoundMessageByURL",n.CREATEVIDEOMESSAGEBYURL="CreateVideoMessageByURL",n.CREATEFILEMESSAGEBYURL="CreateFileMessageByURL",n.CREATEIMAGEMESSAGEFROMFULLPATH="CreateImageMessageFromFullPath",n.CREATESOUNDMESSAGEFROMFULLPATH="CreateSoundMessageFromFullPath",n.CREATEVIDEOMESSAGEFROMFULLPATH="CreateVideoMessageFromFullPath",n.CREATEFILEMESSAGEFROMFULLPATH="CreateFileMessageFromFullPath",n.CREATELOCATIONMESSAGE="CreateLocationMessage",n.CREATECUSTOMMESSAGE="CreateCustomMessage",n.CREATEMERGERMESSAGE="CreateMergerMessage",n.CREATEFORWARDMESSAGE="CreateForwardMessage",n.CREATEQUOTEMESSAGE="CreateQuoteMessage",n.CREATEADVANCEDQUOTEMESSAGE="CreateAdvancedQuoteMessage",n.CREATECARDMESSAGE="CreateCardMessage",n.CREATEFACEMESSAGE="CreateFaceMessage",n.SENDMESSAGE="SendMessage",n.SENDMESSAGENOTOSS="SendMessageNotOss",n.GETHISTORYMESSAGELIST="GetHistoryMessageList",n.GETADVANCEDHISTORYMESSAGELIST="GetAdvancedHistoryMessageList",n.GETHISTORYMESSAGELISTREVERSE="GetHistoryMessageListReverse",n.REVOKEMESSAGE="RevokeMessage",n.SETONECONVERSATIONPRIVATECHAT="SetOneConversationPrivateChat",n.DELETEMESSAGEFROMLOCALSTORAGE="DeleteMessageFromLocalStorage",n.DELETEMESSAGEFROMLOCALANDSVR="DeleteMessageFromLocalAndSvr",n.DELETECONVERSATIONFROMLOCALANDSVR="DeleteConversationFromLocalAndSvr",n.DELETEALLCONVERSATIONFROMLOCAL="DeleteAllConversationFromLocal",n.DELETEALLMSGFROMLOCALANDSVR="DeleteAllMsgFromLocalAndSvr",n.DELETEALLMSGFROMLOCAL="DeleteAllMsgFromLocal",n.MARKSINGLEMESSAGEHASREAD="MarkSingleMessageHasRead",n.INSERTSINGLEMESSAGETOLOCALSTORAGE="InsertSingleMessageToLocalStorage",n.INSERTGROUPMESSAGETOLOCALSTORAGE="InsertGroupMessageToLocalStorage",n.TYPINGSTATUSUPDATE="TypingStatusUpdate",n.MARKC2CMESSAGEASREAD="MarkC2CMessageAsRead",n.MARKMESSAGEASREADBYCONID="MarkMessageAsReadByConID",n.CLEARC2CHISTORYMESSAGE="ClearC2CHistoryMessage",n.CLEARC2CHISTORYMESSAGEFROMLOCALANDSVR="ClearC2CHistoryMessageFromLocalAndSvr",n.CLEARGROUPHISTORYMESSAGE="ClearGroupHistoryMessage",n.CLEARGROUPHISTORYMESSAGEFROMLOCALANDSVR="ClearGroupHistoryMessageFromLocalAndSvr",n.ADDFRIEND="AddFriend",n.SEARCHFRIENDS="SearchFriends",n.GETDESIGNATEDFRIENDSINFO="GetDesignatedFriendsInfo",n.GETRECVFRIENDAPPLICATIONLIST="GetRecvFriendApplicationList",n.GETSENDFRIENDAPPLICATIONLIST="GetSendFriendApplicationList",n.GETFRIENDLIST="GetFriendList",n.SETFRIENDREMARK="SetFriendRemark",n.ADDBLACK="AddBlack",n.GETBLACKLIST="GetBlackList",n.REMOVEBLACK="RemoveBlack",n.CHECKFRIEND="CheckFriend",n.ACCEPTFRIENDAPPLICATION="AcceptFriendApplication",n.REFUSEFRIENDAPPLICATION="RefuseFriendApplication",n.DELETEFRIEND="DeleteFriend",n.GETUSERSINFO="GetUsersInfo",n.SETSELFINFO="SetSelfInfo",n.GETALLCONVERSATIONLIST="GetAllConversationList",n.GETCONVERSATIONLISTSPLIT="GetConversationListSplit",n.GETONECONVERSATION="GetOneConversation",n.GETCONVERSATIONIDBYSESSIONTYPE="GetConversationIDBySessionType",n.GETMULTIPLECONVERSATION="GetMultipleConversation",n.DELETECONVERSATION="DeleteConversation",n.SETCONVERSATIONDRAFT="SetConversationDraft",n.PINCONVERSATION="PinConversation",n.GETTOTALUNREADMSGCOUNT="GetTotalUnreadMsgCount",n.GETCONVERSATIONRECVMESSAGEOPT="GetConversationRecvMessageOpt",n.SETCONVERSATIONRECVMESSAGEOPT="SetConversationRecvMessageOpt",n.SEARCHLOCALMESSAGES="SearchLocalMessages",n.MARKGROUPMESSAGEHASREAD="MarkGroupMessageHasRead",n.MARKGROUPMESSAGEASREAD="MarkGroupMessageAsRead",n.INVITEUSERTOGROUP="InviteUserToGroup",n.KICKGROUPMEMBER="KickGroupMember",n.GETGROUPMEMBERSINFO="GetGroupMembersInfo",n.GETGROUPMEMBERLIST="GetGroupMemberList",n.GETGROUPMEMBERLISTBYJOINTIMEFILTER="GetGroupMemberListByJoinTimeFilter",n.SEARCHGROUPMEMBERS="SearchGroupMembers",n.SETGROUPAPPLYMEMBERFRIEND="SetGroupApplyMemberFriend",n.SETGROUPLOOKMEMBERINFO="SetGroupLookMemberInfo",n.GETJOINEDGROUPLIST="GetJoinedGroupList",n.CREATEGROUP="CreateGroup",n.SETGROUPINFO="SetGroupInfo",n.SETGROUPMEMBERNICKNAME="SetGroupMemberNickname",n.GETGROUPSINFO="GetGroupsInfo",n.JOINGROUP="JoinGroup",n.SEARCHGROUPS="SearchGroups",n.QUITGROUP="QuitGroup",n.DISMISSGROUP="DismissGroup",n.CHANGEGROUPMUTE="ChangeGroupMute",n.CHANGEGROUPMEMBERMUTE="ChangeGroupMemberMute",n.TRANSFERGROUPOWNER="TransferGroupOwner",n.GETSENDGROUPAPPLICATIONLIST="GetSendGroupApplicationList",n.GETRECVGROUPAPPLICATIONLIST="GetRecvGroupApplicationList",n.ACCEPTGROUPAPPLICATION="AcceptGroupApplication",n.REFUSEGROUPAPPLICATION="RefuseGroupApplication",n.SIGNAL_INGINVITE="SignalingInvite",n.SIGNALINGINVITEINGROUP="SignalingInviteInGroup",n.SIGNALINGACCEPT="SignalingAccept",n.SIGNALINGREJECT="SignalingReject",n.SIGNALINGCANCEL="SignalingCancel",n.SIGNALINGHUNGUP="SignalingHungUp",n.GETSUBDEPARTMENT="GetSubDepartment",n.GETDEPARTMENTMEMBER="GetDepartmentMember",n.GETUSERINDEPARTMENT="GetUserInDepartment",n.GETDEPARTMENTMEMBERANDSUBDEPARTMENT="GetDepartmentMemberAndSubDepartment",n.GETDEPARTMENTINFO="GetDepartmentInfo",n.SEARCHORGANIZATION="SearchOrganization",n.RESETCONVERSATIONGROUPATTYPE="ResetConversationGroupAtType",n.SETGROUPMEMBERROLELEVEL="SetGroupMemberRoleLevel",n.SETGROUPVERIFICATION="SetGroupVerification",n.SETGLOBALRECVMESSAGEOPT="SetGlobalRecvMessageOpt",n.NEWREVOKEMESSAGE="NewRevokeMessage",n.FINDMESSAGELIST="FindMessageList",e.CbEvents=void 0,(t=e.CbEvents||(e.CbEvents={})).ONCONNECTFAILED="OnConnectFailed",t.ONCONNECTSUCCESS="OnConnectSuccess",t.ONCONNECTING="OnConnecting",t.ONKICKEDOFFLINE="OnKickedOffline",t.ONSELFINFOUPDATED="OnSelfInfoUpdated",t.ONUSERTOKENEXPIRED="OnUserTokenExpired",t.ONPROGRESS="OnProgress",t.ONRECVNEWMESSAGE="OnRecvNewMessage",t.ONRECVNEWMESSAGES="OnRecvNewMessages",t.ONRECVMESSAGEREVOKED="OnRecvMessageRevoked",t.ONRECVC2CREADRECEIPT="OnRecvC2CReadReceipt",t.ONRECVGROUPREADRECEIPT="OnRecvGroupReadReceipt",t.ONCONVERSATIONCHANGED="OnConversationChanged",t.ONNEWCONVERSATION="OnNewConversation",t.ONSYNCSERVERFAILED="OnSyncServerFailed",t.ONSYNCSERVERFINISH="OnSyncServerFinish",t.ONSYNCSERVERSTART="OnSyncServerStart",t.ONTOTALUNREADMESSAGECOUNTCHANGED="OnTotalUnreadMessageCountChanged",t.ONBLACKADDED="OnBlackAdded",t.ONBLACKDELETED="OnBlackDeleted",t.ONFRIENDAPPLICATIONACCEPTED="OnFriendApplicationAccepted",t.ONFRIENDAPPLICATIONADDED="OnFriendApplicationAdded",t.ONFRIENDAPPLICATIONDELETED="OnFriendApplicationDeleted",t.ONFRIENDAPPLICATIONREJECTED="OnFriendApplicationRejected",t.ONFRIENDINFOCHANGED="OnFriendInfoChanged",t.ONFRIENDADDED="OnFriendAdded",t.ONFRIENDDELETED="OnFriendDeleted",t.ONJOINEDGROUPADDED="OnJoinedGroupAdded",t.ONJOINEDGROUPDELETED="OnJoinedGroupDeleted",t.ONGROUPMEMBERADDED="OnGroupMemberAdded",t.ONGROUPMEMBERDELETED="OnGroupMemberDeleted",t.ONGROUPAPPLICATIONADDED="OnGroupApplicationAdded",t.ONGROUPAPPLICATIONDELETED="OnGroupApplicationDeleted",t.ONGROUPINFOCHANGED="OnGroupInfoChanged",t.ONGROUPMEMBERINFOCHANGED="OnGroupMemberInfoChanged",t.ONGROUPAPPLICATIONACCEPTED="OnGroupApplicationAccepted",t.ONGROUPAPPLICATIONREJECTED="OnGroupApplicationRejected",t.ONRECEIVENEWINVITATION="OnReceiveNewInvitation",t.ONINVITEEACCEPTED="OnInviteeAccepted",t.ONINVITEEREJECTED="OnInviteeRejected",t.ONINVITATIONCANCELLED="OnInvitationCancelled",t.ONHANGUP="OnHangUp",t.ONINVITATIONTIMEOUT="OnInvitationTimeout",t.ONINVITEEACCEPTEDBYOTHERDEVICE="OnInviteeAcceptedByOtherDevice",t.ONINVITEEREJECTEDBYOTHERDEVICE="OnInviteeRejectedByOtherDevice",t.ONORGANIZATIONUPDATED="OnOrganizationUpdated",t.ONRECVNEWMESSAGEFROMOTHERWEB="OnRecvNewMessageFromOtherWeb",t.ONNEWRECVMESSAGEREVOKED="OnNewRecvMessageRevoked",t.ONSENSITIVEWORDBLOCKED="OnSensitiveWordBlocked",function(e){e[e.UPLOAD_RATE_LIMIT=10001]="UPLOAD_RATE_LIMIT",e[e.SENSITIVE_WORD_BLOCKED=10002]="SENSITIVE_WORD_BLOCKED"}(r||(r={}));var c=function(e){try{e&&e.terminate()}catch(e){console.log(e)}},E=function(e){return(36*Math.random()).toString(36).slice(2)+(new Date).getTime().toString()+e},d=/*#__PURE__*/function(){function e(){this.userUploadRecords=new Map,this.UPLOAD_LIMIT=6,this.TIME_WINDOW=6e4,this.PENDING_EXPIRE_TIME=6e4}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var n=e.prototype;return n.checkUploadLimit=function(e){var n=this,t=Date.now(),r=this.userUploadRecords.get(e);return r||(r={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,r)),r.timestamps=r.timestamps.filter(function(e){return t-e<n.TIME_WINDOW}),r.timestamps.length>=this.UPLOAD_LIMIT?(console.log("[UploadRateLimit] 用户 "+e+" 上传次数已达限制: "+r.timestamps.length+"/"+this.UPLOAD_LIMIT),!1):(r.timestamps.push(t),console.log("[UploadRateLimit] 用户 "+e+" 上传记录: "+r.timestamps.length+"/"+this.UPLOAD_LIMIT),!0)},n.checkLimit=function(e){var n=this,t=Date.now(),r=this.userUploadRecords.get(e);r||(r={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,r)),r.timestamps=r.timestamps.filter(function(e){return t-e<n.TIME_WINDOW});for(var o,i=u(r.pendingUploads.entries());!(o=i()).done;){var s=o.value;t-s[1]>this.TIME_WINDOW&&r.pendingUploads.delete(s[0])}var a=r.timestamps.length+r.pendingUploads.size;return!(a>=this.UPLOAD_LIMIT&&(console.log("[UploadRateLimit] 用户 "+e+" 达到限制: 实际"+r.timestamps.length+" + 预占"+r.pendingUploads.size+" = "+a+"/"+this.UPLOAD_LIMIT),1))},n.recordUpload=function(e,n){var t=Date.now(),r=this.userUploadRecords.get(e);r||(r={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,r)),n?(r.pendingUploads.set(n,t),console.log("[UploadRateLimit] 用户 "+e+" 预占用配额,token: "+n)):r.timestamps.push(t)},n.releaseQuota=function(e,n){var t=this.userUploadRecords.get(e);t&&t.pendingUploads.has(n)&&(t.pendingUploads.delete(n),console.log("[UploadRateLimit] 用户 "+e+" 释放配额,token: "+n))},n.getRemainingTime=function(e){var n=this,t=Date.now(),r=this.userUploadRecords.get(e);if(!r)return 0;for(var o,i=[].concat(r.timestamps),s=u(r.pendingUploads.entries());!(o=s()).done;)i.push(o.value[1]);var a=i.filter(function(e){return t-e<n.TIME_WINDOW});return a.length<this.UPLOAD_LIMIT?0:(a.sort(function(e,n){return e-n}),Math.max(0,this.TIME_WINDOW-(t-a[a.length-this.UPLOAD_LIMIT])))},n.clearUserRecord=function(e){this.userUploadRecords.delete(e)},n.clearAllRecords=function(){this.userUploadRecords.clear()},e}();d.instance=void 0;var I=d.getInstance(),S=["乱伦","春药","疆独","藏独","暴动","毛片","军火","针孔","女优","肉棍","反华","反共","换妻","偷拍","露点","走光","共奴","乱交","鸡巴","露毛","肉棒","龟头","冰毒","迷药","性奴","暴政","婊子","法+輪+功","干 你 妈","草你妈","老 婊 子","蒙-汗-药","迷-魂-药","迷魂药","迷昏药","江泽民","胡锦涛","习近平","毛泽东","李克强"],R=new(/*#__PURE__*/function(){function e(){this.words=[],this.mode=2,this.loadWords(S)}var n=e.prototype;return n.loadWords=function(e){this.words=e},n.setMode=function(e){this.mode=e},n.getMode=function(){return this.mode},n.detect=function(e){for(var n,t=[],r=u(this.words);!(n=r()).done;){var o=n.value;e.includes(o)&&t.push(o)}return{hasSensitive:t.length>0,words:t}},n.replace=function(e){for(var n,t=e,r=u(this.words);!(n=r()).done;){var o=n.value,i="*".repeat(o.length),s=new RegExp(o,"g");t=t.replace(s,i)}return t},n.filter=function(e){return this.detect(e).hasSensitive?1===this.mode?{success:!0,content:this.replace(e)}:{success:!1,content:e,message:"该消息有敏感词被屏蔽"}:{success:!0,content:e}},e}());function D(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}e.QnzsIMSDK=/*#__PURE__*/function(n){function t(){var t;return(t=n.call(this)||this).ws=void 0,t.uid=void 0,t.token=void 0,t.platform="web",t.wsUrl="",t.lock=!1,t.logoutFlag=!1,t.ws2promise={},t.onceFlag=!0,t.timer=void 0,t.lastTime=0,t.heartbeatCount=0,t.heartbeatStartTime=0,t.platformID=0,t.isBatch=!1,t.worker=null,t.checkUploadPermission=function(e){return new Promise(function(n,o){var i=e||E(t.uid);if(!I.checkLimit(t.uid||""))return t.emitUploadLimitMessage(i),void o({event:"checkUploadPermission",errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:{allowed:!1,reason:"rate_limit",remainingTime:I.getRemainingTime(t.uid||"")},operationID:i});var u=i;I.recordUpload(t.uid||"",u),n({event:"checkUploadPermission",errCode:0,errMsg:"",data:{allowed:!0,uploadToken:u,expiresIn:6e4},operationID:i})})},t.releaseUploadQuota=function(e){I.releaseQuota(t.uid||"",e)},t.getLoginStatus=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETLOGINSTATUS,operationID:i,userID:t.uid,data:""},r,o)})},t.getLoginUser=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETLOGINUSER,operationID:i,userID:t.uid,data:""},r,o)})},t.getSelfUserInfo=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETSELFUSERINFO,operationID:i,userID:t.uid,data:""},r,o)})},t.getUsersInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETUSERSINFO,operationID:u,userID:t.uid,data:n},o,i)})},t.setSelfInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETSELFINFO,operationID:u,userID:t.uid,data:n},o,i)})},t.createTextMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATETEXTMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.createTextAtMessage=function(n,r){return new Promise(function(o,i){var u=s({},n);u.atUserIDList=JSON.stringify(u.atUserIDList),u.atUsersInfo=JSON.stringify(u.atUsersInfo);var a=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATETEXTATMESSAGE,operationID:a,userID:t.uid,data:u},o,i)})},t.createAdvancedTextMessage=function(n,r){return new Promise(function(o,i){var u=s({},n);u.messageEntityList=JSON.stringify(u.messageEntityList);var a=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATEADVANCEDTEXTMESSAGE,operationID:a,userID:t.uid,data:u},o,i)})},t.createImageMessage=function(n,o){return new Promise(function(i,u){var a=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(a),void u({event:e.RequestFunc.CREATEIMAGEMESSAGEFROMBYURL,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:a});var c=s({},n);c.bigPicture=JSON.stringify(c.bigPicture),c.snapshotPicture=JSON.stringify(c.snapshotPicture),c.sourcePicture=JSON.stringify(c.sourcePicture);var d={reqFuncName:e.RequestFunc.CREATEIMAGEMESSAGEFROMBYURL,operationID:a,userID:t.uid,data:JSON.stringify(c)};t.wsSend(d,i,u)})},t.createSoundMessage=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATESOUNDMESSAGEBYURL,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});var a={soundBaseInfo:JSON.stringify(n)},c={reqFuncName:e.RequestFunc.CREATESOUNDMESSAGEBYURL,operationID:s,userID:t.uid,data:JSON.stringify(a)};t.wsSend(c,i,u)})},t.createVideoMessage=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATEVIDEOMESSAGEBYURL,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});var a={videoBaseInfo:JSON.stringify(n)},c={reqFuncName:e.RequestFunc.CREATEVIDEOMESSAGEBYURL,operationID:s,userID:t.uid,data:JSON.stringify(a)};t.wsSend(c,i,u)})},t.createFileMessage=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATEFILEMESSAGEBYURL,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});var a={fileBaseInfo:JSON.stringify(n)},c={reqFuncName:e.RequestFunc.CREATEFILEMESSAGEBYURL,operationID:s,userID:t.uid,data:JSON.stringify(a)};t.wsSend(c,i,u)})},t.createFileMessageFromFullPath=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATEFILEMESSAGEFROMFULLPATH,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});t.wsSend({reqFuncName:e.RequestFunc.CREATEFILEMESSAGEFROMFULLPATH,operationID:s,userID:t.uid,data:n},i,u)})},t.createImageMessageFromFullPath=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATEIMAGEMESSAGEFROMFULLPATH,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});t.wsSend({reqFuncName:e.RequestFunc.CREATEIMAGEMESSAGEFROMFULLPATH,operationID:s,userID:t.uid,data:n},i,u)})},t.createSoundMessageFromFullPath=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATESOUNDMESSAGEFROMFULLPATH,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});t.wsSend({reqFuncName:e.RequestFunc.CREATESOUNDMESSAGEFROMFULLPATH,operationID:s,userID:t.uid,data:n},i,u)})},t.createVideoMessageFromFullPath=function(n,o){return new Promise(function(i,u){var s=o||E(t.uid);if(!I.checkUploadLimit(t.uid||"unknown"))return t.emitUploadLimitMessage(s),void u({event:e.RequestFunc.CREATEVIDEOMESSAGEFROMFULLPATH,errCode:r.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:s});t.wsSend({reqFuncName:e.RequestFunc.CREATEVIDEOMESSAGEFROMFULLPATH,operationID:s,userID:t.uid,data:n},i,u)})},t.createMergerMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.messageList=JSON.stringify(n.messageList),a.summaryList=JSON.stringify(n.summaryList),t.wsSend({reqFuncName:e.RequestFunc.CREATEMERGERMESSAGE,operationID:u,userID:t.uid,data:a},o,i)})},t.createForwardMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATEFORWARDMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.createFaceMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATEFACEMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.createLocationMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATELOCATIONMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.createCustomMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATECUSTOMMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.createQuoteMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATEQUOTEMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.createAdvancedQuoteMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.messageEntityList=JSON.stringify(a.messageEntityList),t.wsSend({reqFuncName:e.RequestFunc.CREATEADVANCEDQUOTEMESSAGE,operationID:u,userID:t.uid,data:a},o,i)})},t.createCardMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CREATECARDMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.sendMessage=function(n,o){return new Promise(function(i,u){var a=o||E(t.uid),c=s({},n);try{var d=JSON.parse(n.message);if([101,106,114,117].includes(d.contentType)&&d.content){var I=R.filter(d.content);if(!I.success){var S=R.detect(d.content);console.log("[IM SDK] 检测到敏感词,阻止发送:",S.words);var D={clientMsgID:"system_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 该消息有敏感词被屏蔽",senderUserID:"system",senderNickname:"系统提示",recvID:n.recvID,groupID:n.groupID,status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isSensitiveWordBlocked:!0,blockedWords:S.words,originalContent:d.content})};setTimeout(function(){t.emit(e.CbEvents.ONRECVNEWMESSAGE,{event:e.CbEvents.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:D,operationID:a})},0),t.emit(e.CbEvents.ONSENSITIVEWORDBLOCKED,{originalMessage:d,blockedWords:S.words,recvID:n.recvID,groupID:n.groupID});var A={event:e.RequestFunc.SENDMESSAGE,errCode:r.SENSITIVE_WORD_BLOCKED,errMsg:I.message||"该消息有敏感词被屏蔽",data:"",operationID:a};return console.log("[IM SDK] 返回敏感词错误:",A),void u(A)}I.content!==d.content&&(console.log("[IM SDK] 敏感词已替换"),d.content=I.content,c.message=JSON.stringify(d))}}catch(e){console.error("[IM SDK] 解析消息内容失败:",e)}c.offlinePushInfo=c.offlinePushInfo?JSON.stringify(n.offlinePushInfo):"",t.wsSend({reqFuncName:e.RequestFunc.SENDMESSAGE,operationID:a,userID:t.uid,data:c},i,u)})},t.sendMessageNotOss=function(n,o){return new Promise(function(i,u){var a=o||E(t.uid),c=s({},n);try{var d=JSON.parse(n.message);if([101,106,114,117].includes(d.contentType)&&d.content){var I=R.filter(d.content);if(!I.success){var S=R.detect(d.content);console.log("[IM SDK] 检测到敏感词,阻止发送:",S.words);var D={clientMsgID:"system_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 该消息有敏感词被屏蔽",senderUserID:"system",senderNickname:"系统提示",recvID:n.recvID,groupID:n.groupID,status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isSensitiveWordBlocked:!0,blockedWords:S.words,originalContent:d.content})};setTimeout(function(){t.emit(e.CbEvents.ONRECVNEWMESSAGE,{event:e.CbEvents.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:D,operationID:a})},0),t.emit(e.CbEvents.ONSENSITIVEWORDBLOCKED,{originalMessage:d,blockedWords:S.words,recvID:n.recvID,groupID:n.groupID});var A={event:e.RequestFunc.SENDMESSAGENOTOSS,errCode:r.SENSITIVE_WORD_BLOCKED,errMsg:I.message||"该消息有敏感词被屏蔽",data:"",operationID:a};return console.log("[IM SDK] 返回敏感词错误:",A),void u(A)}I.content!==d.content&&(console.log("[IM SDK] 敏感词已替换"),d.content=I.content,c.message=JSON.stringify(d))}}catch(e){console.error("[IM SDK] 解析消息内容失败:",e)}c.offlinePushInfo=c.offlinePushInfo?JSON.stringify(n.offlinePushInfo):"",t.wsSend({reqFuncName:e.RequestFunc.SENDMESSAGENOTOSS,operationID:a,userID:t.uid,data:c},i,u)})},t.getHistoryMessageList=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETHISTORYMESSAGELIST,operationID:u,userID:t.uid,data:n},o,i)})},t.getAdvancedHistoryMessageList=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETADVANCEDHISTORYMESSAGELIST,operationID:u,userID:t.uid,data:n},o,i)})},t.getHistoryMessageListReverse=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETHISTORYMESSAGELISTREVERSE,operationID:u,userID:t.uid,data:n},o,i)})},t.revokeMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.REVOKEMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.setOneConversationPrivateChat=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETONECONVERSATIONPRIVATECHAT,operationID:u,userID:t.uid,data:n},o,i)})},t.deleteMessageFromLocalStorage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETEMESSAGEFROMLOCALSTORAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.deleteMessageFromLocalAndSvr=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETEMESSAGEFROMLOCALANDSVR,operationID:u,userID:t.uid,data:n},o,i)})},t.deleteConversationFromLocalAndSvr=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETECONVERSATIONFROMLOCALANDSVR,operationID:u,userID:t.uid,data:n},o,i)})},t.deleteAllConversationFromLocal=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETEALLCONVERSATIONFROMLOCAL,operationID:i,userID:t.uid,data:""},r,o)})},t.deleteAllMsgFromLocal=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETEALLMSGFROMLOCAL,operationID:i,userID:t.uid,data:""},r,o)})},t.deleteAllMsgFromLocalAndSvr=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETEALLMSGFROMLOCALANDSVR,operationID:i,userID:t.uid,data:""},r,o)})},t.markGroupMessageHasRead=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.MARKGROUPMESSAGEHASREAD,operationID:u,userID:t.uid,data:n},o,i)})},t.markGroupMessageAsRead=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.msgIDList=JSON.stringify(a.msgIDList),t.wsSend({reqFuncName:e.RequestFunc.MARKGROUPMESSAGEASREAD,operationID:u,userID:t.uid,data:a},o,i)})},t.insertSingleMessageToLocalStorage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.INSERTSINGLEMESSAGETOLOCALSTORAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.insertGroupMessageToLocalStorage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.INSERTGROUPMESSAGETOLOCALSTORAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.typingStatusUpdate=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.TYPINGSTATUSUPDATE,operationID:u,userID:t.uid,data:n},o,i)})},t.markC2CMessageAsRead=function(n,r){return new Promise(function(o,i){var u=s({},n);u.msgIDList=JSON.stringify(u.msgIDList);var a=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.MARKC2CMESSAGEASREAD,operationID:a,userID:t.uid,data:u},o,i)})},t.markNotifyMessageHasRead=function(e,n){t.markMessageAsReadByConID({conversationID:e,msgIDList:[]})},t.markMessageAsReadByConID=function(n,r){return new Promise(function(o,i){var u=s({},n);u.msgIDList=JSON.stringify(u.msgIDList);var a=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.MARKMESSAGEASREADBYCONID,operationID:a,userID:t.uid,data:u},o,i)})},t.clearC2CHistoryMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CLEARC2CHISTORYMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.clearC2CHistoryMessageFromLocalAndSvr=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CLEARC2CHISTORYMESSAGEFROMLOCALANDSVR,operationID:u,userID:t.uid,data:n},o,i)})},t.clearGroupHistoryMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CLEARGROUPHISTORYMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.clearGroupHistoryMessageFromLocalAndSvr=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CLEARGROUPHISTORYMESSAGEFROMLOCALANDSVR,operationID:u,userID:t.uid,data:n},o,i)})},t.getAllConversationList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETALLCONVERSATIONLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.getConversationListSplit=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETCONVERSATIONLISTSPLIT,operationID:u,userID:t.uid,data:n},o,i)})},t.getOneConversation=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETONECONVERSATION,operationID:u,userID:t.uid,data:n},o,i)})},t.getConversationIDBySessionType=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETCONVERSATIONIDBYSESSIONTYPE,operationID:u,userID:t.uid,data:n},o,i)})},t.getMultipleConversation=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETMULTIPLECONVERSATION,operationID:u,userID:t.uid,data:n},o,i)})},t.deleteConversation=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETECONVERSATION,operationID:u,userID:t.uid,data:n},o,i)})},t.setConversationDraft=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETCONVERSATIONDRAFT,operationID:u,userID:t.uid,data:n},o,i)})},t.pinConversation=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.PINCONVERSATION,operationID:u,userID:t.uid,data:n},o,i)})},t.getTotalUnreadMsgCount=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETTOTALUNREADMSGCOUNT,operationID:i,userID:t.uid,data:""},r,o)})},t.getConversationRecvMessageOpt=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETCONVERSATIONRECVMESSAGEOPT,operationID:u,userID:t.uid,data:n},o,i)})},t.setConversationRecvMessageOpt=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.conversationIDList=JSON.stringify(n.conversationIDList),t.wsSend({reqFuncName:e.RequestFunc.SETCONVERSATIONRECVMESSAGEOPT,operationID:u,userID:t.uid,data:a},o,i)})},t.searchLocalMessages=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SEARCHLOCALMESSAGES,operationID:u,userID:t.uid,data:n},o,i)})},t.addFriend=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.ADDFRIEND,operationID:u,userID:t.uid,data:n},o,i)})},t.searchFriends=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SEARCHFRIENDS,operationID:u,userID:t.uid,data:n},o,i)})},t.getDesignatedFriendsInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETDESIGNATEDFRIENDSINFO,operationID:u,userID:t.uid,data:n},o,i)})},t.getRecvFriendApplicationList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETRECVFRIENDAPPLICATIONLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.getSendFriendApplicationList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETSENDFRIENDAPPLICATIONLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.getFriendList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETFRIENDLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.setFriendRemark=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETFRIENDREMARK,operationID:u,userID:t.uid,data:n},o,i)})},t.checkFriend=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CHECKFRIEND,operationID:u,userID:t.uid,data:n},o,i)})},t.acceptFriendApplication=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.ACCEPTFRIENDAPPLICATION,operationID:u,userID:t.uid,data:n},o,i)})},t.refuseFriendApplication=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.REFUSEFRIENDAPPLICATION,operationID:u,userID:t.uid,data:n},o,i)})},t.deleteFriend=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DELETEFRIEND,operationID:u,userID:t.uid,data:n},o,i)})},t.addBlack=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.ADDBLACK,operationID:u,userID:t.uid,data:n},o,i)})},t.removeBlack=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.REMOVEBLACK,operationID:u,userID:t.uid,data:n},o,i)})},t.getBlackList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETBLACKLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.inviteUserToGroup=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.userIDList=JSON.stringify(a.userIDList),t.wsSend({reqFuncName:e.RequestFunc.INVITEUSERTOGROUP,operationID:u,userID:t.uid,data:a},o,i)})},t.kickGroupMember=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.userIDList=JSON.stringify(a.userIDList),t.wsSend({reqFuncName:e.RequestFunc.KICKGROUPMEMBER,operationID:u,userID:t.uid,data:a},o,i)})},t.getGroupMembersInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.userIDList=JSON.stringify(a.userIDList),t.wsSend({reqFuncName:e.RequestFunc.GETGROUPMEMBERSINFO,operationID:u,userID:t.uid,data:a},o,i)})},t.getGroupMemberList=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETGROUPMEMBERLIST,operationID:u,userID:t.uid,data:n},o,i)})},t.getGroupMemberListByJoinTimeFilter=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.filterUserIDList=JSON.stringify(a.filterUserIDList),t.wsSend({reqFuncName:e.RequestFunc.GETGROUPMEMBERLISTBYJOINTIMEFILTER,operationID:u,userID:t.uid,data:a},o,i)})},t.searchGroupMembers=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),s={reqFuncName:e.RequestFunc.SEARCHGROUPMEMBERS,operationID:u,userID:t.uid,data:{searchParam:JSON.stringify(n)}};t.wsSend(s,o,i)})},t.setGroupApplyMemberFriend=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETGROUPAPPLYMEMBERFRIEND,operationID:u,userID:t.uid,data:n},o,i)})},t.setGroupLookMemberInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETGROUPLOOKMEMBERINFO,operationID:u,userID:t.uid,data:n},o,i)})},t.getJoinedGroupList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETJOINEDGROUPLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.createGroup=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.groupBaseInfo=JSON.stringify(a.groupBaseInfo),a.memberList=JSON.stringify(a.memberList),t.wsSend({reqFuncName:e.RequestFunc.CREATEGROUP,operationID:u,userID:t.uid,data:a},o,i)})},t.setGroupInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),a=s({},n);a.groupInfo=JSON.stringify(a.groupInfo),t.wsSend({reqFuncName:e.RequestFunc.SETGROUPINFO,operationID:u,userID:t.uid,data:a},o,i)})},t.setGroupMemberNickname=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETGROUPMEMBERNICKNAME,operationID:u,userID:t.uid,data:n},o,i)})},t.getGroupsInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETGROUPSINFO,operationID:u,userID:t.uid,data:n},o,i)})},t.joinGroup=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.JOINGROUP,operationID:u,userID:t.uid,data:n},o,i)})},t.searchGroups=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SEARCHGROUPS,operationID:u,userID:t.uid,data:n},o,i)})},t.quitGroup=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.QUITGROUP,operationID:u,userID:t.uid,data:n},o,i)})},t.dismissGroup=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.DISMISSGROUP,operationID:u,userID:t.uid,data:n},o,i)})},t.changeGroupMute=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CHANGEGROUPMUTE,operationID:u,userID:t.uid,data:n},o,i)})},t.changeGroupMemberMute=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.CHANGEGROUPMEMBERMUTE,operationID:u,userID:t.uid,data:n},o,i)})},t.transferGroupOwner=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.TRANSFERGROUPOWNER,operationID:u,userID:t.uid,data:n},o,i)})},t.getSendGroupApplicationList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETSENDGROUPAPPLICATIONLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.getRecvGroupApplicationList=function(n){return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETRECVGROUPAPPLICATIONLIST,operationID:i,userID:t.uid,data:""},r,o)})},t.acceptGroupApplication=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.ACCEPTGROUPAPPLICATION,operationID:u,userID:t.uid,data:n},o,i)})},t.refuseGroupApplication=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.REFUSEGROUPAPPLICATION,operationID:u,userID:t.uid,data:n},o,i)})},t.signalingInvite=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),s={};s.invitation=n,t.wsSend({reqFuncName:e.RequestFunc.SIGNAL_INGINVITE,operationID:u,userID:t.uid,data:s},o,i)})},t.signalingInviteInGroup=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),s={};s.invitation=n,t.wsSend({reqFuncName:e.RequestFunc.SIGNALINGINVITEINGROUP,operationID:u,userID:t.uid,data:s},o,i)})},t.signalingAccept=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SIGNALINGACCEPT,operationID:u,userID:t.uid,data:n},o,i)})},t.signalingReject=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SIGNALINGREJECT,operationID:u,userID:t.uid,data:n},o,i)})},t.signalingCancel=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SIGNALINGCANCEL,operationID:u,userID:t.uid,data:n},o,i)})},t.signalingHungUp=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SIGNALINGHUNGUP,operationID:u,userID:t.uid,data:n},o,i)})},t.getSubDepartment=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETSUBDEPARTMENT,operationID:u,userID:t.uid,data:n},o,i)})},t.getDepartmentMember=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETDEPARTMENTMEMBER,operationID:u,userID:t.uid,data:n},o,i)})},t.getUserInDepartment=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETUSERINDEPARTMENT,operationID:u,userID:t.uid,data:n},o,i)})},t.getDepartmentMemberAndSubDepartment=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETDEPARTMENTMEMBERANDSUBDEPARTMENT,operationID:u,userID:t.uid,data:n},o,i)})},t.getDepartmentInfo=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.GETDEPARTMENTINFO,operationID:u,userID:t.uid,data:n},o,i)})},t.searchOrganization=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid),s=n;s.input=JSON.stringify(s.input),t.wsSend({reqFuncName:e.RequestFunc.SEARCHORGANIZATION,operationID:u,userID:t.uid,data:s},o,i)})},t.resetConversationGroupAtType=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.RESETCONVERSATIONGROUPATTYPE,operationID:u,userID:t.uid,data:n},o,i)})},t.setGroupMemberRoleLevel=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETGROUPMEMBERROLELEVEL,operationID:u,userID:t.uid,data:n},o,i)})},t.setGroupVerification=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETGROUPVERIFICATION,operationID:u,userID:t.uid,data:n},o,i)})},t.setGlobalRecvMessageOpt=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.SETGLOBALRECVMESSAGEOPT,operationID:u,userID:t.uid,data:n},o,i)})},t.newRevokeMessage=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.NEWREVOKEMESSAGE,operationID:u,userID:t.uid,data:n},o,i)})},t.findMessageList=function(n,r){return new Promise(function(o,i){var u=r||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.FINDMESSAGELIST,operationID:u,userID:t.uid,data:n},o,i)})},t.wsSend=function(n,r,o){var i,u,s;if(null==(i=window)||!i.navigator||window.navigator.onLine)if((null==(u=t.ws)?void 0:u.readyState)===(null==(s=t.ws)?void 0:s.OPEN)){"object"==typeof n.data&&(n.data=JSON.stringify(n.data));var a={oid:n.operationID||E(t.uid),mname:n.reqFuncName,mrsve:r,mrjet:o,flag:!1};t.ws2promise[a.oid]=a;var c=function(r){t.lastTime=(new Date).getTime();var o=JSON.parse(r.data);if(e.CbEvents[o.event.toUpperCase()])t.emit(o.event,o);else{n.reqFuncName===e.RequestFunc.LOGOUT&&(t.logoutFlag=!0,t.ws.close(),t.ws=void 0);var i=t.ws2promise[o.operationID];i?(0===o.errCode?i.mrsve(o):i.mrjet(o),delete t.ws2promise[o.operationID]):o.event!==e.RequestFunc.SENDMESSAGE&&o.event!==e.RequestFunc.SENDMESSAGENOTOSS||t.emit(e.CbEvents.ONRECVNEWMESSAGEFROMOTHERWEB,o)}};try{"web"==t.platform?(t.ws.send(JSON.stringify(n)),t.ws.onmessage=c):(t.ws.send({data:JSON.stringify(n),success:function(e){"uni"===t.platform&&void 0!==t.ws._callbacks&&void 0!==t.ws._callbacks.message&&(t.ws._callbacks.message=[])}}),t.onceFlag&&(t.ws.onMessage(c),t.onceFlag=!1))}catch(e){return void o({event:n.reqFuncName,errCode:112,errMsg:"no ws conect...",data:"",operationID:n.operationID||""})}n.reqFuncName===e.RequestFunc.LOGOUT&&(t.onceFlag=!0)}else o({event:n.reqFuncName,errCode:112,errMsg:"ws conecting...",data:"",operationID:n.operationID||""});else o({event:n.reqFuncName,errCode:113,errMsg:"net work error",data:"",operationID:n.operationID||""})},t.getPlatform(),t}var o,i;i=n,(o=t).prototype=Object.create(i.prototype),o.prototype.constructor=o,a(o,i);var u=t.prototype;return u.emitUploadLimitMessage=function(n){var t=this,r={clientMsgID:"system_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 上传太频繁,每分钟最多上传6次文件",senderUserID:"system",senderNickname:"系统提示",recvID:this.uid||"",groupID:"",status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isUploadLimitExceeded:!0,limitType:"file_upload",limit:6,timeWindow:60})};setTimeout(function(){t.emit(e.CbEvents.ONRECVNEWMESSAGE,{event:e.CbEvents.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:r,operationID:n})},0)},u.login=function(n){var t=this;return new Promise(function(r,o){var i=n.userID,u=n.token,s=n.platformID,a=n.isBatch,c=void 0!==a&&a,E=n.operationID,d=n.censorWordsUrl;t.wsUrl=n.url+"?sendID="+i+"&token="+u+"&platformID="+s,t.platformID=s;var I={userID:i,token:u},S={event:e.RequestFunc.LOGIN,errCode:0,errMsg:"",data:"",operationID:E||""};t.createWs(function(){t.uid=i,t.token=u,t.isBatch=c,t.iLogin(I,E).then(function(e){try{var n=function(){r(e)};t.logoutFlag=!1,t.heartbeat();var o=function(){if(d){var e=D(function(){return Promise.resolve(t.loadRemoteCensorWords(d)).then(function(){})},function(e){console.warn("Failed to load remote censor words:",e)});if(e&&e.then)return e.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(e){return Promise.reject(e)}}).catch(function(e){S.errCode=e.errCode,S.errMsg=e.errMsg,o(S)})},function(){S.errCode=111,S.errMsg="ws connect close...",t.logoutFlag||Object.values(t.ws2promise).forEach(function(e){return e.mrjet({event:e.mname,errCode:111,errMsg:"ws connect close...",data:"",operationID:e.oid})}),o(S)},function(e){console.log(e),S.errCode=112,S.errMsg="ws connect error...",o(S)}),t.ws||(S.errCode=112,S.errMsg="The current platform is not supported...",o(S))})},u.iLogin=function(n,t){var r=this;return new Promise(function(o,i){var u=t||E(r.uid);r.wsSend({reqFuncName:e.RequestFunc.LOGIN,operationID:u,userID:r.uid,data:n,batchMsg:r.isBatch?1:0},o,i)})},u.logout=function(n){var t=this;return new Promise(function(r,o){var i=n||E(t.uid);t.wsSend({reqFuncName:e.RequestFunc.LOGOUT,operationID:i,userID:t.uid,data:""},r,o)})},u.loadRemoteCensorWords=function(e){try{var n=this;return Promise.resolve(D(function(){function t(e){Array.isArray(r)&&r.length>0&&(R.loadWords(r),console.log("Loaded "+r.length+" censor words from remote"))}var r=[],o="web"===n.platform?Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("HTTP error! status: "+e.status);return Promise.resolve(e.json()).then(function(e){r=e.words||e})}):function(){if("uni"===n.platform)return Promise.resolve(uni.request({url:e,method:"GET"})).then(function(e){var n=e[0];if(n)throw n;var t=e[1].data;r=t.words||t});var t=function(){if("wx"===n.platform)return Promise.resolve(new Promise(function(n,t){wx.request({url:e,method:"GET",success:function(e){var t=e.data;n(t.words||t)},fail:t})})).then(function(e){r=e})}();return t&&t.then?t.then(function(){}):void 0}();return o&&o.then?o.then(t):t()},function(e){throw console.error("Error loading remote censor words:",e),e}))}catch(e){return Promise.reject(e)}},u.getPlatform=function(){var e=typeof WebSocket,n=typeof uni,t=typeof wx;this.platform="undefined"===e?"object"===n&&"object"!==t?"uni":"object"!==n&&"object"===t?"wx":"unknow":"web"},u.createWs=function(e,n,t){var r=this;return console.log("start createWs..."),new Promise(function(o,i){var u;null==(u=r.ws)||u.close(),r.ws=void 0;var s=function(){r.iLogin({userID:r.uid,token:r.token}).then(function(e){r.logoutFlag=!1,console.log("iLogin suc..."),r.heartbeat(),o()})};e&&(s=e);var a=function(){console.log("ws close agin:::"),r.logoutFlag||Object.values(r.ws2promise).forEach(function(e){return e.mrjet({event:e.mname,errCode:111,errMsg:"ws connect close...",data:"",operationID:e.oid})})};n&&(a=n);var c=function(){};if(t&&(c=t),"web"===r.platform)return r.ws=new WebSocket(r.wsUrl),r.ws.onclose=a,r.ws.onopen=s,void(r.ws.onerror=c);var E="uni"===r.platform?uni:wx;r.ws=E.connectSocket({url:r.wsUrl,complete:function(){}}),r.ws.onClose(a),r.ws.onOpen(s),r.ws.onError(c)})},u.reconnect=function(){var e=this;this.onceFlag||(this.onceFlag=!0),this.lock||(this.lock=!0,this.clearTimer(),this.timer=setTimeout(function(){e.createWs(),e.lock=!1},500))},u.clearTimer=function(){this.timer&&clearTimeout(this.timer)},u.heartbeat=function(){var e,n,t,r,o=this;console.log("start heartbeat..."),this.clearTimer(),this.worker&&c(this.worker);try{this.worker=(e=function(){var e,n,t,r;o.logoutFlag?o.worker&&c(o.worker):(null==(e=o.ws)?void 0:e.readyState)===(null==(n=o.ws)?void 0:n.CONNECTING)||(null==(t=o.ws)?void 0:t.readyState)===(null==(r=o.ws)?void 0:r.OPEN)?(new Date).getTime()-o.lastTime<9e3||o.getLoginStatus().catch(function(e){return o.reconnect()}):o.reconnect()},n=new Blob(["(function (e) {\n setInterval(function () {\n this.postMessage(null)\n }, 10000)\n })()"]),t=window.URL.createObjectURL(n),(r=new Worker(t)).onmessage=e,r)}catch(e){}},t}(o),e.emitter=o,e.uuid=E}); //# sourceMappingURL=index.umd.js.map