UNPKG

qn-im-sdk

Version:

QnzsIM SDK

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