@tencentcloud/lite-chat 1.2.0 → 1.3.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 +164 -4
- package/README.md +15 -12
- package/basic.d.ts +3110 -0
- package/basic.es.js +2 -0
- package/basic.js +2 -0
- package/index.d.ts +1 -1
- package/package.json +28 -13
- 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.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.d.ts +8 -0
- package/plugins/follow.es.js +1 -0
- package/plugins/follow.js +1 -0
- 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 +4 -1
- package/plugins/message-enhancer.js +4 -1
- package/plugins/rich-media-message.es.js +1 -1
- package/plugins/rich-media-message.js +1 -1
- package/plugins/signaling.es.js +1 -0
- package/plugins/signaling.js +1 -0
- 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 -0
- package/professional.js +5 -0
- package/standard.es.js +5 -0
- package/standard.js +5 -0
- package/index.es.js +0 -1
- package/index.js +0 -1
- package/plugins/user-enhancer.d.ts +0 -8
package/plugins/group.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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="@TGS#_",p="@TOPIC#_",l="notStart",h="resolved",m="rejected",d=10018,g=11e3,_=2,f=["Owner","Admin","Member"],G=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],b=0,v=1,I=2,y=4,C=1,M=2,A=1,D=2,L=3,S=4,O=5,w=1,T=0,N=4,$=6,E=1,R=2,P=3,U=4,k=5,q=6,F=400,j=300,x={from:!0,groupID:!0,groupName:!0,to:!0},K={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},V=2,J=4,B=5,H=7,Y=8,W=15,Q=20,z=2600,X=2602,Z=2603,ee=2620,te=2621,oe=2623,re=2660,ie=2661,ne=2681,se=2683,ue=2684,ae=2685,ce=2687,pe=3122,le=t=>t===e.core.OuterConstant.GRP_PUBLIC,he=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,me=({type:t,groupID:o})=>t===e.core.OuterConstant.GRP_COMMUNITY||`${o}`.startsWith(c)&&!`${o}`.includes(p),de=(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},ge=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},_e=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},fe=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];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.memberNum=0,this.memberCount=0,this.maxMemberNum=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}_initGroup(e){for(const t in e)fe.indexOf(t)<0||("selfInfo"!==t?"isSupportTopic"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),this[t]=e[t]):this.isSupportTopic=1===e[t]:this.updateSelfInfo(e[t]))}updateGroup(t){const{utils:{isArray:o,isUndefined:r,isNumber:i},common:{deepMerge:n}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);const s=JSON.parse(JSON.stringify(t));s.lastMsgTime&&(this.lastMessage.lastTime=s.lastMsgTime),r(s.muteAllMembers)||(s.muteAllMembers="On"===s.muteAllMembers),s.groupCustomField&&de(this.groupCustomField,s.groupCustomField),r(s.memberNum)||(this.memberCount=s.memberNum),r(s.maxMemberNum)||(this.maxMemberCount=s.maxMemberNum),r(s.isSupportTopic)||(this.isSupportTopic=i(s.isSupportTopic)?1===s.isSupportTopic:s.isSupportTopic),n(this,s,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),o(s.members)&&s.members.length>0&&s.members.forEach((e=>{e.userID===this.selfInfo.userID&&n(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(),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 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(){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 ve(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 Ie(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 ye(e,t,o){return Ie(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 Ce=function(e){return{code:0,data:e||{}}};var Me=new class{constructor(){this._name="GetGroupList",this._pagingStatus=l,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 Ie(this,void 0,void 0,(function*(){if(console.log(`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===m||this._pagingStatus===l)return this._syncGroupList().then((()=>{const e=be.getLocalGroupList();return Ce({groupList:e,isSyncCompleted:this._isSyncCompleted()})})).catch((e=>{throw console.error(`${this._name}.getGroupList fail:`,e),e}));const e=be.getLocalGroupList();return console.log(`${this._name}.getGroupList return group count:${e.length}`),Ce({groupList:e,isSyncCompleted:this._isSyncCompleted()})}))}_syncGroupList(){return Ie(this,void 0,void 0,(function*(){this._pagingStatus===l&&be.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=h,this._groupListTreeShaking(t),be.updateLocalGroup(t);const o=be.getLocalGroupList().length;return console.log(`${this._name}._syncGroupList ok, count:${o}`),be.emitGroupListUpdate(),t}catch(e){throw this._pagingStatus=m,console.error(`${this._name}._syncGroupList fail:`,e),e}}))}_pagingGetGroupList(e){return Ie(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 Ie(this,void 0,void 0,(function*(){const{type:o,limit:r,offset:i,memberAccount:n,responseFilter:s}=e;return ye(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===d)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===g&&console.log(`${this._name}._pagingGetGroupList ok. community unavailable`),o;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===h}_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,MaxMemberNum:h,MuteAllMember:m,Name:d,NextMsgSeq:g,Notification:_,Owner_Account:f,ShutUpAllMember:G,Type:b,LastRecallTime:v,SelfInfo:I}=e[o],y=ge(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,maxMemberNum:h,muteAllMember:m,name:d,nextMessageSeq:g,notification:_,ownerID:f,shutUpAllMember: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 Ae=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return Ie(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 Ie(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?_e(o):void 0}}))),ye("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 Ce({group:new Ge(e)});be.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:n})]),this._sendCustomMessage(n,e.type);const u=be.getLocalGroup(n);return be.emitGroupListUpdate(),Ce({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}}=this._core,s=!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:z});if(!me({type:o})){if(s&&me({groupID:r}))throw new this._core.helper.ChatError({code:X});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),me({type:o})&&s&&!me({groupID:r}))throw new this._core.helper.ChatError({code:X})}_canIUseMemberList(e){return!he(e)}_canIUseJoinOption(e){return le(e)||me({type:e})}_canIUseTopic(e){const{type:t,isSupportTopic:o}=e,{utils:{isUndefined:r}}=this._core;return me({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 De=new class{constructor(){this._name="DismissGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"dismissGroup",context:this})}dismissGroup(e){return Ie(this,void 0,void 0,(function*(){console.log(`${this._name}.dismissGroup groupID:${e}`);try{return yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("group_open_http_svc.destroy_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.dismissGroup ok.`),be.deleteLocalGroup(e),be.emitGroupListUpdate(),Ce({groupID:e})}catch(e){throw console.error(`${this._name}.dismissGroup fail:`,e),e}}))}};var Le=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return Ie(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!be.hasLocalGroup(t)&&he(o[0].type)?n=new Ge(o[0]):(be.updateLocalGroup(o),n=be.getLocalGroup(t)),n.isSupportTopic||be.updateConversationGroupProfile(t),console.log(`${this._name}.getGroupProfile ok.`),Ce({group:n})}catch(e){throw console.error(`${this._name}.getGroupProfile fail:`,e),e}}))}getGroupProfileAdvance(e){return Ie(this,void 0,void 0,(function*(){const{groupIDList:t}=e,o=t.filter((e=>!me({groupID:e}))),r=t.filter((e=>me({groupID:e})));o.length>50&&(o.length=50),r.length>50&&(r.length=50);const i=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:o})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:r,isCommunityProfile:!0}))]),n=[],s=[];return i.forEach((e=>{n.push(...e.successGroupList),s.push(...e.failureGroupList)})),{successGroupList:n,failureGroupList:s}}))}_getGroupProfileAdvance(e){return Ie(this,void 0,void 0,(function*(){const{isCommunityProfile:t=!1}=e,o=ve(e,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupIDList:o,responseFilter:r}=e;return ye("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=ge(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,maxMemberNum:m,memberNum:d,muteAllMember: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=ge(r);t.push({memberCustomField:p,joinTime:i,userID:n,messageRemindType:s,sequence:u,nameCard:a,role:c})}return t}};var Se=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 Ie(this,void 0,void 0,(function*(){const{groupID:t}=e;try{if(be.hasLocalGroup(t))try{return yield Le.getGroupProfile({groupID:t}),Ce({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS})}catch(o){console.warn(`${this._name}.joinGroup ${t} was unjoined, start to join!`),be.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 Ie(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 Ie(this,void 0,void 0,(function*(){const{groupID:o,applyMessage:r,historyMessageFlag:i}=e;return ye("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 Le.getGroupProfile({groupID:i})).data.group}catch(t){e=new Ge({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:re})}))}_handleJoinResult(e){const{group:t,avChatRoomFlag:o}=e;return 1===o?Ce(e):(be.updateLocalGroup([t]),be.emitGroupListUpdate(),Ce({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}};var Oe=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 Ie(this,void 0,void 0,(function*(){if(!be.hasLocalGroup(e))throw new this._core.helper.ChatError({code:oe});try{yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("group_open_http_svc.quit_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.quitGroup ok, groupID:${e}`);const{type:t}=be.getLocalGroup(e);return be.deleteLocalGroup(e),be.emitGroupListUpdate(),Ce({groupID:e,type:t})}catch(e){throw console.error(`${this._name}.quitGroup fail:`,e),e}}))}};var we=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return Ie(this,void 0,void 0,(function*(){console.log(`${this._name}.searchGroupByID groupID:${e}`);try{const t=yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("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=ge(r),G=new Ge({groupID:e,name:h,avatar:u,introduction:a,joinOption:n,inviteOption:c,maxMemberNum:p,memberNum:l,type:d,ownerID:m,createTime:s,groupCustomField:f});return Ce({group:G})}catch(e){throw console.error(`${this._name}.searchGroupByID fail:`,e),e}}))}};var Te=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return Ie(this,void 0,void 0,(function*(){const{groupID:t}=e,{utils:{isUndefined:o}}=this._core;let r=be.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 Ie(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 ye("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?_e(p):void 0},t)}))}(e,this._core),console.log(`${this._name}.updateGroupProfile groupID:${t} ok.`),r?(r.updateGroup(e),be.emitGroupListUpdate()):r=new Ge(e),Ce({group:r})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}}))}_canIUseJoinOption(e){return le(e)||me({type:e})}};var Ne=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return Ie(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:ee});if(r===u())throw new n.ChatError({functionName:t,code:te});console.log(`${this._name}.${t} groupID:${o} newOwnerID:${r}`);try{return yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,newOwnerID:r}=e;return ye("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,be.emitGroupListUpdate(),Ce({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 $e=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupOnlineMemberCount",context:this})}getGroupOnlineMemberCount(e){return Ie(this,void 0,void 0,(function*(){const t="getGroupOnlineMemberCount",o=be.hasLocalGroup(e);if(console.log(`${this._name}.${t} groupID:${e} isAVChatRoom:false hasGroup:${o}`),!o)return Ce({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 Ce({memberCount:i})}try{const o=yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("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}`),Ce({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 Ee=new class{init(e,t){console.log("GroupAction.init"),Me.init(e),Ae.init(e),De.init(e),Se.init(e,t),Oe.init(e,t),we.init(e),Le.init(e),Te.init(e),Ne.init(e),$e.init(e)}joinGroup(e){return Se.joinGroup(e)}quitGroup(e){return Oe.quitGroup(e)}};function Re(e,t,o){return Ie(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 Pe=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return Ie(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 Ce({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(e){return Ie(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 Ie(this,void 0,void 0,(function*(){const{type:o,startTime:r,limit:i,handleAccount:n}=e;return Re(me({type:o})?"million_group_open_http_svc.get_pendency":"group_open_http_svc.get_pendency",{StartTime:r,Limit:i,Handle_Account:n},t)}))}({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=ve(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 Ue=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return Ie(this,void 0,void 0,(function*(){const t="handleGroupApplication",{application:o}=e,r=this._handleParams(e);try{(null==o?void 0:o.applicationType)===_?yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,invitee:u}=e;return Re(me({groupID:o})?"million_group_open_http_svc.handle_invite_join_permission_group":"group_open_http_svc.handle_invite_join_permission_group",{GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,Invited_Account:u},t)}))}(r,this._core):yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,messageKey:u}=e;return Re(me({groupID:o})?"million_group_open_http_svc.handle_apply_join_group":"group_open_http_svc.handle_apply_join_group",{GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,MsgKey:u},t)}))}(r,this._core),console.log(`${this._name}.${t} ok.`);const e=be.getLocalGroup(r.groupID);return Ce({group:e})}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}}))}_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)===_&&(p=n.userID),{handleAction:o,handleMessage:r,applicant:s,invitee:p,groupID:u,authentication:a,messageKey:c}}};var ke=new class{init(e){console.log("GroupApplication.init"),Pe.init(e),Ue.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&&de(this.memberCustomField,t.memberCustomField),r(this,t,["memberCustomField","marks","onlineStatus","muteTime"],i)}};function Fe(e,t,o){return Ie(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 je(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,userID:r,muteTime:i,role:n,nameCard:s,memberCustomField:u}=e;let a;u&&(a=_e(u));return Fe("group_open_http_svc.modify_group_member_info",{GroupId:o,Member_Account:r,ShutUpTime:i,Role:n,NameCard:s,AppMemberDefinedData:a},t)}))}var xe=new class{constructor(){this._name="GetGroupMemberList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberList",context:this})}getGroupMemberList(e){return Ie(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=be.getLocalGroup(o);u&&he(u.type);const a=i>100?100:i,c={groupID:o,offset:r,limit:a,memberRoleFilter:f.includes(n)?[n]:void 0,memberInfoFilter:G};try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,offset:r,limit:i,memberRoleFilter:n,memberInfoFilter:s}=e;return Fe("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}}=this._core;if(u&&(u.memberNum=n),!p(i)||0===i.length)return Ce({memberList:[],offset:0});let h=r+a;me({groupID:o})&&(h=l(s)?0:s),i.length<a&&(h=0);let m=this._convertMemberInfo(i);m=yield this._patchAvatarAndNick(m);const d=this._generateGroupMember(m);return Ce({memberList:d,offset:h})}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=ge(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_patchAvatarAndNick(e){return Ie(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 Ke=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return Ie(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}}=this._core;if(n&&he(n.type))throw new s.ChatError({functionName:t,code:ce});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 Ie(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,memberInfoFilter:i,memberCustomFieldFilter:n}=e;return Fe("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:[...G]},this._core);console.log(`${this._name}.${t} ok.`);const{MemberList:n}=e||{};if(!u(n)||0===n.length)return Ce({memberList:[]});let s=this._convertMemberInfo(n);s=yield this._getMemberAvatarAndNick(s);const a=this._generateGroupMember(s);return Ce({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=ge(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_getMemberAvatarAndNick(e){return Ie(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 Ie(this,void 0,void 0,(function*(){const t="addGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n}=this._core;if(i&&he(i.type))throw new n.ChatError({functionName:t,code:ie});const s=r.map((e=>({Member_Account:e})));try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r}=e;return Fe("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}`),Ce({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===b?t.push(s):n===v?o.push(s):n===I?r.push(s):n===y&&i.push(s)})),{failureUserIDList:t,successUserIDList:o,existedUserIDList:r,overLimitUserIDList:i}}};var Je=new class{constructor(){this._name="DeleteGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupMember",context:this})}deleteGroupMember(e){return Ie(this,void 0,void 0,(function*(){const t="deleteGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n,utils:{isUndefined:s}}=this._core;if(s(i))throw new n.ChatError({functionName:t,code:Z});if(he(i.type))throw new n.ChatError({functionName:t,code:pe});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 Ie(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,reason:i}=e;return Fe("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}`),Ce({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 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 Ie(this,void 0,void 0,(function*(){const t="setGroupMemberMuteTime",{helper:o}=this._core;this._preCheckSettingMuteParams(e);try{yield je(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=be.getLocalGroup(o),s=new qe({userID:r,muteTime:i});return Ce({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:ae})}};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 Ie(this,void 0,void 0,(function*(){const t="setGroupMemberRole",{helper:o}=this._core;this._preCheckSettingRoleParams(e);try{yield je(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=be.getLocalGroup(o),s=new qe({userID:r,role:i});return Ce({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}=this._core,a=be.getLocalGroup(o);if((null===(t=null==a?void 0:a.selfInfo)||void 0===t?void 0:t.role)!==u.GRP_MBR_ROLE_OWNER)throw new s.ChatError({functionName:"setGroupMemberRole",code:ne});if(r===n.get("login").userId)throw new s.ChatError({functionName:"setGroupMemberRole",code:ue});const c=[...f];if(me({groupID:o})&&c.push(u.GRP_MBR_ROLE_CUSTOM),!c.includes(i))throw new s.ChatError({functionName:"setGroupMemberRole",code:se})}};var Ye=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupMemberNameCard",{helper:o}=this._core;this._preCheckSettingNameCardParams(e);try{yield je(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=be.getLocalGroup(o),s=new qe({userID:r,nameCard:i});return Ce({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=be.getLocalGroup(t);if(he(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberNameCard",code:ce})}};var We=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupMemberCustomField",{helper:o}=this._core;this._preCheckSettingCustomFiledParams(e);try{yield je(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=be.getLocalGroup(o),s=new qe({userID:r,memberCustomField:i});return Ce({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=be.getLocalGroup(t);if(he(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberCustomField",code:ce})}};var Qe=new class{constructor(){this._name="MarkGroupMemberList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"markGroupMemberList",context:this})}markGroupMemberList(e){return Ie(this,void 0,void 0,(function*(){const t="markGroupMemberList",{helper:o}=this._core,{groupID:r,markType:i,enableMark:n,userIDList:s=[]}=e;s.length>500&&(console.warn(`${this._name}.${t} userIDList length:${s.length} exceeds limit 500`),s.splice(500));const u=s.map((e=>({Member_Account:e,Marks:[i]}))),a=n?C:M;try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,operationType:r,memberList:i}=e;return Fe("group_open_avchatroom_http_svc.modify_user_info",{GroupId:o,CommandType:r,MemberList:i},t)}))}({groupID:r,memberList:u,operationType:a},this._core),{MemberList:o=[]}=e||{},{successUserIDList:i,failureUserIDList:n}=this._handleResult(o,s);return console.log(`${this._name}.${t} ok, groupID:${r} success count:${i.length} fail count:${n.length}`),Ce({successUserIDList:i,failureUserIDList:n})}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}}))}_handleResult(e,t){const o=[],r=[];return e.length===t.length?(o.push(...t),{successUserIDList:o,failureUserIDList:r}):(t.forEach((t=>{e.find((e=>e.Member_Account===t))?o.push(t):r.push(t)})),{successUserIDList:o,failureUserIDList:r})}};var ze=new class{init(e){console.log("GroupMember.init"),xe.init(e),Ke.init(e),Ve.init(e),Je.init(e),Be.init(e),He.init(e),Ye.init(e),We.init(e),Qe.init(e)}};var Xe=new class{init(e){this._core=e}};function Ze(e,t,o){return Ie(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 et=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)}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!==O&&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!==L?r!==S?(r===A&&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 tt=new class{constructor(){this._name="InitGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="initGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n}=et.getGroupAttributesCache(o),s=et.convertKeyValueMapToList(r);try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ze("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 et.saveGroupAttributesCacheValuesCopy(o),et.refreshGroupAttributesCache({groupID:o,serverMainSequence:u,groupAttributeList:c,operation:A}),et.emitGroupAttributesUpdated(o),Ce({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 ot=new class{constructor(){this._name="SetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n,values:s}=et.getGroupAttributesCache(o),u=et.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 Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ze("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 et.saveGroupAttributesCacheValuesCopy(o),et.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:c,operation:D}),et.emitGroupAttributesUpdated(o),Ce({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 rt=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(e){return Ie(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}`),et.saveGroupAttributesCacheValuesCopy(o),et.refreshGroupAttributesCache({groupID:o,serverMainSequence:n,groupAttributeList:u,operation:s}),et.emitGroupAttributesUpdated(o),Ce({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 Ie(this,void 0,void 0,(function*(){const{serverMainSequence:o,avChatRoomKey:r,values:i}=et.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 Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ze("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:S}}))}_clearGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const{serverMainSequence:t,avChatRoomKey:o,values:r}=et.getGroupAttributesCache(e),i=[...r.keys()],n=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,avChatRoomKey:i}=e;return Ze("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:L}}))}};var it=new class{constructor(){this._name="GetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="getGroupAttributes",{groupID:o}=e,{avChatRoomKey:r,lastUpdateTime:i,localMainSequence:n,serverMainSequence:s}=et.getGroupAttributesCache(o);if(Date.now()-i>=3e4||n<s)try{yield this.getGroupAttributesFromServer({groupID:o,avChatRoomKey:r});const i=et.getGroupAttributesCacheValues(e);return console.log(`${this._name}.${t} from server. groupID:${o}`),Ce({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=et.getGroupAttributesCacheValues(e);return console.log(`${this._name}.${t} from cache. groupID:${o}`),Ce({groupAttributes:u})}))}getGroupAttributesFromServer(e){return Ie(this,void 0,void 0,(function*(){const{utils:{isUndefined:t}}=this._core,{groupID:o,avChatRoomKey:r}=e,i=t(r)?T:w,n=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,groupType:r,avChatRoomKey:i}=e;return Ze("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}}));et.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:e,operation:O})}}))}};var nt=new class{init(e){console.log("GroupAttribute.init"),tt.init(e),ot.init(e),rt.init(e),it.init(e),et.init(e)}isGroupAttributesUpdated(e){return et.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){const{to:t,elements:{newGroupProfile:o}}=e,{groupAttributeOption:r}=o,{serverMainSequence:i,withChangedAttributeInfo:n}=r,{localMainSequence:s}=et.getGroupAttributesCache(t),u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:${u}`),0!==u)if(et.saveGroupAttributesCacheValuesCopy(t),1!==n||1!==u){if(et.hasGroupAttributesCache(t)){const{avChatRoomKey:e}=et.getGroupAttributesCache(t);it.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then((()=>{et.emitGroupAttributesUpdated(t)})).catch((()=>{}))}}else et.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:r})}};function st(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?ut(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 ut(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"MemberNum":t.memberNum=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=>at(e)));break;case"MsgOperatorMemberExtraInfo":t.operatorInfo=at(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 at(e){const{ImageUrl:t,NickName:o,Role:r,UserId:i}=e;return{avatar:t,nick:o,role:r,userID:i}}class ct{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(t)}static parseServerPushElement(e){const t=ut(e);return new ct(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"memberNum":this.content.memberNum=e[t],this.content.memberCount=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];x[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 pt=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,ct)}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=st(o[e],"tips");if(t===$&&nt.isGroupAttributesUpdated(i)){nt.handleGroupAttributesUpdated(i);continue}const{groupProfile:{groupID:s}}=i;if(!be.hasLocalGroup(s))continue;const u=this._assembleMessage(i);if(t===$&&(u._onlineOnlyFlag=!0,n.push(u)),t===N){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 ct(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!==E&&r!==P&&r!==U&&r!==k||(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 E:this._handleNewMemberJoined(e);break;case R:this._handleMemberQuitted(e);break;case P:this._handleMemberKicked(e);break;case q: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=be.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])})),be.emitGroupListUpdate(),be.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){const{common:o,OuterConstant:r}=this._core,i=be.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===F?r=o.GRP_MBR_ROLE_OWNER:t===j&&(r=o.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:r})}_handleGroupMemberCountUpdated(e){const{memberCount:t,groupProfile:{groupID:o}}=e.payload,r=be.getLocalGroup(o),{utils:{isNumber:i}}=this._core;r&&i(t)&&r.memberCount!==t&&(r.memberCount=t,be.emitGroupListUpdate(),be.updateConversationGroupProfile(o))}};class lt{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];K[r]&&(this.content.groupProfile[r]=e[r])}}}var ht=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,lt)}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=st(e[i],"system"),{elements:{operationType:s}}=n;if(s===W)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 lt(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 V:this._handleGroupJoinResult(e);break;case J:this._handleMemberKicked(e);break;case B:this._handleGroupDismissed(e);break;case H:this._handleGroupInvitedResult(e);break;case Y:this._handleGroupQuitResult(e);break;case Q:this._handleMessageRemindTypeSynced(e)}}))}_handleGroupJoinResult(e){const{groupProfile:t}=e.payload,{groupID:o,type:r}=t,i=be.hasLocalGroup(o);console.log(`${this._name}._handleGroupJoinResult groupID:${o} type:${r} hasLocalGroup:${i}`),i||he(r)||(be.updateLocalGroup([Object.assign({},t)]),be.emitGroupListUpdate())}_handleMemberKicked(e){const{groupProfile:{groupID:t,type:o}}=e.payload;be.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupDismissed(e){const{groupProfile:{groupID:t,type:o}}=e.payload;be.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupInvitedResult(e){const{groupProfile:t}=e.payload,{groupID:o}=t,r=be.hasLocalGroup(o);console.log(`${this._name}._handleGroupInvitedResult groupID:${o} hasLocalGroup:${r}`),r||(be.updateLocalGroup([Object.assign({},t)]),be.emitGroupListUpdate())}_handleGroupQuitResult(e){const{groupProfile:{groupID:t,type:o}}=e.payload,r=be.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})}_deleteLocalGroup(e,t){if(he(t)){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core;t.deleteConversation(`${o}${e}`)}be.deleteLocalGroup(e),be.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 mt=new class{init(e){this._core=e,console.log("GroupNotificationHandler.init"),pt.init(e),ht.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){pt.onNewGroupTips(e)}_onNewGroupSystemNotification(e){ht.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 dt={required:!0,rules:["string"],allowEmpty:!1},gt={required:!0,rules:["number"],allowEmpty:!1},_t={required:!0,rules:["array"],allowEmpty:!1},ft={required:!0,rules:["object"],allowEmpty:!1},Gt={createGroup:{name:dt,type:dt},dismissGroup:[Object.assign({key:"groupID"},dt)],joinGroup:{groupID:dt,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},dt)],searchGroupByID:[Object.assign({key:"groupID"},dt)],getGroupProfile:{groupID:dt,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:dt,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:dt,newOwnerID:dt},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},dt)],handleGroupApplication:{handleAction:dt},getGroupMemberList:{groupID:dt},getGroupMemberProfile:{groupID:dt,userIDList:_t,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:dt,userIDList:_t},deleteGroupMember:{groupID:dt,userIDList:_t},setGroupMemberMuteTime:{groupID:dt,userID:dt,muteTime:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:dt,userID:dt,role:dt},setGroupMemberNameCard:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:dt},setGroupMemberCustomField:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:_t},markGroupMemberList:{groupID:dt,markType:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:_t},initGroupAttributes:{groupID:dt,groupAttributes:ft},setGroupAttributes:{groupID:dt,groupAttributes:ft},deleteGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})},getGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})}},bt={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};var vt=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=be,this.groupAction=Ee,this.groupAttribute=nt}install(t,o=[]){this._core=t,e.init(t),be.init(t),Ee.init(t,this),ke.init(t),ze.init(t),Xe.init(t),nt.init(t),mt.init(t),t.helper.registerValidateConfig({auth:bt,params:Gt}),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(){be.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)}};export{vt as default};
|
|
1
|
+
let e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r="GRP_COUNTER",n="Set",i="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,v=11e3,C=2,I=["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,N=5,$=1,E=0,P=4,R=6,k=1,U=2,q=3,F=4,j=5,K=6,x=400,V=300,J={from:!0,groupID:!0,groupName:!0,to:!0},B={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},H=2,Y=4,W=5,Q=7,z=8,X=15,Z=20,ee=21,te=2600,oe=2602,re=2603,ne=2620,ie=2621,se=2623,ue=2660,ae=2661,ce=2681,pe=2683,le=2684,me=2685,he=2687,de=3122,ge=10018,_e=t=>t===e.core.OuterConstant.GRP_PUBLIC,fe=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,Ge=(o,t)=>{var r=e.core.utils["isArray"];if(!r(o)||!r(t))return!1;let i=!1;return t.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},be=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},ve=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 Ce(t,r){var o=e.core["helper"];if(!o.checkBusinessCapabilityBits(r))throw new o.ChatError({functionName:t,code:de,replacement1:t})}function Ie(t,r){var o=e.core["helper"],o=new o.ChatError({functionName:t,code:(null==r?void 0:r.errorCode)||(null==r?void 0:r.code),message:(null==r?void 0:r.errorInfo)||(null==r?void 0:r.message)});throw console.error(t+" fail:",o),o}let ye=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];class Ae{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}=e.core["utils"];for(let e in t)ye.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(t){let{utils:{isArray:r,isUndefined:o,isNumber:i,isString:n},common:{deepMerge:s}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);t=JSON.parse(JSON.stringify(t));t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),n(t.muteAllMembers)&&(t.muteAllMembers="On"===t.muteAllMembers),t.groupCustomField&&Ge(this.groupCustomField,t.groupCustomField),o(t.isSupportTopic)||(this.isSupportTopic=i(t.isSupportTopic)?1===t.isSupportTopic:t.isSupportTopic),s(this,t,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),r(t.members)&&0<t.members.length&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&s(this.selfInfo,e,["sequence"])})}updateSelfInfo(t){var{nameCard:t,joinTime:r,role:o,messageRemindType:i,readedSequence:n,excludedUnreadSequenceList:s}=t,u=e.core["common"]["deepMerge"];u(this.selfInfo,{nameCard:t,joinTime:r,role:o,messageRemindType:i,readedSequence:n,excludedUnreadSequenceList:s},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var Me=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 Ae(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 Le(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 De(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 Se(s,u){return De(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}})})}let Oe=function(e){return{code:0,data:e||{}}};var Te=new class{constructor(){this._name="GetGroupList",this._pagingStatus=_,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 De(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}),Me.updateLocalGroup(e),Me.getLocalGroupList()}return console.log(this._name+".getGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===G||this._pagingStatus===_?this._syncGroupList().then(()=>{var e=Me.getLocalGroupList();return Oe({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw console.error(this._name+".getGroupList fail:",e),e}):(e=Me.getLocalGroupList(),console.log(this._name+".getGroupList return group count:"+e.length),Oe({groupList:e,isSyncCompleted:this._isSyncCompleted()}))})}_syncGroupList(){return De(this,void 0,void 0,function*(){this._pagingStatus===_&&Me.clearLocalGroup();var e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=f,this._groupListTreeShaking(t),Me.updateLocalGroup(t);var r=Me.getLocalGroupList();return console.log(this._name+"._syncGroupList ok, count:"+r.length),Me.emitGroupListUpdate(),r}catch(e){throw this._pagingStatus=G,console.error(this._name+"._syncGroupList fail:",e),e}})}_pagingGetGroupList(e){return De(this,void 0,void 0,function*(){var{isCommunityRelay:u=!1,groupList:a}=e;let l,{limit:c,offset:h}=e;var d=[...p];u&&(l=this._core.OuterConstant.GRP_COMMUNITY,d.push("AtInfoList"));try{let e=yield Se({type:l,limit:c,offset:h,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:d,SelfInfoFilter:[...m]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t),i=(a.push(...o),h+c),n=!(r>i),s=`offset:${h} limit:${c} total:${r} isCompleted:${n} current:${a.length} isCommunityRelay:`+u;return console.log(this._name+"._pagingGetGroupList ok. "+s),u?n?a:(h=i,this._pagingGetGroupList({isCommunityRelay:!0,limit:c,offset:h,groupList:a})):n?(console.log(this._name+"._pagingGetGroupList start to get community list"),h=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:c,offset:h,groupList:a})):(h=i,this._pagingGetGroupList({limit:c,offset:h,groupList:a}))}catch(e){if(e.ErrorCode===b)return console.warn(this._name+"._pagingGetGroupList response size exceeds the limit, request count:"+c),this._pagingGetGroupList({isCommunityRelay:u,limit:50,offset:h,groupList:a});if(u)return e.code===v&&console.log(this._name+"._pagingGetGroupList ok. community unavailable"),a;throw e}})}_pagingGetJoinedCommunityList(e){return De(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 Se({limit:u,offset:a,type:n.GRP_COMMUNITY,memberAccount:i(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...p],SelfInfoFilter:[...m]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t);s.push(...o);var l=a+u,c=!(l<r),h=`offset:${a} limit:${u} total:${r} isCompleted:${c} current:`+s.length;return console.log(this._name+"._pagingGetJoinedCommunityList ok. "+h),c?s:(a=l,this._pagingGetJoinedCommunityList({limit:u,offset:a,groupList:s}))}catch(e){if(e.code===ge)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([...Me.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++)Me.deleteLocalGroup(i[e])}_isSyncCompleted(){return this._pagingStatus===f}_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:v,Notification:f,Owner_Account:G,Type:b,LastRecallTime:I,SelfInfo:C,AtInfoList:y=[],SupportTopic:M}=r[e],i=be(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:v,notification:f,ownerID:G,type:b,selfInfo:C,_lastRevokedTime:I,_groupAtInfoList:y,isSupportTopic:M})}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}},we=new class{constructor(){this._name="CreateGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"createGroup",context:this})}createGroup(u){return De(this,void 0,void 0,function*(){var n;this._preCheckParams(u);try{let{utils:{isEmpty:e},common:{getCurrentUserID:t}}=this._core,r=yield function(h,d){return De(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?ve(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({},u),{ownerID:t()}),this._core),{GroupId:o,OverJoinedGroupLimit_Account:i=[]}=r||{};console.log(`${this._name}.createGroup ok, type:${u.type} groupID:${o} overLimitUserIDList:`+i),e(u.memberList)||e(i)||(u.memberList=null==(n=u.memberList)?void 0:n.filter(e=>i.includes(e.userID))),Me.updateLocalGroup([Object.assign(Object.assign({},u),{groupID:o})]);var s=Me.getLocalGroup(o);return this._notNeedSendCustomMessage(u)||(this._sendCustomMessage(o,u.type),Me.emitGroupListUpdate()),Oe({group:s})}catch(e){throw console.error(this._name+".createGroup fail:",e),e}})}_preCheckParams(t){var{type:r,groupID:o}=t,{utils:{isEmpty:i,isUndefined:n},common:{isCommunity:s}}=this._core,i=!i(o);if(!(()=>{var{GRP_PUBLIC:t,GRP_WORK:r,GRP_MEETING:o,GRP_AVCHATROOM:i,GRP_COMMUNITY:n}=e.core.OuterConstant;return[t,r,o,i,n]})().includes(r))throw new this._core.helper.ChatError({code:te});if(!s({type:r})){if(i&&s({groupID:o}))throw new this._core.helper.ChatError({code:oe});n(t.isSupportTopic)||(t.isSupportTopic=void 0)}if(this._canIUseMemberList(r)||n(t.memberList)||(t.memberList=void 0),this._canIUseJoinOption(r)||n(t.joinOption)||(t.joinOption=void 0),s({type:r})){if(i&&!s({groupID:o}))throw new this._core.helper.ChatError({code:oe});t.isSupportTopic=this._canIUseTopic(t)?1:0}}_canIUseMemberList(e){return!fe(e)}_canIUseJoinOption(e){return _e(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=d;t===r.GRP_COMMUNITY&&(o="Create Community",i=g);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,{})}},Ne=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"];n!==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;r!==T?r!==w?(r===S&&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={}}},$e=new class{constructor(){this._name="DismissGroup"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}dismissGroup(t){return De(this,void 0,void 0,function*(){console.log(this._name+".dismissGroup groupID:"+t);try{yield function(e,t){return De(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:{GroupId:e}})})}(t,this._core),console.log(this._name+".dismissGroup ok.");var e=Me.getLocalGroup(t)["type"];return Me.deleteLocalGroup(t),Me.emitGroupListUpdate(),Ne.deleteGroupAttributesCache(t),Oe({groupID:t,type:e})}catch(e){throw console.error(this._name+".dismissGroup fail:",e),e}})}},Ee=new class{constructor(){this._name="GetGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(t){return De(this,void 0,void 0,function*(){let{groupID:i,groupCustomFieldFilter:e}=t,n={groupIDList:[i],responseFilter:{GroupBaseInfoFilter:[...p],AppDefinedDataFilter_Group:e,MemberInfoFilter:[...h]}};try{let e=yield this.getGroupProfileAdvance(n),{successGroupList:t,failureGroupList:r}=e;if(0<r.length)throw r[0];let o;return(o=!Me.hasLocalGroup(i)&&fe(t[0].type)?new Ae(t[0]):(Me.updateLocalGroup(t),Me.getLocalGroup(i))).isSupportTopic||Me.updateConversationGroupProfile(i),console.log(this._name+".getGroupProfile ok."),Oe({group:o})}catch(e){throw console.error(this._name+".getGroupProfile fail:",e),e}})}getGroupProfileAdvance(u){return De(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 De(this,void 0,void 0,function*(){let{isCommunityProfile:t=!1}=e,s=Le(e,["isCommunityProfile"]);if(0===s.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{let e=yield function(r,o){return De(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:v,NextMsgSeq:f,Notification:G,Owner_Account:b,ShutUpAllMember:I,ShutUpUntil:C,Type:y,MemberList:M,ErrorCode:D,ErrorInfo:A}=r[e],i=be(i),M=this._convertMembers(M);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:v,nextMessageSeq:f,notification:G,ownerID:b,shutUpAllMember:I,muteUntil:C,type:y,members:M,errorCode:D,errorInfo:A})}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=be(i);o.push({memberCustomField:i,joinTime:n,userID:s,messageRemindType:u,sequence:a,nameCard:p,role:l})}return o}},Pe=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()}},Re=new class{constructor(){this._name="JoinGroup"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"joinGroup",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}joinGroup(e){return De(this,void 0,void 0,function*(){var t=e["groupID"];try{if(Me.hasLocalGroup(t))try{return yield Ee.getGroupProfile({groupID:t}),Oe({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS})}catch(e){console.warn(this._name+`.joinGroup ${t} was unjoined, start to join!`),Me.deleteLocalGroup(t)}return yield this._applyJoinGroup(e)}catch(e){throw console.error(this._name+".joinGroup fail:",e),e}})}_applyJoinGroup(c){return De(this,void 0,void 0,function*(){var{OuterConstant:t,helper:e}=this._core,r=c["groupID"],i=Object.assign({},c),e=e.checkBusinessCapabilityBits(o),i=(e&&(i.historyMessageFlag=1),yield function(o,i){return De(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}})})}(i,this._core)),{Type:i,JoinedStatus:n,LongPollingKey:s,StartSeq:u,HugeGroupFlag:a,AVChatRoomKey:p,RspMsgList:l=[]}=i||{},e=`groupID:${r} joinedStatus:${n} longPollingKey:${s} startSeq:${u} avChatRoomFlag:${a} canGetAVChatRoomHistoryMsg:${e}, historyMessageCount:`+l.length;if(console.log(this._name+"._applyJoinGroup ok, "+e),n===t.JOIN_STATUS_WAIT_APPROVAL)return Oe({status:t.JOIN_STATUS_WAIT_APPROVAL,group:{groupID:r,type:i}});if(n!==t.JOIN_STATUS_SUCCESS)throw new this._core.helper.ChatError({code:ue});{let e=null;try{e=(yield Ee.getGroupProfile({groupID:r})).data.group}catch(t){e=new Ae({groupID:r}),console.warn(this._name+`._applyJoinGroup getGroupProfile failed, groupID: ${r}, errorCode:`,null==t?void 0:t.code)}return this._handleJoinResult({group:e,avChatRoomFlag:a,longPollingKey:s,startSequence:u,avChatRoomKey:p,historyMessageList:l})}})}_handleJoinResult(e){var{group:t,avChatRoomFlag:r,avChatRoomKey:o}=e;return 1===r?(Ne.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:o}),Pe.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:o}),Oe(e)):(Me.updateLocalGroup([t]),Me.emitGroupListUpdate(),Oe({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}},ke=new class{constructor(){this._name="QuitGroup"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"quitGroup",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}quitGroup(t){return De(this,void 0,void 0,function*(){if(!Me.hasLocalGroup(t))throw new this._core.helper.ChatError({code:se});try{yield function(e,t){return De(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:{GroupId:e}})})}(t,this._core),console.log(this._name+".quitGroup ok, groupID:"+t);var e=Me.getLocalGroup(t)["type"];return Me.deleteLocalGroup(t),Me.emitGroupListUpdate(),Ne.deleteGroupAttributesCache(t),Oe({groupID:t,type:e})}catch(e){throw console.error(this._name+".quitGroup fail:",e),e}})}},Ue=new class{constructor(){this._name="SearchGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(f){return De(this,void 0,void 0,function*(){console.log(this._name+".searchGroupByID groupID:"+f);try{var e=yield function(t,r){return De(this,void 0,void 0,function*(){var e={GroupIdList:[t],GroupBasePublicInfoFilter:[...l]};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:c,Owner_Account:m,Type:h,ErrorCode:d,ErrorInfo:g}=t[0];if(0!==d)throw new this._core.helper.ChatError({code:d,message:g});console.log(this._name+".searchGroupByID ok.");var _=be(r),v=new Ae({groupID:f,name:c,avatar:n,introduction:s,joinOption:o,inviteOption:u,maxMemberCount:a,memberCount:p,type:h,ownerID:m,createTime:i,groupCustomField:_});return Oe({group:v})}catch(e){throw console.error(this._name+".searchGroupByID fail:",e),e}})}},qe=new class{constructor(){this._name="UpdateGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(i){return De(this,void 0,void 0,function*(){let t=i["groupID"],{isUndefined:r}=this._core["utils"],o=Me.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 De(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?ve(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),Me.emitGroupListUpdate()):o=new Ae(i),Oe({group:o})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}})}_canIUseJoinOption(e){return _e(e)||this._core.common.isCommunity({type:e})}},Fe=new class{constructor(){this._name="ChangeGroupOwner"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(u){return De(this,void 0,void 0,function*(){let r="changeGroupOwner",{groupID:e,newOwnerID:t}=u,o=Me.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:ne});if(t===s())throw new i.ChatError({functionName:r,code:ie});console.log(`${this._name}.${r} groupID:${e} newOwnerID:`+t);try{return yield function(r,o){return De(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,Me.emitGroupListUpdate(),Oe({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}})}},je=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}getGroupOnlineMemberCount(i){return De(this,void 0,void 0,function*(){let r="getGroupOnlineMemberCount",e=Me.hasLocalGroup(i);if(console.log(`${this._name}.${r} groupID:${i} hasLocalGroup:`+e),!e)return Oe({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 Oe({memberCount:r})}try{let e=yield function(e,t){return De(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),Oe({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}})}},Ke=new class{init(e,t){console.log("GroupAction.init"),Te.init(e),we.init(e),$e.init(e,t),Re.init(e,t),ke.init(e,t),Ue.init(e),Ee.init(e),qe.init(e),Fe.init(e),je.init(e,t)}dismissGroup(e){return $e.dismissGroup(e)}joinGroup(e){return Re.joinGroup(e)}quitGroup(e){return ke.quitGroup(e)}getGroupOnlineMemberCount(e){return je.getGroupOnlineMemberCount(e)}},xe=new class{constructor(){this._name="GetGroupApplicationList"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return De(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 Oe({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 De(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 De(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=Le(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}}},Ve=new class{constructor(){this._name="HandleGroupApplication"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return De(this,void 0,void 0,function*(){let r="handleGroupApplication",t=e["application"],o=this._handleParams(e);try{(null==t?void 0:t.applicationType)===C?yield function(s,u){return De(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 De(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=Me.getLocalGroup(o.groupID);return Oe({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(null==o?void 0:o.applicationType)===C&&(a=o.userID),{handleAction:e,handleMessage:t,applicant:i,invitee:a,groupID:n,authentication:s,messageKey:u}}},Je=new class{init(e){console.log("GroupApplication.init"),xe.init(e),Ve.init(e)}};let Be=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){var{utils:{isUndefined:r},common:{deepMerge:o}}=e["core"],r=(r(t.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*t.muteTime)/1e3)),r(t.onlineStatus)||(this.isOnline="Online"===t.onlineStatus),[null,void 0,"",0,NaN]);t.memberCustomField&&Ge(this.memberCustomField,t.memberCustomField),o(this,t,["memberCustomField","marks","onlineStatus","muteTime"],r)}};function He(u,a){return De(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?ve(n):s};return a.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:e})})}var Ye=new class{constructor(){this._name="GetGroupMemberList"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}getGroupMemberList(o){return De(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=Me.getLocalGroup(s),p=100<e?100:e,l={groupID:s,offset:u,limit:p,memberRoleFilter:I.includes(t)?[t]:void 0,memberInfoFilter:y};try{let e=yield function(n,s){return De(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 Oe({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 Oe({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=be(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i})}return o}_patchAvatarAndNick(n){return De(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 Be(r[e]);o.push(i)}return o}},We=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(t){return De(this,void 0,void 0,function*(){let r="getGroupMemberProfile",{groupID:o,userIDList:i,memberCustomFieldFilter:n}=t,e=Me.getLocalGroup(o),{helper:s,utils:{isArray:u}}=this._core;if(e&&fe(e.type))throw new s.ChatError({functionName:r,replacement1:r,code:he});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 De(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:[...y]},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),Oe({memberList:p})):Oe({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=be(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i})}return o}_getMemberAvatarAndNick(n){return De(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 Be(r[e]);o.push(i)}return o}},Qe=new class{constructor(){this._name="AddGroupMember"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(t){return De(this,void 0,void 0,function*(){let s="addGroupMember",{groupID:u,userIDList:e}=t,a=Me.getLocalGroup(u),r=this._core["helper"];if(a&&fe(a.type))throw new r.ChatError({functionName:s,code:ae});var p=e.map(e=>({Member_Account:e}));try{let e=yield function(r,o){return De(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),Oe({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;e===A?r.push(t):e===M?o.push(t):e===L?i.push(t):e===D&&n.push(t)}),{failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n}}},ze=new class{constructor(){this._name="DeleteGroupMember"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}deleteGroupMember(s){return De(this,void 0,void 0,function*(){let r="deleteGroupMember",{groupID:e,userIDList:t}=s,o=Me.getLocalGroup(e),{helper:i,utils:{isUndefined:n}}=this._core;if(n(o))throw new i.ChatError({functionName:r,code:re});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 De(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),Oe({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}})}},Xe=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(s){return De(this,void 0,void 0,function*(){let o="setGroupMemberMuteTime",t=this._core["helper"];this._preCheckSettingMuteParams(s);try{yield He(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=Me.getLocalGroup(e),n=new Be({userID:t,muteTime:r});return Oe({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:me})}},Ze=new class{constructor(){this._name="SetGroupMemberRole"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(s){return De(this,void 0,void 0,function*(){let o="setGroupMemberRole",t=this._core["helper"];this._preCheckSettingRoleParams(s);try{yield He(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=Me.getLocalGroup(e),n=new Be({userID:t,role:r});return Oe({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=Me.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:ce});if(t===o.get("login").userId)throw new i.ChatError({functionName:"setGroupMemberRole",code:le});u=[...I];if(s({groupID:e})&&u.push(n.GRP_MBR_ROLE_CUSTOM),!u.includes(r))throw new i.ChatError({functionName:"setGroupMemberRole",code:pe})}},et=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(a){return De(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 He(o,this._core),console.log(`${this._name}.${i} ok, groupID:${e} userID:${t} nameCard:`+r);var s=Me.getLocalGroup(e),u=new Be({userID:t,nameCard:r});return Oe({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=Me.getLocalGroup(e);if(fe(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberNameCard",code:he})}},tt=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(a){return De(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 He(o,this._core),console.log(`${this._name}.${i} ok, groupID:${e} userID:${t} memberCustomField:`+JSON.stringify(r));var s=Me.getLocalGroup(e),u=new Be({userID:t,memberCustomField:r});return Oe({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=Me.getLocalGroup(e);if(fe(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberCustomField",code:he})}},ot=new class{init(e,t){console.log("GroupMember.init"),Ye.init(e,t),We.init(e),Qe.init(e),ze.init(e,t),Xe.init(e),Ze.init(e),et.init(e),tt.init(e)}getGroupMemberList(e){return Ye.getGroupMemberList(e)}deleteGroupMember(e){return ze.deleteGroupMember(e)}},rt=new class{init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(l){return De(this,void 0,void 0,function*(){var t="getGroupCounters";try{Ce(t,r);var o,i,n,{groupID:s,keyList:u=[]}=l,{avChatRoomKey:a,lastUpdateTime:p}=Pe.getLocalGroupCounters(s);return Date.now()-p>=this._getExpireTime()&&(o=yield function(n){return De(this,void 0,void 0,function*(){var{groupID:t,GroupCounterKeys:r,avChatRoomKey:o}=n,i=e.core["common"];return i.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:{GroupId:t,keyList:r,BytesKey:o}})})}({groupID:s,keyList:u,avChatRoomKey:a}),{GroupCounter:i=[],GroupCounterSeq:n}=o,Pe.updateLocalGroupCounters({groupID:s,counterList:i,groupCounterSeq:n})),{code:0,data:{counters:Pe.getLocalCounters(s,u)}}}catch(e){Ie(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)}},nt=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 De(this,void 0,void 0,function*(){return this._handleCounterOperation(n,e)})}increaseGroupCounter(e){return De(this,void 0,void 0,function*(){return this._handleCounterOperation(i,e)})}decreaseGroupCounter(e){return De(this,void 0,void 0,function*(){return this._handleCounterOperation(s,e)})}_handleCounterOperation(p,l){return De(this,void 0,void 0,function*(){var t=p+"GroupCounter";try{Ce(t,r);var{groupID:e,key:o,value:i=0}=l,s=Pe.getLocalGroupCounters(e)["avChatRoomKey"],u=p===n?this._convertObjectToList(l.counters):[{Key:o,Value:i}],a=yield this._updateGroupCounters({groupID:e,counterList:u,avChatRoomKey:s,mode:p});return Pe.setGroupCounters(e,a),{code:0,data:{counters:a}}}catch(e){Ie(t,e)}})}_updateGroupCounters(s){return De(this,void 0,void 0,function*(){let t=yield function(){var{groupID:t,counterList:r,mode:o,avChatRoomKey:i}=s,n=e.core["common"];return n.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:{GroupId:t,GroupCounter:r,Mode:o,BytesKey:i}})}(),{GroupCounter:r=[]}=t,o={};return r.forEach(e=>{var{Key:e,Value:t=0}=e;o[e]=t}),o})}_convertObjectToList(e){return Object.entries(e).map(([e,t])=>({Key:e,Value:t||0}))}},it=new class{init(e){this._core=e,rt.init(e),nt.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;e!==u&&e!==c||this._processAndNotifyCounterUpdate(o,t,r),e===a&&Pe.deleteLocalGroupCounters({groupID:o,groupCounterSeq:t,counterList:r})})}_processAndNotifyCounterUpdate(r,e,t){let{OuterEvent:o,notificationCenter:i}=this._core;Pe.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(){Pe.reset()}},st=new class{constructor(){this._name="InitGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return De(this,void 0,void 0,function*(){let o="initGroupAttributes",{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u}=Ne.getGroupAttributesCache(i),a=Ne.convertKeyValueMapToList(n);try{let e=yield function(i,n){return De(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 Ne.saveGroupAttributesCacheValuesCopy(i),Ne.refreshGroupAttributesCache({groupID:i,serverMainSequence:t,groupAttributeList:p,operation:S}),Ne.emitGroupAttributesUpdated(i),Oe({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}})}},ut=new class{constructor(){this._name="SetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return De(this,void 0,void 0,function*(){let o="setGroupAttributes",{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u,values:a}=Ne.getGroupAttributesCache(i),p=Ne.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 De(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 Ne.saveGroupAttributesCacheValuesCopy(i),Ne.refreshGroupAttributesCache({groupID:i,serverMainSequence:t,groupAttributeList:l,operation:O}),Ne.emitGroupAttributesUpdated(i),Oe({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}})}},at=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(u){return De(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),Ne.saveGroupAttributesCacheValuesCopy(e),Ne.refreshGroupAttributesCache({groupID:e,serverMainSequence:i,groupAttributeList:s,operation:n}),Ne.emitGroupAttributesUpdated(e),Oe({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 De(this,void 0,void 0,function*(){let{serverMainSequence:e,avChatRoomKey:t,values:r}=Ne.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 De(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:w}})}_clearGroupAttributes(o){return De(this,void 0,void 0,function*(){var{serverMainSequence:e,avChatRoomKey:t,values:r}=Ne.getGroupAttributesCache(o),r=[...r.keys()],t=((yield function(o,i){return De(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:T}})}},ct=new class{constructor(){this._name="GetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(u){return De(this,void 0,void 0,function*(){let r="getGroupAttributes",t=u["groupID"],{avChatRoomKey:o,lastUpdateTime:e,localMainSequence:i,serverMainSequence:n}=Ne.getGroupAttributesCache(t);if(3e4<=Date.now()-e||i<n)try{yield this.getGroupAttributesFromServer({groupID:t,avChatRoomKey:o});let e=Ne.getGroupAttributesCacheValues(u);return console.log(this._name+`.${r} from server. groupID:`+t),Oe({groupAttributes: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}var s=Ne.getGroupAttributesCacheValues(u);return console.log(this._name+`.${r} from cache. groupID:`+t),Oe({groupAttributes:s})})}getGroupAttributesFromServer(o){return De(this,void 0,void 0,function*(){var e=this._core["utils"]["isUndefined"],{groupID:t,avChatRoomKey:r}=o,{AttrMainSeq:e=0,GroupAttrAry:r}=(yield function(o,i){return De(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)?E:$},this._core))||{},r=(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}}));Ne.refreshGroupAttributesCache({groupID:t,serverMainSequence:e,groupAttributeList:r,operation:N})})}},pt=new class{init(e){console.log("GroupAttribute.init"),st.init(e),ut.init(e),at.init(e),ct.init(e),Ne.init(e)}isGroupAttributesUpdated(e){return Ne.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){let{to:t,elements:{newGroupProfile:r}}=e,o=r["groupAttributeOption"],{serverMainSequence:i,withChangedAttributeInfo:n}=o,s=Ne.getGroupAttributesCache(t)["localMainSequence"],u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:`+u),0!=u)if(Ne.saveGroupAttributesCacheValuesCopy(t),1!==n||1!=u){if(Ne.hasGroupAttributesCache(t)){let e=Ne.getGroupAttributesCache(t)["avChatRoomKey"];ct.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then(()=>{Ne.emitGroupAttributesUpdated(t)}).catch(()=>{})}}else Ne.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:o})}reset(){Ne.reset()}};function lt(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?mt:dt)(m)}}function mt(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=>ht(e));break;case"MsgOperatorMemberExtraInfo":e.operatorInfo=ht(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 ht(e){var{ImageUrl:e,NickName:t,Role:r,UserId:o}=e;return{avatar:e,nick:t,role:r,userID:o}}function dt(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 gt{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(t)}static parseServerPushElement(e){e=mt(e);return new gt(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];J[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 _t=new class{constructor(){this._name="GroupTipsNotification"}init(e){var{message:{messageFactory:e},OuterConstant:t}=this._core=e;null!=e&&e.registerElementClass(t.MSG_GRP_TIP,gt)}onNewGroupTips(e){var e=this._handleGroupTips(e)["messageList"],{notificationCenter:t,OuterEvent:r}=this._core;0<e.length&&(t.emitOuterEvent(r.MESSAGE_RECEIVED,{name:r.MESSAGE_RECEIVED,data:e}),this._handleGroupTipMessage(e))}_handleGroupTips(e){let{Event:r,GroupTips:o}=e,i=new Map,t=[],n=[];for(let t=0,e=o.length;t<e;t++){let e=lt(o[t],"tips");if(r===R){if(pt.isGroupAttributesUpdated(e)){pt.handleGroupAttributesUpdated(e);continue}if(it.isGroupCounterUpdated(e)){it.handleGroupCounterUpdated(e);continue}}var s=e["groupProfile"]["groupID"];if(Me.hasLocalGroup(s)){s=this._assembleMessage(e);if(r===R&&(s._onlineOnlyFlag=!0,n.push(s)),r===P){if(!this._core.message.messageDataHandler.storeConversationMessage(s))continue;n.push(s)}this._handleConversationOptions(i,s)}}return t.push(...i.values()),{conversationUpdateFieldList:t,messageList:n}}_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 gt(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)})));return t.setElement(r),t.isSystemMessage=!1,t}_patchNickAndAvatar(e,r){let{isEmpty:t}=this._core["utils"],{operationType:o,memberInfoList:i,operatorInfo:n}=e,s={};if(t(i)?t(n)||(s=n):o!==k&&o!==q&&o!==F&&o!==j||(s=Object.assign({},i[0])),!t(s)){let{nick:e="",avatar:t=""}=s;r.nick=e,r.avatar=t}}_handleConversationOptions(e,t){var{conversationID:r,conversationType:o}=t;let i;if(e.has(r))i=e.get(r),"in"!==t.flow||t._isExcludedFromUnreadCount||t._onlineOnlyFlag||i.unreadCount++,i.type=o,i.lastMessage=t._isExcludedFromLastMessage?"":t;else{let e=0;"in"!==t.flow||t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1),i={conversationID:r,unreadCount:e,type:o,lastMessage:t._isExcludedFromLastMessage?"":t}}e.set(r,i)}_handleGroupTipMessage(e){e.forEach(e=>{var t=e.payload["operationType"];switch(t){case k:this._handleNewMemberJoined(e);break;case U:this._handleMemberQuitted(e);break;case q:this._handleMemberKicked(e);break;case K: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=Me.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])}),Me.emitGroupListUpdate(),Me.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){var{common:r,OuterConstant:o}=this._core,e=Me.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;t===x?o=r.GRP_MBR_ROLE_OWNER:t===V&&(o=r.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:o})}_handleGroupMemberCountUpdated(e){var{memberCount:e,groupProfile:{groupID:t}}=e.payload,r=Me.getLocalGroup(t),o=this._core["utils"]["isNumber"];r&&o(e)&&r.memberCount!==e&&(r.memberCount=e,Me.emitGroupListUpdate(),Me.updateConversationGroupProfile(t))}};class ft{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}static parseServerPushElement(e){e=dt(e);return new ft(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];B[o]&&(this.content.groupProfile[o]=t[o])}}}var Gt=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,ft)}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=lt(t[e],"system"),s=n["elements"]["operationType"];s!==X&&(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 ft(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 H:this._handleGroupJoinResult(e);break;case Y:this._handleMemberKicked(e);break;case W:this._handleGroupDismissed(e);break;case Q:this._handleGroupInvitedResult(e);break;case z:this._handleGroupQuitResult(e);break;case Z:this._handleMessageRemindTypeSynced(e);break;case ee:this._handleAVChatRoomMemberBanned(e)}})}_handleGroupJoinResult(e){var e=e.payload["groupProfile"],{groupID:t,type:r}=e,o=Me.hasLocalGroup(t);console.log(this._name+`._handleGroupJoinResult groupID:${t} type:${r} hasLocalGroup:`+o),o||fe(r)||(Me.updateLocalGroup([Object.assign({},e)]),Me.emitGroupListUpdate())}_handleMemberKicked(e){var{groupID:e,type:t}=e.payload["groupProfile"];Me.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupDismissed(e){var{groupID:e,type:t}=e.payload["groupProfile"];Me.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupInvitedResult(e){var e=e.payload["groupProfile"],t=e["groupID"],r=Me.hasLocalGroup(t);console.log(this._name+`._handleGroupInvitedResult groupID:${t} hasLocalGroup:`+r),r||(Me.updateLocalGroup([Object.assign({},e)]),Me.emitGroupListUpdate())}_handleGroupQuitResult(e){var{groupID:e,type:t}=e.payload["groupProfile"],r=Me.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(fe(e)){let{appStore:{conversationStore:e},OuterConstant:{CONV_GROUP:t}}=this._core;e.deleteConversation(""+t+r)}Me.deleteLocalGroup(r),Me.emitGroupListUpdate()}_updateConversationProfile(e,t){var{appStore:{conversationStore:r},OuterConstant:{CONV_GROUP:o}}=this._core,o=""+o+e;r.getConversation(o)&&r.updateConversation(o,t)}},bt=new class{init(e){this._core=e,console.log("GroupNotificationHandler.init"),_t.init(e),Gt.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){_t.onNewGroupTips(e)}_onNewGroupSystemNotification(e){Gt.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 vt={required:!0,rules:["string"],allowEmpty:!1},Ct={required:!0,rules:["number"],allowEmpty:!1},It={required:!0,rules:["array"],allowEmpty:!1},yt={required:!0,rules:["object"],allowEmpty:!1},At={createGroup:{name:vt,type:vt},dismissGroup:[Object.assign({key:"groupID"},vt)],joinGroup:{groupID:vt,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},vt)],searchGroupByID:[Object.assign({key:"groupID"},vt)],getGroupProfile:{groupID:vt,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:vt,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:vt,newOwnerID:vt},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},vt)],handleGroupApplication:{handleAction:vt},getGroupMemberList:{groupID:vt},getGroupMemberProfile:{groupID:vt,userIDList:It,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:vt,userIDList:It},deleteGroupMember:{groupID:vt,userIDList:It},setGroupMemberMuteTime:{groupID:vt,userID:vt,muteTime:Object.assign(Object.assign({},Ct),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:vt,userID:vt,role:vt},setGroupMemberNameCard:{groupID:vt,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:vt},setGroupMemberCustomField:{groupID:vt,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:It},markGroupMemberList:{groupID:vt,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:It},initGroupAttributes:{groupID:vt,groupAttributes:yt},setGroupAttributes:{groupID:vt,groupAttributes:yt},deleteGroupAttributes:{groupID:vt,keyList:Object.assign(Object.assign({},It),{allowEmpty:!0})},getGroupAttributes:{groupID:vt,keyList:Object.assign(Object.assign({},It),{allowEmpty:!0})},getGroupCounters:{groupID:vt,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:vt,counters:yt},increaseGroupCounter:{groupID:vt,key:vt,value:Ct},decreaseGroupCounter:{groupID:vt,key:vt,value:Ct}},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,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};var Lt=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=Me,this.groupAction=Ke,this.groupAttribute=pt,this.groupMember=ot}install(t,r=[]){this._core=t,e.init(t),Me.init(t),Ke.init(t,this),ot.init(t,this),Je.init(t),it.init(t),pt.init(t),bt.init(t),t.helper.registerValidateConfig({auth:Mt,params:At}),this._installSubPlugins(r);var{notificationCenter:r,InnerEvent:t}=t;r.subscribeInnerEvent(t.LOGOUT,this._reset,this),r.subscribeInnerEvent(t.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(){Me.reset(),pt.reset(),it.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)}};export{Lt as default};
|