@openim/client-sdk
Version:
JavaScript/TypeScript Client SDK for OpenIM
1 lines • 178 kB
JavaScript
import e from"loglevel";import t from"spark-md5";import{decode as n,encode as r}from"base64-arraybuffer";import{PbCoder as o,SdkWsProto as i}from"@openim/protocol";function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var c=0;function u(e){return"__private_"+c+++"_"+e}function d(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);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 g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function p(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function v(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function m(e){var t="function"==typeof Map?new Map:void 0;return m=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(f())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&h(o,n.prototype),o}(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},m(e)}var I,M,D,y=function(e){try{if(!e.ok)throw new Error(e.statusText);return Promise.resolve(e.json()).then(function(e){if(0!==e.errCode)throw new Error(e.errMsg);return e.data})}catch(e){return Promise.reject(e)}},S={txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",csv:"text/csv",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",mp3:"audio/mpeg",mp4:"video/mp4",wav:"audio/wav",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",xml:"application/xml",zip:"application/zip",tar:"application/x-tar","7z":"application/x-7z-compressed",rar:"application/vnd.rar",ogg:"audio/ogg",midi:"audio/midi",webm:"audio/webm",avi:"video/x-msvideo",mpeg:"video/mpeg",ts:"video/mp2t",mov:"video/quicktime",wmv:"video/x-ms-wmv",flv:"video/x-flv",mkv:"video/x-matroska",webp:"image/webp",heic:"image/heic",psd:"image/vnd.adobe.photoshop",ai:"application/postscript",eps:"application/postscript",ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2",jsonld:"application/ld+json",ics:"text/calendar",sh:"application/x-sh",php:"application/x-httpd-php",jar:"application/java-archive"};!function(e){e.InitSDK="InitSDK",e.Login="Login",e.Logout="Logout",e.GetLoginStatus="GetLoginStatus",e.GetLoginUserID="GetLoginUserID",e.ForceReconnect="ForceReconnect",e.GetSelfUserInfo="GetSelfUserInfo",e.SetSelfInfo="SetSelfInfo",e.GetUsersInfo="GetUsersInfo",e.SubscribeUsersStatus="SubscribeUsersStatus",e.UnsubscribeUsersStatus="UnsubscribeUsersStatus",e.GetSubscribeUsersStatus="GetSubscribeUsersStatus",e.SetAppBackgroundStatus="SetAppBackgroundStatus",e.NetworkStatusChanged="NetworkStatusChanged",e.SetGlobalRecvMessageOpt="SetGlobalRecvMessageOpt",e.AcceptFriendApplication="AcceptFriendApplication",e.AddBlack="AddBlack",e.AddFriend="AddFriend",e.CheckFriend="CheckFriend",e.DeleteFriend="DeleteFriend",e.GetBlackList="GetBlackList",e.GetFriendApplicationListAsApplicant="GetFriendApplicationListAsApplicant",e.GetFriendApplicationListAsRecipient="GetFriendApplicationListAsRecipient",e.GetFriendList="GetFriendList",e.GetFriendListPage="GetFriendListPage",e.GetSpecifiedFriendsInfo="GetSpecifiedFriendsInfo",e.RefuseFriendApplication="RefuseFriendApplication",e.RemoveBlack="RemoveBlack",e.SearchFriends="SearchFriends",e.UpdateFriends="UpdateFriends",e.CreateGroup="CreateGroup",e.JoinGroup="JoinGroup",e.InviteUserToGroup="InviteUserToGroup",e.GetJoinedGroupList="GetJoinedGroupList",e.GetJoinedGroupListPage="GetJoinedGroupListPage",e.SearchGroups="SearchGroups",e.GetSpecifiedGroupsInfo="GetSpecifiedGroupsInfo",e.SetGroupInfo="SetGroupInfo",e.GetGroupApplicationListAsRecipient="GetGroupApplicationListAsRecipient",e.GetGroupApplicationListAsApplicant="GetGroupApplicationListAsApplicant",e.AcceptGroupApplication="AcceptGroupApplication",e.RefuseGroupApplication="RefuseGroupApplication",e.GetGroupMemberList="GetGroupMemberList",e.GetSpecifiedGroupMembersInfo="GetSpecifiedGroupMembersInfo",e.SearchGroupMembers="SearchGroupMembers",e.SetGroupMemberInfo="SetGroupMemberInfo",e.GetGroupMemberOwnerAndAdmin="GetGroupMemberOwnerAndAdmin",e.GetGroupMemberListByJoinTimeFilter="GetGroupMemberListByJoinTimeFilter",e.KickGroupMember="KickGroupMember",e.ChangeGroupMemberMute="ChangeGroupMemberMute",e.ChangeGroupMute="ChangeGroupMute",e.TransferGroupOwner="TransferGroupOwner",e.DismissGroup="DismissGroup",e.QuitGroup="QuitGroup",e.GetUsersInGroup="GetUsersInGroup",e.IsJoinGroup="IsJoinGroup",e.GetAllConversationList="GetAllConversationList",e.GetConversationListSplit="GetConversationListSplit",e.GetOneConversation="GetOneConversation",e.GetMultipleConversation="GetMultipleConversation",e.GetConversationIDBySessionType="GetConversationIDBySessionType",e.GetTotalUnreadMsgCount="GetTotalUnreadMsgCount",e.MarkConversationMessageAsRead="MarkConversationMessageAsRead",e.SetConversationDraft="SetConversationDraft",e.PinConversation="PinConversation",e.SetConversationRecvMessageOpt="SetConversationRecvMessageOpt",e.SetConversationPrivateChat="SetConversationPrivateChat",e.SetConversationBurnDuration="SetConversationBurnDuration",e.ResetConversationGroupAtType="ResetConversationGroupAtType",e.HideConversation="HideConversation",e.HideAllConversation="HideAllConversation",e.ClearConversationAndDeleteAllMsg="ClearConversationAndDeleteAllMsg",e.DeleteConversationAndDeleteAllMsg="DeleteConversationAndDeleteAllMsg",e.ChangeInputStates="ChangeInputStates",e.GetInputStates="GetInputStates",e.CreateTextMessage="CreateTextMessage",e.CreateTextAtMessage="CreateTextAtMessage",e.CreateImageMessageByFile="CreateImageMessageByFile",e.CreateImageMessageByURL="CreateImageMessageByURL",e.CreateSoundMessageByFile="CreateSoundMessageByFile",e.CreateSoundMessageByURL="CreateSoundMessageByURL",e.CreateVideoMessageByFile="CreateVideoMessageByFile",e.CreateVideoMessageByURL="CreateVideoMessageByURL",e.CreateFileMessageByFile="CreateFileMessageByFile",e.CreateFileMessageByURL="CreateFileMessageByURL",e.CreateMergerMessage="CreateMergerMessage",e.CreateForwardMessage="CreateForwardMessage",e.CreateLocationMessage="CreateLocationMessage",e.CreateQuoteMessage="CreateQuoteMessage",e.CreateCardMessage="CreateCardMessage",e.CreateCustomMessage="CreateCustomMessage",e.CreateFaceMessage="CreateFaceMessage",e.SendMessage="SendMessage",e.SendMessageNotOss="SendMessageNotOss",e.UploadFile="UploadFile",e.TypingStatusUpdate="TypingStatusUpdate",e.RevokeMessage="RevokeMessage",e.DeleteMessage="DeleteMessage",e.DeleteMessageFromLocalStorage="DeleteMessageFromLocalStorage",e.DeleteAllMsgFromLocal="DeleteAllMsgFromLocal",e.DeleteAllMsgFromLocalAndSvr="DeleteAllMsgFromLocalAndSvr",e.SearchLocalMessages="SearchLocalMessages",e.GetAdvancedHistoryMessageList="GetAdvancedHistoryMessageList",e.GetAdvancedHistoryMessageListReverse="GetAdvancedHistoryMessageListReverse",e.FindMessageList="FindMessageList",e.InsertGroupMessageToLocalStorage="InsertGroupMessageToLocalStorage",e.InsertSingleMessageToLocalStorage="InsertSingleMessageToLocalStorage",e.SetMessageLocalEx="SetMessageLocalEx",e.SetConversation="SetConversation"}(M||(M={})),function(e){e.GetFriendVersion="GetFriendVersion",e.GetGroupVersion="GetGroupVersion",e.GetJoinedGroupIDList="GetJoinedGroupIDList",e.GetGroupMemberVersion="GetGroupMemberVersion",e.GetConversationVersion="GetConversationVersion",e.GetConversationsHasReadAndMaxSeq="GetConversationsHasReadAndMaxSeq",e.GetDesignatedFriendsApplication="GetDesignatedFriendsApplication",e.GetDesignatedGroupApplication="GetDesignatedGroupApplication",e.GetDesignatedBlackUser="GetDesignatedBlackUser",e.GetActiveConversations="GetActiveConversations",e.GetDesignatedConversation="GetDesignatedConversation",e.GetNotNotifyConversationIDs="GetNotNotifyConversationIDs",e.GetFullFriendUserIDs="GetFullFriendUserIDs",e.GetFullGroupMemberUserIDs="GetFullGroupMemberUserIDs"}(D||(D={}));var C,T,b,P,G,A,N,R,w,U,O,F,k=((I={})[M.AddFriend]="/friend/add_friend",I[M.CheckFriend]="/friend/is_friend",I[M.DeleteFriend]="/friend/delete_friend",I[M.AcceptFriendApplication]="/friend/add_friend_response",I[M.RefuseFriendApplication]="/friend/add_friend_response",I[M.GetFriendListPage]="/friend/get_friend_list",I[M.GetSpecifiedFriendsInfo]="/friend/get_designated_friends",I[M.GetFriendApplicationListAsApplicant]="/friend/get_self_friend_apply_list",I[M.GetFriendApplicationListAsRecipient]="/friend/get_friend_apply_list",I[M.UpdateFriends]="/friend/update_friends",I[M.AddBlack]="/friend/add_black",I[M.RemoveBlack]="/friend/remove_black",I[M.GetBlackList]="/friend/get_black_list",I[M.CreateGroup]="/group/create_group",I[M.JoinGroup]="/group/join_group",I[M.InviteUserToGroup]="/group/invite_user_to_group",I[M.GetJoinedGroupListPage]="/group/get_joined_group_list",I[M.GetSpecifiedGroupsInfo]="/group/get_groups_info",I[M.SetGroupInfo]="/group/set_group_info_ex",I[M.GetGroupApplicationListAsApplicant]="/group/get_user_req_group_applicationList",I[M.GetGroupApplicationListAsRecipient]="/group/get_recv_group_applicationList",I[M.AcceptGroupApplication]="/group/group_application_response",I[M.RefuseGroupApplication]="/group/group_application_response",I[M.GetGroupMemberList]="/group/get_group_member_list",I[M.GetSpecifiedGroupMembersInfo]="/group/get_group_members_info",I[M.SetGroupMemberInfo]="/group/set_group_member_info",I[M.KickGroupMember]="/group/kick_group",I[M.TransferGroupOwner]="/group/transfer_group",I[M.DismissGroup]="/group/dismiss_group",I[M.QuitGroup]="/group/quit_group",I[M.GetSelfUserInfo]="/user/get_users_info",I[M.SetSelfInfo]="/user/update_user_info_ex",I[M.GetUsersInfo]="/user/get_users_info",I[M.SubscribeUsersStatus]="/user/subscribe_users_status",I[M.UnsubscribeUsersStatus]="/user/subscribe_users_status",I[M.GetSubscribeUsersStatus]="/user/get_subscribe_users_status",I[M.SetGlobalRecvMessageOpt]="/user/set_global_msg_recv_opt",I[M.RevokeMessage]="/msg/revoke_msg",I[M.DeleteMessage]="/msg/delete_msgs",I[M.DeleteConversationAndDeleteAllMsg]="/msg/clear_conversation_msg",I[M.DeleteAllMsgFromLocalAndSvr]="/msg/user_clear_all_msg",I[M.MarkConversationMessageAsRead]="/msg/mark_conversation_as_read",I[M.SetConversation]="/conversation/set_conversations",I[D.GetFriendVersion]="/friend/get_incremental_friends",I[D.GetGroupVersion]="/group/get_incremental_join_groups",I[D.GetJoinedGroupIDList]="/group/get_full_join_group_ids",I[D.GetGroupMemberVersion]="/group/get_incremental_group_members_batch",I[D.GetConversationVersion]="/conversation/get_incremental_conversations",I[D.GetConversationsHasReadAndMaxSeq]="/conversation/get_conversations_has_read_and_max_seq",I[D.GetDesignatedFriendsApplication]="/friend/get_designated_friend_apply",I[D.GetDesignatedGroupApplication]="/group/get_specified_user_group_request_info",I[D.GetDesignatedBlackUser]="/friend/get_specified_blacks",I[D.GetActiveConversations]="/jssdk/get_active_conversations",I[D.GetDesignatedConversation]="/jssdk/get_conversations",I[D.GetNotNotifyConversationIDs]="/conversation/get_not_notify_conversation_ids",I[D.GetFullFriendUserIDs]="/friend/get_full_friend_user_ids",I[D.GetFullGroupMemberUserIDs]="/group/get_full_group_member_user_ids",I);!function(e){e.OnConnectFailed="OnConnectFailed",e.OnConnectSuccess="OnConnectSuccess",e.OnConnecting="OnConnecting",e.OnKickedOffline="OnKickedOffline",e.OnSelfInfoUpdated="OnSelfInfoUpdated",e.OnUserTokenExpired="OnUserTokenExpired",e.OnUserTokenInvalid="OnUserTokenInvalid",e.OnProgress="OnProgress",e.OnRecvNewMessage="OnRecvNewMessage",e.OnRecvNewMessages="OnRecvNewMessages",e.OnRecvOfflineNewMessage="onRecvOfflineNewMessage",e.OnRecvOfflineNewMessages="onRecvOfflineNewMessages",e.OnRecvOnlineOnlyMessage="OnRecvOnlineOnlyMessage",e.OnRecvOnlineOnlyMessages="OnRecvOnlineOnlyMessages",e.OnNewRecvMessageRevoked="OnNewRecvMessageRevoked",e.OnRecvC2CReadReceipt="OnRecvC2CReadReceipt",e.OnRecvGroupReadReceipt="OnRecvGroupReadReceipt",e.OnConversationChanged="OnConversationChanged",e.OnNewConversation="OnNewConversation",e.OnConversationUserInputStatusChanged="OnConversationUserInputStatusChanged",e.OnSyncServerFailed="OnSyncServerFailed",e.OnSyncServerFinish="OnSyncServerFinish",e.OnSyncServerProgress="OnSyncServerProgress",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.OnGroupDismissed="OnGroupDismissed",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.UploadComplete="UploadComplete",e.OnRecvCustomBusinessMessage="OnRecvCustomBusinessMessage",e.OnUserStatusChanged="OnUserStatusChanged",e.OnUploadLogsProgress="OnUploadLogsProgress",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.OnStreamChange="OnStreamChange",e.OnRoomParticipantConnected="OnRoomParticipantConnected",e.OnRoomParticipantDisconnected="OnRoomParticipantDisconnected",e.OnReceiveCustomSignal="OnReceiveCustomSignal",e.UnUsedEvent="UnUsedEvent"}(C||(C={})),function(e){e[e.NetworkError=1e4]="NetworkError",e[e.NetworkTimeoutError=10001]="NetworkTimeoutError",e[e.ArgsError=10002]="ArgsError",e[e.CtxDeadlineExceededError=10003]="CtxDeadlineExceededError",e[e.ResourceLoadNotCompleteError=10004]="ResourceLoadNotCompleteError",e[e.UnknownCode=10005]="UnknownCode",e[e.SdkInternalError=10006]="SdkInternalError",e[e.NoUpdateError=10007]="NoUpdateError",e[e.UserIDNotFoundError=10100]="UserIDNotFoundError",e[e.LoginOutError=10101]="LoginOutError",e[e.LoginRepeatError=10102]="LoginRepeatError",e[e.FileNotFoundError=10200]="FileNotFoundError",e[e.MsgDeCompressionError=10201]="MsgDeCompressionError",e[e.MsgDecodeBinaryWsError=10202]="MsgDecodeBinaryWsError",e[e.MsgBinaryTypeNotSupportError=10203]="MsgBinaryTypeNotSupportError",e[e.MsgRepeatError=10204]="MsgRepeatError",e[e.MsgContentTypeNotSupportError=10205]="MsgContentTypeNotSupportError",e[e.MsgHasNoSeqError=10206]="MsgHasNoSeqError",e[e.NotSupportOptError=10301]="NotSupportOptError",e[e.NotSupportTypeError=10302]="NotSupportTypeError",e[e.UnreadCountError=10303]="UnreadCountError",e[e.GroupIDNotFoundError=10400]="GroupIDNotFoundError",e[e.GroupTypeErr=10401]="GroupTypeErr"}(b||(b={})),function(e){e[e.GetNewestSeq=1001]="GetNewestSeq",e[e.PullMsgByRange=1002]="PullMsgByRange",e[e.SendMsg=1003]="SendMsg",e[e.SendSignalMsg=1004]="SendSignalMsg",e[e.PullMsgBySeqList=1005]="PullMsgBySeqList",e[e.GetConvMaxReadSeq=1006]="GetConvMaxReadSeq",e[e.PushMsg=2001]="PushMsg",e[e.KickOnlineMsg=2002]="KickOnlineMsg",e[e.LogoutMsg=2003]="LogoutMsg",e[e.SetBackgroundStatus=2004]="SetBackgroundStatus",e[e.WsSubUserOnlineStatus=2005]="WsSubUserOnlineStatus",e[e.WSServerConfigMsg=2100]="WSServerConfigMsg",e[e.WSDataError=3001]="WSDataError"}(P||(P={})),function(e){e[e.Text=101]="Text",e[e.Picture=102]="Picture",e[e.Sound=103]="Sound",e[e.Video=104]="Video",e[e.File=105]="File",e[e.AtText=106]="AtText",e[e.Merger=107]="Merger",e[e.Card=108]="Card",e[e.Location=109]="Location",e[e.Custom=110]="Custom",e[e.Typing=113]="Typing",e[e.Quote=114]="Quote",e[e.Face=115]="Face",e[e.AdvancedText=117]="AdvancedText",e[e.CustomMsgNotTriggerConversation=119]="CustomMsgNotTriggerConversation",e[e.CustomMsgOnlineOnly=120]="CustomMsgOnlineOnly",e[e.ReactionMessageModifier=121]="ReactionMessageModifier",e[e.ReactionMessageDeleter=122]="ReactionMessageDeleter"}(G||(G={})),function(e){e[e.NotificationBegin=1e3]="NotificationBegin",e[e.FriendNotificationBegin=1200]="FriendNotificationBegin",e[e.FriendApplicationApprovedNotification=1201]="FriendApplicationApprovedNotification",e[e.FriendApplicationRejectedNotification=1202]="FriendApplicationRejectedNotification",e[e.FriendApplicationNotification=1203]="FriendApplicationNotification",e[e.FriendAddedNotification=1204]="FriendAddedNotification",e[e.FriendDeletedNotification=1205]="FriendDeletedNotification",e[e.FriendRemarkSetNotification=1206]="FriendRemarkSetNotification",e[e.BlackAddedNotification=1207]="BlackAddedNotification",e[e.BlackDeletedNotification=1208]="BlackDeletedNotification",e[e.FriendInfoUpdatedNotification=1209]="FriendInfoUpdatedNotification",e[e.FriendsInfoUpdateNotification=1210]="FriendsInfoUpdateNotification",e[e.FriendNotificationEnd=1299]="FriendNotificationEnd",e[e.ConversationChangeNotification=1300]="ConversationChangeNotification",e[e.UserNotificationBegin=1301]="UserNotificationBegin",e[e.UserInfoUpdatedNotification=1303]="UserInfoUpdatedNotification",e[e.UserStatusChangeNotification=1304]="UserStatusChangeNotification",e[e.UserCommandAddNotification=1305]="UserCommandAddNotification",e[e.UserCommandDeleteNotification=1306]="UserCommandDeleteNotification",e[e.UserCommandUpdateNotification=1307]="UserCommandUpdateNotification",e[e.UserNotificationEnd=1399]="UserNotificationEnd",e[e.OANotification=1400]="OANotification",e[e.GroupNotificationBegin=1500]="GroupNotificationBegin",e[e.GroupCreatedNotification=1501]="GroupCreatedNotification",e[e.GroupInfoSetNotification=1502]="GroupInfoSetNotification",e[e.JoinGroupApplicationNotification=1503]="JoinGroupApplicationNotification",e[e.MemberQuitNotification=1504]="MemberQuitNotification",e[e.GroupApplicationAcceptedNotification=1505]="GroupApplicationAcceptedNotification",e[e.GroupApplicationRejectedNotification=1506]="GroupApplicationRejectedNotification",e[e.GroupOwnerTransferredNotification=1507]="GroupOwnerTransferredNotification",e[e.MemberKickedNotification=1508]="MemberKickedNotification",e[e.MemberInvitedNotification=1509]="MemberInvitedNotification",e[e.MemberEnterNotification=1510]="MemberEnterNotification",e[e.GroupDismissedNotification=1511]="GroupDismissedNotification",e[e.GroupMemberMutedNotification=1512]="GroupMemberMutedNotification",e[e.GroupMemberCancelMutedNotification=1513]="GroupMemberCancelMutedNotification",e[e.GroupMutedNotification=1514]="GroupMutedNotification",e[e.GroupCancelMutedNotification=1515]="GroupCancelMutedNotification",e[e.GroupMemberInfoSetNotification=1516]="GroupMemberInfoSetNotification",e[e.GroupMemberSetToAdminNotification=1517]="GroupMemberSetToAdminNotification",e[e.GroupMemberSetToOrdinaryUserNotification=1518]="GroupMemberSetToOrdinaryUserNotification",e[e.GroupInfoSetAnnouncementNotification=1519]="GroupInfoSetAnnouncementNotification",e[e.GroupInfoSetNameNotification=1520]="GroupInfoSetNameNotification",e[e.GroupNotificationEnd=1599]="GroupNotificationEnd",e[e.SignalingNotificationBegin=1600]="SignalingNotificationBegin",e[e.SignalingNotification=1601]="SignalingNotification",e[e.RoomParticipantsConnectedNotification=1602]="RoomParticipantsConnectedNotification",e[e.RoomParticipantsDisconnectedNotification=1603]="RoomParticipantsDisconnectedNotification",e[e.StreamChangedNotification=1604]="StreamChangedNotification",e[e.CustomSignalNotification=1605]="CustomSignalNotification",e[e.SignalingNotificationEnd=1649]="SignalingNotificationEnd",e[e.SuperGroupNotificationBegin=1650]="SuperGroupNotificationBegin",e[e.SuperGroupUpdateNotification=1651]="SuperGroupUpdateNotification",e[e.MsgDeleteNotification=1652]="MsgDeleteNotification",e[e.ReactionMessageModifierNotification=1653]="ReactionMessageModifierNotification",e[e.ReactionMessageDeleteNotification=1654]="ReactionMessageDeleteNotification",e[e.SuperGroupNotificationEnd=1699]="SuperGroupNotificationEnd",e[e.ConversationPrivateChatNotification=1701]="ConversationPrivateChatNotification",e[e.ConversationUnreadNotification=1702]="ConversationUnreadNotification",e[e.ClearConversationNotification=1703]="ClearConversationNotification",e[e.WorkMomentNotificationBegin=1900]="WorkMomentNotificationBegin",e[e.WorkMomentNotification=1901]="WorkMomentNotification",e[e.BusinessNotificationBegin=2e3]="BusinessNotificationBegin",e[e.BusinessNotification=2001]="BusinessNotification",e[e.BusinessNotificationEnd=2099]="BusinessNotificationEnd",e[e.RevokeNotification=2101]="RevokeNotification",e[e.HasReadReceiptNotification=2150]="HasReadReceiptNotification",e[e.GroupHasReadReceiptNotification=2155]="GroupHasReadReceiptNotification",e[e.DeleteMsgsNotification=2102]="DeleteMsgsNotification",e[e.HasReadReceipt=2200]="HasReadReceipt",e[e.HasGroupReadReceipt=2300]="HasGroupReadReceipt",e[e.NotificationEnd=5e3]="NotificationEnd"}(A||(A={})),function(e){e[e.UserMsgType=100]="UserMsgType",e[e.SysMsgType=200]="SysMsgType"}(N||(N={})),function(e){e[e.MsgStatusDefault=0]="MsgStatusDefault",e[e.MsgStatusSending=1]="MsgStatusSending",e[e.MsgStatusSendSuccess=2]="MsgStatusSendSuccess",e[e.MsgStatusSendFailed=3]="MsgStatusSendFailed",e[e.MsgStatusHasDeleted=4]="MsgStatusHasDeleted",e[e.MsgStatusFiltered=5]="MsgStatusFiltered"}(R||(R={})),function(e){e.IsHistory="history",e.IsPersistent="persistent",e.IsUnreadCount="unreadCount",e.IsConversationUpdate="conversationUpdate",e.IsOfflinePush="offlinePush",e.IsSenderSync="senderSync",e.IsNotPrivate="notPrivate",e.IsSenderConversationUpdate="senderConversationUpdate"}(w||(w={})),function(e){e[e.GroupOk=0]="GroupOk",e[e.GroupBanChat=1]="GroupBanChat",e[e.GroupStatusDismissed=2]="GroupStatusDismissed",e[e.GroupStatusMuted=3]="GroupStatusMuted"}(U||(U={})),function(e){e[e.WorkMomentCommentNotification=0]="WorkMomentCommentNotification",e[e.WorkMomentLikeNotification=1]="WorkMomentLikeNotification",e[e.WorkMomentAtUserNotification=2]="WorkMomentAtUserNotification"}(O||(O={})),function(e){e[e.TokenExpiredError=1501]="TokenExpiredError",e[e.TokenInvalidError=1502]="TokenInvalidError",e[e.TokenMalformedError=1503]="TokenMalformedError",e[e.TokenNotValidYetError=1504]="TokenNotValidYetError",e[e.TokenUnknownError=1505]="TokenUnknownError",e[e.TokenKickedError=1506]="TokenKickedError",e[e.TokenNotExistError=1507]="TokenNotExistError"}(F||(F={}));var q,E,L,x,j,B,V,_,H,J,W,Q,K,z,Y,X,$,Z,ee,te=((T={})[F.TokenExpiredError]=C.OnUserTokenExpired,T[F.TokenInvalidError]=C.OnUserTokenInvalid,T[F.TokenMalformedError]=C.OnUserTokenInvalid,T[F.TokenNotValidYetError]=C.OnUserTokenInvalid,T[F.TokenUnknownError]=C.OnUserTokenInvalid,T[F.TokenKickedError]=C.OnKickedOffline,T[F.TokenNotExistError]=C.OnUserTokenInvalid,T);!function(e){e[e.Nomal=0]="Nomal",e[e.NotReceive=1]="NotReceive",e[e.NotNotify=2]="NotNotify"}(q||(q={})),function(e){e[e.Allowed=0]="Allowed",e[e.NotAllowed=1]="NotAllowed"}(E||(E={})),function(e){e[e.Group=2]="Group",e[e.WorkingGroup=2]="WorkingGroup"}(L||(L={})),function(e){e[e.Invitation=2]="Invitation",e[e.Search=3]="Search",e[e.QrCode=4]="QrCode"}(x||(x={})),function(e){e[e.Nomal=20]="Nomal",e[e.Admin=60]="Admin",e[e.Owner=100]="Owner"}(j||(j={})),function(e){e[e.ApplyNeedInviteNot=0]="ApplyNeedInviteNot",e[e.AllNeed=1]="AllNeed",e[e.AllNot=2]="AllNot"}(B||(B={})),function(e){e[e.Sending=1]="Sending",e[e.Succeed=2]="Succeed",e[e.Failed=3]="Failed"}(V||(V={})),function(e){e[e.iOS=1]="iOS",e[e.Android=2]="Android",e[e.Windows=3]="Windows",e[e.MacOSX=4]="MacOSX",e[e.Web=5]="Web",e[e.Linux=7]="Linux",e[e.AndroidPad=8]="AndroidPad",e[e.iPad=9]="iPad"}(_||(_={})),function(e){e[e.Silent=5]="Silent",e[e.Error=4]="Error",e[e.Warn=3]="Warn",e[e.Info=2]="Info",e[e.Debug=1]="Debug",e[e.Trace=0]="Trace"}(H||(H={})),function(e){e[e.Unprocessed=0]="Unprocessed",e[e.Agree=1]="Agree",e[e.Reject=-1]="Reject"}(J||(J={})),function(e){e[e.TextMessage=101]="TextMessage",e[e.PictureMessage=102]="PictureMessage",e[e.VoiceMessage=103]="VoiceMessage",e[e.VideoMessage=104]="VideoMessage",e[e.FileMessage=105]="FileMessage",e[e.AtTextMessage=106]="AtTextMessage",e[e.MergeMessage=107]="MergeMessage",e[e.CardMessage=108]="CardMessage",e[e.LocationMessage=109]="LocationMessage",e[e.CustomMessage=110]="CustomMessage",e[e.TypingMessage=113]="TypingMessage",e[e.QuoteMessage=114]="QuoteMessage",e[e.FaceMessage=115]="FaceMessage",e[e.FriendAdded=1201]="FriendAdded",e[e.OANotification=1400]="OANotification",e[e.GroupCreated=1501]="GroupCreated",e[e.MemberQuit=1504]="MemberQuit",e[e.GroupOwnerTransferred=1507]="GroupOwnerTransferred",e[e.MemberKicked=1508]="MemberKicked",e[e.MemberInvited=1509]="MemberInvited",e[e.MemberEnter=1510]="MemberEnter",e[e.GroupDismissed=1511]="GroupDismissed",e[e.GroupMemberMuted=1512]="GroupMemberMuted",e[e.GroupMemberCancelMuted=1513]="GroupMemberCancelMuted",e[e.GroupMuted=1514]="GroupMuted",e[e.GroupCancelMuted=1515]="GroupCancelMuted",e[e.GroupAnnouncementUpdated=1519]="GroupAnnouncementUpdated",e[e.GroupNameUpdated=1520]="GroupNameUpdated",e[e.BurnMessageChange=1701]="BurnMessageChange",e[e.RevokeMessage=2101]="RevokeMessage"}(W||(W={})),function(e){e[e.Single=1]="Single",e[e.Group=3]="Group",e[e.Notification=4]="Notification"}(Q||(Q={})),function(e){e[e.Nomal=0]="Nomal",e[e.Baned=1]="Baned",e[e.Dismissed=2]="Dismissed",e[e.Muted=3]="Muted"}(U||(U={})),function(e){e[e.AtNormal=0]="AtNormal",e[e.AtMe=1]="AtMe",e[e.AtAll=2]="AtAll",e[e.AtAllAtMe=3]="AtAllAtMe",e[e.AtGroupNotice=4]="AtGroupNotice"}(K||(K={})),function(e){e[e.All=0]="All",e[e.Owner=1]="Owner",e[e.Admin=2]="Admin",e[e.Nomal=3]="Nomal",e[e.AdminAndNomal=4]="AdminAndNomal",e[e.AdminAndOwner=5]="AdminAndOwner"}(z||(z={})),function(e){e[e.isBlack=0]="isBlack",e[e.isFriend=1]="isFriend"}(Y||(Y={})),function(e){e[e.Logout=1]="Logout",e[e.Logging=2]="Logging",e[e.Logged=3]="Logged"}(X||(X={})),function(e){e[e.Online=1]="Online",e[e.Offline=0]="Offline"}($||($={})),function(e){e[e.ViewHistory=0]="ViewHistory",e[e.ViewSearch=1]="ViewSearch"}(Z||(Z={}));var ne=function(){return(36*Math.random()).toString(36).slice(2)+(new Date).getTime().toString()},re=function(e){var n=(new Date).getTime().toString(),r=Math.floor(Math.random()*(new Date).getTime());return t.hash(n+e+r)},oe=function(e){if(e.sessionType===Q.Single){var t=[e.sendID,e.recvID].sort();return"si_"+t[0]+"_"+t[1]}return e.sessionType===Q.Group?"sg_"+e.groupID:e.sessionType===Q.Notification?"sn_"+e.sendID+"_"+e.recvID:""},ie=function(e){if(e.sessionType===Q.Single){var t=[e.sourceID,e.userID].sort();return"si_"+t[0]+"_"+t[1]}return e.sessionType===Q.Group?"sg_"+e.sourceID:e.sessionType===Q.Notification?"sn_"+e.sourceID+"_"+e.userID:""},se=function(e,t){return!(t in e&&!e[t])},ae=((ee={})[P.GetNewestSeq]=o.GetMaxSeqResp.decode,ee[P.PullMsgByRange]=o.PullMessageBySeqsResp.decode,ee[P.SendMsg]=o.UserSendMsgResp.decode,ee[P.PullMsgBySeqList]=o.GetSeqMessageResp.decode,ee[P.PushMsg]=o.PushMessages.decode,ee[P.SetBackgroundStatus]=o.SetAppBackgroundStatusResp.decode,ee[P.WsSubUserOnlineStatus]=o.SubUserOnlineStatusTips.decode,ee[P.GetConvMaxReadSeq]=o.GetConversationsHasReadAndMaxSeqResp.decode,ee[D.GetActiveConversations]=o.GetActiveConversationsResp.decode,ee[D.GetDesignatedConversation]=o.GetConversationsResp.decode,ee),ce=function(e,t){if(!e)return{conversations:[]};var r=n(e),o=ae[t];return o?o(new Uint8Array(r)):{conversations:[]}},ue=function(e,t,n){var r=(new Date).getTime(),o=e.userTrigger.cache.getSelfUserInfo();return{clientMsgID:re(e.userID),createTime:r,sendTime:r,sessionType:0,sendID:e.userID,msgFrom:t,contentType:n,senderPlatformID:e.platform,senderNickname:null==o?void 0:o.nickname,senderFaceUrl:null==o?void 0:o.faceURL,seq:0,isRead:!1,status:V.Sending}},de=function(e){return e.sort(function(e,t){return e.isPinned===t.isPinned?e.latestMsgSendTime>t.latestMsgSendTime?-1:e.latestMsgSendTime<t.latestMsgSendTime?1:0:e.isPinned&&!t.isPinned?-1:1})},ge=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,n)||this).errCode=void 0,r.name=r.constructor.name,r.errCode=t,Error.captureStackTrace&&Error.captureStackTrace(r,r.constructor),r}return p(t,e),t}(/*#__PURE__*/m(Error)),le=function(e,t,n,r){var o={event:t,operationID:n,data:null,errMsg:"",errCode:0};return e===X.Logout?Promise.reject(g({},o,{errCode:b.ResourceLoadNotCompleteError,errMsg:"Resource load not complete"})):r().then(function(e){return void 0===e&&(e=null),g({},o,{data:e})}).catch(function(e){return g({},o,{errCode:e.errCode||b.SdkInternalError,errMsg:e.message||"Internal Error"})})},pe="UTF-8",fe="ASCII",ve=pe,he=65533,me=function(e,t){if(e<128)t.push(e);else for(var n=[127,2047,65535,2097151],r=0;;){if(++r===n.length)return console.error("UTF-8 Write - attempted to encode illegally high code point - "+e),void me(he,t);if(e<=n[r]){r+=1;var o=0,i=void 0;for(i=0;i<r;i++)o<<=1,o|=1;for(o<<=8-r,t.push(o|=e>>6*(r-1)),i=1;i<r;i++)o=128,t.push(o|=e>>6*(r-(i+1))&191);return}}},Ie=function(e,t,n,r){var o=t.getUint8(n);if(e.bytesRead=1,e.charVal=0,128&o){for(var i=0,s=o;128&s;)i++,s<<=1;if(1===i)return console.error("UTF-8 read - found continuation byte at beginning of character"),void(e.charVal=he);if(i>r)return console.error("UTF-8 read - attempted to read "+i+" byte character, "+(r-i)+" bytes past end of buffer"),void(e.charVal=he);e.charVal=o&255>>i+1;for(var a=1;a<i;a++){if(128!=(192&(s=t.getUint8(n+a))))return console.error("UTF-8 read - attempted to read "+i+" byte character, found non-continuation at byte "+a),e.charVal=he,void(e.bytesRead=1);if(e.charVal<<=6,e.charVal|=63&s,!(1!==a||e.charVal>>8-(i+1)-1))return console.error("UTF-8 read - found overlong encoding"),e.charVal=he,void(e.bytesRead=1);e.bytesRead++}if(e.charVal>1114111)return console.error("UTF-8 read - found illegally high code point "+e.charVal),e.charVal=he,void(e.bytesRead=1)}else e.charVal=o},Me=function(e){for(var t=[],n=0;n<e.length;n++)me(e.charCodeAt(n),t);return t},De=function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r>255&&(r="?".charCodeAt(0)),t.push(r)}return t},ye=function(e,t,n,r){var o=void 0===n,i=t||0;if(!o&&i+n>e.byteLength)throw new Error("Attempted to read "+(i+n-e.byteLength)+" bytes past end of buffer");for(var s=[],a={};i<e.byteLength&&(o||n>i-t)&&(Ie(a,e,i,o?e.byteLength-(i+t):n-(i-t)),i+=a.bytesRead,!o||a.charVal!==r);)s.push(String.fromCharCode(a.charVal));return{str:s.join(""),byteLength:i-t}},Se=function(e,t,n,r){var o=[],i=0;t=t||0;var s=!1;void 0===n&&(s=!0,n=e.byteLength-e.byteOffset);for(var a=0;a<n;a++){var c=e.getUint8(a+t);if(i++,s&&c===r)break;o.push(String.fromCharCode(c))}return{str:o.join(""),byteLength:i}},Ce=/*#__PURE__*/u("readString"),Te=/*#__PURE__*/u("writeString"),be=/*#__PURE__*/u("checkEncoding");function Pe(e){if(void 0===e&&(e=ve),!a(this,Te)[Te].has(e))throw new Error("Unknown string encoding '"+e+"'");return e}var Ge,Ae=new(/*#__PURE__*/function(){function e(){Object.defineProperty(this,be,{value:Pe}),Object.defineProperty(this,Ce,{writable:!0,value:new Map([[fe,Se],[pe,ye]])}),Object.defineProperty(this,Te,{writable:!0,value:new Map([[fe,De],[pe,Me]])})}var t=e.prototype;return t.addStringCodec=function(e,t,n){a(this,Ce)[Ce].put(e,t),a(this,Te)[Te].put(e,n)},t.stringByteLength=function(e,t){return t=a(this,be)[be](t),a(this,Te)[Te].get(t)(e).length},t.getString=function(e,t,n,r){return this.getStringData(e,t,n,r).str},t.getStringData=function(e,t,n,r){return r=a(this,be)[be](r),n||(n=e.byteLength-t),a(this,Ce)[Ce].get(r)(e,t,n)},t.getStringNT=function(e,t,n,r){return void 0===r&&(r=0),this.getStringDataNT(e,t,n,r).str},t.getStringDataNT=function(e,t,n,r){return void 0===r&&(r=0),n=a(this,be)[be](n),a(this,Ce)[Ce].get(n)(e,t,void 0,r)},t.setString=function(e,t,n,r){r=a(this,be)[be](r);var o,i=a(this,Te)[Te].get(r)(n);for(o=0;o<i.length&&t+o<e.byteLength;o++)e.setUint8(t+o,i[o]);return o},t.setStringNT=function(e,t,n,r){var o=this.setString(e,t,n,r);return t+o>=e.byteLength&&(o-=1),e.setUint8(t+o,0),o+1},e}()),Ne=function(e){return(new TextDecoder).decode(e)},Re=function(e){return(new TextEncoder).encode(e)};!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(Ge||(Ge={}));var we,Ue=/*#__PURE__*/function(){function e(e,t,n,r,o,i,s,a,c,u){var d=this,l=this;void 0===a&&(a=5e3),void 0===c&&(c=Infinity),this.url=void 0,this.onMessage=void 0,this.onClose=void 0,this.onReconnecting=void 0,this.onReconnectFailed=void 0,this.onReconnectSuccess=void 0,this.reconnectInterval=void 0,this.maxReconnectAttempts=void 0,this.ws=void 0,this.connectParams=void 0,this.reconnectAttempts=void 0,this.shouldReconnect=void 0,this.isProcessingMessage=!1,this.consecutiveHeartbeatFailures=0,this.connectTimeoutId=null,this.platformNamespace=void 0,this.envListenersInstalled=!1,this.heartbeatConfig={interval:1e4,timeout:5e3,maxFailures:3},this.heartbeatWorker=null,this.legacyTimer=null,this.heartbeatTimeoutId=null,this.workerUrl=null,this.lastPongAt=0,this.forceImmediateReconnect=!1,this.checkPlatform=function(){if("undefined"!=typeof WebSocket)try{if("undefined"!=typeof window&&window.WebSocket)return"web";if("undefined"!=typeof global&&global.WebSocket)return"web"}catch(e){}return"undefined"!=typeof my&&"function"==typeof my.connectSocket?"my":"undefined"!=typeof uni&&"function"==typeof uni.connectSocket?"uni":"undefined"!=typeof wx&&"function"==typeof wx.connectSocket?"wx":"unknow"},this.urlFormat=function(){for(var e="?",t=0,n=Object.entries(l.connectParams);t<n.length;t++){var r=n[t];e+=r[0]+"="+r[1]+"&"}return l.url+e.slice(0,-1)},this.startHeartbeat=function(){if(l.heartbeatWorker&&l.stopHeartbeat(),l.consecutiveHeartbeatFailures=0,"undefined"!=typeof Worker)try{var e=new Blob(["\n let timerId = null;\n let heartbeatInterval;\n\n self.onmessage = (e) => {\n if (e.data.type === 'start') {\n heartbeatInterval = e.data.interval;\n if (timerId) return;\n \n timerId = self.setInterval(() => {\n self.postMessage({ type: 'ping' });\n }, heartbeatInterval);\n } else if (e.data.type === 'stop') {\n if (timerId) {\n self.clearInterval(timerId);\n timerId = null;\n }\n }\n };\n "],{type:"application/javascript"});l.workerUrl=URL.createObjectURL(e),l.heartbeatWorker=new Worker(l.workerUrl),l.heartbeatWorker.onmessage=function(e){"ping"===e.data.type&&l.sendPing()},l.heartbeatWorker.postMessage({type:"start",interval:l.heartbeatConfig.interval})}catch(e){l.heartbeatWorker=null,l.workerUrl&&(URL.revokeObjectURL(l.workerUrl),l.workerUrl=null),l.legacyTimer=setInterval(function(){l.sendPing()},l.heartbeatConfig.interval)}else l.legacyTimer=setInterval(function(){l.sendPing()},l.heartbeatConfig.interval)},this.connect=function(e){return void 0===e&&(e=1e4),"unknow"===l.platformNamespace?Promise.reject(new Error("WebSocket is not supported")):new Promise(function(t,n){if(l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),l.connectTimeoutId=setTimeout(function(){l.ws&&(l.ws.close(),l.onClose()),n(new Error("Connection timeout after "+e+"ms"))},e),l.ws&&l.ws.readyState!==Ge.CLOSED)l.ws.readyState===l.ws.OPEN?(l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),t()):(l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),n(new Error("WebSocket is in an unknown state")));else{var r=function(){l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),l.reconnectAttempts&&l.onReconnectSuccess(),l.reconnectAttempts=0,l.consecutiveHeartbeatFailures=0,l.lastPongAt=Date.now(),l.startHeartbeat(),t()},o=function(e){l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),n(e)};if("web"===l.platformNamespace)l.ws=new WebSocket(l.urlFormat()),l.ws.onopen=r,l.ws.onerror=o;else{var i={url:l.urlFormat(),complete:function(){}};"my"===l.platformNamespace&&(i.multiple=!0),"uni"===l.platformNamespace&&(l.ws=uni.connectSocket(i)),"wx"===l.platformNamespace&&(l.ws=wx.connectSocket(i)),"my"===l.platformNamespace&&(l.ws=my.connectSocket(i)),l.ws.onOpen(r),l.ws.onError(o)}l.setupEventListeners(),l.installEnvListeners()}})},this.setupEventListeners=function(){if(l.ws){var e=function(e){return l.onBinaryMessage(e.data)},t=function(e){if(l.shouldReconnect&&l.reconnectAttempts<l.maxReconnectAttempts){if(l.isProcessingMessage)return void setTimeout(function(){return t()},100);var n=function(){l.onReconnecting(),l.connectParams.operationID=ne(),l.connect().catch(function(){l.onReconnectFailed()}),l.reconnectAttempts++};if(l.forceImmediateReconnect)l.forceImmediateReconnect=!1,n();else{var r=Math.min(l.reconnectInterval*Math.pow(1.5,l.reconnectAttempts),6e4),o=.25*r*(2*Math.random()-1),i=Math.max(r+o,1e3);setTimeout(function(){n()},i)}}l.stopHeartbeat(),l.heartbeatTimeoutId&&(clearTimeout(l.heartbeatTimeoutId),l.heartbeatTimeoutId=null),l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null)};"web"===l.platformNamespace?(l.ws.onmessage=e,l.ws.onclose=t):(l.ws.onMessage(e),l.ws.onClose(t))}},this.onBinaryMessage=function(e){try{return"string"!=typeof e&&"my"===d.platformNamespace&&(e=e.data),"string"==typeof e&&"pong"===JSON.parse(e).type?(d.heartbeatTimeoutId&&(clearTimeout(d.heartbeatTimeoutId),d.heartbeatTimeoutId=null),d.consecutiveHeartbeatFailures=0,d.lastPongAt=Date.now(),Promise.resolve()):(d.isProcessingMessage=!0,Promise.resolve(d.onMessage(e,d.connectParams.operationID)).then(function(){d.isProcessingMessage=!1}))}catch(e){return Promise.reject(e)}},this.sendPing=function(){var e;if((null==(e=l.ws)?void 0:e.readyState)===Ge.OPEN){if(l.consecutiveHeartbeatFailures>=l.heartbeatConfig.maxFailures)return console.warn("Heartbeat failed "+l.consecutiveHeartbeatFailures+" times, closing connection"),l.ws.close(),l.onClose(),void l.stopHeartbeat();l.heartbeatTimeoutId&&clearTimeout(l.heartbeatTimeoutId),l.heartbeatTimeoutId=setTimeout(function(){var e;l.consecutiveHeartbeatFailures++,console.warn("Heartbeat timeout, consecutive failures: "+l.consecutiveHeartbeatFailures),l.consecutiveHeartbeatFailures>=l.heartbeatConfig.maxFailures&&(null==(e=l.ws)||e.close(),l.onClose(),l.stopHeartbeat())},l.heartbeatConfig.timeout);var t=JSON.stringify({type:"ping"});l.ws.send("web"===l.platformNamespace?t:{data:t})}else l.heartbeatTimeoutId&&(clearTimeout(l.heartbeatTimeoutId),l.heartbeatTimeoutId=null)},this.forceHealthCheck=function(e){void 0===e&&(e=!1),l.ws&&l.ws.readyState===Ge.OPEN&&(e&&(l.consecutiveHeartbeatFailures=Math.max(l.heartbeatConfig.maxFailures-1,0)),l.sendPing())},this.handleVisibilityChange=function(){try{"visible"===("undefined"!=typeof document?document.visibilityState:"visible")&&l.forceHealthCheck(!0)}catch(e){}},this.handleOnline=function(){if(!l.ws||l.ws.readyState!==Ge.OPEN)return l.reconnectAttempts=0,l.onReconnecting(),l.connectParams.operationID=ne(),void l.connect().catch(function(){l.onReconnectFailed()});var e=Date.now();l.lastPongAt&&e-l.lastPongAt>l.heartbeatConfig.interval+l.heartbeatConfig.timeout*l.heartbeatConfig.maxFailures&&l.forceHealthCheck(!0)},this.handleOffline=function(){l.stopHeartbeat()},this.installEnvListeners=function(){if(!l.envListenersInstalled&&"web"===l.platformNamespace)try{"undefined"!=typeof document&&document.addEventListener&&document.addEventListener("visibilitychange",l.handleVisibilityChange),"undefined"!=typeof window&&window.addEventListener&&(window.addEventListener("online",l.handleOnline),window.addEventListener("offline",l.handleOffline),window.addEventListener("pageshow",l.handleVisibilityChange),window.addEventListener("focus",l.handleVisibilityChange)),l.envListenersInstalled=!0}catch(e){}},this.removeEnvListeners=function(){if(l.envListenersInstalled&&"web"===l.platformNamespace){try{"undefined"!=typeof document&&document.removeEventListener&&document.removeEventListener("visibilitychange",l.handleVisibilityChange),"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener("online",l.handleOnline),window.removeEventListener("offline",l.handleOffline),window.removeEventListener("pageshow",l.handleVisibilityChange),window.removeEventListener("focus",l.handleVisibilityChange))}catch(e){}l.envListenersInstalled=!1}},this.sendMessage=function(e){var t,n=Re(JSON.stringify(e));(null==(t=l.ws)?void 0:t.readyState)===Ge.OPEN?l.ws.send("web"===l.platformNamespace?n:{data:Uint8Array.from(n).buffer}):console.error("WebSocket is not open. Message not sent.")},this.close=function(){var e;l.shouldReconnect=!1,l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),l.heartbeatTimeoutId&&(clearTimeout(l.heartbeatTimeoutId),l.heartbeatTimeoutId=null),(null==(e=l.ws)?void 0:e.readyState)===Ge.OPEN&&(l.ws.close(),l.onClose()),l.stopHeartbeat(),l.removeEnvListeners()},this.forceReconnect=function(e){if(void 0===e&&(e=!0),l.shouldReconnect=!0,l.reconnectAttempts=0,l.consecutiveHeartbeatFailures=0,e&&(l.forceImmediateReconnect=!0),!l.ws||l.ws.readyState===Ge.CLOSED)return l.onReconnecting(),l.connectParams.operationID=ne(),void l.connect().catch(function(){l.onReconnectFailed()});l.stopHeartbeat();try{l.ws.close()}catch(e){l.onReconnecting(),l.connectParams.operationID=ne(),l.connect().catch(function(){l.onReconnectFailed()})}},this.reset=function(){l.shouldReconnect=!0,l.reconnectAttempts=0,l.consecutiveHeartbeatFailures=0,l.connectTimeoutId&&(clearTimeout(l.connectTimeoutId),l.connectTimeoutId=null),l.heartbeatTimeoutId&&(clearTimeout(l.heartbeatTimeoutId),l.heartbeatTimeoutId=null),l.stopHeartbeat(),l.removeEnvListeners()},this.url=e,this.onMessage=n,this.onClose=r,this.onReconnecting=o,this.onReconnectFailed=i,this.onReconnectSuccess=s,this.reconnectInterval=a,this.maxReconnectAttempts=c,this.connectParams=t,this.reconnectInterval=a,this.maxReconnectAttempts=c,this.reconnectAttempts=0,this.shouldReconnect=!0,this.platformNamespace=this.checkPlatform(),u&&(this.heartbeatConfig=g({},this.heartbeatConfig,u))}return e.prototype.stopHeartbeat=function(){this.heartbeatTimeoutId&&(clearTimeout(this.heartbeatTimeoutId),this.heartbeatTimeoutId=null),this.heartbeatWorker&&(this.heartbeatWorker.postMessage({type:"stop"}),this.heartbeatWorker.terminate(),this.workerUrl&&(URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.heartbeatWorker=null),this.legacyTimer&&(clearInterval(this.legacyTimer),this.legacyTimer=null)},e}(),Oe=/*#__PURE__*/function(){function e(){this.events=void 0,this.events={}}var t=e.prototype;return t.emit=function(e,t){return this.events[e]&&this.events[e].forEach(function(e){return e(t)}),this},t.on=function(e,t){return this.events[e]?this.events[e].push(t):this.events[e]=[t],this},t.off=function(e,t){if(e&&"function"==typeof t&&this.events[e]){var n=this.events[e];if(!n||0===n.length)return;var r=n.findIndex(function(e){return e===t});-1!==r&&n.splice(r,1)}return this},e}(),Fe=["friendUser"],ke=["blackUserInfo"],qe=function(e){var t,n,r,o,i,s,a,c,u,d,g,l,p,f;return{createTime:null==(t=e.groupInfo)?void 0:t.createTime,creatorUserID:null==(n=e.groupInfo)?void 0:n.creatorUserID,ex:e.ex,groupFaceURL:null==(r=e.groupInfo)?void 0:r.faceURL,groupID:null==(o=e.groupInfo)?void 0:o.groupID,groupName:null==(i=e.groupInfo)?void 0:i.groupName,groupType:null==(s=e.groupInfo)?void 0:s.groupType,handleResult:e.handleResult,handleUserID:e.handleUserID,handledMsg:e.handleMsg,handledTime:e.handleTime,introduction:null==(a=e.groupInfo)?void 0:a.introduction,memberCount:null==(c=e.groupInfo)?void 0:c.memberCount,nickname:null==(u=e.userInfo)?void 0:u.nickname,notification:null==(d=e.groupInfo)?void 0:d.notification,ownerUserID:null==(g=e.groupInfo)?void 0:g.ownerUserID,reqMsg:e.reqMsg,reqTime:e.reqTime,joinSource:e.joinSource,status:null==(l=e.groupInfo)?void 0:l.status,userFaceURL:null==(p=e.userInfo)?void 0:p.faceURL,userID:null==(f=e.userInfo)?void 0:f.userID}},Ee=function(e){return{clientMsgID:e.clientMsgID,serverMsgID:e.serverMsgID,createTime:e.createTime,sendTime:e.sendTime,sessionType:e.sessionType,sendID:e.sendID,recvID:e.recvID,msgFrom:e.msgFrom,contentType:e.contentType,senderPlatformID:e.senderPlatformID,senderNickname:e.senderNickname,senderFaceUrl:e.senderFaceURL,groupID:e.groupID,content:e.content.length?Ne(e.content):"",seq:e.seq,isRead:e.isRead,status:R.MsgStatusSendSuccess,isExternalExtensions:!1,offlinePush:e.offlinePushInfo,attachedInfo:e.attachedInfo,ex:e.ex,localEx:""}},Le=function(t){var n=g({},t);try{switch(t.contentType){case G.Text:n.textElem=JSON.parse(n.content);break;case G.Picture:n.pictureElem=JSON.parse(n.content);break;case G.Sound:n.soundElem=JSON.parse(n.content);break;case G.Video:n.videoElem=JSON.parse(n.content);break;case G.File:n.fileElem=JSON.parse(n.content);break;case G.AtText:n.atTextElem=JSON.parse(n.content);break;case G.Location:n.locationElem=JSON.parse(n.content);break;case G.Custom:case G.CustomMsgNotTriggerConversation:case G.CustomMsgOnlineOnly:n.customElem=JSON.parse(n.content);break;case G.Typing:n.typingElem=JSON.parse(n.content);break;case G.Merger:n.mergeElem=JSON.parse(n.content);break;case G.Face:n.faceElem=JSON.parse(n.content);break;case G.Quote:n.quoteElem=JSON.parse(n.content);break;case G.Card:n.cardElem=JSON.parse(n.content);break;default:n.notificationElem=JSON.parse(n.content)}}catch(t){e.warn("messageElemFormater messageElem parse failed",n)}if(t.attachedInfo)try{n.attachedInfoElem=JSON.parse(n.attachedInfo),n.attachedInfo=""}catch(t){e.warn("messageElemFormater attachedInfoElem failed",n.attachedInfo)}return n.content="",n},xe=function(e){var t=Ne(e),n=JSON.parse(t);return JSON.parse(n.detail)},je=function(e,t,n){var r=e.conversation,o=e.group,i=e.friend,s=e.user,a=e.lastMsg,c=e.maxSeq,u=e.readSeq;try{var d,g,l,p,f=function(){var e,t;return{conversationID:r.conversationID,conversationType:r.conversationType,userID:r.userID,groupID:r.groupID,showName:d,faceURL:v,recvMsgOpt:r.recvMsgOpt,unreadCount:c-u,groupAtType:r.groupAtType,latestMsg:h,latestMsgSendTime:null!=(e=null!=(t=null==a?void 0:a.sendTime)?t:n)?e:0,draftText:"",draftTextTime:0,burnDuration:r.burnDuration,msgDestructTime:r.msgDestructTime,isPinned:r.isPinned,isPrivateChat:r.isPrivateChat,isMsgDestruct:r.isMsgDestruct,attachedInfo:r.attachedInfo,ex:r.ex}},v="",h=a?JSON.stringify(Le(Ee(a))):"";(null==r?void 0:r.conversationType)===Q.Group?(d=null!=(g=null==o?void 0:o.groupName)?g:"",v=null!=(l=null==o?void 0:o.faceURL)?l:""):(d=(null==i?void 0:i.remark)||(null==s?void 0:s.nickname)||"",v=null!=(p=null==s?void 0:s.faceURL)?p:"");var m=function(){if((null==a?void 0:a.status)===R.MsgStatusHasDeleted)return Promise.resolve(t({conversationID:null==r?void 0:r.conversationID,seq:a.seq,operationID:ne()})).then(function(e){e&&(h=JSON.stringify(Le(e)))})}();return Promise.resolve(m&&m.then?m.then(f):f())}catch(e){return Promise.reject(e)}},Be=function(e){var t=e.friendUser;return g({},v(e,Fe),{userID:t.userID,nickname:t.nickname,faceURL:t.faceURL,attachedInfo:""})},Ve=function(e){var t=e.blackUserInfo;return g({},v(e,ke),{userID:t.userID,nickname:t.nickname,faceURL:t.faceURL})},_e=/*#__PURE__*/function(){function e(e){var t=this;this.store=void 0,this.options=void 0,this.expiryListeners=[],this.cleanupTimer=void 0,this.options=e,this.store=new Map,this.options.cleanupInterval>0&&(this.cleanupTimer=setInterval(function(){t.deleteExpired()},this.options.cleanupInterval))}var t=e.prototype;return t.onExpiry=function(e){this.expiryListeners.push(e)},t.triggerExpiry=function(e,t){this.expiryListeners.forEach(function(n){return n(e,t)}),this.delete(e)},t.set=function(e,t){var n=this;this.delete(e);var r=Date.now(),o=nu