@tencentcloud/lite-chat 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/basic.d.ts +3110 -0
- package/basic.es.js +3 -1
- package/basic.js +3 -1
- package/package.json +3 -3
- package/plugins/avchatroom.es.js +1 -1
- package/plugins/avchatroom.js +1 -1
- package/plugins/cloud-search.es.js +1 -1
- package/plugins/cloud-search.js +1 -1
- package/plugins/conversation-group.d.ts +8 -0
- package/plugins/conversation-group.es.js +1 -0
- package/plugins/conversation-group.js +1 -0
- package/plugins/conversation.es.js +1 -1
- package/plugins/conversation.js +1 -1
- package/plugins/follow.es.js +1 -1
- package/plugins/follow.js +1 -1
- package/plugins/friend.es.js +1 -1
- package/plugins/friend.js +1 -1
- package/plugins/group.es.js +1 -1
- package/plugins/group.js +1 -1
- package/plugins/message-enhancer.es.js +3 -1
- package/plugins/message-enhancer.js +3 -1
- package/plugins/offline-message-synchronizer.d.ts +9 -0
- package/plugins/offline-message-synchronizer.es.js +1 -0
- package/plugins/offline-message-synchronizer.js +1 -0
- package/plugins/rich-media-message.es.js +1 -1
- package/plugins/rich-media-message.js +1 -1
- package/plugins/signaling.d.ts +8 -0
- package/plugins/signaling.es.js +1 -1
- package/plugins/signaling.js +1 -1
- package/plugins/topic.d.ts +8 -0
- package/plugins/topic.es.js +1 -0
- package/plugins/topic.js +1 -0
- package/professional.d.ts +3110 -0
- package/professional.es.js +5 -1
- package/professional.js +5 -1
- package/standard.es.js +5 -1
- package/standard.js +5 -1
- package/index.es.js +0 -1
- package/index.js +0 -1
- package/plugins/user-enhancer.d.ts +0 -8
package/plugins/group.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatGroup=t()}(this,(function(){"use strict";const e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],i=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],n=["Role","JoinTime","MsgFlag","MsgSeq"],s=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],u=0,a=1,c="notStart",p="resolved",l="rejected",h=10018,m=11e3,d=2,g=["Owner","Admin","Member"],_=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],f=0,G=1,b=2,v=4,I=1,y=2,C=3,M=4,A=5,D=1,L=0,S=4,O=6,w=1,T=2,$=3,N=4,E=5,P=6,R=400,U=300,k={from:!0,groupID:!0,groupName:!0,to:!0},q={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},F=2,j=4,x=5,K=7,V=8,J=15,B=20,H=21,Y=2600,W=2602,Q=2603,z=2620,X=2621,Z=2623,ee=2660,te=2661,oe=2681,re=2683,ie=2684,ne=2685,se=2687,ue=t=>t===e.core.OuterConstant.GRP_PUBLIC,ae=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,ce=(t,o)=>{const{isArray:r}=e.core.utils;if(!r(t)||!r(o))return!1;let i=!1;return o.forEach((({key:e,value:o})=>{const r=t.find((t=>t.key===e));r?r.value!==o&&(r.value=o,i=!0):(t.push({key:e,value:o}),i=!0)})),i},pe=e=>{const t=[];if(!e)return t;for(let o=0,r=e.length;o<r;o++){const{Key:r,Value:i}=e[o];t.push({key:r,value:i})}return t},le=e=>{const t=[];for(let o=0,r=e.length;o<r;o++){const{key:r,value:i}=e[o];t.push({Key:r,Value:i})}return t},he=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class me{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberCount=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}_initGroup(t){const{utils:{isString:o}}=e.core;for(const e in t)he.indexOf(e)<0||("selfInfo"!==e?"isSupportTopic"!==e?"muteAllMembers"===e&&o(t[e])?this.muteAllMembers="On"===t[e]:this[e]=t[e]:this.isSupportTopic=1===t[e]:this.updateSelfInfo(t[e]))}updateGroup(t){const{utils:{isArray:o,isUndefined:r,isNumber:i,isString:n},common:{deepMerge:s}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);const u=JSON.parse(JSON.stringify(t));u.lastMsgTime&&(this.lastMessage.lastTime=u.lastMsgTime),n(u.muteAllMembers)&&(u.muteAllMembers="On"===u.muteAllMembers),u.groupCustomField&&ce(this.groupCustomField,u.groupCustomField),r(u.isSupportTopic)||(this.isSupportTopic=i(u.isSupportTopic)?1===u.isSupportTopic:u.isSupportTopic),s(this,u,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),o(u.members)&&u.members.length>0&&u.members.forEach((e=>{e.userID===this.selfInfo.userID&&s(this.selfInfo,e,["sequence"])}))}updateSelfInfo(t){const{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u}=t,{common:{deepMerge:a}}=e.core;a(this.selfInfo,{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var de=new class{constructor(){this._name="GroupDataHandler"}init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap(),console.log(`${this._name}.init`)}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){const{common:{getCurrentUserID:t}}=this._core;let o;e.forEach((e=>{var t;o=e.groupID,this.hasLocalGroup(o)?null===(t=this.getLocalGroup(o))||void 0===t||t.updateGroup(e):this._groupMap.set(o,new me(e))}));const r=t();for(const[,e]of this._groupMap)e.selfInfo.userID=r,"Owner"===e.selfInfo.role&&(e.ownerID=r)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){return[...this._groupMap.values()]}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){const e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:o}=this._core;o.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core,r=`${o}${e}`;if(t.getConversation(r)){const o=this.getLocalGroup(e);t.updateConversation(r,{groupProfile:o})}}reset(){this.clearLocalGroup()}};function ge(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(o[r[i]]=e[r[i]])}return o}function _e(e,t,o,r){return new(o||(o=Promise))((function(i,n){function s(e){try{a(r.next(e))}catch(e){n(e)}}function u(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))}function fe(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}"function"==typeof SuppressedError&&SuppressedError;const Ge=function(e){return{code:0,data:e||{}}};var be=new class{constructor(){this._name="GetGroupList",this._pagingStatus=c,this.PAGING_GRP_COUNT_LIMIT=200}init(e){this._core=e;const{helper:t,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:r}}=e;t.registerApi({apiName:"getGroupList",context:this}),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,r.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return _e(this,void 0,void 0,(function*(){if(console.log(`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===l||this._pagingStatus===c)return this._syncGroupList().then((()=>{const e=de.getLocalGroupList();return Ge({groupList:e,isSyncCompleted:this._isSyncCompleted()})})).catch((e=>{throw console.error(`${this._name}.getGroupList fail:`,e),e}));const e=de.getLocalGroupList();return console.log(`${this._name}.getGroupList return group count:${e.length}`),Ge({groupList:e,isSyncCompleted:this._isSyncCompleted()})}))}_syncGroupList(){return _e(this,void 0,void 0,(function*(){this._pagingStatus===c&&de.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=p,this._groupListTreeShaking(t),de.updateLocalGroup(t);const o=de.getLocalGroupList();return console.log(`${this._name}._syncGroupList ok, count:${o.length}`),de.emitGroupListUpdate(),o}catch(e){throw this._pagingStatus=l,console.error(`${this._name}._syncGroupList fail:`,e),e}}))}_pagingGetGroupList(e){return _e(this,void 0,void 0,(function*(){const{isCommunityRelay:t=!1,groupList:o}=e;let i,{limit:s,offset:u}=e;const a=[...r];t&&(i=this._core.OuterConstant.GRP_COMMUNITY,a.push("AtInfoList"));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{type:o,limit:r,offset:i,memberAccount:n,responseFilter:s}=e;return fe(o?"million_group_open_http_svc.get_joined_group_list":"group_open_http_svc.get_joined_group_list",{Limit:r,Offset:i,Member_Account:n,ResponseFilter:s,SupportTopic:0,NeedAppDefineData:1},t)}))}({type:i,limit:s,offset:u,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:a,SelfInfoFilter:[...n]}},this._core),{GroupIdList:r=[],TotalCount:c=0}=e||{},p=this._convertGroupKey(r);o.push(...p);const l=u+s,h=!(c>l),m=`offset:${u} limit:${s} total:${c} isCompleted:${h} current:${o.length} isCommunityRelay:${t}`;return console.log(`${this._name}._pagingGetGroupList ok. ${m}`),t?h?o:(u=l,this._pagingGetGroupList({isCommunityRelay:!0,limit:s,offset:u,groupList:o})):h?(console.log(`${this._name}._pagingGetGroupList start to get community list`),u=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:s,offset:u,groupList:o})):(u=l,this._pagingGetGroupList({limit:s,offset:u,groupList:o}))}catch(e){if(e.ErrorCode===h)return console.warn(`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${s}`),s=50,this._pagingGetGroupList({isCommunityRelay:t,limit:s,offset:u,groupList:o});if(t)return e.code===m&&console.log(`${this._name}._pagingGetGroupList ok. community unavailable`),o;throw e}}))}_groupListTreeShaking(e){const t=new Map([...de.getLocalGroupList()]);for(let o=0,r=e.length;o<r;o++)t.delete(e[o].groupID);const o=[...t.keys()];for(let e=0,t=o.length;e<t;e++)de.deleteLocalGroup(o[e])}_isSyncCompleted(){return this._pagingStatus===p}_convertGroupKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,Introduction:a,InviteJoinOption:c,LastInfoTime:p,LastMsgTime:l,MemberNum:h,MaxMemberNum:m,MuteAllMember:d,Name:g,NextMsgSeq:_,Notification:f,Owner_Account:G,Type:b,LastRecallTime:v,SelfInfo:I}=e[o],y=pe(r),C=this._convertSelfInfo(I);t.push({groupCustomField:y,joinOption:i,createTime:n,avatar:s,groupID:u,introduction:a,inviteOption:c,lastInfoTime:p,lastMsgTime:l,memberCount:h,maxMemberCount:m,muteAllMembers:d,name:g,nextMessageSeq:_,notification:f,ownerID:G,type:b,_lastRevokedTime:v,selfInfo:C})}return t}_convertSelfInfo(e){const{JoinTime:t,MsgFlag:o,MsgSeq:r,NoUnreadSeqList:i,Role:n}=e;return{joinTime:t,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i,role:n}}};var ve=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return _e(this,void 0,void 0,(function*(){var t;this._preCheckParams(e),console.log(`${this._name}.createGroup options:`,e);try{const{utils:{isEmpty:o},common:{getCurrentUserID:r}}=this._core,i=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{name:o,type:r,groupID:i,introduction:n,notification:s,avatar:u,maxMemberNum:a,joinOption:c,inviteOption:p,memberList:l,groupCustomField:h,isSupportTopic:m}=e;let d;return l&&(d=l.map((e=>{const{userID:t,memberCustomField:o}=e;return{Member_Account:t,AppMemberDefinedData:o?le(o):void 0}}))),fe("group_open_http_svc.create_group",{Name:o,Type:r,GroupId:i,Introduction:n,Notification:s,FaceUrl:u,MaxMemberCount:a,ApplyJoinOption:c,InviteJoinOption:p,MemberList:d,AppDefinedData:h,SupportTopic:m,webPushFlag:1},t)}))}(Object.assign(Object.assign({},e),{ownerID:r()}),this._core),{GroupId:n,OverJoinedGroupLimit_Account:s=[]}=i||{};if(console.log(`${this._name}.createGroup ok, groupType:${e.type} groupID:${n} overLimitUserIDList:${s}`),o(e.memberList)||o(s)||(e.memberList=null===(t=e.memberList)||void 0===t?void 0:t.filter((e=>s.includes(e.userID)))),this._notNeedUpdateLocalGroup(e))return Ge({group:new me(e)});de.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:n})]),this._sendCustomMessage(n,e.type);const u=de.getLocalGroup(n);return de.emitGroupListUpdate(),Ge({group:u})}catch(e){throw console.error(`${this._name}.createGroup fail:`,e),e}}))}_preCheckParams(t){const{type:o,groupID:r}=t,{utils:{isEmpty:i,isUndefined:n},common:{isCommunity:s}}=this._core,u=!i(r);if(!(()=>{const{GRP_PUBLIC:t,GRP_WORK:o,GRP_MEETING:r,GRP_AVCHATROOM:i,GRP_COMMUNITY:n}=e.core.OuterConstant;return[t,o,r,i,n]})().includes(o))throw new this._core.helper.ChatError({code:Y});if(!s({type:o})){if(u&&s({groupID:r}))throw new this._core.helper.ChatError({code:W});n(t.isSupportTopic)||(t.isSupportTopic=void 0)}if(this._canIUseMemberList(o)||n(t.memberList)||(t.memberList=void 0),this._canIUseJoinOption(o)||n(t.joinOption)||(t.joinOption=void 0),this._canIUseTopic(t)&&(t.isSupportTopic=!0===t.isSupportTopic?1:0),s({type:o})&&u&&!s({groupID:r}))throw new this._core.helper.ChatError({code:W})}_canIUseMemberList(e){return!ae(e)}_canIUseJoinOption(e){return ue(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){const{type:t,isSupportTopic:o}=e,{utils:{isUndefined:r},common:{isCommunity:i}}=this._core;return i({type:t})&&r(o)}_notNeedUpdateLocalGroup(e){const{type:t,isSupportTopic:o}=e,{OuterConstant:r}=this._core;return t===r.GRP_AVCHATROOM||t===r.GRP_COMMUNITY&&1===o}_sendCustomMessage(e,t){var o,r,i,n,s,c;const{OuterConstant:p}=this._core;let l="Create Group",h=u;t===p.GRP_COMMUNITY&&(l="Create Community",h=a);const m={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:l,cmd:h,opUser:this._core.store.get("login").userId,version:4})}},d=null===(i=null===(r=null===(o=this._core)||void 0===o?void 0:o.message)||void 0===r?void 0:r.messageFactory)||void 0===i?void 0:i.createCustomMessage(m);null===(c=null===(s=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===s?void 0:s.messageSender)||void 0===c||c.sendMessage(d,{})}};var Ie=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){this._core=e;const{helper:t,constants:o}=e;t.registerWorkflowStep(o.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,o.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach((e=>{e.localMainSequence=0}))}isGroupAttributesUpdated(e){const{elements:{newGroupProfile:t}}=e,{utils:{isEmpty:o,isUndefined:r}}=this._core;return!r(t)&&!o(t.groupAttributeOption)}handleGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:o}=e,{serverMainSequence:r,groupAttributeList:i=[],operation:n}=o;console.log(`${this._name}.handleGroupAttributesUpdated groupID:${t} operation:${n}`);const{utils:{isUndefined:s}}=this._core;s(n)||(this.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:i,operation:n}),this.emitGroupAttributesUpdated(t))}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:o}=e;this._groupAttributesCache.set(t,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:o,values:new Map}),console.log(`${this._name}.initGroupAttributesCache. groupID:${t} avChatRoomKey:${o}`)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}refreshGroupAttributesCache(e){const{groupID:t,serverMainSequence:o,groupAttributeList:r,operation:i}=e;if(this.hasGroupAttributesCache(t)){const e=this.getGroupAttributesCache(t),{localMainSequence:n}=e;i!==A&&o-n!=1||(e.serverMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:r,operation:i})),o-n>1&&(e.serverMainSequence=o),this._groupAttributesCache.set(t,e),console.log(`${this._name}.refreshGroupAttributesCache. operation:${i} localMainSequence:${n} serverMainSequence:${o}`)}}_updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:o=[],operation:r}=e;r!==C?r!==M?(r===I&&t.values.clear(),o.forEach((e=>{const{key:o,value:r,sequence:i}=e;t.values.set(o,{value:r,sequence:i})}))):o.forEach((e=>{t.values.delete(e.key)})):t.values.clear()}getGroupAttributesCacheValues(e){var t;const{groupID:o,keyList:r=[]}=e,i={};if(this.hasGroupAttributesCache(o)){const{values:e}=this.getGroupAttributesCache(o);if(0===r.length){for(const o of e.keys())i[o]=(null===(t=e.get(o))||void 0===t?void 0:t.value)||"";return i}return r.forEach((t=>{var o;e.has(t)&&(i[t]=(null===(o=e.get(t))||void 0===o?void 0:o.value)||"")})),i}return i}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t;const o=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:r,deletedKeyList:i}=this._computeValuesChangedData(o);console.log(`${this._name}.emitGroupAttributesUpdated update count:${r.length}, delete count:${i.length}`),0===r.length&&0===i.length||this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:o,updatedKeyList:r,deletedKeyList:i}})}_computeValuesChangedData(e){const{utils:{isUndefined:t}}=this._core,o=[],r=[];return Object.keys(e).forEach((t=>{e[t]!==this._groupAttributesCacheValuesCopy[t]&&o.push(t)})),Object.keys(this._groupAttributesCacheValuesCopy).forEach((o=>{t(e[o])&&r.push(o)})),this._groupAttributesCacheValuesCopy={},{updatedKeyList:o,deletedKeyList:r}}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(e){const t=[];return Object.keys(e).forEach((o=>{t.push({key:o,value:e[o]})})),t}};var ye=new class{constructor(){this._name="DismissGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}dismissGroup(e){return _e(this,void 0,void 0,(function*(){console.log(`${this._name}.dismissGroup groupID:${e}`);try{yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.destroy_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.dismissGroup ok.`);const{type:t}=de.getLocalGroup(e);return de.deleteLocalGroup(e),de.emitGroupListUpdate(),Ie.deleteGroupAttributesCache(e),Ge({groupID:e,type:t})}catch(e){throw console.error(`${this._name}.dismissGroup fail:`,e),e}}))}};var Ce=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return _e(this,void 0,void 0,(function*(){const{groupID:t,groupCustomFieldFilter:o}=e,i={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...r],AppDefinedDataFilter_Group:o,MemberInfoFilter:[...s]}};try{const e=yield this.getGroupProfileAdvance(i),{successGroupList:o,failureGroupList:r}=e;if(r.length>0)throw r[0];let n;return!de.hasLocalGroup(t)&&ae(o[0].type)?n=new me(o[0]):(de.updateLocalGroup(o),n=de.getLocalGroup(t)),n.isSupportTopic||de.updateConversationGroupProfile(t),console.log(`${this._name}.getGroupProfile ok.`),Ge({group:n})}catch(e){throw console.error(`${this._name}.getGroupProfile fail:`,e),e}}))}getGroupProfileAdvance(e){return _e(this,void 0,void 0,(function*(){const{groupIDList:t}=e,{common:{isCommunity:o}}=this._core,r=t.filter((e=>!o({groupID:e}))),i=t.filter((e=>o({groupID:e})));r.length>50&&(r.length=50),i.length>50&&(i.length=50);const n=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:r})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:i,isCommunityProfile:!0}))]),s=[],u=[];return n.forEach((e=>{s.push(...e.successGroupList),u.push(...e.failureGroupList)})),{successGroupList:s,failureGroupList:u}}))}_getGroupProfileAdvance(e){return _e(this,void 0,void 0,(function*(){const{isCommunityProfile:t=!1}=e,o=ge(e,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupIDList:o,responseFilter:r}=e;return fe("group_open_http_svc.get_group_self_member_info",{GroupIdList:o,ResponseFilter:r},t)}))}(o,this._core),{GroupInfo:t=[]}=e||{},r=this._convertGroupProfileKey(t),{utils:{isUndefined:i}}=this._core,n=r.filter((e=>i(e.errorCode)||0===e.errorCode)),s=r.filter((e=>e.errorCode&&0!==e.errorCode)).map((e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})));return console.log(`${this._name}._getGroupProfileAdvance ok, groupID:${o.groupIDList.join(",")}`),{successGroupList:n,failureGroupList:s}}catch(e){if(t)return{successGroupList:[],failureGroupList:[]};throw e}}))}_convertGroupProfileKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,InfoSeq:a,Introduction:c,InviteJoinOption:p,LastInfoTime:l,LastMsgTime:h,MaxMemberNum:m,MemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:G,Owner_Account:b,ShutUpAllMember:v,ShutUpUntil:I,Type:y,MemberList:C,ErrorCode:M,ErrorInfo:A}=e[o],D=pe(r),L=this._convertMembers(C);t.push({groupCustomField:D,joinOption:i,createTime:n,avatar:s,groupID:u,infoSequence:a,introduction:c,inviteOption:p,lastInfoTime:l,lastMsgTime:h,maxMemberCount:m,memberCount:d,muteAllMembers:g,name:_,nextMessageSeq:f,notification:G,ownerID:b,shutUpAllMember:v,muteUntil:I,type:y,members:L,errorCode:M,errorInfo:A})}return t}_convertMembers(e){if(!e)return[];const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,MsgFlag:s,MsgSeq:u,NameCard:a,Role:c}=e[o],p=pe(r);t.push({memberCustomField:p,joinTime:i,userID:n,messageRemindType:s,sequence:u,nameCard:a,role:c})}return t}};var Me=new class{constructor(){this._name="JoinGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"joinGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}joinGroup(e){return _e(this,void 0,void 0,(function*(){const{groupID:t}=e;try{if(de.hasLocalGroup(t))try{return yield Ce.getGroupProfile({groupID:t}),Ge({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS})}catch(o){console.warn(`${this._name}.joinGroup ${t} was unjoined, start to join!`),de.deleteLocalGroup(t);return yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(e){throw console.error(`${this._name}.joinGroup fail:`,e),e}}))}_applyJoinGroup(e){return _e(this,void 0,void 0,(function*(){const{OuterConstant:t,helper:r}=this._core,{groupID:i}=e,n=Object.assign({},e),s=r.checkBusinessCapabilityBits(o);s&&(n.historyMessageFlag=1);const u=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,applyMessage:r,historyMessageFlag:i}=e;return fe("group_open_http_svc.apply_join_group",{GroupId:o,ApplyMsg:r,HugeGroupHistoryMsgFlag:i},t)}))}(n,this._core),{JoinedStatus:a,LongPollingKey:c,StartSeq:p,HugeGroupFlag:l,AVChatRoomKey:h,RspMsgList:m=[]}=u||{},d=`groupID:${i} joinedStatus:${a} longPollingKey:${c} startSeq:${p} avChatRoomFlag:${l} canGetAVChatRoomHistoryMsg:${s}, historyMessageCount:${m.length}`;if(console.log(`${this._name}._applyJoinGroup ok, ${d}`),a===t.JOIN_STATUS_WAIT_APPROVAL)return{code:0,data:{status:t.JOIN_STATUS_WAIT_APPROVAL}};if(a===t.JOIN_STATUS_SUCCESS){let e=null;try{e=(yield Ce.getGroupProfile({groupID:i})).data.group}catch(t){e=new me({groupID:i}),console.warn(`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${i}, errorCode:`,null==t?void 0:t.code)}return this._handleJoinResult({group:e,avChatRoomFlag:l,longPollingKey:c,startSequence:p,avChatRoomKey:h,historyMessageList:m})}throw new this._core.helper.ChatError({code:ee})}))}_handleJoinResult(e){const{group:t,avChatRoomFlag:o,avChatRoomKey:r}=e;return 1===o?(Ie.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:r}),Ge(e)):(de.updateLocalGroup([t]),de.emitGroupListUpdate(),Ge({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}};var Ae=new class{constructor(){this._name="QuitGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"quitGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}quitGroup(e){return _e(this,void 0,void 0,(function*(){if(!de.hasLocalGroup(e))throw new this._core.helper.ChatError({code:Z});try{yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.quit_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.quitGroup ok, groupID:${e}`);const{type:t}=de.getLocalGroup(e);return de.deleteLocalGroup(e),de.emitGroupListUpdate(),Ie.deleteGroupAttributesCache(e),Ge({groupID:e,type:t})}catch(e){throw console.error(`${this._name}.quitGroup fail:`,e),e}}))}};var De=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return _e(this,void 0,void 0,(function*(){console.log(`${this._name}.searchGroupByID groupID:${e}`);try{const t=yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.get_group_public_info",{GroupIdList:[e],GroupBasePublicInfoFilter:[...i]},t)}))}(e,this._core),{GroupInfo:o=[]}=t||{},{AppDefinedData:r=[],ApplyJoinOption:n,CreateTime:s,FaceUrl:u,Introduction:a,InviteJoinOption:c,MaxMemberNum:p,MemberNum:l,Name:h,Owner_Account:m,Type:d,ErrorCode:g,ErrorInfo:_}=o[0];if(0!==g)throw new this._core.helper.ChatError({code:g,message:_});console.log(`${this._name}.searchGroupByID ok.`);const f=pe(r),G=new me({groupID:e,name:h,avatar:u,introduction:a,joinOption:n,inviteOption:c,maxMemberCount:p,memberCount:l,type:d,ownerID:m,createTime:s,groupCustomField:f});return Ge({group:G})}catch(e){throw console.error(`${this._name}.searchGroupByID fail:`,e),e}}))}};var Le=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return _e(this,void 0,void 0,(function*(){const{groupID:t}=e,{utils:{isUndefined:o}}=this._core;let r=de.getLocalGroup(t);if(r){const{type:t}=r;this._canIUseJoinOption(t)||o(e.joinOption)||(console.warn(`${this._name}.updateGroupProfile joinOption is unavailable for Work/Meeting/AVChatRoom`),e.joinOption=void 0)}o(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off");try{return yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,name:r,avatar:i,introduction:n,notification:s,muteAllMembers:u,joinOption:a,inviteOption:c,groupCustomField:p}=e;return fe("group_open_http_svc.modify_group_base_info",{GroupId:o,Name:r,FaceUrl:i,Introduction:n,Notification:s,ShutUpAllMember:u,ApplyJoinOption:a,InviteJoinOption:c,AppDefinedData:p?le(p):void 0},t)}))}(e,this._core),console.log(`${this._name}.updateGroupProfile groupID:${t} ok.`),r?(r.updateGroup(e),de.emitGroupListUpdate()):r=new me(e),Ge({group:r})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}}))}_canIUseJoinOption(e){return ue(e)||this._core.common.isCommunity({type:e})}};var Se=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return _e(this,void 0,void 0,(function*(){const t="changeGroupOwner",{groupID:o,newOwnerID:r}=e,i=de.getLocalGroup(o),{helper:n,OuterConstant:s,common:{getCurrentUserID:u}}=this._core;if((null==i?void 0:i.type)===s.GRP_AVCHATROOM)throw new n.ChatError({functionName:t,code:z});if(r===u())throw new n.ChatError({functionName:t,code:X});console.log(`${this._name}.${t} groupID:${o} newOwnerID:${r}`);try{return yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,newOwnerID:r}=e;return fe("group_open_http_svc.change_group_owner",{GroupId:o,NewOwner_Account:r},t)}))}(e,this._core),console.log(`${this._name}.${t} ok.`),i.ownerID=r,de.emitGroupListUpdate(),Ge({group:i})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var Oe=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}getGroupOnlineMemberCount(e){return _e(this,void 0,void 0,(function*(){const t="getGroupOnlineMemberCount",o=de.hasLocalGroup(e);if(console.log(`${this._name}.${t} groupID:${e} hasLocalGroup:${o}`),!o)return Ge({memberCount:0});const r=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:o=0,memberCount:i=0}=t||{};if(r-o<=6e4)return Ge({memberCount:i})}try{const o=yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.get_online_member_num",{GroupId:e},t)}))}(e,this._core),{OnlineMemberNum:r=0}=o||{};return this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:r}),console.log(`${this._name}.${t} ok. groupID:${e} memberCount:${r}`),Ge({memberCount:r})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var we=new class{init(e,t){console.log("GroupAction.init"),be.init(e),ve.init(e),ye.init(e,t),Me.init(e,t),Ae.init(e,t),De.init(e),Ce.init(e),Le.init(e),Se.init(e),Oe.init(e,t)}dismissGroup(e){return ye.dismissGroup(e)}joinGroup(e){return Me.joinGroup(e)}quitGroup(e){return Ae.quitGroup(e)}getGroupOnlineMemberCount(e){return Oe.getGroupOnlineMemberCount(e)}};function Te(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}var $e=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return _e(this,void 0,void 0,(function*(){const e="getGroupApplicationList";try{const t=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);console.log(`${this._name}.${e} ok.`);const o=this._handleGroupApplicationResult([...t[0],...t[1]]);return Ge({applicationList:o})}catch(t){const o=new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo});throw console.error(`${this._name}.${e} fail:`,o),o}}))}_getGroupApplicationList(t){return _e(this,void 0,void 0,(function*(){const{type:o,startTime:r=0,limit:i=20}=t||{},{common:n}=this._core;let s;try{s=yield function(t,o){return _e(this,void 0,void 0,(function*(){const{type:r,startTime:i,limit:n,handleAccount:s}=t;return Te(e.core.common.isCommunity({type:r})?"million_group_open_http_svc.get_pendency":"group_open_http_svc.get_pendency",{StartTime:i,Limit:n,Handle_Account:s},o)}))}({type:o,startTime:r,limit:i,handleAccount:n.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;s={}}const{NextStartTime:u=0,PendencyList:a=[]}=s||{};if(0===u)return a;const c=yield this._getGroupApplicationList(Object.assign(Object.assign({},t),{startTime:u}));return[...a,...c]}))}_handleGroupApplicationResult(e){const t=[];return e.forEach((e=>{const o=this._convertApplicationData(e),{handled:r}=o,i=ge(o,["handled"]);0===r&&t.push(i)})),t}_convertApplicationData(e){const{Handled:t,AddTime:o,ApplyInviteMsg:r,Authentication:i,FromUserNickName:n,From_Account:s,GroupId:u,GroupName:a,PendencyType:c,To_Account:p}=e;return{handled:t,messageKey:o,applicant:s,applicantNick:n,groupID:u,groupName:a,authentication:i,applicationType:c,userID:p,note:r}}};var Ne=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(t){return _e(this,void 0,void 0,(function*(){const o="handleGroupApplication",{application:r}=t,i=this._handleParams(t);try{(null==r?void 0:r.applicationType)===d?yield function(t,o){return _e(this,void 0,void 0,(function*(){const{groupID:r,handleAction:i,handleMessage:n,applicant:s,authentication:u,invitee:a}=t;return Te(e.core.common.isCommunity({groupID:r})?"million_group_open_http_svc.handle_invite_join_permission_group":"group_open_http_svc.handle_invite_join_permission_group",{GroupId:r,HandleMsg:i,ApprovalMsg:n,Applicant_Account:s,Authentication:u,Invited_Account:a},o)}))}(i,this._core):yield function(t,o){return _e(this,void 0,void 0,(function*(){const{groupID:r,handleAction:i,handleMessage:n,applicant:s,authentication:u,messageKey:a}=t;return Te(e.core.common.isCommunity({groupID:r})?"million_group_open_http_svc.handle_apply_join_group":"group_open_http_svc.handle_apply_join_group",{GroupId:r,HandleMsg:i,ApprovalMsg:n,Applicant_Account:s,Authentication:u,MsgKey:a},o)}))}(i,this._core),console.log(`${this._name}.${o} ok.`);const t=de.getLocalGroup(i.groupID);return Ge({group:t})}catch(e){const t=new this._core.helper.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${o} fail:`,t),t}}))}_handleParams(e){var t;const{handleAction:o,handleMessage:r,message:i,application:n}=e;let s,u,a,c,p;if(i){const{payload:e}=i||{};s=e.operatorID,u=null===(t=e.groupProfile)||void 0===t?void 0:t.groupID,a=e.authentication,c=e.messageKey}else s=(null==n?void 0:n.applicant)||"",u=(null==n?void 0:n.groupID)||"",a=(null==n?void 0:n.authentication)||"",c=(null==n?void 0:n.messageKey)||0;return(null==n?void 0:n.applicationType)===d&&(p=n.userID),{handleAction:o,handleMessage:r,applicant:s,invitee:p,groupID:u,authentication:a,messageKey:c}}};var Ee=new class{init(e){console.log("GroupApplication.init"),$e.init(e),Ne.init(e)}};let Pe=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(t){const{core:{utils:{isUndefined:o},common:{deepMerge:r}}}=e;o(t.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*t.muteTime)/1e3)),o(t.onlineStatus)||(this.isOnline="Online"===t.onlineStatus);const i=[null,void 0,"",0,NaN];t.memberCustomField&&ce(this.memberCustomField,t.memberCustomField),r(this,t,["memberCustomField","marks","onlineStatus","muteTime"],i)}};function Re(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}function Ue(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userID:r,muteTime:i,role:n,nameCard:s,memberCustomField:u}=e;let a;u&&(a=le(u));return Re("group_open_http_svc.modify_group_member_info",{GroupId:o,Member_Account:r,ShutUpTime:i,Role:n,NameCard:s,AppMemberDefinedData:a},t)}))}var ke=new class{constructor(){this._name="GetGroupMemberList"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}getGroupMemberList(e){return _e(this,void 0,void 0,(function*(){const t="getGroupMemberList",{groupID:o,offset:r=0,count:i=100,role:n="",filter:s=""}=e;console.log(`${this._name}.${t} groupID:${o} offset:${r} count:${i} role:${n} filter:${s}`);const u=de.getLocalGroup(o),a=i>100?100:i,c={groupID:o,offset:r,limit:a,memberRoleFilter:g.includes(n)?[n]:void 0,memberInfoFilter:_};try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,offset:r,limit:i,memberRoleFilter:n,memberInfoFilter:s}=e;return Re("group_open_http_svc.get_group_member_info",{GroupId:o,Offset:r,Limit:i,MemberRoleFilter:n,MemberInfoFilter:s},t)}))}(c,this._core),{MemberList:i,MemberNum:n,Next:s}=e||{};console.log(`${this._name}.${t} ok, totalMemberCount:${n} next:${s}`);const{utils:{isArray:p,isEmpty:l},common:{isCommunity:h}}=this._core;if(u&&(u.memberCount=n),!p(i)||0===i.length)return Ge({memberList:[],offset:0});let m=r+a;h({groupID:o})&&(m=l(s)?0:s),i.length<a&&(m=0);let d=this._convertMemberInfo(i);d=yield this._patchAvatarAndNick(d);const g=this._generateGroupMember(d);return Ge({memberList:g,offset:m})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a}=e[o],c=pe(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_patchAvatarAndNick(e){return _e(this,void 0,void 0,(function*(){var t;const o=e.map((e=>e.userID)),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map((e=>[e.userID,e])));return e.forEach((e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}})),e}))}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new Pe(e[o]);t.push(r)}return t}};var qe=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return _e(this,void 0,void 0,(function*(){const t="getGroupMemberProfile",{groupID:o,userIDList:r,memberCustomFieldFilter:i}=e,n=de.getLocalGroup(o),{helper:s,utils:{isArray:u}}=this._core;if(n&&ae(n.type))throw new s.ChatError({functionName:t,replacement1:t,code:se});r.length>50&&(console.warn(`${this._name}.${t} userIDList length:${r.length} exceeds limit 50`),r.splice(50));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,memberInfoFilter:i,memberCustomFieldFilter:n}=e;return Re("group_open_http_svc.get_specified_group_member_info",{GroupId:o,Member_List_Account:r,MemberInfoFilter:i,AppDefinedDataFilter_GroupMember:n},t)}))}({groupID:o,userIDList:r,memberCustomFieldFilter:i,memberInfoFilter:[..._]},this._core);console.log(`${this._name}.${t} ok.`);const{MemberList:n}=e||{};if(!u(n)||0===n.length)return Ge({memberList:[]});let s=this._convertMemberInfo(n);s=yield this._getMemberAvatarAndNick(s);const a=this._generateGroupMember(s);return Ge({memberList:a})}catch(e){const o=new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a}=e[o],c=pe(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_getMemberAvatarAndNick(e){return _e(this,void 0,void 0,(function*(){var t;const o=e.map((e=>e.userID)),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map((e=>[e.userID,e])));return e.forEach((e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}})),e}))}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new Pe(e[o]);t.push(r)}return t}};var Fe=new class{constructor(){this._name="AddGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(e){return _e(this,void 0,void 0,(function*(){const t="addGroupMember",{groupID:o,userIDList:r}=e,i=de.getLocalGroup(o),{helper:n}=this._core;if(i&&ae(i.type))throw new n.ChatError({functionName:t,code:te});const s=r.map((e=>({Member_Account:e})));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r}=e;return Re("group_open_http_svc.add_group_member",{GroupId:o,MemberList:r},t)}))}({groupID:o,userIDList:s},this._core),{MemberList:r=[]}=e||{},{failureUserIDList:n,successUserIDList:u,existedUserIDList:a,overLimitUserIDList:c}=this._handleResult(r);return console.log(`${this._name}.${t} groupID:${o} ok, successUserIDList:${u} failureUserIDList:${n} existedUserIDList:${a} overLimitUserIDList:${c}`),Ge({failureUserIDList:n,successUserIDList:u,existedUserIDList:a,overLimitUserIDList:c,group:i})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_handleResult(e){const t=[],o=[],r=[],i=[];return e.forEach((e=>{const{Result:n,Member_Account:s}=e;n===f?t.push(s):n===G?o.push(s):n===b?r.push(s):n===v&&i.push(s)})),{failureUserIDList:t,successUserIDList:o,existedUserIDList:r,overLimitUserIDList:i}}};var je=new class{constructor(){this._name="DeleteGroupMember"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}deleteGroupMember(e){return _e(this,void 0,void 0,(function*(){const t="deleteGroupMember",{groupID:o,userIDList:r}=e,i=de.getLocalGroup(o),{helper:n,utils:{isUndefined:s}}=this._core;if(s(i))throw new n.ChatError({functionName:t,code:Q});r.length>20&&(console.warn(`${this._name}.${t} userIDList length:${r.length} exceeds limit 20`),r.splice(20));try{return yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,reason:i}=e;return Re("group_open_http_svc.delete_group_member",{GroupId:o,MemberToDel_Account:r,Reason:i},t)}))}({groupID:o,userIDList:r},this._core),console.log(`${this._name}.${t} ok, groupID:${o} userIDList length:${r.length}`),Ge({group:i,userIDList:r})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var xe=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberMuteTime",{helper:o}=this._core;this._preCheckSettingMuteParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,muteTime:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} muteTime:${i}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,muteTime:i});return Ge({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingMuteParams(e){const{userID:t}=e,{store:o,helper:r}=this._core;if(t===o.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberMuteTime",code:ne})}};var Ke=new class{constructor(){this._name="SetGroupMemberRole"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberRole",{helper:o}=this._core;this._preCheckSettingRoleParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,role:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} role:${i}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,role:i});return Ge({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingRoleParams(e){var t;const{groupID:o,userID:r,role:i}=e,{store:n,helper:s,OuterConstant:u,common:{isCommunity:a}}=this._core,c=de.getLocalGroup(o);if((null===(t=null==c?void 0:c.selfInfo)||void 0===t?void 0:t.role)!==u.GRP_MBR_ROLE_OWNER)throw new s.ChatError({functionName:"setGroupMemberRole",code:oe});if(r===n.get("login").userId)throw new s.ChatError({functionName:"setGroupMemberRole",code:ie});const p=[...g];if(a({groupID:o})&&p.push(u.GRP_MBR_ROLE_CUSTOM),!p.includes(i))throw new s.ChatError({functionName:"setGroupMemberRole",code:re})}};var Ve=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberNameCard",{helper:o}=this._core;this._preCheckSettingNameCardParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,nameCard:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} nameCard:${i}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,nameCard:i});return Ge({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:o}=this._core,r=de.getLocalGroup(t);if(ae(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberNameCard",code:se})}};var Je=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberCustomField",{helper:o}=this._core;this._preCheckSettingCustomFiledParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,memberCustomField:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} memberCustomField:${JSON.stringify(i)}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,memberCustomField:i});return Ge({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:o}=this._core,r=de.getLocalGroup(t);if(ae(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberCustomField",code:se})}};var Be=new class{init(e,t){console.log("GroupMember.init"),ke.init(e,t),qe.init(e),Fe.init(e),je.init(e,t),xe.init(e),Ke.init(e),Ve.init(e),Je.init(e)}getGroupMemberList(e){return ke.getGroupMemberList(e)}deleteGroupMember(e){return je.deleteGroupMember(e)}};var He=new class{init(e){this._core=e}};function Ye(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}var We=new class{constructor(){this._name="InitGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="initGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n}=Ie.getGroupAttributesCache(o),s=Ie.convertKeyValueMapToList(r);try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ye("group_open_http_svc.set_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:o,avChatRoomKey:n,groupAttributeList:s,mainSequence:i},this._core),{AttrMainSeq:u,GroupAttr:a}=e||{};console.log(`${this._name}.${t} ok. groupID:${o} serverMainSequence:${u}`);const c=a.map((e=>{const{Key:t,seq:o}=e;return{key:t,value:r[t],sequence:o}}));return Ie.saveGroupAttributesCacheValuesCopy(o),Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:u,groupAttributeList:c,operation:I}),Ie.emitGroupAttributesUpdated(o),Ge({groupAttributes:r})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var Qe=new class{constructor(){this._name="SetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="setGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n,values:s}=Ie.getGroupAttributesCache(o),u=Ie.convertKeyValueMapToList(r).map((e=>{var t;const{key:o,value:r}=e;return{key:o,value:r,seq:(null===(t=s.get(e.key))||void 0===t?void 0:t.sequence)||0}}));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ye("group_open_http_svc.modify_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:o,avChatRoomKey:n,groupAttributeList:u,mainSequence:i},this._core),{AttrMainSeq:s,GroupAttr:a}=e||{};console.log(`${this._name}.${t} ok. groupID:${o} serverMainSequence:${s}`);const c=a.map((e=>{const{Key:t,seq:o}=e;return{key:t,value:r[t],sequence:o}}));return Ie.saveGroupAttributesCacheValuesCopy(o),Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:c,operation:y}),Ie.emitGroupAttributesUpdated(o),Ge({groupAttributes:r})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var ze=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="deleteGroupAttributes",{groupID:o,keyList:r=[]}=e;try{let e;e=0===r.length?yield this._clearGroupAttributes(o):yield this._deleteGroupAttributes(o,r);const{resultList:i,serverMainSequence:n,operation:s,groupAttributeList:u}=e||{};return console.log(`${this._name}.${t} ok. groupID:${o} operation: ${s}`),Ie.saveGroupAttributesCacheValuesCopy(o),Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:n,groupAttributeList:u,operation:s}),Ie.emitGroupAttributesUpdated(o),Ge({keyList:i})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_deleteGroupAttributes(e,t){return _e(this,void 0,void 0,(function*(){const{serverMainSequence:o,avChatRoomKey:r,values:i}=Ie.getGroupAttributesCache(e),n=[],s=[];t.forEach((e=>{if(i.has(e)){const{sequence:t=0}=i.get(e)||{};s.push({key:e,seq:t}),n.push(e)}}));const u=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ye("group_open_http_svc.delete_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:e,avChatRoomKey:r,groupAttributeList:s,mainSequence:o},this._core),{AttrMainSeq:a}=u||{};return{resultList:n,serverMainSequence:a,groupAttributeList:s,operation:M}}))}_clearGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const{serverMainSequence:t,avChatRoomKey:o,values:r}=Ie.getGroupAttributesCache(e),i=[...r.keys()],n=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,avChatRoomKey:i}=e;return Ye("group_open_http_svc.clear_group_attr",{GroupId:o,AttrMainSeq:r,BytesKey:i,AttrControl:["RaceConflict"]},t)}))}({groupID:e,avChatRoomKey:o,mainSequence:t},this._core),{AttrMainSeq:s}=n||{};return{resultList:i,serverMainSequence:s,operation:C}}))}};var Xe=new class{constructor(){this._name="GetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="getGroupAttributes",{groupID:o}=e,{avChatRoomKey:r,lastUpdateTime:i,localMainSequence:n,serverMainSequence:s}=Ie.getGroupAttributesCache(o);if(Date.now()-i>=3e4||n<s)try{yield this.getGroupAttributesFromServer({groupID:o,avChatRoomKey:r});const i=Ie.getGroupAttributesCacheValues(e);return console.log(`${this._name}.${t} from server. groupID:${o}`),Ge({groupAttributes:i})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}const u=Ie.getGroupAttributesCacheValues(e);return console.log(`${this._name}.${t} from cache. groupID:${o}`),Ge({groupAttributes:u})}))}getGroupAttributesFromServer(e){return _e(this,void 0,void 0,(function*(){const{utils:{isUndefined:t}}=this._core,{groupID:o,avChatRoomKey:r}=e,i=t(r)?L:D,n=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,groupType:r,avChatRoomKey:i}=e;return Ye("group_open_attr_http_svc.get_group_attr",{GroupId:o,GroupType:r,Key:i},t)}))}({groupID:o,avChatRoomKey:r,groupType:i},this._core),{AttrMainSeq:s,GroupAttrAry:u}=n||{};if(console.log(`${this._name}._getGroupAttributesFromServer ok. groupID:${o} serverMainSequence:${s}`),!t(s)){const e=u.map((e=>{const{key:t,value:o,seq:r}=e;return{key:t,value:o,sequence:r}}));Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:e,operation:A})}}))}};var Ze=new class{init(e){console.log("GroupAttribute.init"),We.init(e),Qe.init(e),ze.init(e),Xe.init(e),Ie.init(e)}isGroupAttributesUpdated(e){return Ie.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){const{to:t,elements:{newGroupProfile:o}}=e,{groupAttributeOption:r}=o,{serverMainSequence:i,withChangedAttributeInfo:n}=r,{localMainSequence:s}=Ie.getGroupAttributesCache(t),u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:${u}`),0!==u)if(Ie.saveGroupAttributesCacheValuesCopy(t),1!==n||1!==u){if(Ie.hasGroupAttributesCache(t)){const{avChatRoomKey:e}=Ie.getGroupAttributesCache(t);Xe.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then((()=>{Ie.emitGroupAttributesUpdated(t)})).catch((()=>{}))}}else Ie.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:r})}};function et(e,t="tips"){const{ClientSeq:o,From_Account:r,MsgClientTime:i,MsgPriority:n,MsgRandom:s,MsgSeq:u,MsgTimeStamp:a,TinyId:c,ToGroupId:p,GroupInfo:l,MsgBody:h}=e,m=function(e){const{GroupCode:t,GroupId:o,GroupName:r,GroupType:i,MsgFrom_AccountExtraInfo:n,From_Account:s,To_Account:u}=e;return{groupCode:t,groupID:o,groupName:r,type:i,messageFromAccountExtraInformation:n,from:s,to:u}}(l);return{clientSequence:o,from:r,clientTime:i,priority:n,random:s,sequence:u,time:a,tinyID:c,to:p,groupProfile:m,elements:"tips"===t?tt(h):function(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"MsgKey":t.messageKey=e[o];break;case"Operator_Account":t.operatorID=e[o];break;case"ReportType":t.operationType=e[o];break;case"Authentication":t.authentication=e[o];break;case"MsgFlag":t.messageRemindType=e[o];break;case"UserDefinedField":t.userDefinedField=e[o];break;case"RemarkInfo":t.remarkInfo=e[o];break;case"BanDuration":t.duration=e[o]}})),t}(h)}}function tt(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"MemberNum":t.memberCount=e[o];break;case"OpType":t.operationType=e[o];break;case"Operator_Account":t.operatorID=e[o];break;case"List_Account":t.userIDList=e[o];break;case"MsgMemberExtraInfo":t.memberInfoList=e[o].map((e=>ot(e)));break;case"MsgOperatorMemberExtraInfo":t.operatorInfo=ot(e[o]);break;case"MsgGroupNewInfo":t.newGroupProfile=function(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"GroupIntroduction":t.introduction=e[o];break;case"GroupName":t.groupName=e[o];break;case"GroupFaceUrl":t.avatar=e[o];break;case"GroupNotification":t.notification=e[o];break;case"ApplyJoinOption":t.joinOption=e[o];break;case"InviteJoinOption":t.inviteOption=e[o];break;case"ShutupAll":t.muteAllMembers=e[o];break;case"Owner_Account":t.ownerID=e[o];break;case"GroupAttrOption":t.groupAttributeOption=function(e){const{BytesChangedKeys:t,GroupAttrSeq:o,OpType:r,PushChangedAttrValFlag:i,GroupAttrInfo:n}=e,s=n.map((e=>{const{Key:t,Val:o,SubKeySeq:r}=e;return{key:t,value:o,sequence:r}}));return{changedKeyList:t,groupAttributeList:s,serverMainSequence:o,operation:r,withChangedAttributeInfo:i}}(e[o])}})),t}(e[o]);break;case"MsgMemberInfo":t.msgMemberInfo=e[o].map((e=>function(e){const{ShutupTime:t,User_Account:o}=e;return{muteTime:t,userID:o}}(e)));break;case"OnlineMemberInfo":t.onlineMemberInfo=function(e){const{ExpireTime:t,OnlineMemberNum:o}=e;return{expireTime:t,onlineMemberNum:o}}(e[o])}})),t}function ot(e){const{ImageUrl:t,NickName:o,Role:r,UserId:i}=e;return{avatar:t,nick:o,role:r,userID:i}}class rt{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(t)}static parseServerPushElement(e){const t=tt(e);return new rt(t)}_initContent(e){Object.keys(e).forEach((t=>{switch(t){case"groupProfile":this._initGroupProfile(e[t]);break;case"operatorInfo":this._initOperatorInfo(e[t]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"newGroupProfile":this._initNewGroupProfile(e[t]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[t]=e[t]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];k[r]&&(this.content.groupProfile[r]=e[r])}}_initOperatorInfo(e){this.content.operatorInfo={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];this.content.operatorInfo[r]=e[r]}}_updateMemberList(e){this.content.memberList?this.content.memberList.forEach((t=>{e.forEach((e=>{t.userID===e.userID&&Object.assign(t,e)}))})):this.content.memberList=e}_initNewGroupProfile(e){this.content.newGroupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];"muteAllMembers"!==r?this.content.newGroupProfile[r]=e[r]:this.content.newGroupProfile.muteAllMembers=1===e.muteAllMembers}}}var it=new class{constructor(){this._name="GroupTipsNotification"}init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:o}=e;null==t||t.registerElementClass(o.MSG_GRP_TIP,rt)}onNewGroupTips(e){console.log(`${this._name}.onNewGroupTips options:${JSON.stringify(e)}`);const{messageList:t}=this._handleGroupTips(e),{notificationCenter:o,OuterEvent:r}=this._core;t.length>0&&(o.emitOuterEvent(r.MESSAGE_RECEIVED,{name:r.MESSAGE_RECEIVED,data:t}),this._handleGroupTipMessage(t))}_handleGroupTips(e){const{Event:t,GroupTips:o}=e,r=new Map,i=[],n=[];for(let e=0,i=o.length;e<i;e++){const i=et(o[e],"tips");if(t===O&&Ze.isGroupAttributesUpdated(i)){Ze.handleGroupAttributesUpdated(i);continue}const{groupProfile:{groupID:s}}=i;if(!de.hasLocalGroup(s))continue;const u=this._assembleMessage(i);if(t===O&&(u._onlineOnlyFlag=!0,n.push(u)),t===S){if(!this._core.message.messageDataHandler.storeConversationMessage(u))continue;n.push(u)}this._handleConversationOptions(r,u)}return i.push(...r.values()),{conversationUpdateFieldList:i,messageList:n}}_assembleMessage(e){const{OuterConstant:t,message:{messageFactory:o}}=this._core;e.flow="in",e.conversationType=t.CONV_GROUP;const r=o.createMessage(e);this._patchNickAndAvatar(e.elements,r);const i=new rt(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));return r.setElement(i),r.isSystemMessage=!1,r}_patchNickAndAvatar(e,t){const{utils:{isEmpty:o}}=this._core,{operationType:r,memberInfoList:i,operatorInfo:n}=e;let s={};if(o(i)?o(n)||(s=n):r!==w&&r!==$&&r!==N&&r!==E||(s=Object.assign({},i[0])),!o(s)){const{nick:e="",avatar:o=""}=s;t.nick=e,t.avatar=o}}_handleConversationOptions(e,t){const{conversationID:o,conversationType:r}=t;let i;if(e.has(o))i=e.get(o),"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||i.unreadCount++),i.type=r,i.lastMessage=t._isExcludedFromLastMessage?"":t;else{let e=0;"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1)),i={conversationID:o,unreadCount:e,type:r,lastMessage:t._isExcludedFromLastMessage?"":t}}e.set(o,i)}_handleGroupTipMessage(e){e.forEach((e=>{const{operationType:t}=e.payload;switch(t){case w:this._handleNewMemberJoined(e);break;case T:this._handleMemberQuitted(e);break;case $:this._handleMemberKicked(e);break;case P:this._handleGroupProfileUpdated(e)}}))}_handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}_handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}_handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}_handleGroupProfileUpdated(e){var t;const{newGroupProfile:o,groupProfile:r,operatorInfo:i}=e.payload,{groupID:n}=r,s=de.getLocalGroup(n);Object.keys(o).forEach((e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(n,o);break;case"groupName":s.name=o[e];break;default:s[e]=o[e]}}));const{utils:{isUndefined:u}}=this._core;u(i)||(null===(t=null==s?void 0:s.selfInfo)||void 0===t?void 0:t.userID)!==i.userID||Object.keys(i).forEach((e=>{"nameCard"===e&&s.updateSelfInfo({nameCard:i[e]}),"role"===e&&this._updateSelfRole(s,i[e])})),de.emitGroupListUpdate(),de.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){const{common:o,OuterConstant:r}=this._core,i=de.getLocalGroup(e),n=o.getCurrentUserID(),{ownerID:s}=t;n===s&&i.updateGroup({ownerID:s,selfInfo:{role:r.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(e,t){const{OuterConstant:o}=this._core;let r=o.GRP_MBR_ROLE_MEMBER;t===R?r=o.GRP_MBR_ROLE_OWNER:t===U&&(r=o.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:r})}_handleGroupMemberCountUpdated(e){const{memberCount:t,groupProfile:{groupID:o}}=e.payload,r=de.getLocalGroup(o),{utils:{isNumber:i}}=this._core;r&&i(t)&&r.memberCount!==t&&(r.memberCount=t,de.emitGroupListUpdate(),de.updateConversationGroupProfile(o))}};class nt{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}_initContent(e){Object.keys(e).forEach((t=>{switch(t){case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this._initGroupProfile(e[t]);break;case"memberInfoList":break;default:this.content[t]=e[t]}}))}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];q[r]&&(this.content.groupProfile[r]=e[r])}}}var st=new class{constructor(){this._name="GroupSystemNotification"}init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:{MSG_GRP_SYS_NOTICE:o}}=e;null==t||t.registerElementClass(o,nt)}onNewGroupSystemNotification(e){const{GroupTips:t=[],isInstantMessage:o=!0}=e;console.log(`${this._name}.onNewGroupSystemNotification count:${t.length} isInstantMessage:${o}`);const{conversationUpdateFieldList:r,messageList:i}=this._handleGroupSystemNotification(t,o),{notificationCenter:n,OuterEvent:s}=this._core;r.length>0&&this._handleGroupSysTemMessage(o,i),!0===o&&i.length>0&&n.emitOuterEvent(s.MESSAGE_RECEIVED,{name:s.MESSAGE_RECEIVED,data:i})}_handleGroupSystemNotification(e,t){const o=[];let r={};for(let i=0;i<e.length;i++){const n=et(e[i],"system"),{elements:{operationType:s}}=n;if(s===J)continue;const u=this._assembleMessage(n);this._core.message.messageDataHandler.storeConversationMessage(u)&&(o.push(u),r=this._handleConversationOptions(u,t))}return r.lastMessage=o[o.length-1],{conversationUpdateFieldList:o.length>0?[r]:[],messageList:o}}_assembleMessage(e){const{message:{messageFactory:t},OuterConstant:o,utils:{randomInt:r}}=this._core;e.flow="in",e.conversationType=o.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=o.CONV_SYSTEM;const i=t.createMessage(e),n=new nt(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));i.setElement(n),i.isSystemMessage=!0;const s=1===i.sequence&&1===i.random,u=2===i.sequence&&2===i.random;return(s||u)&&(i.sequence=r(),i.random=r(),i.generateMessageID()),i}_handleConversationOptions(e,t){const{OuterConstant:o}=this._core,r={conversationID:o.CONV_SYSTEM,unreadCount:0,type:o.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&r.unreadCount++,r}_handleGroupSysTemMessage(e,t){e&&t.forEach((e=>{const{operationType:t}=e.payload;switch(t){case F:this._handleGroupJoinResult(e);break;case j:this._handleMemberKicked(e);break;case x:this._handleGroupDismissed(e);break;case K:this._handleGroupInvitedResult(e);break;case V:this._handleGroupQuitResult(e);break;case B:this._handleMessageRemindTypeSynced(e);break;case H:this._handleAVChatRoomMemberBanned(e)}}))}_handleGroupJoinResult(e){const{groupProfile:t}=e.payload,{groupID:o,type:r}=t,i=de.hasLocalGroup(o);console.log(`${this._name}._handleGroupJoinResult groupID:${o} type:${r} hasLocalGroup:${i}`),i||ae(r)||(de.updateLocalGroup([Object.assign({},t)]),de.emitGroupListUpdate())}_handleMemberKicked(e){const{groupProfile:{groupID:t,type:o}}=e.payload;de.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupDismissed(e){const{groupProfile:{groupID:t,type:o}}=e.payload;de.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupInvitedResult(e){const{groupProfile:t}=e.payload,{groupID:o}=t,r=de.hasLocalGroup(o);console.log(`${this._name}._handleGroupInvitedResult groupID:${o} hasLocalGroup:${r}`),r||(de.updateLocalGroup([Object.assign({},t)]),de.emitGroupListUpdate())}_handleGroupQuitResult(e){const{groupProfile:{groupID:t,type:o}}=e.payload,r=de.hasLocalGroup(t);console.log(`${this._name}._handleGroupQuitResult groupID:${t} type:${o} hasLocalGroup:${r}`),r&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleMessageRemindTypeSynced(e){const{groupProfile:{groupID:t},messageRemindType:o}=e.payload;this._updateConversationProfile(t,{messageRemindType:o})}_handleAVChatRoomMemberBanned(e){const{groupProfile:{groupID:t,type:o}}=e.payload;this._deleteLocalGroup(t,o)}_deleteLocalGroup(e,t){if(ae(t)){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core;t.deleteConversation(`${o}${e}`)}de.deleteLocalGroup(e),de.emitGroupListUpdate()}_updateConversationProfile(e,t){const{appStore:{conversationStore:o},OuterConstant:{CONV_GROUP:r}}=this._core,i=`${r}${e}`;o.getConversation(i)&&o.updateConversation(i,t)}};var ut=new class{init(e){this._core=e,console.log("GroupNotificationHandler.init"),it.init(e),st.init(e);const{notificationCenter:t,InnerEvent:o}=e,{InnerEventSubType:r}=t;t.subscribeInnerEvent(o.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),t.subscribeInnerEvent(o.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(e){it.onNewGroupTips(e)}_onNewGroupSystemNotification(e){st.onNewGroupSystemNotification(e)}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:o}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,o.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,o.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};const at={required:!0,rules:["string"],allowEmpty:!1},ct={required:!0,rules:["number"],allowEmpty:!1},pt={required:!0,rules:["array"],allowEmpty:!1},lt={required:!0,rules:["object"],allowEmpty:!1},ht={createGroup:{name:at,type:at},dismissGroup:[Object.assign({key:"groupID"},at)],joinGroup:{groupID:at,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},at)],searchGroupByID:[Object.assign({key:"groupID"},at)],getGroupProfile:{groupID:at,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:at,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:at,newOwnerID:at},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},at)],handleGroupApplication:{handleAction:at},getGroupMemberList:{groupID:at},getGroupMemberProfile:{groupID:at,userIDList:pt,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:at,userIDList:pt},deleteGroupMember:{groupID:at,userIDList:pt},setGroupMemberMuteTime:{groupID:at,userID:at,muteTime:Object.assign(Object.assign({},ct),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:at,userID:at,role:at},setGroupMemberNameCard:{groupID:at,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:at},setGroupMemberCustomField:{groupID:at,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:pt},markGroupMemberList:{groupID:at,markType:Object.assign(Object.assign({},ct),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:pt},initGroupAttributes:{groupID:at,groupAttributes:lt},setGroupAttributes:{groupID:at,groupAttributes:lt},deleteGroupAttributes:{groupID:at,keyList:Object.assign(Object.assign({},pt),{allowEmpty:!0})},getGroupAttributes:{groupID:at,keyList:Object.assign(Object.assign({},pt),{allowEmpty:!0})}},mt={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0};return new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=de,this.groupAction=we,this.groupAttribute=Ze,this.groupMember=Be}install(t,o=[]){this._core=t,e.init(t),de.init(t),we.init(t,this),Be.init(t,this),Ee.init(t),He.init(t),Ze.init(t),ut.init(t),t.helper.registerValidateConfig({auth:mt,params:ht}),this._installSubPlugins(o);const{notificationCenter:r,InnerEvent:i}=t;r.subscribeInnerEvent(i.LOGOUT,this._reset,this),r.subscribeInnerEvent(i.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(e){const{utils:{isArray:t}}=this._core;e&&t(e)&&e.forEach((e=>{var t;null===(t=e.install)||void 0===t||t.call(e,this._core,this),this._installedSubPlugins.push(e.name)}))}_reset(){de.reset()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatGroup=t()}(this,function(){let p=new class{init(e){this.core=e}},r="AVChatRoom",l="GRP_COUNTER",h=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],k=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],d=["Role","JoinTime","MsgFlag","MsgSeq"],U=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],o="notStart",i="resolved",n="rejected",_=["Owner","Admin","Member"],f=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],q={from:!0,groupID:!0,groupName:!0,to:!0},F={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},t=e=>e===p.core.OuterConstant.GRP_PUBLIC,c=e=>e===p.core.OuterConstant.GRP_AVCHATROOM,s=(o,e)=>{var t=p.core.utils["isArray"];if(!t(o)||!t(e))return!1;let i=!1;return e.forEach(({key:t,value:e})=>{var r=o.find(e=>e.key===t);r?r.value!==e&&(r.value=e,i=!0):(o.push({key:t,value:e}),i=!0)}),i},D=r=>{var o=[];if(r)for(let e=0,t=r.length;e<t;e++){var{Key:i,Value:n}=r[e];o.push({key:i,value:n})}return o},g=r=>{var o=[];for(let e=0,t=r.length;e<t;e++){var{key:i,value:n}=r[e];o.push({Key:i,Value:n})}return o};function m(e,t){var r=p.core["helper"];if(!r.checkBusinessCapabilityBits(t))throw new r.ChatError({functionName:e,code:3122,replacement1:e})}function v(e,t){var r=p.core["helper"],r=new r.ChatError({functionName:e,code:(null==t?void 0:t.errorCode)||(null==t?void 0:t.code),message:(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)});throw console.error(e+" fail:",r),r}let $=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];class G{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberCount=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._groupAtInfoList=[],this._initGroup(e)}_initGroup(t){var{isString:r}=p.core["utils"];for(let e in t)$.indexOf(e)<0||("selfInfo"!==e?"isSupportTopic"!==e?"muteAllMembers"===e&&r(t[e])?this.muteAllMembers="On"===t[e]:this[e]=t[e]:this.isSupportTopic=1===t[e]:this.updateSelfInfo(t[e]))}updateGroup(e){let{utils:{isArray:t,isUndefined:r,isNumber:o,isString:i},common:{deepMerge:n}}=p.core;e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);e=JSON.parse(JSON.stringify(e));e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),i(e.muteAllMembers)&&(e.muteAllMembers="On"===e.muteAllMembers),e.groupCustomField&&s(this.groupCustomField,e.groupCustomField),r(e.isSupportTopic)||(this.isSupportTopic=o(e.isSupportTopic)?1===e.isSupportTopic:e.isSupportTopic),n(this,e,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),t(e.members)&&0<e.members.length&&e.members.forEach(e=>{e.userID===this.selfInfo.userID&&n(this.selfInfo,e,["sequence"])})}updateSelfInfo(e){var{nameCard:e,joinTime:t,role:r,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:n}=e,s=p.core["common"]["deepMerge"];s(this.selfInfo,{nameCard:e,joinTime:t,role:r,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:n},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var I=new class{constructor(){this._name="GroupDataHandler"}init(e){var e=(this._core=e)["appStore"]["groupStore"];this._groupMap=e.getGroupMap(),console.log(this._name+".init")}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){var{getCurrentUserID:t}=this._core["common"];let r;e.forEach(e=>{var t;r=e.groupID,this.hasLocalGroup(r)?null!=(t=this.getLocalGroup(r))&&t.updateGroup(e):this._groupMap.set(r,new G(e))});var o=t();for(let[,e]of this._groupMap)e.selfInfo.userID=o,"Owner"===e.selfInfo.role&&(e.ownerID=o)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){let{GRP_ROOM:t,GRP_LIVE:r}=this._core["OuterConstant"];return[...this._groupMap.values()].filter(e=>{e=e.type;return e!==t&&e!==r})}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){var e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:r}=this._core;r.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(t){let{appStore:{conversationStore:r},OuterConstant:{CONV_GROUP:e}}=this._core,o=""+e+t;if(r.getConversation(o)){let e=this.getLocalGroup(t);r.updateConversation(o,{groupProfile:e})}}reset(){this.clearLocalGroup()}};function u(e,t){var r={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(r[i[o]]=e[i[o]]);return r}function b(e,s,u,a){return new(u=u||Promise)(function(r,t){function o(e){try{n(a.next(e))}catch(e){t(e)}}function i(e){try{n(a.throw(e))}catch(e){t(e)}}function n(e){var t;e.done?r(e.value):((t=e.value)instanceof u?t:new u(function(e){e(t)})).then(o,i)}n((a=a.apply(e,s||[])).next())})}function C(s,u){return b(this,void 0,void 0,function*(){var{type:e,limit:t,offset:r,supportTopic:o=0,memberAccount:i,responseFilter:n}=s;return u.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_joined_group_list",data:{Type:e,Limit:t,Offset:r,Member_Account:i,ResponseFilter:n,SupportTopic:o,NeedAppDefineData:1}})})}function y(e){return{code:0,data:e||{}}}var j=new class{constructor(){this._name="GetGroupList",this._pagingStatus=o,this.PAGING_GRP_COUNT_LIMIT=200}init(e){var{helper:e,constants:{WORKFLOW_NAME:t,WORKFLOW_STEP:r}}=this._core=e;e.registerApi({apiName:"getGroupList",context:this}),e.registerWorkflowStep(t.SYNC_SERVER_INFO_AFTER_LOGIN,r.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return b(this,arguments,void 0,function*(e=!1){if(e){let e=[];return yield this._pagingGetJoinedCommunityList({limit:this.PAGING_GRP_COUNT_LIMIT,offset:0,groupList:e}),I.updateLocalGroup(e),I.getLocalGroupList()}return console.log(this._name+".getGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===n||this._pagingStatus===o?this._syncGroupList().then(()=>{var e=I.getLocalGroupList();return y({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw console.error(this._name+".getGroupList fail:",e),e}):(e=I.getLocalGroupList(),console.log(this._name+".getGroupList return group count:"+e.length),y({groupList:e,isSyncCompleted:this._isSyncCompleted()}))})}_syncGroupList(){return b(this,void 0,void 0,function*(){this._pagingStatus===o&&I.clearLocalGroup();var e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=i,this._groupListTreeShaking(t),I.updateLocalGroup(t);var r=I.getLocalGroupList();return console.log(this._name+"._syncGroupList ok, count:"+r.length),I.emitGroupListUpdate(),r}catch(e){throw this._pagingStatus=n,console.error(this._name+"._syncGroupList fail:",e),e}})}_pagingGetGroupList(e){return b(this,void 0,void 0,function*(){var{isCommunityRelay:u=!1,groupList:a}=e;let p,{limit:l,offset:c}=e;var m=[...h];u&&(p=this._core.OuterConstant.GRP_COMMUNITY,m.push("AtInfoList"));try{let e=yield C({type:p,limit:l,offset:c,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:m,SelfInfoFilter:[...d]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t),i=(a.push(...o),c+l),n=!(r>i),s=`offset:${c} limit:${l} total:${r} isCompleted:${n} current:${a.length} isCommunityRelay:`+u;return console.log(this._name+"._pagingGetGroupList ok. "+s),u?n?a:(c=i,this._pagingGetGroupList({isCommunityRelay:!0,limit:l,offset:c,groupList:a})):n?(console.log(this._name+"._pagingGetGroupList start to get community list"),c=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:l,offset:c,groupList:a})):(c=i,this._pagingGetGroupList({limit:l,offset:c,groupList:a}))}catch(e){if(10018===e.ErrorCode)return console.warn(this._name+"._pagingGetGroupList response size exceeds the limit, request count:"+l),this._pagingGetGroupList({isCommunityRelay:u,limit:50,offset:c,groupList:a});if(u)return 11e3===e.code&&console.log(this._name+"._pagingGetGroupList ok. community unavailable"),a;throw e}})}_pagingGetJoinedCommunityList(e){return b(this,void 0,void 0,function*(){var{common:{getCurrentUserID:i},OuterConstant:n}=this._core,s=e["groupList"];let{limit:u,offset:a}=e;try{let e=yield C({limit:u,offset:a,type:n.GRP_COMMUNITY,memberAccount:i(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...h],SelfInfoFilter:[...d]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t);s.push(...o);var p=a+u,l=!(p<r),c=`offset:${a} limit:${u} total:${r} isCompleted:${l} current:`+s.length;return console.log(this._name+"._pagingGetJoinedCommunityList ok. "+c),l?s:(a=p,this._pagingGetJoinedCommunityList({limit:u,offset:a,groupList:s}))}catch(e){if(10018===e.code)return console.warn(this._name+"._pagingGetJoinedCommunityList response size exceeds the limit, request count:"+u),this._pagingGetJoinedCommunityList({limit:50,offset:a,groupList:s});throw e}})}_groupListTreeShaking(r){var o=new Map([...I.getLocalGroupList()]);for(let e=0,t=r.length;e<t;e++)o.delete(r[e].groupID);var i=[...o.keys()];for(let e=0,t=i.length;e<t;e++)I.deleteLocalGroup(i[e])}_isSyncCompleted(){return this._pagingStatus===i}_convertGroupKey(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppDefinedData:i,ApplyJoinOption:n,CreateTime:s,FaceUrl:u,GroupId:a,Introduction:p,InviteJoinOption:l,LastInfoTime:c,LastMsgTime:m,MemberNum:h,MaxMemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:v,Owner_Account:G,Type:I,LastRecallTime:b,SelfInfo:C,AtInfoList:y=[],SupportTopic:A}=r[e],i=D(i),C=this._convertSelfInfo(C),y=this._convertAtInfoList(a,y);o.push({groupCustomField:i,joinOption:n,createTime:s,avatar:u,groupID:a,introduction:p,inviteOption:l,lastInfoTime:c,lastMsgTime:m,memberCount:h,maxMemberCount:d,muteAllMembers:g,name:_,nextMessageSeq:f,notification:v,ownerID:G,type:I,selfInfo:C,_lastRevokedTime:b,_groupAtInfoList:y,isSupportTopic:A})}return o}_convertSelfInfo(e){var{JoinTime:e,MsgFlag:t,MsgSeq:r,NoUnreadSeqList:o,Role:i}=e;return{joinTime:e,messageRemindType:t,readedSequence:r,excludedUnreadSequenceList:o,role:i}}_convertAtInfoList(o,e){if(0===e.length)return[];let i=[];return e.forEach(e=>{var{AtFlagList:e,AtMsgSeq:t,From_Account:r}=e;i.push({groupID:o,groupAtType:e,sequence:t,from:r})}),i}},K=new class{constructor(){this._name="CreateGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"createGroup",context:this})}createGroup(a){return b(this,void 0,void 0,function*(){var n;this._preCheckParams(a);let{ssoLog:e,helper:{ChatError:o}}=this._core,s=e.createSSOLogData({method:"createGroup"});try{let{utils:{isEmpty:e},common:{getCurrentUserID:t}}=this._core,r=yield function(h,d){return b(this,void 0,void 0,function*(){var{name:e,type:t,groupID:r,introduction:o,notification:i,avatar:n,maxMemberNum:s,joinOption:u,inviteOption:a,memberList:p,groupCustomField:l,isSupportTopic:c}=h;let m;e={Name:e,Type:t,GroupId:r,Introduction:o,Notification:i,FaceUrl:n,MaxMemberCount:s,ApplyJoinOption:u,InviteJoinOption:a,MemberList:m=p?p.map(e=>{var{userID:e,memberCustomField:t}=e;return{Member_Account:e,AppMemberDefinedData:t?g(t):void 0}}):m,AppDefinedData:l,SupportTopic:c,webPushFlag:1};return d.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:e})})}(Object.assign(Object.assign({},a),{ownerID:t()}),this._core),{GroupId:o,OverJoinedGroupLimit_Account:i=[]}=r||{};s.setLogInfo({message:"groupID:"+o}).end(),console.log(`${this._name}.createGroup ok, type:${a.type} groupID:${o} overLimitUserIDList:`+i),e(a.memberList)||e(i)||(a.memberList=null==(n=a.memberList)?void 0:n.filter(e=>i.includes(e.userID))),I.updateLocalGroup([Object.assign(Object.assign({},a),{groupID:o})]);var u=I.getLocalGroup(o);return this._notNeedSendCustomMessage(a)||(this._sendCustomMessage(o,a.type),I.emitGroupListUpdate()),y({group:u})}catch(n){let{errorCode:e,errorInfo:t}=n,r=new o({functionName:"createGroup",code:e,message:t});throw s.setLogInfo({message:"groupID:"+(a.groupID||"")}).setError(r).end(),console.error(this._name+".createGroup fail:",r),r}})}_preCheckParams(e){var{type:t,groupID:r}=e,{utils:{isEmpty:o,isUndefined:i},common:{isCommunity:n}}=this._core,o=!o(r);if(!(()=>{var{GRP_PUBLIC:e,GRP_WORK:t,GRP_MEETING:r,GRP_AVCHATROOM:o,GRP_COMMUNITY:i}=p.core.OuterConstant;return[e,t,r,o,i]})().includes(t))throw new this._core.helper.ChatError({code:2600});if(!n({type:t})){if(o&&n({groupID:r}))throw new this._core.helper.ChatError({code:2602});i(e.isSupportTopic)||(e.isSupportTopic=void 0)}if(this._canIUseMemberList(t)||i(e.memberList)||(e.memberList=void 0),this._canIUseJoinOption(t)||i(e.joinOption)||(e.joinOption=void 0),n({type:t})){if(o&&!n({groupID:r}))throw new this._core.helper.ChatError({code:2602});e.isSupportTopic=this._canIUseTopic(e)?1:0}}_canIUseMemberList(e){return!c(e)}_canIUseJoinOption(e){return t(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){e=e.isSupportTopic;return!0===e}_notNeedSendCustomMessage(e){var{type:e,isSupportTopic:t}=e,{GRP_AVCHATROOM:r,GRP_COMMUNITY:o}=this._core["OuterConstant"];return e===r||e===o&&1===t}_sendCustomMessage(e,t){var r=this._core["OuterConstant"];let o="Create Group",i=0;t===r.GRP_COMMUNITY&&(o="Create Community",i=1);var t={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:o,cmd:i,opUser:this._core.store.get("login").userId,version:4})}},e=null==(r=null==(e=null==(r=this._core)?void 0:r.message)?void 0:e.messageFactory)?void 0:r.createCustomMessage(t);null!=(r=null==(t=null==(r=this._core)?void 0:r.message)?void 0:t.messageSender)&&r.sendMessage(e,{})}},A=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){var{helper:e,constants:t}=this._core=e;e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdated(e){var e=e["elements"]["newGroupProfile"],{isEmpty:t,isUndefined:r}=this._core["utils"];return!r(e)&&!t(e.groupAttributeOption)}handleGroupAttributesUpdated(e){var{groupID:e,groupAttributeOption:t}=e,{serverMainSequence:t,groupAttributeList:r=[],operation:o}=t,i=(console.log(this._name+`.handleGroupAttributesUpdated groupID:${e} operation:`+o),this._core)["utils"]["isUndefined"];i(o)||(this.refreshGroupAttributesCache({groupID:e,serverMainSequence:t,groupAttributeList:r,operation:o}),this.emitGroupAttributesUpdated(e))}initGroupAttributesCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupAttributesCache.set(e,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:t,values:new Map}),console.log(this._name+`.initGroupAttributesCache. groupID:${e} avChatRoomKey:`+t)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}refreshGroupAttributesCache(e){var{groupID:r,serverMainSequence:o,groupAttributeList:i,operation:n}=e;if(this.hasGroupAttributesCache(r)){let e=this.getGroupAttributesCache(r),t=e["localMainSequence"];5!==n&&o-t!=1||(e.serverMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:i,operation:n})),1<o-t&&(e.serverMainSequence=o),this._groupAttributesCache.set(r,e),console.log(this._name+`.refreshGroupAttributesCache. operation:${n} localMainSequence:${t} serverMainSequence:`+o)}}_updateGroupAttributesCacheValues(e){let{groupAttributes:o,groupAttributeList:t=[],operation:r}=e;3!==r?4!==r?(1===r&&o.values.clear(),t.forEach(e=>{var{key:e,value:t,sequence:r}=e;o.values.set(e,{value:t,sequence:r})})):t.forEach(e=>{o.values.delete(e.key)}):o.values.clear()}getGroupAttributesCacheValues(e){let r,{groupID:o,keyList:i=[]}=e,n={};if(this.hasGroupAttributesCache(o)){let t=this.getGroupAttributesCache(o)["values"];if(0===i.length)for(let e of t.keys())n[e]=(null==(r=t.get(e))?void 0:r.value)||"";else i.forEach(e=>{t.has(e)&&(n[e]=(null==(e=t.get(e))?void 0:e.value)||"")})}return n}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t,r=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:o,deletedKeyList:i}=this._computeValuesChangedData(r);console.log(`${this._name}.emitGroupAttributesUpdated update count:${o.length}, delete count:`+i.length),0===o.length&&0===i.length||this._emitEvent({name:null==(t=this._core)?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:r,updatedKeyList:o,deletedKeyList:i}})}_computeValuesChangedData(t){let{isUndefined:r}=this._core["utils"],o=[],i=[];return Object.keys(t).forEach(e=>{t[e]!==this._groupAttributesCacheValuesCopy[e]&&o.push(e)}),Object.keys(this._groupAttributesCacheValuesCopy).forEach(e=>{r(t[e])&&i.push(e)}),this._groupAttributesCacheValuesCopy={},{updatedKeyList:o,deletedKeyList:i}}_emitEvent(e){var t;null!=(t=this._core)&&t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(t){let r=[];return Object.keys(t).forEach(e=>{r.push({key:e,value:t[e]})}),r}reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}},x=new class{constructor(){this._name="DismissGroup"}init(e,t){e=(this._core=e).helper;e.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(r)})}dismissGroup(t){return b(this,void 0,void 0,function*(){console.log(this._name+".dismissGroup groupID:"+t);let{ssoLog:e,helper:{ChatError:i}}=this._core,n=e.createSSOLogData({method:"dismissGroup"});n.setLogInfo({message:"groupID:"+t});try{yield function(e,t){return b(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:{GroupId:e}})})}(t,this._core),n.end(),console.log(this._name+".dismissGroup ok.");let e=I.getLocalGroup(t)["type"];return I.deleteLocalGroup(t),I.emitGroupListUpdate(),A.deleteGroupAttributesCache(t),y({groupID:t,type:e})}catch(e){let{errorCode:t,errorInfo:r}=e,o=new i({functionName:"dismissGroup",code:t,message:r});throw n.setError(o).end(),console.error(this._name+".dismissGroup fail:",o),o}})}},M=new class{constructor(){this._name="GetGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(r){return b(this,void 0,void 0,function*(){let{groupID:i,groupCustomFieldFilter:e}=r,n={groupIDList:[i],responseFilter:{GroupBaseInfoFilter:[...h],AppDefinedDataFilter_Group:e,MemberInfoFilter:[...U]}},{ssoLog:t,helper:{ChatError:s}}=this._core,u=t.createSSOLogData({method:"getGroupProfile"});u.setLogInfo({message:"groupID:"+i});try{let e=yield this.getGroupProfileAdvance(n),{successGroupList:t,failureGroupList:r}=e;if(0<r.length)throw r[0];let o;return(o=!I.hasLocalGroup(i)&&c(t[0].type)?new G(t[0]):(I.updateLocalGroup(t),I.getLocalGroup(i))).isSupportTopic||I.updateConversationGroupProfile(i),u.end(),console.log(this._name+".getGroupProfile ok."),y({group:o})}catch(e){let{code:t,message:r}=e,o=new s({functionName:"getGroupProfile",code:t,message:r});throw u.setError(o).end(),console.error(this._name+".getGroupProfile fail:",o),e}})}getGroupProfileAdvance(u){return b(this,void 0,void 0,function*(){let e=u["groupIDList"],{isCommunity:t}=this._core["common"],r=e.filter(e=>!t({groupID:e})),o=e.filter(e=>t({groupID:e})),i=(50<r.length&&(r.length=50),50<o.length&&(o.length=50),yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},u),{groupIDList:r})),this._getGroupProfileAdvance(Object.assign(Object.assign({},u),{groupIDList:o,isCommunityProfile:!0}))])),n=[],s=[];return i.forEach(e=>{n.push(...e.successGroupList),s.push(...e.failureGroupList)}),{successGroupList:n,failureGroupList:s}})}_getGroupProfileAdvance(e){return b(this,void 0,void 0,function*(){let{isCommunityProfile:t=!1}=e,s=u(e,["isCommunityProfile"]);if(0===s.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{let e=yield function(r,o){return b(this,void 0,void 0,function*(){var{groupIDList:e,responseFilter:t}=r;return o.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:{GroupIdList:e,ResponseFilter:t}})})}(s,this._core),{GroupInfo:t=[]}=e||{},r=this._convertGroupProfileKey(t),{isUndefined:o}=this._core["utils"],i=r.filter(e=>o(e.errorCode)||0===e.errorCode),n=r.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return console.log(this._name+"._getGroupProfileAdvance ok, groupID:"+s.groupIDList.join(",")),{successGroupList:i,failureGroupList:n}}catch(e){if(t)return{successGroupList:[],failureGroupList:[]};throw e}})}_convertGroupProfileKey(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppDefinedData:i,ApplyJoinOption:n,CreateTime:s,FaceUrl:u,GroupId:a,InfoSeq:p,Introduction:l,InviteJoinOption:c,LastInfoTime:m,LastMsgTime:h,MaxMemberNum:d,MemberNum:g,MuteAllMember:_,Name:f,NextMsgSeq:v,Notification:G,Owner_Account:I,ShutUpAllMember:b,ShutUpUntil:C,Type:y,MemberList:A,ErrorCode:M,ErrorInfo:L}=r[e],i=D(i),A=this._convertMembers(A);o.push({groupCustomField:i,joinOption:n,createTime:s,avatar:u,groupID:a,infoSequence:p,introduction:l,inviteOption:c,lastInfoTime:m,lastMsgTime:h,maxMemberCount:d,memberCount:g,muteAllMembers:_,name:f,nextMessageSeq:v,notification:G,ownerID:I,shutUpAllMember:b,muteUntil:C,type:y,members:A,errorCode:M,errorInfo:L})}return o}_convertMembers(r){if(!r)return[];var o=[];for(let e=0,t=r.length;e<t;e++){var{AppMemberDefinedData:i,JoinTime:n,Member_Account:s,MsgFlag:u,MsgSeq:a,NameCard:p,Role:l}=r[e],i=D(i);o.push({memberCustomField:i,joinTime:n,userID:s,messageRemindType:u,sequence:a,nameCard:p,role:l})}return o}},L=new class{constructor(){this._groupCountersMap=new Map}init(e){this._core=e}getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}updateLocalGroupCounters(e){var{groupID:o,counterList:i=[],groupCounterSeq:n}=e;if(this._hasLocalGroupCounters(o)){let{counters:r,avChatRoomKey:e,groupCounterSeq:t}=this.getLocalGroupCounters(o);0<n&&n<t||(i.forEach(e=>{var{Key:e,Value:t=0}=e;r.set(e,t)}),this._groupCountersMap.set(o,{lastUpdateTime:Date.now(),groupCounterSeq:n,counters:r,avChatRoomKey:e}))}}initGroupCountersCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupCountersMap.set(e,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:t})}getLocalCounters(e,r){let o={};if(this._hasLocalGroupCounters(e)){let t=this.getLocalGroupCounters(e)["counters"];if(0<r.length)r.forEach(e=>{t.has(e)&&(o[e]=t.get(e))});else for(let e of t.keys())o[e]=t.get(e)}return o}deleteLocalGroupCounters(e){var{groupID:r,counterList:o=[],groupCounterSeq:i}=e;if(this._hasLocalGroupCounters(r)){let{counters:t,avChatRoomKey:e}=this.getLocalGroupCounters(r);o.forEach(e=>{t.delete(e.key)}),this._groupCountersMap.set(r,{lastUpdateTime:Date.now(),groupCounterSeq:i,counters:t,avChatRoomKey:e})}}setGroupCounters(t,i){if(this._hasLocalGroupCounters(t)){let e=this.getLocalGroupCounters(t),r=e["counters"],o=!1;Object.entries(i).forEach(([e,t])=>{r.has(e)&&r.get(e)!==t&&(r.set(e,t),o=!0)}),o&&this._groupCountersMap.set(t,Object.assign(Object.assign({},e),{lastUpdateTime:Date.now(),counters:r}))}}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}reset(){this._groupCountersMap.clear()}},V=new class{constructor(){this._name="JoinGroup"}init(e,t){e=(this._core=e).helper;e.registerApi({apiName:"joinGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(r)})}joinGroup(s){return b(this,void 0,void 0,function*(){let t=s["groupID"],{ssoLog:r,ChatError:i,OuterConstant:o}=this._core,n=r.createSSOLogData({method:"joinGroup"});try{if(I.hasLocalGroup(t))try{return yield M.getGroupProfile({groupID:t}),n.setLogInfo({message:`groupID:${t} joinedStatus:`+o.JOIN_STATUS_ALREADY_IN_GROUP}).end(),y({status:o.JOIN_STATUS_ALREADY_IN_GROUP})}catch(r){console.warn(`${this._name}.joinGroup ${t} was unjoined, start to join!`),I.deleteLocalGroup(t);let e=yield this._applyJoinGroup(s);return n.setLogInfo({message:"groupID:"+t}).end(),e}let e=yield this._applyJoinGroup(s);return n.setLogInfo({message:"groupID:"+t}).end(),e}catch(e){let{errorCode:t,errorInfo:r}=e,o=new i({functionName:"joinGroup",code:t,message:r});throw n.setError(o).end(),console.error(this._name+".joinGroup fail:",e),e}})}_applyJoinGroup(l){return b(this,void 0,void 0,function*(){var{OuterConstant:t,helper:e}=this._core,r=l["groupID"],o=Object.assign({},l),e=e.checkBusinessCapabilityBits("AV_HISTORY_MSG"),o=(e&&(o.historyMessageFlag=1),yield function(o,i){return b(this,void 0,void 0,function*(){var{groupID:e,applyMessage:t,historyMessageFlag:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:{GroupId:e,ApplyMsg:t,HugeGroupHistoryMsgFlag:r}})})}(o,this._core)),{Type:o,JoinedStatus:i,LongPollingKey:n,StartSeq:s,HugeGroupFlag:u,AVChatRoomKey:a,RspMsgList:p=[]}=o||{},e=`groupID:${r} joinedStatus:${i} longPollingKey:${n} startSeq:${s} avChatRoomFlag:${u} canGetAVChatRoomHistoryMsg:${e}, historyMessageCount:`+p.length;if(console.log(this._name+"._applyJoinGroup ok, "+e),i===t.JOIN_STATUS_WAIT_APPROVAL)return y({status:t.JOIN_STATUS_WAIT_APPROVAL,group:{groupID:r,type:o}});if(i!==t.JOIN_STATUS_SUCCESS)throw new this._core.helper.ChatError({code:2660});{let e=null;try{e=(yield M.getGroupProfile({groupID:r})).data.group}catch(t){e=new G({groupID:r}),console.warn(this._name+`._applyJoinGroup getGroupProfile failed, groupID: ${r}, errorCode:`,null==t?void 0:t.code)}return this._handleJoinResult({group:e,avChatRoomFlag:u,longPollingKey:n,startSequence:s,avChatRoomKey:a,historyMessageList:p})}})}_handleJoinResult(e){var{group:t,avChatRoomFlag:r,avChatRoomKey:o}=e;return 1===r?(A.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:o}),L.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:o}),y(e)):(I.updateLocalGroup([t]),I.emitGroupListUpdate(),y({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}},J=new class{constructor(){this._name="QuitGroup"}init(e,t){e=(this._core=e).helper;e.registerApi({apiName:"quitGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(r)})}quitGroup(t){return b(this,void 0,void 0,function*(){if(!I.hasLocalGroup(t))throw new this._core.helper.ChatError({code:2623});let{ssoLog:e,helper:{ChatError:i}}=this._core,n=e.createSSOLogData({method:"quitGroup"});n.setLogInfo({message:"groupID:"+t});try{yield function(e,t){return b(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:{GroupId:e}})})}(t,this._core),n.end(),console.log(this._name+".quitGroup ok, groupID:"+t);let e=I.getLocalGroup(t)["type"];return I.deleteLocalGroup(t),I.emitGroupListUpdate(),A.deleteGroupAttributesCache(t),y({groupID:t,type:e})}catch(e){let{errorCode:t,errorInfo:r}=e,o=new i({functionName:"quitGroup",code:t,message:r});throw n.setError(o).end(),console.error(this._name+".quitGroup fail:",o),o}})}},B=new class{constructor(){this._name="SearchGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(f){return b(this,void 0,void 0,function*(){console.log(this._name+".searchGroupByID groupID:"+f);try{var e=yield function(t,r){return b(this,void 0,void 0,function*(){var e={GroupIdList:[t],GroupBasePublicInfoFilter:[...k]};return r.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:e})})}(f,this._core),{GroupInfo:t=[]}=e||{},{AppDefinedData:r=[],ApplyJoinOption:o,CreateTime:i,FaceUrl:n,Introduction:s,InviteJoinOption:u,MaxMemberNum:a,MemberNum:p,Name:l,Owner_Account:c,Type:m,ErrorCode:h,ErrorInfo:d}=t[0];if(0!==h)throw new this._core.helper.ChatError({code:h,message:d});console.log(this._name+".searchGroupByID ok.");var g=D(r),_=new G({groupID:f,name:l,avatar:n,introduction:s,joinOption:o,inviteOption:u,maxMemberCount:a,memberCount:p,type:m,ownerID:c,createTime:i,groupCustomField:g});return y({group:_})}catch(e){throw console.error(this._name+".searchGroupByID fail:",e),e}})}},Y=new class{constructor(){this._name="UpdateGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(i){return b(this,void 0,void 0,function*(){let t=i["groupID"],{isUndefined:r}=this._core["utils"],o=I.getLocalGroup(t);if(o){let e=o["type"];this._canIUseJoinOption(e)||r(i.joinOption)||(console.warn(this._name+".updateGroupProfile joinOption is unavailable for Work/Meeting/AVChatRoom"),i.joinOption=void 0)}r(i.muteAllMembers)||(i.muteAllMembers=!0===i.muteAllMembers?"On":"Off");try{return yield function(p,l){return b(this,void 0,void 0,function*(){var{groupID:e,name:t,avatar:r,introduction:o,notification:i,muteAllMembers:n,joinOption:s,inviteOption:u,groupCustomField:a}=p,e={GroupId:e,Name:t,FaceUrl:r,Introduction:o,Notification:i,ShutUpAllMember:n,ApplyJoinOption:s,InviteJoinOption:u,AppDefinedData:a?g(a):void 0};return l.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:e})})}(i,this._core),console.log(`${this._name}.updateGroupProfile groupID:${t} ok.`),o?(o.updateGroup(i),I.emitGroupListUpdate()):o=new G(i),y({group:o})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}})}_canIUseJoinOption(e){return t(e)||this._core.common.isCommunity({type:e})}},H=new class{constructor(){this._name="ChangeGroupOwner"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(u){return b(this,void 0,void 0,function*(){let r="changeGroupOwner",{groupID:e,newOwnerID:t}=u,o=I.getLocalGroup(e),{helper:i,OuterConstant:n,common:{getCurrentUserID:s}}=this._core;if((null==o?void 0:o.type)===n.GRP_AVCHATROOM)throw new i.ChatError({functionName:r,code:2620});if(t===s())throw new i.ChatError({functionName:r,code:2621});console.log(`${this._name}.${r} groupID:${e} newOwnerID:`+t);try{return yield function(r,o){return b(this,void 0,void 0,function*(){var{groupID:e,newOwnerID:t}=r;return o.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:{GroupId:e,NewOwner_Account:t}})})}(u,this._core),console.log(this._name+`.${r} ok.`),o.ownerID=t,I.emitGroupListUpdate(),y({group:o})}catch(e){let t=new i.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}},W=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,t){e=(this._core=e).helper;e.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(r)})}getGroupOnlineMemberCount(i){return b(this,void 0,void 0,function*(){let r="getGroupOnlineMemberCount",e=I.hasLocalGroup(i);if(console.log(`${this._name}.${r} groupID:${i} hasLocalGroup:`+e),!e)return y({memberCount:0});let o=Date.now();if(this._onlineMemberCountMap.has(i)){let e=this._onlineMemberCountMap.get(i),{lastReqTime:t=0,memberCount:r=0}=e||{};if(o-t<=6e4)return y({memberCount:r})}try{let e=yield function(e,t){return b(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:{GroupId:e}})})}(i,this._core),{OnlineMemberNum:t=0}=e||{};return this._onlineMemberCountMap.set(i,{lastReqTime:Date.now(),memberCount:t}),console.log(`${this._name}.${r} ok. groupID:${i} memberCount:`+t),y({memberCount:t})}catch(e){let t=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${r} fail:`,t),t}})}},Q=new class{init(e,t){console.log("GroupAction.init"),j.init(e),K.init(e),x.init(e,t),V.init(e,t),J.init(e,t),B.init(e),M.init(e),Y.init(e),H.init(e),W.init(e,t)}dismissGroup(e){return x.dismissGroup(e)}joinGroup(e){return V.joinGroup(e)}quitGroup(e){return J.quitGroup(e)}getGroupOnlineMemberCount(e){return W.getGroupOnlineMemberCount(e)}},z=new class{constructor(){this._name="GetGroupApplicationList"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return b(this,void 0,void 0,function*(){var t="getGroupApplicationList";try{var r=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]),e=(console.log(this._name+`.${t} ok.`),this._handleGroupApplicationResult([...r[0],...r[1]]));return y({applicationList:e})}catch(e){r=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${t} fail:`,r),r}})}_getGroupApplicationList(n){return b(this,void 0,void 0,function*(){var{type:e,startTime:t=0,limit:r=20}=n||{},o=this._core["common"];let i;try{i=yield function(i,n){return b(this,void 0,void 0,function*(){var{type:e,startTime:t,limit:r,handleAccount:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:{Type:e,StartTime:t,Limit:r,Handle_Account:o}})})}({type:e,startTime:t,limit:r,handleAccount:o.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;i={}}var{NextStartTime:e=0,PendencyList:t=[]}=i||{};return 0===e?t:(r=yield this._getGroupApplicationList(Object.assign(Object.assign({},n),{startTime:e})),[...t,...r])})}_handleGroupApplicationResult(e){let r=[];return e.forEach(e=>{var e=this._convertApplicationData(e),t=e["handled"],e=u(e,["handled"]);0===t&&r.push(e)}),r}_convertApplicationData(e){var{Handled:e,AddTime:t,ApplyInviteMsg:r,Authentication:o,FromUserNickName:i,From_Account:n,GroupId:s,GroupName:u,PendencyType:a,To_Account:p}=e;return{handled:e,messageKey:t,applicant:n,applicantNick:i,groupID:s,groupName:u,authentication:o,applicationType:a,userID:p,note:r}}},X=new class{constructor(){this._name="HandleGroupApplication"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return b(this,void 0,void 0,function*(){let r="handleGroupApplication",t=e["application"],o=this._handleParams(e);try{2===(null==t?void 0:t.applicationType)?yield function(s,u){return b(this,void 0,void 0,function*(){var{groupID:e,handleAction:t,handleMessage:r,applicant:o,authentication:i,invitee:n}=s;return u.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:{GroupId:e,HandleMsg:t,ApprovalMsg:r,Applicant_Account:o,Authentication:i,Invited_Account:n}})})}(o,this._core):yield function(s,u){return b(this,void 0,void 0,function*(){var{groupID:e,handleAction:t,handleMessage:r,applicant:o,authentication:i,messageKey:n}=s;return u.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:{GroupId:e,HandleMsg:t,ApprovalMsg:r,Applicant_Account:o,Authentication:i,MsgKey:n}})})}(o,this._core),console.log(this._name+`.${r} ok.`);let e=I.getLocalGroup(o.groupID);return y({group:e})}catch(e){let t=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}_handleParams(e){var{handleAction:e,handleMessage:t,message:r,application:o}=e;let i,n,s,u,a;if(r){let e=(r||{})["payload"];i=e.operatorID,n=null==(r=e.groupProfile)?void 0:r.groupID,s=e.authentication,u=e.messageKey}else i=(null==o?void 0:o.applicant)||"",n=(null==o?void 0:o.groupID)||"",s=(null==o?void 0:o.authentication)||"",u=(null==o?void 0:o.messageKey)||0;return 2===(null==o?void 0:o.applicationType)&&(a=o.userID),{handleAction:e,handleMessage:t,applicant:i,invitee:a,groupID:n,authentication:s,messageKey:u}}},Z=new class{init(e){console.log("GroupApplication.init"),z.init(e),X.init(e)}};let S=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(e){var{utils:{isUndefined:t},common:{deepMerge:r}}=p["core"],t=(t(e.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*e.muteTime)/1e3)),t(e.onlineStatus)||(this.isOnline="Online"===e.onlineStatus),[null,void 0,"",0,NaN]);e.memberCustomField&&s(this.memberCustomField,e.memberCustomField),r(this,e,["memberCustomField","marks","onlineStatus","muteTime"],t)}};function O(u,a){return b(this,void 0,void 0,function*(){var{groupID:e,userID:t,muteTime:r,role:o,nameCard:i,memberCustomField:n}=u;let s;e={GroupId:e,Member_Account:t,ShutUpTime:r,Role:o,NameCard:i,AppMemberDefinedData:s=n?g(n):s};return a.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:e})})}var ee=new class{constructor(){this._name="GetGroupMemberList"}init(e,t){e=(this._core=e).helper;e.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(r)})}getGroupMemberList(o){return b(this,void 0,void 0,function*(){let n="getGroupMemberList",{groupID:s,offset:u=0,count:e=100,role:t="",filter:r=""}=o;console.log(`${this._name}.${n} groupID:${s} offset:${u} count:${e} role:${t} filter:`+r);var a=I.getLocalGroup(s),p=100<e?100:e,l={groupID:s,offset:u,limit:p,memberRoleFilter:_.includes(t)?[t]:void 0,memberInfoFilter:f};try{let e=yield function(n,s){return b(this,void 0,void 0,function*(){var{groupID:e,offset:t,limit:r,memberRoleFilter:o,memberInfoFilter:i}=n;return s.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:{GroupId:e,Offset:t,Limit:r,MemberRoleFilter:o,MemberInfoFilter:i}})})}(l,this._core),{MemberList:t,MemberNum:r,Next:o}=e||{};console.log(`${this._name}.${n} ok, totalMemberCount:${r} next:`+o);var{utils:{isArray:c,isEmpty:m},common:{isCommunity:h}}=this._core;if(a&&(a.memberCount=r),!c(t)||0===t.length)return y({memberList:[],offset:0});let i=u+p;h({groupID:s})&&(i=m(o)?0:o),t.length<p&&(i=0);var d=this._convertMemberInfo(t),d=yield this._patchAvatarAndNick(d),g=this._generateGroupMember(d);return y({memberList:g,offset:i})}catch(e){let t=new this._core.helper.ChatError({functionName:n,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${n} fail:`,t),t}})}_convertMemberInfo(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppMemberDefinedData:i,JoinTime:n,Member_Account:s,OnlineStatus:u,Role:a,ShutUpUntil:p}=r[e],i=D(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i})}return o}_patchAvatarAndNick(n){return b(this,void 0,void 0,function*(){let e,t=n.map(e=>e.userID),r=yield null==(e=this._core.user.userProfile)?void 0:e.getUserProfile({userIDList:t}),o=(null==r?void 0:r.data)||[],i=new Map(o.map(e=>[e.userID,e]));return n.forEach(e=>{var t,r;i.has(e.userID)&&({nick:t="",avatar:r=""}=i.get(e.userID),e.nick=t,e.avatar=r)}),n})}_generateGroupMember(r){var o=[];for(let e=0,t=r.length;e<t;e++){var i=new S(r[e]);o.push(i)}return o}},te=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(t){return b(this,void 0,void 0,function*(){let r="getGroupMemberProfile",{groupID:o,userIDList:i,memberCustomFieldFilter:n}=t,e=I.getLocalGroup(o),{helper:s,utils:{isArray:u}}=this._core;if(e&&c(e.type))throw new s.ChatError({functionName:r,replacement1:r,code:2687});50<i.length&&(console.warn(`${this._name}.${r} userIDList length:${i.length} exceeds limit 50`),i.splice(50));try{let e=yield function(i,n){return b(this,void 0,void 0,function*(){var{groupID:e,userIDList:t,memberInfoFilter:r,memberCustomFieldFilter:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:{GroupId:e,Member_List_Account:t,MemberInfoFilter:r,AppDefinedDataFilter_GroupMember:o}})})}({groupID:o,userIDList:i,memberCustomFieldFilter:n,memberInfoFilter:[...f]},this._core),t=(console.log(this._name+`.${r} ok.`),e||{})["MemberList"];var a,p;return u(t)&&0!==t.length?(a=this._convertMemberInfo(t),a=yield this._getMemberAvatarAndNick(a),p=this._generateGroupMember(a),y({memberList:p})):y({memberList:[]})}catch(e){let t=new s.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}_convertMemberInfo(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppMemberDefinedData:i,JoinTime:n,Member_Account:s,OnlineStatus:u,Role:a,ShutUpUntil:p}=r[e],i=D(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i})}return o}_getMemberAvatarAndNick(n){return b(this,void 0,void 0,function*(){let e,t=n.map(e=>e.userID),r=yield null==(e=this._core.user.userProfile)?void 0:e.getUserProfile({userIDList:t}),o=(null==r?void 0:r.data)||[],i=new Map(o.map(e=>[e.userID,e]));return n.forEach(e=>{var t,r;i.has(e.userID)&&({nick:t="",avatar:r=""}=i.get(e.userID),e.nick=t,e.avatar=r)}),n})}_generateGroupMember(r){var o=[];for(let e=0,t=r.length;e<t;e++){var i=new S(r[e]);o.push(i)}return o}},re=new class{constructor(){this._name="AddGroupMember"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(t){return b(this,void 0,void 0,function*(){let s="addGroupMember",{groupID:u,userIDList:e}=t,a=I.getLocalGroup(u),r=this._core["helper"];if(a&&c(a.type))throw new r.ChatError({functionName:s,code:2661});var p=e.map(e=>({Member_Account:e}));try{let e=yield function(r,o){return b(this,void 0,void 0,function*(){var{groupID:e,userIDList:t}=r;return o.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:{GroupId:e,MemberList:t}})})}({groupID:u,userIDList:p},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n}=this._handleResult(t);return console.log(`${this._name}.${s} groupID:${u} ok, successUserIDList:${o} failureUserIDList:${r} existedUserIDList:${i} overLimitUserIDList:`+n),y({failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n,group:a})}catch(e){let t=new r.ChatError({functionName:s,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${s} fail:`,t),t}})}_handleResult(e){let r=[],o=[],i=[],n=[];return e.forEach(e=>{var{Result:e,Member_Account:t}=e;0===e?r.push(t):1===e?o.push(t):2===e?i.push(t):4===e&&n.push(t)}),{failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n}}},oe=new class{constructor(){this._name="DeleteGroupMember"}init(e,t){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(r)})}deleteGroupMember(s){return b(this,void 0,void 0,function*(){let r="deleteGroupMember",{groupID:e,userIDList:t}=s,o=I.getLocalGroup(e),{helper:i,utils:{isUndefined:n}}=this._core;if(n(o))throw new i.ChatError({functionName:r,code:2603});20<t.length&&(console.warn(`${this._name}.${r} userIDList length:${t.length} exceeds limit 20`),t.splice(20));try{return yield function(o,i){return b(this,void 0,void 0,function*(){var{groupID:e,userIDList:t,reason:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:{GroupId:e,MemberToDel_Account:t,Reason:r}})})}({groupID:e,userIDList:t},this._core),console.log(`${this._name}.${r} ok, groupID:${e} userIDList length:`+t.length),y({group:o,userIDList:t})}catch(e){let t=new i.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}},ie=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(s){return b(this,void 0,void 0,function*(){let o="setGroupMemberMuteTime",t=this._core["helper"];this._preCheckSettingMuteParams(s);try{yield O(s,this._core);let{groupID:e,userID:t,muteTime:r}=s;console.log(`${this._name}.${o} ok, groupID:${e} userID:${t} muteTime:`+r);var i=I.getLocalGroup(e),n=new S({userID:t,muteTime:r});return y({group:i,member:n})}catch(e){i=new t.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${o} fail:`,i),i}})}_preCheckSettingMuteParams(e){var e=e["userID"],{store:t,helper:r}=this._core;if(e===t.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberMuteTime",code:2685})}},ne=new class{constructor(){this._name="SetGroupMemberRole"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(s){return b(this,void 0,void 0,function*(){let o="setGroupMemberRole",t=this._core["helper"];this._preCheckSettingRoleParams(s);try{yield O(s,this._core);let{groupID:e,userID:t,role:r}=s;console.log(`${this._name}.${o} ok, groupID:${e} userID:${t} role:`+r);var i=I.getLocalGroup(e),n=new S({userID:t,role:r});return y({group:i,member:n})}catch(e){i=new t.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${o} fail:`,i),i}})}_preCheckSettingRoleParams(e){var{groupID:e,userID:t,role:r}=e,{store:o,helper:i,OuterConstant:n,common:{isCommunity:s}}=this._core,u=I.getLocalGroup(e);if((null==(u=null==u?void 0:u.selfInfo)?void 0:u.role)!==n.GRP_MBR_ROLE_OWNER)throw new i.ChatError({functionName:"setGroupMemberRole",code:2681});if(t===o.get("login").userId)throw new i.ChatError({functionName:"setGroupMemberRole",code:2684});u=[..._];if(s({groupID:e})&&u.push(n.GRP_MBR_ROLE_CUSTOM),!u.includes(r))throw new i.ChatError({functionName:"setGroupMemberRole",code:2683})}},se=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(a){return b(this,void 0,void 0,function*(){let i="setGroupMemberNameCard",{helper:r,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingNameCardParams(a);try{let{groupID:e,userID:t=n(),nameCard:r}=a,o={groupID:e,userID:t,nameCard:r};yield O(o,this._core),console.log(`${this._name}.${i} ok, groupID:${e} userID:${t} nameCard:`+r);var s=I.getLocalGroup(e),u=new S({userID:t,nameCard:r});return y({group:s,member:u})}catch(e){let t=new r.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${i} fail:`,t),t}})}_preCheckSettingNameCardParams(e){var e=e["groupID"],t=this._core["helper"],e=I.getLocalGroup(e);if(c(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberNameCard",code:2687})}},ue=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(a){return b(this,void 0,void 0,function*(){let i="setGroupMemberCustomField",{helper:r,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingCustomFiledParams(a);try{let{groupID:e,userID:t=n(),memberCustomField:r}=a,o={groupID:e,userID:t,memberCustomField:r};yield O(o,this._core),console.log(`${this._name}.${i} ok, groupID:${e} userID:${t} memberCustomField:`+JSON.stringify(r));var s=I.getLocalGroup(e),u=new S({userID:t,memberCustomField:r});return y({group:s,member:u})}catch(e){let t=new r.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${i} fail:`,t),t}})}_preCheckSettingCustomFiledParams(e){var e=e["groupID"],t=this._core["helper"],e=I.getLocalGroup(e);if(c(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberCustomField",code:2687})}},ae=new class{init(e,t){console.log("GroupMember.init"),ee.init(e,t),te.init(e),re.init(e),oe.init(e,t),ie.init(e),ne.init(e),se.init(e),ue.init(e)}getGroupMemberList(e){return ee.getGroupMemberList(e)}deleteGroupMember(e){return oe.deleteGroupMember(e)}},pe=new class{init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(a){return b(this,void 0,void 0,function*(){var t="getGroupCounters";try{m(t,l);var e,r,o,{groupID:i,keyList:n=[]}=a,{avChatRoomKey:s,lastUpdateTime:u}=L.getLocalGroupCounters(i);return Date.now()-u>=this._getExpireTime()&&(e=yield function(i){return b(this,void 0,void 0,function*(){var{groupID:e,GroupCounterKeys:t,avChatRoomKey:r}=i,o=p.core["common"];return o.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:{GroupId:e,keyList:t,BytesKey:r}})})}({groupID:i,keyList:n,avChatRoomKey:s}),{GroupCounter:r=[],GroupCounterSeq:o}=e,L.updateLocalGroupCounters({groupID:i,counterList:r,groupCounterSeq:o})),{code:0,data:{counters:L.getLocalCounters(i,n)}}}catch(e){v(t,e)}})}_getExpireTime(){var{store:e,utils:{isUndefined:t}}=this._core,e=(e.get("cloudConfig")||{})["grp_counter_expire_time"];return t(e)?3e4:Number(e)}},le=new class{init(e){e=e.helper;e.registerApi({apiName:"setGroupCounters",context:this}),e.registerApi({apiName:"increaseGroupCounter",context:this}),e.registerApi({apiName:"decreaseGroupCounter",context:this})}setGroupCounters(e){return b(this,void 0,void 0,function*(){return this._handleCounterOperation("Set",e)})}increaseGroupCounter(e){return b(this,void 0,void 0,function*(){return this._handleCounterOperation("Increase",e)})}decreaseGroupCounter(e){return b(this,void 0,void 0,function*(){return this._handleCounterOperation("Decrease",e)})}_handleCounterOperation(u,a){return b(this,void 0,void 0,function*(){var t=u+"GroupCounter";try{m(t,l);var{groupID:e,key:r,value:o=0}=a,i=L.getLocalGroupCounters(e)["avChatRoomKey"],n="Set"===u?this._convertObjectToList(a.counters):[{Key:r,Value:o}],s=yield this._updateGroupCounters({groupID:e,counterList:n,avChatRoomKey:i,mode:u});return L.setGroupCounters(e,s),{code:0,data:{counters:s}}}catch(e){v(t,e)}})}_updateGroupCounters(n){return b(this,void 0,void 0,function*(){let e=yield function(){var{groupID:e,counterList:t,mode:r,avChatRoomKey:o}=n,i=p.core["common"];return i.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:{GroupId:e,GroupCounter:t,Mode:r,BytesKey:o}})}(),{GroupCounter:t=[]}=e,r={};return t.forEach(e=>{var{Key:e,Value:t=0}=e;r[e]=t}),r})}_convertObjectToList(e){return Object.entries(e).map(([e,t])=>({Key:e,Value:t||0}))}},a=new class{init(e){this._core=e,pe.init(e),le.init(e)}isGroupCounterUpdated(e){var e=e["elements"]["groupCounterInfo"],t=this._core["utils"]["isEmpty"];return!t(e)}handleGroupCounterUpdated(e){let{to:o,elements:{groupCounterInfo:t}}=e;t.forEach(e=>{var{type:e,groupCounterSeq:t,counterList:r=[]}=e;0!==e&&2!==e||this._processAndNotifyCounterUpdate(o,t,r),1===e&&L.deleteLocalGroupCounters({groupID:o,groupCounterSeq:t,counterList:r})})}_processAndNotifyCounterUpdate(r,e,t){let{OuterEvent:o,notificationCenter:i}=this._core;L.updateLocalGroupCounters({groupID:r,groupCounterSeq:e,counterList:t}),t.forEach(({Key:e,Value:t=0})=>{i.emitOuterEvent(o.GROUP_COUNTER_UPDATED,{name:o.GROUP_COUNTER_UPDATED,data:{groupID:r,key:e,value:t}})})}reset(){L.reset()}},ce=new class{constructor(){this._name="InitGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return b(this,void 0,void 0,function*(){let o="initGroupAttributes",{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u}=A.getGroupAttributesCache(i),a=A.convertKeyValueMapToList(n);try{let e=yield function(i,n){return b(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,groupAttributeList:r,avChatRoomKey:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.set_group_attr",data:{GroupId:e,AttrMainSeq:t,GroupAttr:r,BytesKey:o,AttrControl:["RaceConflict"]}})})}({groupID:i,avChatRoomKey:u,groupAttributeList:a,mainSequence:s},this._core),{AttrMainSeq:t,GroupAttr:r}=e||{};console.log(`${this._name}.${o} ok. groupID:${i} serverMainSequence:`+t);var p=r.map(e=>{var{Key:e,seq:t}=e;return{key:e,value:n[e],sequence:t}});return A.saveGroupAttributesCacheValuesCopy(i),A.refreshGroupAttributesCache({groupID:i,serverMainSequence:t,groupAttributeList:p,operation:1}),A.emitGroupAttributesUpdated(i),y({groupAttributes:n})}catch(e){let t=new this._core.helper.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${o} fail:`,t),t}})}},me=new class{constructor(){this._name="SetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return b(this,void 0,void 0,function*(){let o="setGroupAttributes",{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u,values:a}=A.getGroupAttributesCache(i),p=A.convertKeyValueMapToList(n).map(e=>{var{key:t,value:r}=e;return{key:t,value:r,seq:(null==(t=a.get(e.key))?void 0:t.sequence)||0}});try{let e=yield function(i,n){return b(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,groupAttributeList:r,avChatRoomKey:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_attr",data:{GroupId:e,AttrMainSeq:t,GroupAttr:r,BytesKey:o,AttrControl:["RaceConflict"]}})})}({groupID:i,avChatRoomKey:u,groupAttributeList:p,mainSequence:s},this._core),{AttrMainSeq:t,GroupAttr:r}=e||{};console.log(`${this._name}.${o} ok. groupID:${i} serverMainSequence:`+t);var l=r.map(e=>{var{Key:e,seq:t}=e;return{key:e,value:n[e],sequence:t}});return A.saveGroupAttributesCacheValuesCopy(i),A.refreshGroupAttributesCache({groupID:i,serverMainSequence:t,groupAttributeList:l,operation:2}),A.emitGroupAttributesUpdated(i),y({groupAttributes:n})}catch(e){let t=new this._core.helper.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${o} fail:`,t),t}})}},he=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(u){return b(this,void 0,void 0,function*(){let r="deleteGroupAttributes",{groupID:e,keyList:t=[]}=u;try{var{resultList:o,serverMainSequence:i,operation:n,groupAttributeList:s}=(0===t.length?yield this._clearGroupAttributes(e):yield this._deleteGroupAttributes(e,t))||{};return console.log(`${this._name}.${r} ok. groupID:${e} operation: `+n),A.saveGroupAttributesCacheValuesCopy(e),A.refreshGroupAttributesCache({groupID:e,serverMainSequence:i,groupAttributeList:s,operation:n}),A.emitGroupAttributesUpdated(e),y({keyList:o})}catch(e){let t=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}_deleteGroupAttributes(s,u){return b(this,void 0,void 0,function*(){let{serverMainSequence:e,avChatRoomKey:t,values:r}=A.getGroupAttributesCache(s),o=[],i=[];u.forEach(e=>{var t;r.has(e)&&({sequence:t=0}=r.get(e)||{},i.push({key:e,seq:t}),o.push(e))});var n=((yield function(i,n){return b(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,groupAttributeList:r,avChatRoomKey:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_attr",data:{GroupId:e,AttrMainSeq:t,GroupAttr:r,BytesKey:o,AttrControl:["RaceConflict"]}})})}({groupID:s,avChatRoomKey:t,groupAttributeList:i,mainSequence:e},this._core))||{})["AttrMainSeq"];return{resultList:o,serverMainSequence:n,groupAttributeList:i,operation:4}})}_clearGroupAttributes(o){return b(this,void 0,void 0,function*(){var{serverMainSequence:e,avChatRoomKey:t,values:r}=A.getGroupAttributesCache(o),r=[...r.keys()],t=((yield function(o,i){return b(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,avChatRoomKey:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_http_svc.clear_group_attr",data:{GroupId:e,AttrMainSeq:t,BytesKey:r,AttrControl:["RaceConflict"]}})})}({groupID:o,avChatRoomKey:t,mainSequence:e},this._core))||{})["AttrMainSeq"];return{resultList:r,serverMainSequence:t,operation:3}})}},de=new class{constructor(){this._name="GetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(l){return b(this,void 0,void 0,function*(){let o="getGroupAttributes",i=l["groupID"],{avChatRoomKey:n,lastUpdateTime:e,localMainSequence:t,serverMainSequence:r}=A.getGroupAttributesCache(i),{ssoLog:s,helper:{ChatError:u}}=this._core,a=s.createSSOLogData({method:"getGroupAttributes"});if(a.setLogInfo({message:`groupID:${i} localMainSequence:${t} serverMainSequence:${r} keyList:`+l.keyList}),3e4<=Date.now()-e||t<r)try{let e=yield this.getGroupAttributesFromServer({groupID:i,avChatRoomKey:n}),t=A.getGroupAttributesCacheValues(l),{serverGroupAttributeList:r=[]}=e||{};return a.setLogInfo({moreMessage:"from server, count:"+r.length}).end(),console.log(this._name+`.${o} from server. groupID:`+i),y({groupAttributes:t})}catch(e){let t=new u({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw a.setError(t).end(),console.error(this._name+`.${o} fail:`,t),t}var p=A.getGroupAttributesCacheValues(l);return a.setLogInfo({moreMessage:"from cache."}).end(),console.log(this._name+`.${o} from cache. groupID:`+i),y({groupAttributes:p})})}getGroupAttributesFromServer(i){return b(this,void 0,void 0,function*(){var e=this._core["utils"]["isUndefined"],{groupID:t,avChatRoomKey:r}=i,{AttrMainSeq:e=0,GroupAttrAry:r}=(yield function(o,i){return b(this,void 0,void 0,function*(){var{groupID:e,groupType:t,avChatRoomKey:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_attr_http_svc.get_group_attr",data:{GroupId:e,GroupType:t,Key:r}})})}({groupID:t,avChatRoomKey:r,groupType:e(r)?0:1},this._core))||{},o=(console.log(this._name+`._getGroupAttributesFromServer ok. groupID:${t} serverMainSequence:`+e),r.map(e=>{var{key:e,value:t,seq:r}=e;return{key:e,value:t,sequence:r}}));return A.refreshGroupAttributesCache({groupID:t,serverMainSequence:e,groupAttributeList:o,operation:5}),{serverGroupAttributeList:r}})}},T=new class{init(e){console.log("GroupAttribute.init"),ce.init(e),me.init(e),he.init(e),de.init(e),A.init(e)}isGroupAttributesUpdated(e){return A.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){let{to:t,elements:{newGroupProfile:r}}=e,o=r["groupAttributeOption"],{serverMainSequence:i,withChangedAttributeInfo:n}=o,s=A.getGroupAttributesCache(t)["localMainSequence"],u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:`+u),0!=u)if(A.saveGroupAttributesCacheValuesCopy(t),1!==n||1!=u){if(A.hasGroupAttributesCache(t)){let e=A.getGroupAttributesCache(t)["avChatRoomKey"];de.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then(()=>{A.emitGroupAttributesUpdated(t)}).catch(()=>{})}}else A.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:o})}reset(){A.reset()}};function ge(e,t="tips"){let{ClientSeq:r,From_Account:o,MsgClientTime:i,MsgPriority:n,MsgRandom:s,MsgSeq:u,MsgTimeStamp:a,TinyId:p,ToGroupId:l,GroupInfo:c,MsgBody:m}=e,h=function(){var{GroupCode:e,GroupId:t,GroupName:r,GroupType:o,MsgFrom_AccountExtraInfo:i,From_Account:n,To_Account:s}=c;return{groupCode:e,groupID:t,groupName:r,type:o,messageFromAccountExtraInformation:i,from:n,to:s}}();return{clientSequence:r,from:o,clientTime:i,priority:n,random:s,sequence:u,time:a,tinyID:p,to:l,groupProfile:h,elements:("tips"===t?_e:ve)(m)}}function _e(o){let e={};return Object.keys(o).forEach(r=>{switch(r){case"MemberNum":e.memberCount=o[r];break;case"OpType":e.operationType=o[r];break;case"Operator_Account":e.operatorID=o[r];break;case"List_Account":e.userIDList=o[r];break;case"MsgMemberExtraInfo":e.memberInfoList=o[r].map(e=>fe(e));break;case"MsgOperatorMemberExtraInfo":e.operatorInfo=fe(o[r]);break;case"MsgGroupNewInfo":e.newGroupProfile=function(s){let e={};return Object.keys(s).forEach(n=>{switch(n){case"GroupIntroduction":e.introduction=s[n];break;case"GroupName":e.groupName=s[n];break;case"GroupFaceUrl":e.avatar=s[n];break;case"GroupNotification":e.notification=s[n];break;case"ApplyJoinOption":e.joinOption=s[n];break;case"InviteJoinOption":e.inviteOption=s[n];break;case"ShutupAll":e.muteAllMembers=s[n];break;case"Owner_Account":e.ownerID=s[n];break;case"GroupAttrOption":e.groupAttributeOption=function(){var{BytesChangedKeys:e,GroupAttrSeq:t,OpType:r,PushChangedAttrValFlag:o,GroupAttrInfo:i}=s[n];return{changedKeyList:e,groupAttributeList:i.map(e=>{var{Key:e,Val:t,SubKeySeq:r}=e;return{key:e,value:t,sequence:r}}),serverMainSequence:t,operation:r,withChangedAttributeInfo:o}}()}}),e}(o[r]);break;case"MsgMemberInfo":e.msgMemberInfo=o[r].map(e=>{var{ShutupTime:e,User_Account:t}=e;return{muteTime:e,userID:t}});break;case"OnlineMemberInfo":e.onlineMemberInfo=function(){var{ExpireTime:e,OnlineMemberNum:t}=o[r];return{expireTime:e,onlineMemberNum:t}}();break;case"GroupCounterInfo":e.groupCounterInfo=o[r].map(e=>{var{GroupCounterSeq:e,GroupCounter:t,Type:r}=e;return{type:r,groupCounterSeq:e,counterList:t}})}}),e}function fe(e){var{ImageUrl:e,NickName:t,Role:r,UserId:o}=e;return{avatar:e,nick:t,role:r,userID:o}}function ve(t){let r={};return Object.keys(t).forEach(e=>{switch(e){case"MsgKey":r.messageKey=t[e];break;case"Operator_Account":r.operatorID=t[e];break;case"ReportType":r.operationType=t[e];break;case"Authentication":r.authentication=t[e];break;case"MsgFlag":r.messageRemindType=t[e];break;case"UserDefinedField":r.userDefinedField=t[e];break;case"RemarkInfo":r.remarkInfo=t[e];break;case"BanDuration":r.duration=t[e];break;case"MuteTime":r.muteTime=t[e]}}),r}class w{constructor(e){this.type=p.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(e)}static parseServerPushElement(e){e=_e(e);return new w(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"groupProfile":this._initGroupProfile(t[e]);break;case"operatorInfo":this._initOperatorInfo(t[e]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(t[e]);break;case"newGroupProfile":this._initNewGroupProfile(t[e]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[e]=t[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(t){this.content.groupProfile={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];q[o]&&(this.content.groupProfile[o]=t[o])}}_initOperatorInfo(t){this.content.operatorInfo={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];this.content.operatorInfo[o]=t[o]}}_updateMemberList(e){this.content.memberList?this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})}):this.content.memberList=e}_initNewGroupProfile(t){this.content.newGroupProfile={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];"muteAllMembers"!==o?this.content.newGroupProfile[o]=t[o]:this.content.newGroupProfile.muteAllMembers=1===t.muteAllMembers}}}var Ge=new class{constructor(){this._name="GroupTipsNotification"}init(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:r,WORKFLOW_STEP:o}}=this._core=e,{message:{messageFactory:e},OuterConstant:i}=e;null!=e&&e.registerElementClass(i.MSG_GRP_TIP,w),t.registerWorkflowStep(r.SYNC_SERVER_INFO_AFTER_RE_ONLINE,o.GROUP_TIPS_RECOVER,this._handleGroupTipsRecover,this)}onNewGroupTips(e){let{messageList:t,conversationUpdateFieldList:r}=this._handleGroupTips(e),{notificationCenter:o,OuterEvent:i,appStore:n}=this._core;null!=r&&r.forEach(e=>{var{conversationID:e,lastMessage:t,unreadCount:r}=e;n.conversationStore.updateConversation(e,{lastMessage:t,unreadCount:r})}),0<t.length&&(o.emitOuterEvent(i.MESSAGE_RECEIVED,{name:i.MESSAGE_RECEIVED,data:t}),this._handleGroupTipMessage(t))}_handleGroupTips(e,r=!0){let{Event:o,GroupTips:i}=e,n=new Map,t=[],s=[];for(let t=0,e=i.length;t<e;t++){let e=ge(i[t],"tips");if(6===o){if(T.isGroupAttributesUpdated(e)){T.handleGroupAttributesUpdated(e);continue}if(a.isGroupCounterUpdated(e)){a.handleGroupCounterUpdated(e);continue}}var u=e["groupProfile"]["groupID"];if(I.hasLocalGroup(u)){u=this._assembleMessage(e);if(6===o&&(u._onlineOnlyFlag=!0,s.push(u)),4===o){if(!this._core.message.messageDataHandler.storeConversationMessage(u)&&r)continue;s.push(u)}this._handleConversationOptions(n,u)}}return t.push(...n.values()),{conversationUpdateFieldList:t,messageList:s}}_assembleMessage(e){var{OuterConstant:t,message:{messageFactory:r}}=this._core,t=(e.flow="in",e.conversationType=t.CONV_GROUP,r.createMessage(e)),r=(this._patchNickAndAvatar(e.elements,t),new w(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)})));return t.setElement(r),t.isSystemMessage=!1,t}_patchNickAndAvatar(e,r){let{utils:{isEmpty:t},OuterConstant:{GROUP_TIPS_OPERATION_TYPE:o}}=this._core,{operationType:i,memberInfoList:n,operatorInfo:s}=e,u={};if(t(n)?t(s)||(u=s):i!==o.JOINED&&i!==o.KICKED&&i!==o.ADMIN_SET&&i!==o.ADMIN_CANCELED||(u=Object.assign({},n[0])),!t(u)){let{nick:e="",avatar:t=""}=u;r.nick=e,r.avatar=t}}_handleConversationOptions(e,t){var{common:{getMessagePreviewText:r},utils:{isObject:o}}=this._core,{conversationID:i,conversationType:n}=t;let s;if(e.has(i))s=e.get(i),"in"!==t.flow||t._isExcludedFromUnreadCount||t._onlineOnlyFlag||s.unreadCount++,s.type=n,s.lastMessage=t._isExcludedFromLastMessage?"":Object.assign({},t);else{let e=0;"in"!==t.flow||t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1),s={conversationID:i,unreadCount:e,type:n,lastMessage:t._isExcludedFromLastMessage?"":Object.assign({},t)}}o(s.lastMessage)&&(s.lastMessage.messageForShow=r(s.lastMessage.type,s.lastMessage.payload)),e.set(i,s)}_handleGroupTipMessage(e){let{GROUP_TIPS_OPERATION_TYPE:r}=this._core["OuterConstant"];e.forEach(e=>{var t=e.payload["operationType"];switch(t){case r.JOINED:this._handleNewMemberJoined(e);break;case r.QUITTED:this._handleMemberQuitted(e);break;case r.KICKED:this._handleMemberKicked(e);break;case r.GROUP_PROFILE_UPDATED:this._handleGroupProfileUpdated(e)}})}_handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}_handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}_handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}_handleGroupProfileUpdated(e){let t,{newGroupProfile:r,groupProfile:o,operatorInfo:i}=e.payload,n=o.groupID,s=I.getLocalGroup(n);Object.keys(r).forEach(e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(n,r);break;case"groupName":s.name=r[e];break;default:s[e]=r[e]}});var e=this._core["utils"]["isUndefined"];e(i)||(null==(t=null==s?void 0:s.selfInfo)?void 0:t.userID)!==i.userID||Object.keys(i).forEach(e=>{"nameCard"===e&&s.updateSelfInfo({nameCard:i[e]}),"role"===e&&this._updateSelfRole(s,i[e])}),I.emitGroupListUpdate(),I.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){var{common:r,OuterConstant:o}=this._core,e=I.getLocalGroup(e),t=t["ownerID"];r.getCurrentUserID()===t&&e.updateGroup({ownerID:t,selfInfo:{role:o.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(e,t){var r=this._core["OuterConstant"];let o=r.GRP_MBR_ROLE_MEMBER;400===t?o=r.GRP_MBR_ROLE_OWNER:300===t&&(o=r.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:o})}_handleGroupMemberCountUpdated(e){var{memberCount:e,groupProfile:{groupID:t}}=e.payload,r=I.getLocalGroup(t),o=this._core["utils"]["isNumber"];r&&o(e)&&r.memberCount!==e&&(r.memberCount=e,I.emitGroupListUpdate(),I.updateConversationGroupProfile(t))}_handleGroupTipsRecover(e){var t=this._core["utils"]["isArray"],e=((null==e?void 0:e.result)||{})["groupTipList"];t(e)&&e.forEach(e=>{e=this._handleGroupTips({Event:e.Event,GroupTips:[e]},!1).messageList;this._handleGroupTipMessage(e)})}};class E{constructor(e){this.type=p.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}static parseServerPushElement(e){e=ve(e);return new E(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"remarkInfo":this.content.handleMessage=t[e];break;case"groupProfile":this._initGroupProfile(t[e]);break;case"memberInfoList":break;default:this.content[e]=t[e]}})}_initGroupProfile(t){this.content.groupProfile={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];F[o]&&(this.content.groupProfile[o]=t[o])}}}var Ie=new class{constructor(){this._name="GroupSystemNotification"}init(e){var{message:{messageFactory:e},OuterConstant:{MSG_GRP_SYS_NOTICE:t}}=this._core=e;null!=e&&e.registerElementClass(t,E)}onNewGroupSystemNotification(e){var{GroupTips:e=[],isInstantMessage:t=!0}=e,{conversationUpdateFieldList:e,messageList:r}=(console.log(`${this._name}.onNewGroupSystemNotification count:${e.length} isInstantMessage:`+t),this._handleGroupSystemNotification(e,t)),{notificationCenter:o,OuterEvent:i}=this._core;0<e.length&&this._handleGroupSysTemMessage(t,r),!0===t&&0<r.length&&o.emitOuterEvent(i.MESSAGE_RECEIVED,{name:i.MESSAGE_RECEIVED,data:r})}_handleGroupSystemNotification(t,r){var o=[];let i={};for(let e=0;e<t.length;e++){var n=ge(t[e],"system"),s=n["elements"]["operationType"];15!==s&&(s=this._assembleMessage(n),this._core.message.messageDataHandler.storeConversationMessage(s))&&(o.push(s),i=this._handleConversationOptions(s,r))}return i.lastMessage=o[o.length-1],{conversationUpdateFieldList:0<o.length?[i]:[],messageList:o}}_assembleMessage(e){var{message:{messageFactory:t},OuterConstant:r,utils:{randomInt:o}}=this._core,r=(e.flow="in",e.conversationType=r.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=r.CONV_SYSTEM,t.createMessage(e)),t=new E(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)})),e=(r.setElement(t),r.isSystemMessage=!0,1===r.sequence&&1===r.random),t=2===r.sequence&&2===r.random;return(e||t)&&(r.sequence=o(),r.random=o(),r.generateMessageID()),r}_handleConversationOptions(e,t){var r=this._core["OuterConstant"],r={conversationID:r.CONV_SYSTEM,unreadCount:0,type:r.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&r.unreadCount++,r}_handleGroupSysTemMessage(e,t){e&&t.forEach(e=>{var t=e.payload["operationType"];switch(t){case 2:this._handleGroupJoinResult(e);break;case 4:this._handleMemberKicked(e);break;case 5:this._handleGroupDismissed(e);break;case 7:this._handleGroupInvitedResult(e);break;case 8:this._handleGroupQuitResult(e);break;case 20:this._handleMessageRemindTypeSynced(e);break;case 21:this._handleAVChatRoomMemberBanned(e)}})}_handleGroupJoinResult(e){var e=e.payload["groupProfile"],{groupID:t,type:r}=e,o=I.hasLocalGroup(t);console.log(this._name+`._handleGroupJoinResult groupID:${t} type:${r} hasLocalGroup:`+o),o||c(r)||(I.updateLocalGroup([Object.assign({},e)]),I.emitGroupListUpdate())}_handleMemberKicked(e){var{groupID:e,type:t}=e.payload["groupProfile"];I.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupDismissed(e){var{groupID:e,type:t}=e.payload["groupProfile"];I.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupInvitedResult(e){var e=e.payload["groupProfile"],t=e["groupID"],r=I.hasLocalGroup(t);console.log(this._name+`._handleGroupInvitedResult groupID:${t} hasLocalGroup:`+r),r||(I.updateLocalGroup([Object.assign({},e)]),I.emitGroupListUpdate())}_handleGroupQuitResult(e){var{groupID:e,type:t}=e.payload["groupProfile"],r=I.hasLocalGroup(e);console.log(this._name+`._handleGroupQuitResult groupID:${e} type:${t} hasLocalGroup:`+r),r&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleMessageRemindTypeSynced(e){var{groupProfile:{groupID:e},messageRemindType:t}=e.payload;this._updateConversationProfile(e,{messageRemindType:t})}_handleAVChatRoomMemberBanned(e){var{groupID:e,type:t}=e.payload["groupProfile"];this._deleteLocalGroup(e,t)}_deleteLocalGroup(r,e){if(c(e)){let{appStore:{conversationStore:e},OuterConstant:{CONV_GROUP:t}}=this._core;e.deleteConversation(""+t+r)}I.deleteLocalGroup(r),I.emitGroupListUpdate()}_updateConversationProfile(e,t){var{appStore:{conversationStore:r},OuterConstant:{CONV_GROUP:o}}=this._core,o=""+o+e;r.getConversation(o)&&r.updateConversation(o,t)}},be=new class{init(e){this._core=e,console.log("GroupNotificationHandler.init"),Ge.init(e),Ie.init(e);var{notificationCenter:e,InnerEvent:t}=e,r=e["InnerEventSubType"];e.subscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.subscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(e){Ge.onNewGroupTips(e)}_onNewGroupSystemNotification(e){Ie.onNewGroupSystemNotification(e)}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core,r=e["InnerEventSubType"];e.unSubscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};let e={required:!0,rules:["string"],allowEmpty:!1},N={required:!0,rules:["number"],allowEmpty:!1},P={required:!0,rules:["array"],allowEmpty:!1},R={required:!0,rules:["object"],allowEmpty:!1},Ce={createGroup:{name:e,type:e},dismissGroup:[Object.assign({key:"groupID"},e)],joinGroup:{groupID:e,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},e)],searchGroupByID:[Object.assign({key:"groupID"},e)],getGroupProfile:{groupID:e,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:e,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:e,newOwnerID:e},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},e)],handleGroupApplication:{handleAction:e},getGroupMemberList:{groupID:e},getGroupMemberProfile:{groupID:e,userIDList:P,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:e,userIDList:P},deleteGroupMember:{groupID:e,userIDList:P},setGroupMemberMuteTime:{groupID:e,userID:e,muteTime:Object.assign(Object.assign({},N),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:e,userID:e,role:e},setGroupMemberNameCard:{groupID:e,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:e},setGroupMemberCustomField:{groupID:e,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:P},markGroupMemberList:{groupID:e,markType:Object.assign(Object.assign({},N),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:P},initGroupAttributes:{groupID:e,groupAttributes:R},setGroupAttributes:{groupID:e,groupAttributes:R},deleteGroupAttributes:{groupID:e,keyList:Object.assign(Object.assign({},P),{allowEmpty:!0})},getGroupAttributes:{groupID:e,keyList:Object.assign(Object.assign({},P),{allowEmpty:!0})},getGroupCounters:{groupID:e,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:e,counters:R},increaseGroupCounter:{groupID:e,key:e,value:N},decreaseGroupCounter:{groupID:e,key:e,value:N}},ye={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};return new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=I,this.groupAction=Q,this.groupAttribute=T,this.groupMember=ae}install(e,t=[]){this._core=e,p.init(e),I.init(e),Q.init(e,this),ae.init(e,this),Z.init(e),a.init(e),T.init(e),be.init(e),e.helper.registerValidateConfig({auth:ye,params:Ce}),this._installSubPlugins(t);var{notificationCenter:t,InnerEvent:e}=e;t.subscribeInnerEvent(e.LOGOUT,this._reset,this),t.subscribeInnerEvent(e.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(e){var{isArray:t}=this._core["utils"];e&&t(e)&&e.forEach(e=>{var t;null!=(t=e.install)&&t.call(e,this._core,this),this._installedSubPlugins.push(e.name)})}_reset(){I.reset(),T.reset(),a.reset()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}});
|