@tencentcloud/lite-chat
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 79 kB
JavaScript
const e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r="GRP_COUNTER",i="Set",n="Increase",s="Decrease",u=0,a=1,c=2,p=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],l=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],m=["Role","JoinTime","MsgFlag","MsgSeq"],h=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],d=0,g=1,_="notStart",f="resolved",G="rejected",b=10018,I=11e3,v=2,C=["Owner","Admin","Member"],y=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],A=0,M=1,L=2,D=4,S=1,O=2,T=3,w=4,E=5,N=1,P=0,R=4,U=6,k=400,$=300,F={from:!0,groupID:!0,groupName:!0,to:!0},q={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},j=2,K=4,x=5,V=7,J=8,B=15,H=20,W=21,Y=2600,Q=2602,z=2603,X=2620,Z=2621,ee=2623,te=2660,oe=2661,re=2681,ie=2683,ne=2684,se=2685,ue=2687,ae=3122,ce=10018,pe=t=>t===e.core.OuterConstant.GRP_PUBLIC,le=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,me=(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},he=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},de=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};function ge(t,o){const{helper:r}=e.core;if(!r.checkBusinessCapabilityBits(o))throw new r.ChatError({functionName:t,code:ae,replacement1:t})}function _e(t,o){const{helper:r}=e.core,i=new r.ChatError({functionName:t,code:(null==o?void 0:o.errorCode)||(null==o?void 0:o.code),message:(null==o?void 0:o.errorInfo)||(null==o?void 0:o.message)});throw console.error(`${t} fail:`,i),i}const fe=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];class Ge{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){const{utils:{isString:o}}=e.core;for(const e in t)fe.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&&me(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 be=new class{constructor(){this._name="GroupDataHandler"}init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap()}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 Ge(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(){const{OuterConstant:{GRP_ROOM:e,GRP_LIVE:t}}=this._core;return[...this._groupMap.values()].filter(o=>{const{type:r}=o;return r!==e&&r!==t})}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 Ie(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 ve(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 Ce(e,t){return ve(this,void 0,void 0,function*(){const{type:o,limit:r,offset:i,supportTopic:n=0,memberAccount:s,responseFilter:u}=e,a={Type:o,Limit:r,Offset:i,Member_Account:s,ResponseFilter:u,SupportTopic:n,NeedAppDefineData:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_joined_group_list",data:a})})}"function"==typeof SuppressedError&&SuppressedError;const ye=function(e,t){return{code:0,data:e||{},successLog:t}};var Ae=new class{constructor(){this._name="GetGroupList",this._pagingStatus=_,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 ve(this,arguments,void 0,function*(e=!1){if(e){const e=[];return yield this._pagingGetJoinedCommunityList({limit:this.PAGING_GRP_COUNT_LIMIT,offset:0,groupList:e}),be.updateLocalGroup(e),be.getLocalGroupList()}if(this._core.ssoLog.debug("getGroupList",`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===G||this._pagingStatus===_)return this._syncGroupList().then(()=>{const e=be.getLocalGroupList();return ye({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw e});const t=be.getLocalGroupList();return ye({groupList:t,isSyncCompleted:this._isSyncCompleted()},{message:`return group count:${t.length}`})})}_syncGroupList(){return ve(this,void 0,void 0,function*(){this._pagingStatus===_&&be.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=f,this._groupListTreeShaking(t),be.updateLocalGroup(t);const o=be.getLocalGroupList();return this._core.ssoLog.debug("_syncGroupList",`${this._name}._syncGroupList ok, count:${o.length}`),be.emitGroupListUpdate(),o}catch(e){throw this._pagingStatus=G,e}})}_pagingGetGroupList(e){return ve(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,{isCommunityRelay:o=!1,groupList:r}=e;let i,{limit:n,offset:s}=e;const u=[...p];o&&(i=this._core.OuterConstant.GRP_COMMUNITY,u.push("AtInfoList"));try{const e=yield Ce({type:i,limit:n,offset:s,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:u,SelfInfoFilter:[...m]}},this._core),{GroupIdList:a=[],TotalCount:c=0}=e||{},p=this._convertGroupKey(a);r.push(...p);const l=s+n,h=!(c>l),d=`offset:${s} limit:${n} total:${c} isCompleted:${h} current:${r.length} isCommunityRelay:${o}`;return t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. ${d}`),o?h?r:(s=l,this._pagingGetGroupList({isCommunityRelay:!0,limit:n,offset:s,groupList:r})):h?(t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList start to get community list`),s=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:n,offset:s,groupList:r})):(s=l,this._pagingGetGroupList({limit:n,offset:s,groupList:r}))}catch(e){if(e.ErrorCode===b)return t.warn("_pagingGetGroupList",`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${n}`),n=50,this._pagingGetGroupList({isCommunityRelay:o,limit:n,offset:s,groupList:r});if(o)return e.code===I&&t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. community unavailable`),r;throw e}})}_pagingGetJoinedCommunityList(e){return ve(this,void 0,void 0,function*(){const{common:{getCurrentUserID:t},OuterConstant:o,ssoLog:r}=this._core,{groupList:i}=e;let{limit:n,offset:s}=e;try{const e=yield Ce({limit:n,offset:s,type:o.GRP_COMMUNITY,memberAccount:t(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...p],SelfInfoFilter:[...m]}},this._core),{GroupIdList:u=[],TotalCount:a=0}=e||{},c=this._convertGroupKey(u);i.push(...c);const l=s+n,h=!(a>l),d=`offset:${s} limit:${n} total:${a} isCompleted:${h} current:${i.length}`;return r.debug("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList ok. ${d}`),h?i:(s=l,this._pagingGetJoinedCommunityList({limit:n,offset:s,groupList:i}))}catch(e){if(e.code===ce)return r.warn("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList response size exceeds the limit, request count:${n}`),n=50,this._pagingGetJoinedCommunityList({limit:n,offset:s,groupList:i});throw e}})}_groupListTreeShaking(e){const t=new Map([...be.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++)be.deleteLocalGroup(o[e])}_isSyncCompleted(){return this._pagingStatus===f}_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:m,MaxMemberNum:h,MuteAllMember:d,Name:g,NextMsgSeq:_,Notification:f,Owner_Account:G,Type:b,LastRecallTime:I,SelfInfo:v,AtInfoList:C=[],SupportTopic:y}=e[o],A=he(r),M=this._convertSelfInfo(v),L=this._convertAtInfoList(u,C);t.push({groupCustomField:A,joinOption:i,createTime:n,avatar:s,groupID:u,introduction:a,inviteOption:c,lastInfoTime:p,lastMsgTime:l,memberCount:m,maxMemberCount:h,muteAllMembers:d,name:g,nextMessageSeq:_,notification:f,ownerID:G,type:b,selfInfo:M,_lastRevokedTime:I,_groupAtInfoList:L,isSupportTopic:y})}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}}_convertAtInfoList(e,t){if(0===t.length)return[];const o=[];return t.forEach(t=>{const{AtFlagList:r,AtMsgSeq:i,From_Account:n}=t;o.push({groupID:e,groupAtType:r,sequence:i,from:n})}),o}};var Me=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return ve(this,void 0,void 0,function*(){var t;this._preCheckParams(e);const{helper:{ChatError:o}}=this._core;try{const{utils:{isEmpty:o},common:{getCurrentUserID:r}}=this._core,i=yield function(e,t){return ve(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:m,isSupportTopic:h}=e;let d;l&&(d=l.map(e=>{const{userID:t,memberCustomField:o}=e;return{Member_Account:t,AppMemberDefinedData:o?de(o):void 0}}));const g={Name:o,Type:r,GroupId:i,Introduction:n,Notification:s,FaceUrl:u,MaxMemberCount:a,ApplyJoinOption:c,InviteJoinOption:p,MemberList:d,AppDefinedData:m,SupportTopic:h,webPushFlag:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:g})})}(Object.assign(Object.assign({},e),{ownerID:r()}),this._core),{GroupId:n,OverJoinedGroupLimit_Account:s=[]}=i||{},u=`${this._name}.createGroup ok, type:${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))),be.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:n})]);const a=be.getLocalGroup(n);return this._notNeedSendCustomMessage(e)||(this._sendCustomMessage(n,e.type),be.emitGroupListUpdate()),ye({group:a},{message:u})}catch(t){const{errorCode:r,errorInfo:i}=t;throw new o({functionName:"createGroup",code:r,message:i,moreMessage:` groupID:${e.groupID}`})}})}_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:Q});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),s({type:o})){if(u&&!s({groupID:r}))throw new this._core.helper.ChatError({code:Q});t.isSupportTopic=this._canIUseTopic(t)?1:0}}_canIUseMemberList(e){return!le(e)}_canIUseJoinOption(e){return pe(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){const{isSupportTopic:t}=e;return!0===t}_notNeedSendCustomMessage(e){const{type:t,isSupportTopic:o}=e,{OuterConstant:{GRP_AVCHATROOM:r,GRP_COMMUNITY:i}}=this._core;return t===r||t===i&&1===o}_sendCustomMessage(e,t){var o,r,i,n,s,u;const{OuterConstant:a}=this._core;let c="Create Group",p=d;t===a.GRP_COMMUNITY&&(c="Create Community",p=g);const l={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:c,cmd:p,opUser:this._core.store.get("login").userId,version:4})}},m=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(l);null===(u=null===(s=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===s?void 0:s.messageSender)||void 0===u||u.sendMessage(m,{})}};var Le=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;this._core.ssoLog.debug("handleGroupAttributesUpdated",`${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}),this._core.ssoLog.debug("initGroupAttributesCache",`${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!==E&&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),this._core.ssoLog.debug("refreshGroupAttributesCache",`${this._name}.refreshGroupAttributesCache. operation:${i} localMainSequence:${n} serverMainSequence:${o}`)}}_updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:o=[],operation:r}=e;r!==T?r!==w?(r===S&&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);this._core.ssoLog.debug("emitGroupAttributesUpdated",`${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}reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}};var De=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 ve(this,void 0,void 0,function*(){const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:o})})}(e,this._core);const{type:t}=be.getLocalGroup(e);return be.deleteLocalGroup(e),be.emitGroupListUpdate(),Le.deleteGroupAttributesCache(e),ye({groupID:e,type:t},{message:e})}catch(e){const{errorCode:o,errorInfo:r}=e;throw new t({functionName:"dismissGroup",code:o,message:r})}})}};var Se=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return ve(this,void 0,void 0,function*(){const{groupID:t,groupCustomFieldFilter:o}=e,r={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...p],AppDefinedDataFilter_Group:o,MemberInfoFilter:[...h]}},{helper:{ChatError:i}}=this._core;try{const e=yield this.getGroupProfileAdvance(r),{successGroupList:o,failureGroupList:i}=e;if(i.length>0)throw i[0];let n;return!be.hasLocalGroup(t)&&le(o[0].type)?n=new Ge(o[0]):(be.updateLocalGroup(o),n=be.getLocalGroup(t)),n.isSupportTopic||be.updateConversationGroupProfile(t),ye({group:n},{message:`groupID:${t}`})}catch(e){const{code:t,message:o}=e;throw new i({functionName:"getGroupProfile",code:t,message:o})}})}getGroupProfileAdvance(e){return ve(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 ve(this,void 0,void 0,function*(){const{ssoLog:t,utils:{isUndefined:o}}=this._core,{isCommunityProfile:r=!1}=e,i=Ie(e,["isCommunityProfile"]);if(0===i.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupIDList:o,responseFilter:r}=e,i={GroupIdList:o,ResponseFilter:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:i})})}(i,this._core),{GroupInfo:r=[]}=e||{},n=this._convertGroupProfileKey(r),s=n.filter(e=>o(e.errorCode)||0===e.errorCode),u=n.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return t.debug("_getGroupProfileAdvance",`${this._name}._getGroupProfileAdvance ok, groupID:${i.groupIDList.join(",")}`),{successGroupList:s,failureGroupList:u}}catch(e){if(r)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:m,MaxMemberNum:h,MemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:G,Owner_Account:b,ShutUpAllMember:I,ShutUpUntil:v,Type:C,MemberList:y,ErrorCode:A,ErrorInfo:M}=e[o],L=he(r),D=this._convertMembers(y);t.push({groupCustomField:L,joinOption:i,createTime:n,avatar:s,groupID:u,infoSequence:a,introduction:c,inviteOption:p,lastInfoTime:l,lastMsgTime:m,maxMemberCount:h,memberCount:d,muteAllMembers:g,name:_,nextMessageSeq:f,notification:G,ownerID:b,shutUpAllMember:I,muteUntil:v,type:C,members:D,errorCode:A,errorInfo:M})}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=he(r);t.push({memberCustomField:p,joinTime:i,userID:n,messageRemindType:s,sequence:u,nameCard:a,role:c})}return t}};var Oe=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){const{groupID:t,counterList:o=[],groupCounterSeq:r}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i,groupCounterSeq:n}=this.getLocalGroupCounters(t);if(r>0&&r<n)return;o.forEach(t=>{const{Key:o,Value:r=0}=t;e.set(o,r)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:r,counters:e,avChatRoomKey:i})}}initGroupCountersCache(e){const{groupID:t,avChatRoomKey:o}=e;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:o})}getLocalCounters(e,t){const o={};if(!this._hasLocalGroupCounters(e))return o;const{counters:r}=this.getLocalGroupCounters(e);if(t.length>0)t.forEach(e=>{r.has(e)&&(o[e]=r.get(e))});else for(const e of r.keys())o[e]=r.get(e);return o}deleteLocalGroupCounters(e){const{groupID:t,counterList:o=[],groupCounterSeq:r}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i}=this.getLocalGroupCounters(t);o.forEach(t=>{e.delete(t.key)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:r,counters:e,avChatRoomKey:i})}}setGroupCounters(e,t){if(!this._hasLocalGroupCounters(e))return;const o=this.getLocalGroupCounters(e),{counters:r}=o;let i=!1;Object.entries(t).forEach(([e,t])=>{r.has(e)&&r.get(e)!==t&&(r.set(e,t),i=!0)}),i&&this._groupCountersMap.set(e,Object.assign(Object.assign({},o),{lastUpdateTime:Date.now(),counters:r}))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}reset(){this._groupCountersMap.clear()}};var Te=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 ve(this,void 0,void 0,function*(){const{groupID:t}=e,{helper:{ChatError:o},OuterConstant:r,ssoLog:i}=this._core;try{if(be.hasLocalGroup(t))try{return yield Se.getGroupProfile({groupID:t}),ye({status:r.JOIN_STATUS_ALREADY_IN_GROUP,group:be.getLocalGroup(t)},{message:`groupID:${t} joinedStatus:${r.JOIN_STATUS_ALREADY_IN_GROUP}`})}catch(o){i.warn("joinGroup",`${this._name}.joinGroup ${t} was unjoined, start to join!`),be.deleteLocalGroup(t);return yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(e){const{errorCode:r,errorInfo:i}=e;throw new o({functionName:"joinGroup",code:r,message:i,moreMessage:`groupID:${t}`})}})}_applyJoinGroup(e){return ve(this,void 0,void 0,function*(){const{OuterConstant:t,helper:r,ssoLog:i}=this._core,{groupID:n}=e,s=Object.assign({},e),u=r.checkBusinessCapabilityBits(o);u&&(s.historyMessageFlag=1);const a=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,applyMessage:r,historyMessageFlag:i}=e,n={GroupId:o,ApplyMsg:r,HugeGroupHistoryMsgFlag:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:n})})}(s,this._core),{Type:c,JoinedStatus:p,LongPollingKey:l,StartSeq:m,HugeGroupFlag:h,AVChatRoomKey:d,RspMsgList:g=[]}=a||{},_=`groupID:${n} joinedStatus:${p} longPollingKey:${l} startSeq:${m} avChatRoomFlag:${h} canGetAVChatRoomHistoryMsg:${u}, historyMessageCount:${g.length}`;i.debug("_applyJoinGroup",`${this._name}._applyJoinGroup ok, ${_}`);let f=new Ge({groupID:n,type:c});if(p===t.JOIN_STATUS_WAIT_APPROVAL)return ye({status:t.JOIN_STATUS_WAIT_APPROVAL,group:f});if(p===t.JOIN_STATUS_SUCCESS){try{f=(yield Se.getGroupProfile({groupID:n})).data.group}catch(e){i.warn("_applyJoinGroup",`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${n}, errorCode:${null==e?void 0:e.code}`)}return this._handleJoinResult({group:f,avChatRoomFlag:h,longPollingKey:l,startSequence:m,avChatRoomKey:d,historyMessageList:g})}throw new this._core.helper.ChatError({code:te})})}_handleJoinResult(e){const{group:t,avChatRoomFlag:o,avChatRoomKey:r}=e;return 1===o?(Le.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:r}),Oe.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:r}),ye(e)):(be.updateLocalGroup([t]),be.emitGroupListUpdate(),ye({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t},{message:`groupID:${t.groupID}`}))}};var we=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 ve(this,void 0,void 0,function*(){if(!be.hasLocalGroup(e))throw new this._core.helper.ChatError({code:ee});const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:o})})}(e,this._core);const{type:t}=be.getLocalGroup(e);return be.deleteLocalGroup(e),be.emitGroupListUpdate(),Le.deleteGroupAttributesCache(e),ye({groupID:e,type:t},{message:`groupID:${e}`})}catch(o){const{errorCode:r,errorInfo:i}=o;throw new t({functionName:"quitGroup",code:r,message:i,moreMessage:`groupID:${e}`})}})}};var Ee=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return ve(this,void 0,void 0,function*(){try{const t=yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupIdList:[e],GroupBasePublicInfoFilter:[...l]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:o})})}(e,this._core),{GroupInfo:o=[]}=t||{},{AppDefinedData:r=[],ApplyJoinOption:i,CreateTime:n,FaceUrl:s,Introduction:u,InviteJoinOption:a,MaxMemberNum:c,MemberNum:p,Name:m,Owner_Account:h,Type:d,ErrorCode:g,ErrorInfo:_}=o[0];if(0!==g)throw new this._core.helper.ChatError({code:g,message:_});const f=he(r),G=new Ge({groupID:e,name:m,avatar:s,introduction:u,joinOption:i,inviteOption:a,maxMemberCount:c,memberCount:p,type:d,ownerID:h,createTime:n,groupCustomField:f});return ye({group:G})}catch(e){const{errorCode:t,errorInfo:o}=e;throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:t,message:o})}})}};var Ne=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return ve(this,void 0,void 0,function*(){const{groupID:t}=e,{utils:{isUndefined:o},ssoLog:r,helper:i}=this._core;let n=be.getLocalGroup(t);if(n){const{type:i}=n;this._canIUseJoinOption(i)||o(e.joinOption)||(r.warn("updateGroupProfile",`${this._name}.updateGroupProfile groupID:${t} 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 ve(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,l={GroupId:o,Name:r,FaceUrl:i,Introduction:n,Notification:s,ShutUpAllMember:u,ApplyJoinOption:a,InviteJoinOption:c,AppDefinedData:p?de(p):void 0};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:l})})}(e,this._core),n?(n.updateGroup(e),be.emitGroupListUpdate()):n=new Ge(e),ye({group:n},{message:`groupID:${t}`})}catch(e){const{errorCode:o,errorInfo:r}=e;throw new i.ChatError({code:o,message:r,moreMessage:`groupID:${t}`})}})}_canIUseJoinOption(e){return pe(e)||this._core.common.isCommunity({type:e})}};var Pe=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return ve(this,void 0,void 0,function*(){const t="changeGroupOwner",{groupID:o,newOwnerID:r}=e,i=be.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:X});if(r===u())throw new n.ChatError({functionName:t,code:Z});try{return yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,newOwnerID:r}=e,i={GroupId:o,NewOwner_Account:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:i})})}(e,this._core),i.ownerID=r,be.emitGroupListUpdate(),ye({group:i})}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var Re=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 ve(this,void 0,void 0,function*(){const t="getGroupOnlineMemberCount";if(!be.hasLocalGroup(e))return ye({memberCount:0});const o=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:r=0,memberCount:i=0}=t||{};if(o-r<=6e4)return ye({memberCount:i})}try{const o=yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:o})})}(e,this._core),{OnlineMemberNum:r=0}=o||{};this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:r});const i=`${this._name}.${t} ok. groupID:${e} memberCount:${r}`;return ye({memberCount:r},{message:i})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var Ue=new class{init(e,t){e.ssoLog.debug("GroupAction.init"),Ae.init(e),Me.init(e),De.init(e,t),Te.init(e,t),we.init(e,t),Ee.init(e),Se.init(e),Ne.init(e),Pe.init(e),Re.init(e,t)}dismissGroup(e){return De.dismissGroup(e)}joinGroup(e){return Te.joinGroup(e)}quitGroup(e){return we.quitGroup(e)}getGroupOnlineMemberCount(e){return Re.getGroupOnlineMemberCount(e)}};var ke=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return ve(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})]);this._core.ssoLog.debug("getGroupApplicationList",`${this._name}.${e} ok.`);const o=this._handleGroupApplicationResult([...t[0],...t[1]]);return ye({applicationList:o})}catch(t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}})}_getGroupApplicationList(e){return ve(this,void 0,void 0,function*(){const{type:t,startTime:o=0,limit:r=20}=e||{},{common:i}=this._core;let n;try{n=yield function(e,t){return ve(this,void 0,void 0,function*(){const{type:o,startTime:r,limit:i,handleAccount:n}=e,s={Type:o,StartTime:r,Limit:i,Handle_Account:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:s})})}({type:t,startTime:o,limit:r,handleAccount:i.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;n={}}const{NextStartTime:s=0,PendencyList:u=[]}=n||{};if(0===s)return u;const a=yield this._getGroupApplicationList(Object.assign(Object.assign({},e),{startTime:s}));return[...u,...a]})}_handleGroupApplicationResult(e){const t=[];return e.forEach(e=>{const o=this._convertApplicationData(e),{handled:r}=o,i=Ie(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 $e=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return ve(this,void 0,void 0,function*(){const{application:t}=e,o=this._handleParams(e);try{(null==t?void 0:t.applicationType)===v?yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,invitee:u}=e,a={GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,Invited_Account:u};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:a})})}(o,this._core):yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,messageKey:u}=e,a={GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,MsgKey:u};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:a})})}(o,this._core);const e=be.getLocalGroup(o.groupID);return ye({group:e})}catch(e){throw new this._core.helper.ChatError({functionName:"handleGroupApplication",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_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)===v&&(p=n.userID),{handleAction:o,handleMessage:r,applicant:s,invitee:p,groupID:u,authentication:a,messageKey:c}}};var Fe=new class{init(e){e.ssoLog.debug("GroupApplication.init"),ke.init(e),$e.init(e)}};let qe=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&&me(this.memberCustomField,t.memberCustomField),r(this,t,["memberCustomField","marks","onlineStatus","muteTime"],i)}};function je(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userID:r,muteTime:i,role:n,nameCard:s,memberCustomField:u}=e;let a;u&&(a=de(u));const c={GroupId:o,Member_Account:r,ShutUpTime:i,Role:n,NameCard:s,AppMemberDefinedData:a};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:c})})}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 ve(this,void 0,void 0,function*(){const t="getGroupMemberList",{groupID:o,offset:r=0,count:i=100,role:n="",filter:s=""}=e,u=be.getLocalGroup(o),a=i>100?100:i,c={groupID:o,offset:r,limit:a,memberRoleFilter:C.includes(n)?[n]:void 0,memberInfoFilter:y};try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{isCommunity:o}=t.common,{groupID:r,offset:i,limit:n,memberRoleFilter:s,memberInfoFilter:u}=e,a={GroupId:r,Limit:n,MemberRoleFilter:s,MemberInfoFilter:u};return o({groupID:r})?a.Next=String(i):a.Offset=i,t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:a})})}(c,this._core),{MemberList:i,MemberNum:n,Next:s}=e||{},p=`${this._name}.${t} ok, totalMemberCount:${n} next:${s}`,{utils:{isArray:l,isEmpty:m},common:{isCommunity:h}}=this._core;if(u&&(u.memberCount=n),!l(i)||0===i.length)return ye({memberList:[],offset:0},{message:p});let d=r+a;h({groupID:o})&&(d=m(s)?0:s),i.length<a&&(d=0);let g=this._convertMemberInfo(i);g=yield this._patchAvatarAndNick(g);const _=this._generateGroupMember(g);return ye({memberList:_,offset:d},{message:p})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_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,NameCard:c}=e[o],p=he(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:p,nameCard:c})}return t}_patchAvatarAndNick(e){return ve(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 qe(e[o]);t.push(r)}return t}};var xe=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return ve(this,void 0,void 0,function*(){const t="getGroupMemberProfile",{groupID:o,userIDList:r,memberCustomFieldFilter:i}=e,n=be.getLocalGroup(o),{helper:s,utils:{isArray:u},ssoLog:a}=this._core;if(n&&le(n.type))throw new s.ChatError({functionName:t,replacement1:t,code:ue});r.length>50&&(a.warn("getGroupMemberProfile",`${this._name}.${t} userIDList length:${r.length} exceeds limit 50`),r.splice(50));const c=`userIDList length:${r.length} groupID:${o}`;try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userIDList:r,memberInfoFilter:i,memberCustomFieldFilter:n}=e,s={GroupId:o,Member_List_Account:r,MemberInfoFilter:i,AppDefinedDataFilter_GroupMember:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:s})})}({groupID:o,userIDList:r,memberCustomFieldFilter:i,memberInfoFilter:[...y]},this._core),{MemberList:t}=e||{};if(!u(t)||0===t.length)return ye({memberList:[]});let n=this._convertMemberInfo(t);n=yield this._getMemberAvatarAndNick(n);const s=this._generateGroupMember(n);return ye({memberList:s},{message:c})}catch(e){throw new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:c})}})}_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,NameCard:c}=e[o],p=he(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:p,nameCard:c})}return t}_getMemberAvatarAndNick(e){return ve(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 qe(e[o]);t.push(r)}return t}};var Ve=new class{constructor(){this._name="AddGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(e){return ve(this,void 0,void 0,function*(){const t="addGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n}=this._core;if(i&&le(i.type))throw new n.ChatError({functionName:t,code:oe});const s=r.map(e=>({Member_Account:e}));try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userIDList:r}=e,i={GroupId:o,MemberList:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:i})})}({groupID:o,userIDList:s},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:r,successUserIDList:n,existedUserIDList:u,overLimitUserIDList:a}=this._handleResult(t);return ye({failureUserIDList:r,successUserIDList:n,existedUserIDList:u,overLimitUserIDList:a,group:i},{message:` groupID:${o} successUserIDList:${n} failureUserIDList:${r} existedUserIDList:${u} overLimitUserIDList:${a}`})}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_handleResult(e){const t=[],o=[],r=[],i=[];return e.forEach(e=>{const{Result:n,Member_Account:s}=e;n===A?t.push(s):n===M?o.push(s):n===L?r.push(s):n===D&&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 ve(this,void 0,void 0,function*(){const t="deleteGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n,utils:{isUndefined:s},ssoLog:u}=this._core;if(s(i))throw new n.ChatError({functionName:t,code:z});r.length>20&&(u.warn("deleteGroupMember",`${this._name}.${t} userIDList length:${r.length} exceeds limit 20`),r.splice(20));try{return yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userIDList:r,reason:i}=e,n={GroupId:o,MemberToDel_Account:r,Reason:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:n})})}({groupID:o,userIDList:r},this._core),ye({group:i,userIDList:r},{message:`groupID:${o} userIDList length:${r.length}`})}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var Be=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(e){return ve(this,void 0,void 0,function*(){const{helper:t}=this._core,{groupID:o,userID:r,muteTime:i}=e,n=` groupID:${o} userID:${r} muteTime:${i}`;this._preCheckSettingMuteParams(e);try{yield je(e,this._core);const t=be.getLocalGroup(o),s=new qe({userID:r,muteTime:i});return ye({group:t,member:s},{message:n})}catch(e){throw new t.ChatError({functionName:"setGroupMemberMuteTime",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:n})}})}_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:se})}};var He=new class{constructor(){this._name="SetGroupMemberRole"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(e){return ve(this,void 0,void 0,function*(){const t="setGroupMemberRole",{helper:o}=this._core,{groupID:r,userID:i,role:n}=e,s=`${this._name}.${t} ok, groupID:${r} userID:${i} role:${n}`;this._preCheckSettingRoleParams(e);try{yield je(e,this._core);const t=be.getLocalGroup(r),o=new qe({userID:i,role:n});return ye({group:t,member:o},{message:s})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:s})}})}_preCheckSettingRoleParams(e){var t;const{groupID:o,userID:r,role:i}=e,{store:n,helper:s,OuterConstant:u,common:{isCommunity:a}}=this._core,c=be.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:re});if(r===n.get("login").userId)throw new s.ChatError({functionName:"setGroupMemberRole",code:ne});const p=[...C];if(a({groupID:o})&&p.push(u.GRP_MBR_ROLE_CUSTOM),!p.includes(i))throw new s.ChatError({functionName:"setGroupMemberRole",code:ie})}};var We=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return ve(this,void 0,void 0,function*(){const t="setGroupMemberNameCard",{helper:o,common:{getCurrentUserID:r}}=this._core;this._preCheckSettingNameCardParams(e);try{const{groupID:o,userID:i=r(),nameCard:n}=e,s={groupID:o,userID:i,nameCard:n};yield je(s,this._core);const u=`${this._name}.${t} ok, groupID:${o} userID:${i} nameCard:${n}`,a=be.getLocalGroup(o),c=new qe({userID:i,nameCard:n});return ye({group:a,member:c},{message:u})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:logText})}})}_preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:o}=this._core,r=be.getLocalGroup(t);if(le(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberNameCard",code:ue})}};var Ye=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return ve(this,void 0,void 0,function*(){const t="setGroupMemberCustomField",{helper:o,common:{getCurrentUserID:r}}=this._core;this._preCheckSettingCustomFiledParams(e);const{groupID:i,userID:n=r(),memberCustomField:s}=e,u=`${this._name}.${t} ok, groupID:${i}userID:${n} memberCustomField:${JSON.stringify(s)}`;try{const e={groupID:i,userID:n,memberCustomField:s};yield je(e,this._core);const t=be.getLocalGroup(i),o=new qe({userID:n,memberCustomField:s});return ye({group:t,member:o},{message:u})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:u})}})}_preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:o}=this._core,r=be.getLocalGroup(t);if(le(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberCustomField",code:ue})}};var Qe=new class{init(e,t){e.ssoLog.debug("GroupMember.init"),Ke.init(e,t),xe.init(e),Ve.init(e),Je.init(e,t),Be.init(e),He.init(e),We.init(e),Ye.init(e)}getGroupMemberList(e){return Ke.getGroupMemberList(e)}deleteGroupMember(e){return Je.deleteGroupMember(e)}};var ze=new class{init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(t){return ve(this,void 0,void 0,function*(){const o="getGroupCounters";try{ge(o,r);const{groupID:i,keyList:n=[]}=t,{avChatRoomKey:s,lastUpdateTime:u}=Oe.getLocalGroupCounters(i);if(!(Date.now()-u>=this._getExpireTime())){return{code:0,data:{counters:Oe.getLocalCounters(i,n)}}}const a=yield function(