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