@tencentcloud/lite-chat 1.1.1-beta.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function t(t,i,e,n){return new(e||(e=Promise))((function(r,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function c(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){var i;t.done?r(t.value):(i=t.value,i instanceof e?i:new e((function(t){t(i)}))).then(o,c)}a((n=n.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i="friend";var e=new class{init(t){this._core=t;const{helper:i}=t;i.registerApi("getBlacklist",this)}getBlacklist(){return t(this,void 0,void 0,(function*(){return console.log(`${i} getBlacklist`),{code:0,data:[]}}))}};var n=new class{init(t){this._core=t;const{helper:i}=t;i.registerApi("getFriendList",this)}getFriendList(){return t(this,void 0,void 0,(function*(){return console.log(`${i} getFriendList`),{code:0,data:[]}}))}};var r=new class{init(t){this._core=t;const{helper:i}=t;i.registerApi("getFriendApplicationList",this)}getFriendApplicationList(){return t(this,void 0,void 0,(function*(){return console.log(`${i} getFriendApplicationList`),{code:0,data:{friendApplicationList:[],unreadCount:0}}}))}};var s=new class{init(t){this._core=t}};const o={getBlacklist:!0,getFriendList:!0,getFriendApplicationList:!0};var c=new class{install(t){e.init(t),n.init(t),r.init(t),s.init(t),t.helper.registerValidateConfig({auth:o})}};export{c as default};
1
+ function e(e,t,r,i){return new(r||(r=Promise))((function(o,n){function s(e){try{a(i.next(e))}catch(e){n(e)}}function d(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,d)}a((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t="friend",r=100,i=2700,o=2710,n=2711,s=2716,d=2742,a=30539,c="Tag_SNS_IM_",u={GROUP:`${c}Group`,REMARK:`${c}Remark`,ADDSOURCE:`${c}AddSource`,ADDWORDING:`${c}Wording`,ADDTIME:`${c}AddTime`},l="Update_Type_Add",p="Update_Type_Delete",h="add",m="remove",_="rename",f=e=>void 0===e;function I(t,r){return e(this,void 0,void 0,(function*(){return function(e){return v(e,"ResultItem",(e=>({to:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_update",data:t}))}))}function F(t,r){return e(this,void 0,void 0,(function*(){return function(e){return v(e,"InfoItem",(e=>({userID:e.To_Account,relation:e.Relation,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_check",data:t}))}))}function v(e,t="ResultItem",r=e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})){const{[t]:i=[],ActionStatus:o,ErrorCode:n,ErrorInfo:s,ErrorDisplay:d}=e;return{resultList:i.map(r),actionStatus:o,errorCode:n,errorInfo:s,errorDisplay:d}}const A={[u.REMARK]:(e,t)=>{e.remark=t},[u.GROUP]:(e,t)=>{e.groupList=t?JSON.parse(JSON.stringify(t)):[]},[u.ADDSOURCE]:(e,t)=>{e.source=t},[u.ADDWORDING]:(e,t)=>{e.wording=t},[u.ADDTIME]:(e,t)=>{e.addTime=t}};let g=class{constructor(e){var t;this.userID="",this.source="",this.wording="",this.remark="",this.addTime=0,this.groupList=[],this.friendCustomField=[];const{userID:r,tagValueList:i=[],core:o}=e,n=null===(t=o.user.userProfile)||void 0===t?void 0:t.createProfile(r,i);this.userID=r,this.profile=n,i.forEach((e=>{const{tag:t,value:r}=e;t.indexOf("Tag_Profile_Custom")>-1&&this.friendCustomField.push({key:t,value:r});const i=A[t];null==i||i(this,r)}))}update(e){const t=[];this.friendCustomField.forEach((e=>{t.push(e.key)})),e.forEach((e=>{const{tag:r,value:i}=e;r.indexOf("Tag_Profile_Custom")>-1&&(t.indexOf(r)>-1?this.friendCustomField.forEach((e=>{e.key===r&&(e.value=i)})):this.friendCustomField.push({key:r,value:i}));const o=A[r];null==o||o(this,i)}))}};var L=new class{constructor(){this._startIndex=0,this._standardSequence=0,this._customSequence=0}init(e){this._core=e;const{helper:t,constants:r}=e;t.registerApi({apiName:"getFriendList",context:this,methodName:"getFriendListFromCache"}),t.registerApi({apiName:"getFriendProfile",context:this}),t.registerApi({apiName:"addFriend",context:this}),t.registerApi({apiName:"deleteFriend",context:this}),t.registerApi({apiName:"updateFriend",context:this}),t.registerApi({apiName:"checkFriend",context:this}),t.registerWorkflowStep(r.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.WORKFLOW_STEP.FRIEND_RECOVER,this.syncFriendListFromServer,this)}getFriendListFromCache(){return e(this,void 0,void 0,(function*(){const{userStore:e}=this._core.appStore,r=[...e.getFriendMap().values()];return console.log(`${t} getFriendListFromCache, data `,r),{code:0,data:r}}))}syncFriendListFromServer(){return e(this,void 0,void 0,(function*(){var r;try{console.log(`${t} syncFriendListFromServer`);const i={From_Account:null===(r=this._core.store.get("login"))||void 0===r?void 0:r.userId,StartIndex:this._startIndex,StandardSequence:this._standardSequence,CustomSequence:this._customSequence},o=yield function(t,r){return e(this,void 0,void 0,(function*(){return function(e){const{UserDataItem:t=[],StandardSequence:r,CustomSequence:i,FriendNum:o,CompleteFlag:n,NextStartIndex:s,ActionStatus:d,ErrorCode:a,ErrorInfo:c,ErrorDisplay:u}=e;return{friendList:t.map((e=>{var t;return{userID:e.To_Account,tagValueList:null===(t=e.ValueItem)||void 0===t?void 0:t.map((e=>({tag:e.Tag,value:e.Value})))}})),standardSequence:r,customSequence:i,friendNumber:o,completeFlag:n,nextStartIndex:s,actionStatus:d,errorCode:a,errorInfo:c,errorDisplay:u}}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_get",data:t}))}))}(i,this._core),{friendList:n,nextStartIndex:s,standardSequence:d,customSequence:a,completeFlag:c}=o;this._startIndex=s,this._standardSequence=d,this._customSequence=a,this._processFriendList(n),0===c?yield this.syncFriendListFromServer():(this._emitFriendListUpdated(),this._fetchFriendProfile()),console.log(`${t} syncFriendListFromServer ok`)}catch(e){throw console.error(`${t} syncFriendListFromServer error:`,e),e}}))}getFriendProfile(i){return e(this,void 0,void 0,(function*(){var o;try{console.log(`${t} getFriendProfile params:`,i);let{userIDList:n}=i;n.length>r&&(n=n.slice(0,r));const{friendUserIdList:s,unFriendUserIdList:d}=this.partitionByIsFriend(n),a=this._createNonFriendErrorList(d);if(0===s.length)return{code:0,data:{friendList:[],failureUserIDList:a}};const c={From_Account:null===(o=this._core.store.get("login"))||void 0===o?void 0:o.userId,To_Account:s},u=(yield function(t,r){return e(this,void 0,void 0,(function*(){return function(e){const{InfoItem:t=[],ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=e;return{friendProfileList:t.map((e=>{var t;return{userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo,relation:e.Relation,standardSequence:e.StandardSequence,customSequence:e.CustomSequence,profileItem:(null===(t=e.SnsProfileItem)||void 0===t?void 0:t.map((e=>({tag:e.Tag,value:e.Value}))))||[]}})),actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:n}}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_get_specified",data:t}))}))}(c,this._core))||{},{successProfiles:l,failedProfiles:p}=this._processFriendProfileResponse(u);return{code:0,data:{friendList:l,failureUserIDList:[...p,...a]}}}catch(e){throw console.error(`${t} getFriendProfile error:`,e),e}}))}addFriend(r){return e(this,void 0,void 0,(function*(){var i;try{console.log(`${t} addFriend options:`,r);const{helper:o,store:n}=this._core,{to:s,source:d,type:c,wording:u,remark:l,groupName:p}=r,h={From_Account:null===(i=n.get("login"))||void 0===i?void 0:i.userId,AddFriendItem:[{To_Account:s,AddSource:d,AddWording:u,GroupName:p,Remark:l}],AddType:c},m=yield function(t,r){return e(this,void 0,void 0,(function*(){return v(yield r.common.buildAndSendPacket({servcmd:"sns.friend_add",data:t}))}))}(h,this._core),{resultList:_=[]}=m,{userID:f,resultCode:I}=_[0];if(0===I)return console.log(`${t} addFriend ok`),{code:0,data:{userID:f}};if(I===a)return console.log(`${t} addFriend wait for the other party to agree`),{code:0,data:{userID:f,code:I,message:"wait for the other party to agree"}};throw new o.ChatError({functionName:"addFriend",code:I})}catch(e){throw console.error(`${t} addFriend error:`,e),e}}))}deleteFriend(i){return e(this,void 0,void 0,(function*(){var o;try{console.log(`${t} deleteFriend options:`,i);const{store:n}=this._core;let{userIDList:s,type:d}=i;const a=null===(o=n.get("login"))||void 0===o?void 0:o.userId;s.length>1e3&&(console.warn(`${t} deleteFriend the length of userIDList cannot exceed:`,1e3),s=s.slice(0,r));const{friendUserIdList:c,unFriendUserIdList:u}=this.partitionByIsFriend(s);if(0===c.length)return{code:0,data:{friendList:[],failureUserIDList:this._createNonFriendErrorList(u)}};const l={From_Account:a,To_Account:c,DeleteType:d},p=yield function(t,r){return e(this,void 0,void 0,(function*(){return v(yield r.common.buildAndSendPacket({servcmd:"sns.friend_delete",data:t}))}))}(l,this._core),{successUserIDList:h,failureUserIDList:m}=this._processOperationResult({resultList:p.resultList,includeRelation:!1});return console.log(`${t} deleteFriend ok`),{code:0,data:{successUserIDList:h,failureUserIDList:m}}}catch(e){throw console.error(`${t} deleteFriend error:`,e),e}}))}updateFriend(r){return e(this,void 0,void 0,(function*(){var e;try{console.log(`${t} updateFriend options:`,r);const{userID:o,remark:n,friendCustomField:s}=r,{helper:d,store:a,appStore:{userStore:c}}=this._core,u=null===(e=a.get("login"))||void 0===e?void 0:e.userId;if(!c.getFriendMap().has(o))throw new d.ChatError({functionName:"updateFriend",code:i});const l={From_Account:u,UpdateItem:[{To_Account:o,SnsItem:this._buildSnsItemList(n,s)}]},p=yield I(l,this._core),{resultList:h}=p,{to:m,resultCode:_,resultInfo:F}=h[0];if(f(_)||0===_){return{code:0,data:this._updateLocalFriend({userID:m,remark:n,friendCustomField:s})}}throw new d.ChatError({functionName:"updateFriend",code:_,message:F})}catch(e){throw console.error(`${t} updateFriend error:`,e),e}}))}checkFriend(r){return e(this,void 0,void 0,(function*(){var e;try{console.log(`${t} checkFriend options:`,r);const{userIDList:i,type:o}=r,{OuterConstant:n,store:s}=this._core,d=null===(e=s.get("login"))||void 0===e?void 0:e.userId,a={From_Account:d,To_Account:i,CheckType:o===n.SNS_CHECK_TYPE_SINGLE?o:n.SNS_CHECK_TYPE_BOTH},c=yield F(a,this._core),{successUserIDList:u=[],failureUserIDList:l=[]}=this._processOperationResult({resultList:c.resultList,includeRelation:!0});return{code:0,data:{successUserIDList:u,failureUserIDList:l}}}catch(e){throw console.error(`${t} checkFriend error:`,e),e}}))}dispose(){this.reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this)}reset(){const{userStore:e}=this._core.appStore;e.getFriendMap().clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}updateFriendList(r){return e(this,void 0,void 0,(function*(){console.log(`${t} updateFriendList data:`,r);const{userStore:e}=this._core.appStore,{addedFriendList:i=[],removedFriendList:o=[]}=r;i.length>0&&(i.forEach((t=>{const r=new g({userID:t,core:this._core});e.getFriendMap().set(t,r)})),yield this.getFriendProfile({userIDList:i}),this._emitFriendListUpdated()),o.length>0&&(o.forEach((t=>{e.getFriendMap().delete(t)})),this._emitFriendListUpdated())}))}updateFriendInfo(e){console.log(`${t} updateFriendInfo data: `,e);const{appStore:{userStore:r,conversationStore:i},utils:{isEmpty:o}}=this._core,{userID:n,tagValueList:s}=e[0]||{},d=r.getFriend(n);if(o(s)||!d)return;const a=s.map((e=>({tag:e.BytesTag,value:e.BytesValue})));a.forEach((e=>{var t;const{tag:r,value:o}=e,s=null===(t=i.getConversation(`C2C${n}`))||void 0===t?void 0:t.remark;r===u.REMARK&&o!==s&&i.updateConversation(`C2C${n}`,{remark:o}),d.update(a)})),this._emitFriendListUpdated()}_processFriendList(e){const{utils:{isEmpty:t},appStore:{userStore:r}}=this._core;t(e)||e.forEach((e=>{const{userID:t,tagValueList:i}=e;if(this._isInvalidFriend(t))return;const o=new g({userID:t,tagValueList:i,core:this._core});r.getFriendMap().set(t,o)}))}_isInvalidFriend(e){return"@TLS#NOT_FOUND"===e||""===e}_fetchFriendProfile(){return e(this,void 0,void 0,(function*(){try{console.log(`${t} _fetchFriendProfile`);const{appStore:{userStore:e},user:{userProfile:r}}=this._core,i=[...e.getFriendMap().keys()],o=100,n=Math.ceil(i.length/o);for(let t=0;t<n;t++){const n=t*o,s=Math.min(n+o,i.length),d=i.slice(n,s),a=yield null==r?void 0:r.getUserProfile({userIDList:d});if(a&&a.data){a.data.forEach((t=>{const r=e.getFriend(t.userID);r&&(r.profile=t)}))}this._emitFriendListUpdated()}}catch(e){throw console.error(`${t} _fetchFriendProfile error:`,e),e}}))}_emitFriendListUpdated(){const{notificationCenter:e,OuterEvent:r,appStore:{userStore:i}}=this._core,o=Array.from(i.getFriendMap().values());console.log(`${t} _emitFriendListUpdated friendList:`,o),e.emitOuterEvent(r.FRIEND_LIST_UPDATED,{name:r.FRIEND_LIST_UPDATED,data:o})}_updateCustomField(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let r=!1;return t.forEach((({key:t,value:i})=>{const o=e.find((e=>e.key===t));o?o.value!==i&&(o.value=i,r=!0):(e.push({key:t,value:i}),r=!0)})),r}_updateLocalFriend(e){const{userStore:t}=this._core.appStore,{userID:r,remark:i,friendCustomField:o}=e,n=t.getFriend(r);if(n)return f(i)||(n.remark=i),Array.isArray(o)&&o.length>0&&this._updateCustomField(n.friendCustomField,o),this._emitFriendListUpdated(),n}_processOperationResult(e){const{resultList:t,includeRelation:r=!1}=e,{isEmpty:i}=this._core.utils,o=[],n=[];return Array.isArray(t)&&!i(t)&&t.forEach((e=>{const{userID:t,relation:i,resultCode:s,resultInfo:d}=e;if(f(s)||0===s){const e={userID:t};r&&(e.code=0,e.relation=i),o.push(e)}else n.push({userID:t,code:s,message:d})})),{successUserIDList:o,failureUserIDList:n}}_createNonFriendErrorList(e){return e.map((e=>({userID:e,code:i,message:"The specified userID is not my friend"})))}_buildSnsItemList(e,t){const r=[];return f(e)||r.push({Tag:u.REMARK,Value:e}),Array.isArray(t)&&t.length>0&&t.forEach((e=>{r.push({tag:e.key,value:e.value})})),r}_processFriendProfileResponse(e){const{friendProfileList:r=[]}=e,{userStore:i}=this._core.appStore,o=[],n=[];return r.forEach((e=>{const{userID:t,resultCode:r,resultInfo:s,profileItem:d}=e;if(0===r){const e=new g({userID:t,tagValueList:d,core:this._core});o.push(e),i.getFriendMap().set(t,e)}else n.push({userID:t,code:r,message:s})})),console.log(`${t} _processFriendProfileResponse successProfiles:`,o),{successProfiles:o,failedProfiles:n}}partitionByIsFriend(e){const r=[],i=[];return e.forEach((e=>{const{userStore:t}=this._core.appStore;t.getFriendMap().has(e)?r.push(e):i.push(e)})),console.log(`${t} partitionByIsFriend, friendUserIdList: ${r}, unFriendUserIdList: ${i}`),{friendUserIdList:r,unFriendUserIdList:i}}isMyFriend(e){const{userStore:t}=this._core.appStore;return t.getFriendMap().has(e)}};var y=new class{init(e){this.core=e}};function S(t){return e(this,void 0,void 0,(function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,ResponseFriendItem:[{To_Account:t.userID,ResponseAction:t.type,Remark:t.remark}]};return C(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))}))}function E(t){return e(this,void 0,void 0,(function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,ResponseFriendItem:[{To_Account:t.userID,ResponseAction:"Response_Action_Reject"}]};return C(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))}))}function D(t){return e(this,void 0,void 0,(function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,To_Account:[t.userID],PendencyType:t.type};return C(yield i.buildAndSendPacket({servcmd:"sns.pendency_delete",data:o}))}))}function C(e){const{ResultItem:t=[],ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=e;return{resultList:t.map((e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))),actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:n}}var T=new class{constructor(){this._friendApplicationMap=new Map,this._unreadCount=0,this._startTime=0,this._currentSequence=0}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendApplicationList",context:this,methodName:"getFriendApplicationListFromCache"}),t.registerApi({apiName:"acceptFriendApplication",context:this}),t.registerApi({apiName:"refuseFriendApplication",context:this}),t.registerApi({apiName:"deleteFriendApplication",context:this}),t.registerApi({apiName:"setFriendApplicationRead",context:this})}getFriendApplicationListFromCache(){return e(this,void 0,void 0,(function*(){const e=[...this._friendApplicationMap.values()];return console.log(`${t} getFriendApplicationListFromCache friendApplicationList:`,e),{code:0,data:{friendApplicationList:e,unreadCount:this._unreadCount}}}))}syncFriendApplicationListFromServer(){return e(this,void 0,void 0,(function*(){const i="syncFriendApplicationListFromServer";console.log(`${t} ${i}`);try{const t=yield function(t){return e(this,void 0,void 0,(function*(){var e;const{store:i,OuterConstant:o,common:n}=y.core,s={From_Account:null===(e=i.get("login"))||void 0===e?void 0:e.userId,PendencyType:o.SNS_APPLICATION_TYPE_BOTH,MaxLimited:r,StartTime:t.startTime,LastSequence:t.currentSequence};return function(e){const{PendencyItem:t=[],StartTime:r,UnreadPendencyCount:i,CurrentSequence:o,ActionStatus:n,ErrorCode:s,ErrorInfo:d,ErrorDisplay:a}=e;return{resultList:t.map((e=>({userID:e.To_Account,time:e.AddTime,source:e.AddSource,wording:e.AddWording,nick:e.Nick,type:e.PendencyType,image:e.Image}))),startTime:r,unreadCount:i,currentSequence:o,actionStatus:n,errorCode:s,errorInfo:d,errorDisplay:a}}(yield n.buildAndSendPacket({servcmd:"sns.pendency_get",data:s}))}))}({startTime:this._startTime,currentSequence:this._currentSequence}),{resultList:i,unreadCount:o,startTime:n,currentSequence:s}=t;this._startTime=n,this._currentSequence=s,this._unreadCount=o,this._friendApplicationMap.clear(),Array.isArray(i)&&i.forEach((e=>{const{userID:t,type:r}=e,i=this._createFriendApplication(e);this._friendApplicationMap.set(`${t}_${r}`,i)})),this._emitApplicationListUpdated()}catch(e){const r=new this._core.helper.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${t} ${i} error:`,r),r}}))}acceptFriendApplication(t){return e(this,void 0,void 0,(function*(){return this._operationApplication({functionName:"acceptFriendApplication",options:t,protocolFunction:S})}))}refuseFriendApplication(t){return e(this,void 0,void 0,(function*(){return this._operationApplication({functionName:"refuseFriendApplication",options:t,protocolFunction:E})}))}deleteFriendApplication(t){return e(this,void 0,void 0,(function*(){const{userID:e,type:r}=t;return this._checkApplicationExists(e,r,"deleteFriendApplication"),this._operationApplication({functionName:"deleteFriendApplication",options:t,protocolFunction:D})}))}_checkApplicationExists(e,t,r){if(!this._friendApplicationMap.has(`${e}_${t}`))throw new this._core.helper.ChatError({functionName:r,code:s})}_operationApplication(r){return e(this,void 0,void 0,(function*(){const{functionName:e,options:i,protocolFunction:o}=r;console.log(`${t} ${e} options:`,i);try{const r=yield o(i),{resultList:n=[]}=r,{resultCode:s,resultInfo:d}=n[0];if(0===s)return console.log(`${t} ${e} ok`),{code:0,data:{}};throw{errorCode:s,errorInfo:d}}catch(r){const i=new this._core.helper.ChatError({functionName:e,code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo});throw console.error(`${t} ${e} error:`,i),i}}))}setFriendApplicationRead(){return e(this,void 0,void 0,(function*(){const r="setFriendApplicationRead";console.log(`${t} ${r}`);try{return yield function(){return e(this,void 0,void 0,(function*(){var e;const{store:t,common:r}=y.core,i={From_Account:null===(e=t.get("login"))||void 0===e?void 0:e.userId,LatestPendencyTimeStamp:(o=Math.floor(Date.now()/1e3),n=0,Math.round(Number(o)*Math.pow(10,n))/Math.pow(10,n))};var o,n;return function(e){const{ActionStatus:t,ErrorCode:r,ErrorInfo:i,ErrorDisplay:o}=e;return{actionStatus:t,errorCode:r,errorInfo:i,errorDisplay:o}}(yield r.buildAndSendPacket({servcmd:"sns.pendency_report",data:i}))}))}(),this._unreadCount=0,this._emitApplicationListUpdated(),console.log(`${t} ${r} ok`),{code:0,data:{}}}catch(e){const i=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${t} ${r} error:`,i),i}}))}updateFriendApplicationList(e){const{from:r,addedApplicationList:i=[],removedApplicationList:o=[]}=e;console.log(`${t} updateFriendApplicationList data:`,e);const{isEmpty:n}=this._core.utils;n(i)||this.onApplicationAdded(i,r),n(o)||this.onApplicationDeleted()}onApplicationAdded(e,t){var r;const{store:i,OuterConstant:o}=this._core,n=t===(null===(r=i.get("login"))||void 0===r?void 0:r.userId)?o.SNS_APPLICATION_SENT_BY_ME:o.SNS_APPLICATION_SENT_TO_ME;e.forEach((e=>{const t=`${e.userID}_${n}`;n!==o.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,this._createFriendApplication(Object.assign(Object.assign({},e),{type:n})))})),this._emitApplicationListUpdated()}onApplicationDeleted(){this._startTime=0,this._currentSequence=0,this.syncFriendApplicationListFromServer()}onApplicationRead(){this._unreadCount=0,this._emitApplicationListUpdated()}reset(){this._startTime=0,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}dispose(){this.reset()}_createFriendApplication(e){return{userID:e.userID||"",nick:e.nick||"",avatar:e.avatar||"",time:e.time||0,source:e.source||"",wording:e.wording||"",type:e.type||""}}_emitApplicationListUpdated(){console.log(`${t} _emitApplicationListUpdated`);const{notificationCenter:e,OuterEvent:r}=this._core;e.emitOuterEvent(r.FRIEND_APPLICATION_LIST_UPDATED,{name:r.FRIEND_APPLICATION_LIST_UPDATED,data:{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}})}};function k(){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,t={From_Account:e.getCurrentUserID(),LastSequence:0,NeedFriend:"Need_Friend_Type_Yes"};return function(e){return M(e,(e=>({name:e.GroupName,userIDList:e.To_Account||[],count:e.FriendNumber})))}(yield e.buildAndSendPacket({servcmd:"sns.group_get",data:t}))}))}function N(t){return e(this,void 0,void 0,(function*(){const{name:e,userIDList:r}=t,{common:i}=y.core,o={From_Account:i.getCurrentUserID(),GroupName:[e],To_Account:r};return function(e){return M(e,(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield i.buildAndSendPacket({servcmd:"sns.group_add",data:o}))}))}function P(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,r={From_Account:e.getCurrentUserID(),GroupName:[t.name]};return function(e){return M(e)}(yield e.buildAndSendPacket({servcmd:"sns.group_delete",data:r}))}))}function G(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,{name:r,userIDList:i}=t,o=R(i,l),n={From_Account:e.getCurrentUserID(),GroupOldName:r,UpdateGroupItem:o};return function(e){return M(e,(e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:n}))}))}function w(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,{name:r,userIDList:i}=t,o=R(i,p),n={From_Account:e.getCurrentUserID(),GroupOldName:r,UpdateGroupItem:o};return function(e){return M(e,(e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:n}))}))}function U(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,{oldName:r,newName:i}=t,o={From_Account:e.getCurrentUserID(),GroupOldName:r,GroupNewName:i};return function(e){return M(e)}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:o}))}))}function R(e,t){return e.filter((e=>L.isMyFriend(e))).map((e=>({To_Account:e,UpdateType:t})))}function M(e,t){const{CurrentSequence:r,ActionStatus:i,ErrorCode:o,ErrorInfo:n,ErrorDisplay:s,ResultItem:d=[]}=e,a={currentSequence:r,actionStatus:i,errorCode:o,errorInfo:n,errorDisplay:s};return t&&d.length>0?Object.assign(Object.assign({},a),{resultList:d.map(t)}):a}class O{constructor(e){const{name:t="",userIDList:r=[]}=e;this.name=t,this.userIDList=r,this.count=r.length}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}var $=new class{constructor(){this._friendGroupMap=new Map}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendGroupList",context:this,methodName:"getFriendGroupListFromCache"}),t.registerApi({apiName:"createFriendGroup",context:this}),t.registerApi({apiName:"deleteFriendGroup",context:this}),t.registerApi({apiName:"addToFriendGroup",context:this}),t.registerApi({apiName:"removeFromFriendGroup",context:this}),t.registerApi({apiName:"renameFriendGroup",context:this})}getFriendGroupListFromCache(){return e(this,void 0,void 0,(function*(){const e=[...this._friendGroupMap.values()];return console.log(`${t} getFriendGroupListFromCache, data: `,e),{code:0,data:e}}))}syncFriendGroupListFromServer(){return e(this,void 0,void 0,(function*(){const e="syncFriendGroupListFromServer";console.log(`${t} ${e}`);try{const r=yield k(),{resultList:i=[]}=r;this._core.helper.isEmpty(i)&&console.log(`${t} ${e} ok. count: 0`),i.forEach((e=>{const t=new O(e);this._friendGroupMap.set(e.name,t)})),this._emitGroupListUpdated()}catch(t){this._handleError(e,t)}}))}createFriendGroup(r){return e(this,void 0,void 0,(function*(){const e="createFriendGroup";console.log(`${t} ${e} params:`,r);try{const{name:t}=r;this._checkGroupExist(e,t);const i=yield N(r),{successUserIDList:o,failureUserIDList:n}=this._parseCreateGroupResponse(i),s=new O({name:t,userIDList:o});return this._friendGroupMap.set(t,s),this._emitGroupListUpdated(),{code:0,data:{friendGroup:s,failureUserIDList:n}}}catch(t){this._handleError(e,t)}}))}deleteFriendGroup(r){return e(this,void 0,void 0,(function*(){const e="deleteFriendGroup";console.log(`${t} ${e} params:`,r);try{const{name:t}=r;this._checkGroupNotExist(e,t),yield P(r);const i=this._friendGroupMap.get(t);return i&&(this._updateFriendGroup({name:t,userIDList:i.userIDList,action:m}),this._friendGroupMap.delete(t)),this._emitGroupListUpdated(),{code:0,data:i}}catch(t){this._handleError(e,t)}}))}addToFriendGroup(t){return e(this,void 0,void 0,(function*(){return this._updateFriendGroupMember({functionName:"addToFriendGroup",params:t,protocolFunction:G})}))}removeFromFriendGroup(t){return e(this,void 0,void 0,(function*(){return this._updateFriendGroupMember({functionName:"removeFromFriendGroup",params:t,protocolFunction:w})}))}renameFriendGroup(r){return e(this,void 0,void 0,(function*(){const e="renameFriendGroup";console.log(`${t} ${e} params:`,r);try{const{oldName:t,newName:i}=r;this._checkGroupNotExist(e,t),this._checkGroupExist(e,i),yield U(r);const o=this._updateGroupNameInCache(t,i);return o&&this._updateFriendGroup({name:t,userIDList:o.userIDList,action:_,newName:i}),this._emitGroupListUpdated(),{code:0,data:o}}catch(t){this._handleError(e,t)}}))}_updateFriendGroupMember(r){return e(this,void 0,void 0,(function*(){const{functionName:e,params:i,protocolFunction:o}=r;console.log(`${t} ${e} params:`,i);try{const{name:t}=i;this._checkGroupNotExist(e,t);const r=yield o(i),{friendGroup:n,failureUserIDList:s}=this._parseUpdateFriendGroupResponse(t,r);return this._emitGroupListUpdated(),{code:0,data:{friendGroup:n,failureUserIDList:s}}}catch(t){this._handleError(e,t)}}))}_updateGroupNameInCache(e,t){const r=this._friendGroupMap.get(e);return r&&(r.name=t,this._friendGroupMap.delete(e),this._friendGroupMap.set(t,r)),r}_parseCreateGroupResponse(e){const{resultList:t=[]}=e,r=[],i=[];return t.forEach((({userID:e,resultCode:t,resultInfo:o})=>{f(t)||0===t?r.push(e):i.push({userID:e,code:t,message:o})})),{successUserIDList:r,failureUserIDList:i}}_parseUpdateFriendGroupResponse(e,t){const{resultList:r=[]}=t,i=this._friendGroupMap.get(e),o=[],n=[],s=[];return r.forEach((t=>{0===t.resultCode?i&&(t.updateType===l?this._addFriendToGroup(e,t.userID,i,n):t.updateType===p&&this._removeFriendFromGroup(e,t.userID,i,s)):o.push({userID:t.userID,code:t.resultCode,message:t.resultInfo})})),{friendGroup:i,failureUserIDList:o}}_addFriendToGroup(e,t,r,i){r.addToUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:h})}_removeFriendFromGroup(e,t,r,i){r.removeFromUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:m})}_emitGroupListUpdated(){const{notificationCenter:e,OuterEvent:r}=this._core,i=[...this._friendGroupMap.values()];console.log(`${t} _emitGroupListUpdated friendGroupList:`,i),e.emitOuterEvent(r.FRIEND_GROUP_LIST_UPDATED,{name:r.FRIEND_GROUP_LIST_UPDATED,data:i})}_checkGroupNotExist(e,t){if(!this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:n})}_checkGroupExist(e,t){if(this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:o})}_updateFriendGroup(e){const{name:r,userIDList:i,action:o,newName:n}=e,{userStore:s}=this._core.appStore;console.log(`${t} updateFriendGroup`,{name:r,userIDList:i,action:o,newName:n}),r&&!this._core.utils.isEmpty(i)&&i.forEach((e=>{const t=s.getFriend(e);if(!t)return;const{groupList:i}=t;switch(o){case h:-1===i.indexOf(r)&&(i.push(r),t.count=i.length);break;case m:{const e=i.indexOf(r);e>-1&&(i.splice(e,1),t.count=i.length);break}case _:{if(!n)return;const e=i.indexOf(r);-1!==e&&(i[e]=n);break}}}))}_handleError(e,r){const i=new this._core.helper.ChatError({functionName:e,code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo});throw console.error(`${t} ${e} error:`,i),i}reset(){this._friendGroupMap.clear()}dispose(){this.reset()}};function B(e){return e&&0!==e.length?e.map((e=>({userID:e.To_Account,addBlackTimeStamp:e.AddBlackTimeStamp}))):[]}var b=new class{constructor(){this._blacklistMap=new Map,this._retryCount=0,this._startIndex=0}init(e){this._core=e;const{helper:t,constants:r}=e;t.registerApi({apiName:"getBlacklist",context:this,methodName:"getBlacklistFromCache"}),t.registerApi({apiName:"addToBlacklist",context:this}),t.registerApi({apiName:"removeFromBlacklist",context:this}),t.registerWorkflowStep(r.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.WORKFLOW_STEP.BLACKLIST_RECOVER,this.syncBlacklistFromServer,this)}getBlacklistFromCache(){return e(this,void 0,void 0,(function*(){return console.log(`${t} getBlacklistFromCache`),{code:0,data:Array.from(this._blacklistMap.keys())}}))}syncBlacklistFromServer(){return e(this,void 0,void 0,(function*(){try{console.log(`${t} syncBlacklistFromServer`);const i={From_Account:this._getCurrentUserId(),MaxLimited:r,StartIndex:this._startIndex},o=yield function(t,r){return e(this,void 0,void 0,(function*(){const{helper:e,channel:i}=r,o="sns.black_list_get",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{BlackListItem:a=[],StartIndex:c=0}=d;return{blackList:B(a),startIndex:c}}))}(i,this._core),{blackList:n=[],startIndex:s=0}=o;return this._startIndex=s,this._addBlacklistMap(n),this._emitBlackListUpdated(),0!==this._startIndex&&this._retryCount<10?(this._retryCount++,yield this.syncBlacklistFromServer()):this._retryCount=0,{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw this._retryCount=0,console.error(`${t} syncBlacklistFromServer error:`,e),e}}))}addToBlacklist(r){return e(this,void 0,void 0,(function*(){try{console.log(`${t} addToBlacklist options:`,r);const i=this._preprocessBlacklist(r),o={From_Account:this._getCurrentUserId(),To_Account:i},n=yield function(t,r){return e(this,void 0,void 0,(function*(){const{helper:e,channel:i}=r,o="sns.black_list_add",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{ResultItem:a=[]}=d;return{blackList:B(a)}}))}(o,this._core),{blackList:s=[]}=n;return this._addBlacklistMap(s),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw console.error(`${t} addToBlacklist error:`,e),e}}))}removeFromBlacklist(r){return e(this,void 0,void 0,(function*(){try{console.log(`${t} removeFromBlacklist options:`,r);const i={From_Account:this._getCurrentUserId(),To_Account:r.userIDList},o=yield function(t,r){return e(this,void 0,void 0,(function*(){const{helper:e,channel:i}=r,o="sns.black_list_delete",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{ResultItem:a=[]}=d;return{blackList:B(a)}}))}(i,this._core),{blackList:n=[]}=o;return this._deleteBlacklistMap(n),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw console.error(`${t} removeFromBlacklist error:`,e),e}}))}dispose(){this.reset()}reset(){this._retryCount=0,this._startIndex=0,this._blacklistMap.clear()}updateBlacklist(e){console.log(`${t} updateBlacklist data:`,e);const{addedBlacklist:r=[],removedBlacklist:i=[]}=e;let o=!1;if(r.length>0){r.some((e=>!this._blacklistMap.has(e)))&&(o=!0,this._addBlacklistMap(r.map((e=>({userID:e})))))}if(i.length>0){i.some((e=>this._blacklistMap.has(e)))&&(o=!0,this._deleteBlacklistMap(i.map((e=>({userID:e})))))}o&&this._emitBlackListUpdated()}_addBlacklistMap(e){console.log(`${t} _addBlacklistMap blackList:`,e),e.forEach((e=>{const{userID:t,addBlackTimeStamp:r=Date.now()}=e;t&&!this._blacklistMap.has(t)&&this._blacklistMap.set(t,{userID:t,addBlackTimeStamp:r})}))}_deleteBlacklistMap(e){console.log(`${t} _deleteBlacklistMap blackList:`,e),e.forEach((e=>{const{userID:t}=e;t&&this._blacklistMap.has(t)&&this._blacklistMap.delete(t)}))}_preprocessBlacklist(e){let{userIDList:t}=e;const r=this._getCurrentUserId();if(1===t.length&&t[0]===r)throw new this._core.helper.ChatError({functionName:"addToBlacklist",code:d});return t.includes(r)&&(t=e.userIDList.filter((e=>e!==r))),t}_getCurrentUserId(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("login"))||void 0===t?void 0:t.userId}_emitBlackListUpdated(){const{notificationCenter:e,OuterEvent:r}=this._core,i=Array.from(this._blacklistMap.keys());console.log(`${t} _emitBlackListUpdated blackList:`,i),e.emitOuterEvent(r.BLACKLIST_UPDATED,{name:r.BLACKLIST_UPDATED,data:i})}};const q={addToBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},getFriendProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},addFriend:{to:{required:!0,rules:["string"],allowEmpty:!1},source:{required:!0,rules:["string"],allowEmpty:!1},wording:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_ADD_TYPE_SINGLE||e===t.SNS_ADD_TYPE_BOTH||"type should be SNS_ADD_TYPE_SINGLE or SNS_ADD_TYPE_BOTH"}},remark:{required:!1,rules:["string"],allowEmpty:!0},groupName:{required:!1,rules:["string"],allowEmpty:!0}},deleteFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_DELETE_TYPE_SINGLE||e===t.SNS_DELETE_TYPE_BOTH||"type should be SNS_DELETE_TYPE_SINGLE or SNS_DELETE_TYPE_BOTH"}}},checkFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0}},updateFriend:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},friendCustomField:{required:!1,rules:["array"],allowEmpty:!0}},acceptFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_APPLICATION_AGREE||e===t.SNS_APPLICATION_AGREE_AND_ADD||"type should be SNS_APPLICATION_AGREE or SNS_APPLICATION_AGREE_AND_ADD"}}},refuseFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1}},deleteFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_APPLICATION_SENT_TO_ME||e===t.SNS_APPLICATION_SENT_BY_ME||"type should be SNS_APPLICATION_SENT_TO_ME or SNS_APPLICATION_SENT_BY_ME"}}},createFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},deleteFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1}},addToFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameFriendGroup:{oldName:{required:!0,rules:["string"],allowEmpty:!1},newName:{required:!0,rules:["string"],allowEmpty:!1}}},x={getBlacklist:!0,addToBlacklist:!0,removeFromBlacklist:!0,getFriendList:!0,addFriend:!0,deleteFriend:!0,updateFriend:!0,checkFriend:!0,getFriendProfile:!0,getFriendApplicationList:!0,acceptFriendApplication:!0,refuseFriendApplication:!0,deleteFriendApplication:!0,setFriendApplicationRead:!0,getFriendGroupList:!0,createFriendGroup:!0,deleteFriendGroup:!0,addToFriendGroup:!0,removeFromFriendGroup:!0,renameFriendGroup:!0};var V=new class{install(e){console.log(`${t} install`),this._core=e;const{helper:r,notificationCenter:i,InnerEvent:o,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:s}}=e;y.init(e),L.init(e),T.init(e),$.init(e),b.init(e),r.registerValidateConfig({auth:x,params:q}),r.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,s.FRIEND_AND_BLACKLIST_SYNC,this.handleLoginSuccess,this),i.subscribeInnerEvent(o.LOGOUT,this.reset,this),i.subscribeInnerEvent(o.MESSAGE_PUSH,i.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this)}handleLoginSuccess(){console.log(`${t} handleLoginSuccess`),b.syncBlacklistFromServer(),L.syncFriendListFromServer(),T.syncFriendApplicationListFromServer(),$.syncFriendGroupListFromServer()}onFriendModified(e){const{from:t,addedBlacklist:r,removedBlacklist:i,addedFriendList:o,removedFriendList:n,addedApplicationList:s,removedApplicationList:d,friendUpdateInfo:a,reportTime:c}=this._parseFriendListModification(null==e?void 0:e.FriendListMod[0]),{isEmpty:u}=this._core.utils;u(r)&&u(i)||b.updateBlacklist({addedBlacklist:r,removedBlacklist:i}),u(o)&&u(n)||(L.updateFriendList({addedFriendList:o,removedFriendList:n}),T.updateFriendApplicationList({from:t,removedApplicationList:o})),u(a)||L.updateFriendInfo(a),u(s)&&u(d)||T.updateFriendApplicationList({from:t,addedApplicationList:s,removedApplicationList:d}),c&&T.onApplicationRead()}_parseFriendListModification(e){const{PushType:t,From_Account:r,To_Account:i,ReportTime:o,BlackListAdd_Account:n=[],BlackListDel_Account:s=[],FriendAdd_Account:d=[],FriendDel_Account:a=[],PendencyAdd:c=[],FrienPencydDel_Account:u=[],FriendUpInfo:l=[]}=e,p=l.map((e=>({userID:e.Friend_Account,tagValueList:[...e.SNS]})));return{pushType:t,from:r,to:i,reportTime:o,addedBlacklist:n,removedBlacklist:s,addedFriendList:d,removedFriendList:a,addedApplicationList:c.map((e=>({userID:e.PendencyAdd_Account,source:e.AddSource,time:e.AddTime,wording:e.AddWording,nick:e.ProfileImNick}))),friendUpdateInfo:p,removedApplicationList:u}}reset(){console.log(`${t} reset`),b.reset(),L.reset(),T.reset(),$.reset()}dispose(){console.log(`${t} dispose`);const{notificationCenter:e,InnerEvent:r}=this._core;e.unSubscribeInnerEvent(r.LOGOUT,this.reset,this),e.unSubscribeInnerEvent(r.MESSAGE_PUSH,e.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this),b.dispose(),L.dispose(),T.dispose(),$.dispose()}};export{V as default};
package/plugins/friend.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TencentCloudChatFriend=e()}(this,(function(){"use strict";function t(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function c(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,c)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const e="friend";var i=new class{init(t){this._core=t;const{helper:e}=t;e.registerApi("getBlacklist",this)}getBlacklist(){return t(this,void 0,void 0,(function*(){return console.log(`${e} getBlacklist`),{code:0,data:[]}}))}};var n=new class{init(t){this._core=t;const{helper:e}=t;e.registerApi("getFriendList",this)}getFriendList(){return t(this,void 0,void 0,(function*(){return console.log(`${e} getFriendList`),{code:0,data:[]}}))}};var o=new class{init(t){this._core=t;const{helper:e}=t;e.registerApi("getFriendApplicationList",this)}getFriendApplicationList(){return t(this,void 0,void 0,(function*(){return console.log(`${e} getFriendApplicationList`),{code:0,data:{friendApplicationList:[],unreadCount:0}}}))}};var r=new class{init(t){this._core=t}};const s={getBlacklist:!0,getFriendList:!0,getFriendApplicationList:!0};return new class{install(t){i.init(t),n.init(t),o.init(t),r.init(t),t.helper.registerValidateConfig({auth:s})}}}));
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).TencentCloudChatFriend=t()}(this,(function(){"use strict";function e(e,t,r,i){return new(r||(r=Promise))((function(o,n){function s(e){try{a(i.next(e))}catch(e){n(e)}}function d(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,d)}a((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t="friend",r=100,i=2700,o=2710,n=2711,s=2716,d=2742,a=30539,c="Tag_SNS_IM_",u={GROUP:`${c}Group`,REMARK:`${c}Remark`,ADDSOURCE:`${c}AddSource`,ADDWORDING:`${c}Wording`,ADDTIME:`${c}AddTime`},l="Update_Type_Add",p="Update_Type_Delete",h="add",m="remove",_="rename",f=e=>void 0===e;function I(t,r){return e(this,void 0,void 0,(function*(){return function(e){return v(e,"ResultItem",(e=>({to:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_update",data:t}))}))}function F(t,r){return e(this,void 0,void 0,(function*(){return function(e){return v(e,"InfoItem",(e=>({userID:e.To_Account,relation:e.Relation,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_check",data:t}))}))}function v(e,t="ResultItem",r=e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})){const{[t]:i=[],ActionStatus:o,ErrorCode:n,ErrorInfo:s,ErrorDisplay:d}=e;return{resultList:i.map(r),actionStatus:o,errorCode:n,errorInfo:s,errorDisplay:d}}const A={[u.REMARK]:(e,t)=>{e.remark=t},[u.GROUP]:(e,t)=>{e.groupList=t?JSON.parse(JSON.stringify(t)):[]},[u.ADDSOURCE]:(e,t)=>{e.source=t},[u.ADDWORDING]:(e,t)=>{e.wording=t},[u.ADDTIME]:(e,t)=>{e.addTime=t}};let g=class{constructor(e){var t;this.userID="",this.source="",this.wording="",this.remark="",this.addTime=0,this.groupList=[],this.friendCustomField=[];const{userID:r,tagValueList:i=[],core:o}=e,n=null===(t=o.user.userProfile)||void 0===t?void 0:t.createProfile(r,i);this.userID=r,this.profile=n,i.forEach((e=>{const{tag:t,value:r}=e;t.indexOf("Tag_Profile_Custom")>-1&&this.friendCustomField.push({key:t,value:r});const i=A[t];null==i||i(this,r)}))}update(e){const t=[];this.friendCustomField.forEach((e=>{t.push(e.key)})),e.forEach((e=>{const{tag:r,value:i}=e;r.indexOf("Tag_Profile_Custom")>-1&&(t.indexOf(r)>-1?this.friendCustomField.forEach((e=>{e.key===r&&(e.value=i)})):this.friendCustomField.push({key:r,value:i}));const o=A[r];null==o||o(this,i)}))}};var L=new class{constructor(){this._startIndex=0,this._standardSequence=0,this._customSequence=0}init(e){this._core=e;const{helper:t,constants:r}=e;t.registerApi({apiName:"getFriendList",context:this,methodName:"getFriendListFromCache"}),t.registerApi({apiName:"getFriendProfile",context:this}),t.registerApi({apiName:"addFriend",context:this}),t.registerApi({apiName:"deleteFriend",context:this}),t.registerApi({apiName:"updateFriend",context:this}),t.registerApi({apiName:"checkFriend",context:this}),t.registerWorkflowStep(r.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.WORKFLOW_STEP.FRIEND_RECOVER,this.syncFriendListFromServer,this)}getFriendListFromCache(){return e(this,void 0,void 0,(function*(){const{userStore:e}=this._core.appStore,r=[...e.getFriendMap().values()];return console.log(`${t} getFriendListFromCache, data `,r),{code:0,data:r}}))}syncFriendListFromServer(){return e(this,void 0,void 0,(function*(){var r;try{console.log(`${t} syncFriendListFromServer`);const i={From_Account:null===(r=this._core.store.get("login"))||void 0===r?void 0:r.userId,StartIndex:this._startIndex,StandardSequence:this._standardSequence,CustomSequence:this._customSequence},o=yield function(t,r){return e(this,void 0,void 0,(function*(){return function(e){const{UserDataItem:t=[],StandardSequence:r,CustomSequence:i,FriendNum:o,CompleteFlag:n,NextStartIndex:s,ActionStatus:d,ErrorCode:a,ErrorInfo:c,ErrorDisplay:u}=e;return{friendList:t.map((e=>{var t;return{userID:e.To_Account,tagValueList:null===(t=e.ValueItem)||void 0===t?void 0:t.map((e=>({tag:e.Tag,value:e.Value})))}})),standardSequence:r,customSequence:i,friendNumber:o,completeFlag:n,nextStartIndex:s,actionStatus:d,errorCode:a,errorInfo:c,errorDisplay:u}}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_get",data:t}))}))}(i,this._core),{friendList:n,nextStartIndex:s,standardSequence:d,customSequence:a,completeFlag:c}=o;this._startIndex=s,this._standardSequence=d,this._customSequence=a,this._processFriendList(n),0===c?yield this.syncFriendListFromServer():(this._emitFriendListUpdated(),this._fetchFriendProfile()),console.log(`${t} syncFriendListFromServer ok`)}catch(e){throw console.error(`${t} syncFriendListFromServer error:`,e),e}}))}getFriendProfile(i){return e(this,void 0,void 0,(function*(){var o;try{console.log(`${t} getFriendProfile params:`,i);let{userIDList:n}=i;n.length>r&&(n=n.slice(0,r));const{friendUserIdList:s,unFriendUserIdList:d}=this.partitionByIsFriend(n),a=this._createNonFriendErrorList(d);if(0===s.length)return{code:0,data:{friendList:[],failureUserIDList:a}};const c={From_Account:null===(o=this._core.store.get("login"))||void 0===o?void 0:o.userId,To_Account:s},u=(yield function(t,r){return e(this,void 0,void 0,(function*(){return function(e){const{InfoItem:t=[],ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=e;return{friendProfileList:t.map((e=>{var t;return{userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo,relation:e.Relation,standardSequence:e.StandardSequence,customSequence:e.CustomSequence,profileItem:(null===(t=e.SnsProfileItem)||void 0===t?void 0:t.map((e=>({tag:e.Tag,value:e.Value}))))||[]}})),actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:n}}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_get_specified",data:t}))}))}(c,this._core))||{},{successProfiles:l,failedProfiles:p}=this._processFriendProfileResponse(u);return{code:0,data:{friendList:l,failureUserIDList:[...p,...a]}}}catch(e){throw console.error(`${t} getFriendProfile error:`,e),e}}))}addFriend(r){return e(this,void 0,void 0,(function*(){var i;try{console.log(`${t} addFriend options:`,r);const{helper:o,store:n}=this._core,{to:s,source:d,type:c,wording:u,remark:l,groupName:p}=r,h={From_Account:null===(i=n.get("login"))||void 0===i?void 0:i.userId,AddFriendItem:[{To_Account:s,AddSource:d,AddWording:u,GroupName:p,Remark:l}],AddType:c},m=yield function(t,r){return e(this,void 0,void 0,(function*(){return v(yield r.common.buildAndSendPacket({servcmd:"sns.friend_add",data:t}))}))}(h,this._core),{resultList:_=[]}=m,{userID:f,resultCode:I}=_[0];if(0===I)return console.log(`${t} addFriend ok`),{code:0,data:{userID:f}};if(I===a)return console.log(`${t} addFriend wait for the other party to agree`),{code:0,data:{userID:f,code:I,message:"wait for the other party to agree"}};throw new o.ChatError({functionName:"addFriend",code:I})}catch(e){throw console.error(`${t} addFriend error:`,e),e}}))}deleteFriend(i){return e(this,void 0,void 0,(function*(){var o;try{console.log(`${t} deleteFriend options:`,i);const{store:n}=this._core;let{userIDList:s,type:d}=i;const a=null===(o=n.get("login"))||void 0===o?void 0:o.userId;s.length>1e3&&(console.warn(`${t} deleteFriend the length of userIDList cannot exceed:`,1e3),s=s.slice(0,r));const{friendUserIdList:c,unFriendUserIdList:u}=this.partitionByIsFriend(s);if(0===c.length)return{code:0,data:{friendList:[],failureUserIDList:this._createNonFriendErrorList(u)}};const l={From_Account:a,To_Account:c,DeleteType:d},p=yield function(t,r){return e(this,void 0,void 0,(function*(){return v(yield r.common.buildAndSendPacket({servcmd:"sns.friend_delete",data:t}))}))}(l,this._core),{successUserIDList:h,failureUserIDList:m}=this._processOperationResult({resultList:p.resultList,includeRelation:!1});return console.log(`${t} deleteFriend ok`),{code:0,data:{successUserIDList:h,failureUserIDList:m}}}catch(e){throw console.error(`${t} deleteFriend error:`,e),e}}))}updateFriend(r){return e(this,void 0,void 0,(function*(){var e;try{console.log(`${t} updateFriend options:`,r);const{userID:o,remark:n,friendCustomField:s}=r,{helper:d,store:a,appStore:{userStore:c}}=this._core,u=null===(e=a.get("login"))||void 0===e?void 0:e.userId;if(!c.getFriendMap().has(o))throw new d.ChatError({functionName:"updateFriend",code:i});const l={From_Account:u,UpdateItem:[{To_Account:o,SnsItem:this._buildSnsItemList(n,s)}]},p=yield I(l,this._core),{resultList:h}=p,{to:m,resultCode:_,resultInfo:F}=h[0];if(f(_)||0===_){return{code:0,data:this._updateLocalFriend({userID:m,remark:n,friendCustomField:s})}}throw new d.ChatError({functionName:"updateFriend",code:_,message:F})}catch(e){throw console.error(`${t} updateFriend error:`,e),e}}))}checkFriend(r){return e(this,void 0,void 0,(function*(){var e;try{console.log(`${t} checkFriend options:`,r);const{userIDList:i,type:o}=r,{OuterConstant:n,store:s}=this._core,d=null===(e=s.get("login"))||void 0===e?void 0:e.userId,a={From_Account:d,To_Account:i,CheckType:o===n.SNS_CHECK_TYPE_SINGLE?o:n.SNS_CHECK_TYPE_BOTH},c=yield F(a,this._core),{successUserIDList:u=[],failureUserIDList:l=[]}=this._processOperationResult({resultList:c.resultList,includeRelation:!0});return{code:0,data:{successUserIDList:u,failureUserIDList:l}}}catch(e){throw console.error(`${t} checkFriend error:`,e),e}}))}dispose(){this.reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this)}reset(){const{userStore:e}=this._core.appStore;e.getFriendMap().clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}updateFriendList(r){return e(this,void 0,void 0,(function*(){console.log(`${t} updateFriendList data:`,r);const{userStore:e}=this._core.appStore,{addedFriendList:i=[],removedFriendList:o=[]}=r;i.length>0&&(i.forEach((t=>{const r=new g({userID:t,core:this._core});e.getFriendMap().set(t,r)})),yield this.getFriendProfile({userIDList:i}),this._emitFriendListUpdated()),o.length>0&&(o.forEach((t=>{e.getFriendMap().delete(t)})),this._emitFriendListUpdated())}))}updateFriendInfo(e){console.log(`${t} updateFriendInfo data: `,e);const{appStore:{userStore:r,conversationStore:i},utils:{isEmpty:o}}=this._core,{userID:n,tagValueList:s}=e[0]||{},d=r.getFriend(n);if(o(s)||!d)return;const a=s.map((e=>({tag:e.BytesTag,value:e.BytesValue})));a.forEach((e=>{var t;const{tag:r,value:o}=e,s=null===(t=i.getConversation(`C2C${n}`))||void 0===t?void 0:t.remark;r===u.REMARK&&o!==s&&i.updateConversation(`C2C${n}`,{remark:o}),d.update(a)})),this._emitFriendListUpdated()}_processFriendList(e){const{utils:{isEmpty:t},appStore:{userStore:r}}=this._core;t(e)||e.forEach((e=>{const{userID:t,tagValueList:i}=e;if(this._isInvalidFriend(t))return;const o=new g({userID:t,tagValueList:i,core:this._core});r.getFriendMap().set(t,o)}))}_isInvalidFriend(e){return"@TLS#NOT_FOUND"===e||""===e}_fetchFriendProfile(){return e(this,void 0,void 0,(function*(){try{console.log(`${t} _fetchFriendProfile`);const{appStore:{userStore:e},user:{userProfile:r}}=this._core,i=[...e.getFriendMap().keys()],o=100,n=Math.ceil(i.length/o);for(let t=0;t<n;t++){const n=t*o,s=Math.min(n+o,i.length),d=i.slice(n,s),a=yield null==r?void 0:r.getUserProfile({userIDList:d});if(a&&a.data){a.data.forEach((t=>{const r=e.getFriend(t.userID);r&&(r.profile=t)}))}this._emitFriendListUpdated()}}catch(e){throw console.error(`${t} _fetchFriendProfile error:`,e),e}}))}_emitFriendListUpdated(){const{notificationCenter:e,OuterEvent:r,appStore:{userStore:i}}=this._core,o=Array.from(i.getFriendMap().values());console.log(`${t} _emitFriendListUpdated friendList:`,o),e.emitOuterEvent(r.FRIEND_LIST_UPDATED,{name:r.FRIEND_LIST_UPDATED,data:o})}_updateCustomField(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let r=!1;return t.forEach((({key:t,value:i})=>{const o=e.find((e=>e.key===t));o?o.value!==i&&(o.value=i,r=!0):(e.push({key:t,value:i}),r=!0)})),r}_updateLocalFriend(e){const{userStore:t}=this._core.appStore,{userID:r,remark:i,friendCustomField:o}=e,n=t.getFriend(r);if(n)return f(i)||(n.remark=i),Array.isArray(o)&&o.length>0&&this._updateCustomField(n.friendCustomField,o),this._emitFriendListUpdated(),n}_processOperationResult(e){const{resultList:t,includeRelation:r=!1}=e,{isEmpty:i}=this._core.utils,o=[],n=[];return Array.isArray(t)&&!i(t)&&t.forEach((e=>{const{userID:t,relation:i,resultCode:s,resultInfo:d}=e;if(f(s)||0===s){const e={userID:t};r&&(e.code=0,e.relation=i),o.push(e)}else n.push({userID:t,code:s,message:d})})),{successUserIDList:o,failureUserIDList:n}}_createNonFriendErrorList(e){return e.map((e=>({userID:e,code:i,message:"The specified userID is not my friend"})))}_buildSnsItemList(e,t){const r=[];return f(e)||r.push({Tag:u.REMARK,Value:e}),Array.isArray(t)&&t.length>0&&t.forEach((e=>{r.push({tag:e.key,value:e.value})})),r}_processFriendProfileResponse(e){const{friendProfileList:r=[]}=e,{userStore:i}=this._core.appStore,o=[],n=[];return r.forEach((e=>{const{userID:t,resultCode:r,resultInfo:s,profileItem:d}=e;if(0===r){const e=new g({userID:t,tagValueList:d,core:this._core});o.push(e),i.getFriendMap().set(t,e)}else n.push({userID:t,code:r,message:s})})),console.log(`${t} _processFriendProfileResponse successProfiles:`,o),{successProfiles:o,failedProfiles:n}}partitionByIsFriend(e){const r=[],i=[];return e.forEach((e=>{const{userStore:t}=this._core.appStore;t.getFriendMap().has(e)?r.push(e):i.push(e)})),console.log(`${t} partitionByIsFriend, friendUserIdList: ${r}, unFriendUserIdList: ${i}`),{friendUserIdList:r,unFriendUserIdList:i}}isMyFriend(e){const{userStore:t}=this._core.appStore;return t.getFriendMap().has(e)}};var y=new class{init(e){this.core=e}};function S(t){return e(this,void 0,void 0,(function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,ResponseFriendItem:[{To_Account:t.userID,ResponseAction:t.type,Remark:t.remark}]};return T(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))}))}function E(t){return e(this,void 0,void 0,(function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,ResponseFriendItem:[{To_Account:t.userID,ResponseAction:"Response_Action_Reject"}]};return T(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))}))}function D(t){return e(this,void 0,void 0,(function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,To_Account:[t.userID],PendencyType:t.type};return T(yield i.buildAndSendPacket({servcmd:"sns.pendency_delete",data:o}))}))}function T(e){const{ResultItem:t=[],ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=e;return{resultList:t.map((e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))),actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:n}}var C=new class{constructor(){this._friendApplicationMap=new Map,this._unreadCount=0,this._startTime=0,this._currentSequence=0}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendApplicationList",context:this,methodName:"getFriendApplicationListFromCache"}),t.registerApi({apiName:"acceptFriendApplication",context:this}),t.registerApi({apiName:"refuseFriendApplication",context:this}),t.registerApi({apiName:"deleteFriendApplication",context:this}),t.registerApi({apiName:"setFriendApplicationRead",context:this})}getFriendApplicationListFromCache(){return e(this,void 0,void 0,(function*(){const e=[...this._friendApplicationMap.values()];return console.log(`${t} getFriendApplicationListFromCache friendApplicationList:`,e),{code:0,data:{friendApplicationList:e,unreadCount:this._unreadCount}}}))}syncFriendApplicationListFromServer(){return e(this,void 0,void 0,(function*(){const i="syncFriendApplicationListFromServer";console.log(`${t} ${i}`);try{const t=yield function(t){return e(this,void 0,void 0,(function*(){var e;const{store:i,OuterConstant:o,common:n}=y.core,s={From_Account:null===(e=i.get("login"))||void 0===e?void 0:e.userId,PendencyType:o.SNS_APPLICATION_TYPE_BOTH,MaxLimited:r,StartTime:t.startTime,LastSequence:t.currentSequence};return function(e){const{PendencyItem:t=[],StartTime:r,UnreadPendencyCount:i,CurrentSequence:o,ActionStatus:n,ErrorCode:s,ErrorInfo:d,ErrorDisplay:a}=e;return{resultList:t.map((e=>({userID:e.To_Account,time:e.AddTime,source:e.AddSource,wording:e.AddWording,nick:e.Nick,type:e.PendencyType,image:e.Image}))),startTime:r,unreadCount:i,currentSequence:o,actionStatus:n,errorCode:s,errorInfo:d,errorDisplay:a}}(yield n.buildAndSendPacket({servcmd:"sns.pendency_get",data:s}))}))}({startTime:this._startTime,currentSequence:this._currentSequence}),{resultList:i,unreadCount:o,startTime:n,currentSequence:s}=t;this._startTime=n,this._currentSequence=s,this._unreadCount=o,this._friendApplicationMap.clear(),Array.isArray(i)&&i.forEach((e=>{const{userID:t,type:r}=e,i=this._createFriendApplication(e);this._friendApplicationMap.set(`${t}_${r}`,i)})),this._emitApplicationListUpdated()}catch(e){const r=new this._core.helper.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${t} ${i} error:`,r),r}}))}acceptFriendApplication(t){return e(this,void 0,void 0,(function*(){return this._operationApplication({functionName:"acceptFriendApplication",options:t,protocolFunction:S})}))}refuseFriendApplication(t){return e(this,void 0,void 0,(function*(){return this._operationApplication({functionName:"refuseFriendApplication",options:t,protocolFunction:E})}))}deleteFriendApplication(t){return e(this,void 0,void 0,(function*(){const{userID:e,type:r}=t;return this._checkApplicationExists(e,r,"deleteFriendApplication"),this._operationApplication({functionName:"deleteFriendApplication",options:t,protocolFunction:D})}))}_checkApplicationExists(e,t,r){if(!this._friendApplicationMap.has(`${e}_${t}`))throw new this._core.helper.ChatError({functionName:r,code:s})}_operationApplication(r){return e(this,void 0,void 0,(function*(){const{functionName:e,options:i,protocolFunction:o}=r;console.log(`${t} ${e} options:`,i);try{const r=yield o(i),{resultList:n=[]}=r,{resultCode:s,resultInfo:d}=n[0];if(0===s)return console.log(`${t} ${e} ok`),{code:0,data:{}};throw{errorCode:s,errorInfo:d}}catch(r){const i=new this._core.helper.ChatError({functionName:e,code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo});throw console.error(`${t} ${e} error:`,i),i}}))}setFriendApplicationRead(){return e(this,void 0,void 0,(function*(){const r="setFriendApplicationRead";console.log(`${t} ${r}`);try{return yield function(){return e(this,void 0,void 0,(function*(){var e;const{store:t,common:r}=y.core,i={From_Account:null===(e=t.get("login"))||void 0===e?void 0:e.userId,LatestPendencyTimeStamp:(o=Math.floor(Date.now()/1e3),n=0,Math.round(Number(o)*Math.pow(10,n))/Math.pow(10,n))};var o,n;return function(e){const{ActionStatus:t,ErrorCode:r,ErrorInfo:i,ErrorDisplay:o}=e;return{actionStatus:t,errorCode:r,errorInfo:i,errorDisplay:o}}(yield r.buildAndSendPacket({servcmd:"sns.pendency_report",data:i}))}))}(),this._unreadCount=0,this._emitApplicationListUpdated(),console.log(`${t} ${r} ok`),{code:0,data:{}}}catch(e){const i=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${t} ${r} error:`,i),i}}))}updateFriendApplicationList(e){const{from:r,addedApplicationList:i=[],removedApplicationList:o=[]}=e;console.log(`${t} updateFriendApplicationList data:`,e);const{isEmpty:n}=this._core.utils;n(i)||this.onApplicationAdded(i,r),n(o)||this.onApplicationDeleted()}onApplicationAdded(e,t){var r;const{store:i,OuterConstant:o}=this._core,n=t===(null===(r=i.get("login"))||void 0===r?void 0:r.userId)?o.SNS_APPLICATION_SENT_BY_ME:o.SNS_APPLICATION_SENT_TO_ME;e.forEach((e=>{const t=`${e.userID}_${n}`;n!==o.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,this._createFriendApplication(Object.assign(Object.assign({},e),{type:n})))})),this._emitApplicationListUpdated()}onApplicationDeleted(){this._startTime=0,this._currentSequence=0,this.syncFriendApplicationListFromServer()}onApplicationRead(){this._unreadCount=0,this._emitApplicationListUpdated()}reset(){this._startTime=0,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}dispose(){this.reset()}_createFriendApplication(e){return{userID:e.userID||"",nick:e.nick||"",avatar:e.avatar||"",time:e.time||0,source:e.source||"",wording:e.wording||"",type:e.type||""}}_emitApplicationListUpdated(){console.log(`${t} _emitApplicationListUpdated`);const{notificationCenter:e,OuterEvent:r}=this._core;e.emitOuterEvent(r.FRIEND_APPLICATION_LIST_UPDATED,{name:r.FRIEND_APPLICATION_LIST_UPDATED,data:{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}})}};function k(){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,t={From_Account:e.getCurrentUserID(),LastSequence:0,NeedFriend:"Need_Friend_Type_Yes"};return function(e){return M(e,(e=>({name:e.GroupName,userIDList:e.To_Account||[],count:e.FriendNumber})))}(yield e.buildAndSendPacket({servcmd:"sns.group_get",data:t}))}))}function N(t){return e(this,void 0,void 0,(function*(){const{name:e,userIDList:r}=t,{common:i}=y.core,o={From_Account:i.getCurrentUserID(),GroupName:[e],To_Account:r};return function(e){return M(e,(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield i.buildAndSendPacket({servcmd:"sns.group_add",data:o}))}))}function P(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,r={From_Account:e.getCurrentUserID(),GroupName:[t.name]};return function(e){return M(e)}(yield e.buildAndSendPacket({servcmd:"sns.group_delete",data:r}))}))}function G(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,{name:r,userIDList:i}=t,o=R(i,l),n={From_Account:e.getCurrentUserID(),GroupOldName:r,UpdateGroupItem:o};return function(e){return M(e,(e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:n}))}))}function w(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,{name:r,userIDList:i}=t,o=R(i,p),n={From_Account:e.getCurrentUserID(),GroupOldName:r,UpdateGroupItem:o};return function(e){return M(e,(e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo})))}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:n}))}))}function U(t){return e(this,void 0,void 0,(function*(){const{common:e}=y.core,{oldName:r,newName:i}=t,o={From_Account:e.getCurrentUserID(),GroupOldName:r,GroupNewName:i};return function(e){return M(e)}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:o}))}))}function R(e,t){return e.filter((e=>L.isMyFriend(e))).map((e=>({To_Account:e,UpdateType:t})))}function M(e,t){const{CurrentSequence:r,ActionStatus:i,ErrorCode:o,ErrorInfo:n,ErrorDisplay:s,ResultItem:d=[]}=e,a={currentSequence:r,actionStatus:i,errorCode:o,errorInfo:n,errorDisplay:s};return t&&d.length>0?Object.assign(Object.assign({},a),{resultList:d.map(t)}):a}class O{constructor(e){const{name:t="",userIDList:r=[]}=e;this.name=t,this.userIDList=r,this.count=r.length}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}var $=new class{constructor(){this._friendGroupMap=new Map}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendGroupList",context:this,methodName:"getFriendGroupListFromCache"}),t.registerApi({apiName:"createFriendGroup",context:this}),t.registerApi({apiName:"deleteFriendGroup",context:this}),t.registerApi({apiName:"addToFriendGroup",context:this}),t.registerApi({apiName:"removeFromFriendGroup",context:this}),t.registerApi({apiName:"renameFriendGroup",context:this})}getFriendGroupListFromCache(){return e(this,void 0,void 0,(function*(){const e=[...this._friendGroupMap.values()];return console.log(`${t} getFriendGroupListFromCache, data: `,e),{code:0,data:e}}))}syncFriendGroupListFromServer(){return e(this,void 0,void 0,(function*(){const e="syncFriendGroupListFromServer";console.log(`${t} ${e}`);try{const r=yield k(),{resultList:i=[]}=r;this._core.helper.isEmpty(i)&&console.log(`${t} ${e} ok. count: 0`),i.forEach((e=>{const t=new O(e);this._friendGroupMap.set(e.name,t)})),this._emitGroupListUpdated()}catch(t){this._handleError(e,t)}}))}createFriendGroup(r){return e(this,void 0,void 0,(function*(){const e="createFriendGroup";console.log(`${t} ${e} params:`,r);try{const{name:t}=r;this._checkGroupExist(e,t);const i=yield N(r),{successUserIDList:o,failureUserIDList:n}=this._parseCreateGroupResponse(i),s=new O({name:t,userIDList:o});return this._friendGroupMap.set(t,s),this._emitGroupListUpdated(),{code:0,data:{friendGroup:s,failureUserIDList:n}}}catch(t){this._handleError(e,t)}}))}deleteFriendGroup(r){return e(this,void 0,void 0,(function*(){const e="deleteFriendGroup";console.log(`${t} ${e} params:`,r);try{const{name:t}=r;this._checkGroupNotExist(e,t),yield P(r);const i=this._friendGroupMap.get(t);return i&&(this._updateFriendGroup({name:t,userIDList:i.userIDList,action:m}),this._friendGroupMap.delete(t)),this._emitGroupListUpdated(),{code:0,data:i}}catch(t){this._handleError(e,t)}}))}addToFriendGroup(t){return e(this,void 0,void 0,(function*(){return this._updateFriendGroupMember({functionName:"addToFriendGroup",params:t,protocolFunction:G})}))}removeFromFriendGroup(t){return e(this,void 0,void 0,(function*(){return this._updateFriendGroupMember({functionName:"removeFromFriendGroup",params:t,protocolFunction:w})}))}renameFriendGroup(r){return e(this,void 0,void 0,(function*(){const e="renameFriendGroup";console.log(`${t} ${e} params:`,r);try{const{oldName:t,newName:i}=r;this._checkGroupNotExist(e,t),this._checkGroupExist(e,i),yield U(r);const o=this._updateGroupNameInCache(t,i);return o&&this._updateFriendGroup({name:t,userIDList:o.userIDList,action:_,newName:i}),this._emitGroupListUpdated(),{code:0,data:o}}catch(t){this._handleError(e,t)}}))}_updateFriendGroupMember(r){return e(this,void 0,void 0,(function*(){const{functionName:e,params:i,protocolFunction:o}=r;console.log(`${t} ${e} params:`,i);try{const{name:t}=i;this._checkGroupNotExist(e,t);const r=yield o(i),{friendGroup:n,failureUserIDList:s}=this._parseUpdateFriendGroupResponse(t,r);return this._emitGroupListUpdated(),{code:0,data:{friendGroup:n,failureUserIDList:s}}}catch(t){this._handleError(e,t)}}))}_updateGroupNameInCache(e,t){const r=this._friendGroupMap.get(e);return r&&(r.name=t,this._friendGroupMap.delete(e),this._friendGroupMap.set(t,r)),r}_parseCreateGroupResponse(e){const{resultList:t=[]}=e,r=[],i=[];return t.forEach((({userID:e,resultCode:t,resultInfo:o})=>{f(t)||0===t?r.push(e):i.push({userID:e,code:t,message:o})})),{successUserIDList:r,failureUserIDList:i}}_parseUpdateFriendGroupResponse(e,t){const{resultList:r=[]}=t,i=this._friendGroupMap.get(e),o=[],n=[],s=[];return r.forEach((t=>{0===t.resultCode?i&&(t.updateType===l?this._addFriendToGroup(e,t.userID,i,n):t.updateType===p&&this._removeFriendFromGroup(e,t.userID,i,s)):o.push({userID:t.userID,code:t.resultCode,message:t.resultInfo})})),{friendGroup:i,failureUserIDList:o}}_addFriendToGroup(e,t,r,i){r.addToUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:h})}_removeFriendFromGroup(e,t,r,i){r.removeFromUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:m})}_emitGroupListUpdated(){const{notificationCenter:e,OuterEvent:r}=this._core,i=[...this._friendGroupMap.values()];console.log(`${t} _emitGroupListUpdated friendGroupList:`,i),e.emitOuterEvent(r.FRIEND_GROUP_LIST_UPDATED,{name:r.FRIEND_GROUP_LIST_UPDATED,data:i})}_checkGroupNotExist(e,t){if(!this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:n})}_checkGroupExist(e,t){if(this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:o})}_updateFriendGroup(e){const{name:r,userIDList:i,action:o,newName:n}=e,{userStore:s}=this._core.appStore;console.log(`${t} updateFriendGroup`,{name:r,userIDList:i,action:o,newName:n}),r&&!this._core.utils.isEmpty(i)&&i.forEach((e=>{const t=s.getFriend(e);if(!t)return;const{groupList:i}=t;switch(o){case h:-1===i.indexOf(r)&&(i.push(r),t.count=i.length);break;case m:{const e=i.indexOf(r);e>-1&&(i.splice(e,1),t.count=i.length);break}case _:{if(!n)return;const e=i.indexOf(r);-1!==e&&(i[e]=n);break}}}))}_handleError(e,r){const i=new this._core.helper.ChatError({functionName:e,code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo});throw console.error(`${t} ${e} error:`,i),i}reset(){this._friendGroupMap.clear()}dispose(){this.reset()}};function B(e){return e&&0!==e.length?e.map((e=>({userID:e.To_Account,addBlackTimeStamp:e.AddBlackTimeStamp}))):[]}var b=new class{constructor(){this._blacklistMap=new Map,this._retryCount=0,this._startIndex=0}init(e){this._core=e;const{helper:t,constants:r}=e;t.registerApi({apiName:"getBlacklist",context:this,methodName:"getBlacklistFromCache"}),t.registerApi({apiName:"addToBlacklist",context:this}),t.registerApi({apiName:"removeFromBlacklist",context:this}),t.registerWorkflowStep(r.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.WORKFLOW_STEP.BLACKLIST_RECOVER,this.syncBlacklistFromServer,this)}getBlacklistFromCache(){return e(this,void 0,void 0,(function*(){return console.log(`${t} getBlacklistFromCache`),{code:0,data:Array.from(this._blacklistMap.keys())}}))}syncBlacklistFromServer(){return e(this,void 0,void 0,(function*(){try{console.log(`${t} syncBlacklistFromServer`);const i={From_Account:this._getCurrentUserId(),MaxLimited:r,StartIndex:this._startIndex},o=yield function(t,r){return e(this,void 0,void 0,(function*(){const{helper:e,channel:i}=r,o="sns.black_list_get",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{BlackListItem:a=[],StartIndex:c=0}=d;return{blackList:B(a),startIndex:c}}))}(i,this._core),{blackList:n=[],startIndex:s=0}=o;return this._startIndex=s,this._addBlacklistMap(n),this._emitBlackListUpdated(),0!==this._startIndex&&this._retryCount<10?(this._retryCount++,yield this.syncBlacklistFromServer()):this._retryCount=0,{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw this._retryCount=0,console.error(`${t} syncBlacklistFromServer error:`,e),e}}))}addToBlacklist(r){return e(this,void 0,void 0,(function*(){try{console.log(`${t} addToBlacklist options:`,r);const i=this._preprocessBlacklist(r),o={From_Account:this._getCurrentUserId(),To_Account:i},n=yield function(t,r){return e(this,void 0,void 0,(function*(){const{helper:e,channel:i}=r,o="sns.black_list_add",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{ResultItem:a=[]}=d;return{blackList:B(a)}}))}(o,this._core),{blackList:s=[]}=n;return this._addBlacklistMap(s),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw console.error(`${t} addToBlacklist error:`,e),e}}))}removeFromBlacklist(r){return e(this,void 0,void 0,(function*(){try{console.log(`${t} removeFromBlacklist options:`,r);const i={From_Account:this._getCurrentUserId(),To_Account:r.userIDList},o=yield function(t,r){return e(this,void 0,void 0,(function*(){const{helper:e,channel:i}=r,o="sns.black_list_delete",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{ResultItem:a=[]}=d;return{blackList:B(a)}}))}(i,this._core),{blackList:n=[]}=o;return this._deleteBlacklistMap(n),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw console.error(`${t} removeFromBlacklist error:`,e),e}}))}dispose(){this.reset()}reset(){this._retryCount=0,this._startIndex=0,this._blacklistMap.clear()}updateBlacklist(e){console.log(`${t} updateBlacklist data:`,e);const{addedBlacklist:r=[],removedBlacklist:i=[]}=e;let o=!1;if(r.length>0){r.some((e=>!this._blacklistMap.has(e)))&&(o=!0,this._addBlacklistMap(r.map((e=>({userID:e})))))}if(i.length>0){i.some((e=>this._blacklistMap.has(e)))&&(o=!0,this._deleteBlacklistMap(i.map((e=>({userID:e})))))}o&&this._emitBlackListUpdated()}_addBlacklistMap(e){console.log(`${t} _addBlacklistMap blackList:`,e),e.forEach((e=>{const{userID:t,addBlackTimeStamp:r=Date.now()}=e;t&&!this._blacklistMap.has(t)&&this._blacklistMap.set(t,{userID:t,addBlackTimeStamp:r})}))}_deleteBlacklistMap(e){console.log(`${t} _deleteBlacklistMap blackList:`,e),e.forEach((e=>{const{userID:t}=e;t&&this._blacklistMap.has(t)&&this._blacklistMap.delete(t)}))}_preprocessBlacklist(e){let{userIDList:t}=e;const r=this._getCurrentUserId();if(1===t.length&&t[0]===r)throw new this._core.helper.ChatError({functionName:"addToBlacklist",code:d});return t.includes(r)&&(t=e.userIDList.filter((e=>e!==r))),t}_getCurrentUserId(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("login"))||void 0===t?void 0:t.userId}_emitBlackListUpdated(){const{notificationCenter:e,OuterEvent:r}=this._core,i=Array.from(this._blacklistMap.keys());console.log(`${t} _emitBlackListUpdated blackList:`,i),e.emitOuterEvent(r.BLACKLIST_UPDATED,{name:r.BLACKLIST_UPDATED,data:i})}};const q={addToBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},getFriendProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},addFriend:{to:{required:!0,rules:["string"],allowEmpty:!1},source:{required:!0,rules:["string"],allowEmpty:!1},wording:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_ADD_TYPE_SINGLE||e===t.SNS_ADD_TYPE_BOTH||"type should be SNS_ADD_TYPE_SINGLE or SNS_ADD_TYPE_BOTH"}},remark:{required:!1,rules:["string"],allowEmpty:!0},groupName:{required:!1,rules:["string"],allowEmpty:!0}},deleteFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_DELETE_TYPE_SINGLE||e===t.SNS_DELETE_TYPE_BOTH||"type should be SNS_DELETE_TYPE_SINGLE or SNS_DELETE_TYPE_BOTH"}}},checkFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0}},updateFriend:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},friendCustomField:{required:!1,rules:["array"],allowEmpty:!0}},acceptFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_APPLICATION_AGREE||e===t.SNS_APPLICATION_AGREE_AND_ADD||"type should be SNS_APPLICATION_AGREE or SNS_APPLICATION_AGREE_AND_ADD"}}},refuseFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1}},deleteFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_APPLICATION_SENT_TO_ME||e===t.SNS_APPLICATION_SENT_BY_ME||"type should be SNS_APPLICATION_SENT_TO_ME or SNS_APPLICATION_SENT_BY_ME"}}},createFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},deleteFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1}},addToFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameFriendGroup:{oldName:{required:!0,rules:["string"],allowEmpty:!1},newName:{required:!0,rules:["string"],allowEmpty:!1}}},x={getBlacklist:!0,addToBlacklist:!0,removeFromBlacklist:!0,getFriendList:!0,addFriend:!0,deleteFriend:!0,updateFriend:!0,checkFriend:!0,getFriendProfile:!0,getFriendApplicationList:!0,acceptFriendApplication:!0,refuseFriendApplication:!0,deleteFriendApplication:!0,setFriendApplicationRead:!0,getFriendGroupList:!0,createFriendGroup:!0,deleteFriendGroup:!0,addToFriendGroup:!0,removeFromFriendGroup:!0,renameFriendGroup:!0};return new class{install(e){console.log(`${t} install`),this._core=e;const{helper:r,notificationCenter:i,InnerEvent:o,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:s}}=e;y.init(e),L.init(e),C.init(e),$.init(e),b.init(e),r.registerValidateConfig({auth:x,params:q}),r.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,s.FRIEND_AND_BLACKLIST_SYNC,this.handleLoginSuccess,this),i.subscribeInnerEvent(o.LOGOUT,this.reset,this),i.subscribeInnerEvent(o.MESSAGE_PUSH,i.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this)}handleLoginSuccess(){console.log(`${t} handleLoginSuccess`),b.syncBlacklistFromServer(),L.syncFriendListFromServer(),C.syncFriendApplicationListFromServer(),$.syncFriendGroupListFromServer()}onFriendModified(e){const{from:t,addedBlacklist:r,removedBlacklist:i,addedFriendList:o,removedFriendList:n,addedApplicationList:s,removedApplicationList:d,friendUpdateInfo:a,reportTime:c}=this._parseFriendListModification(null==e?void 0:e.FriendListMod[0]),{isEmpty:u}=this._core.utils;u(r)&&u(i)||b.updateBlacklist({addedBlacklist:r,removedBlacklist:i}),u(o)&&u(n)||(L.updateFriendList({addedFriendList:o,removedFriendList:n}),C.updateFriendApplicationList({from:t,removedApplicationList:o})),u(a)||L.updateFriendInfo(a),u(s)&&u(d)||C.updateFriendApplicationList({from:t,addedApplicationList:s,removedApplicationList:d}),c&&C.onApplicationRead()}_parseFriendListModification(e){const{PushType:t,From_Account:r,To_Account:i,ReportTime:o,BlackListAdd_Account:n=[],BlackListDel_Account:s=[],FriendAdd_Account:d=[],FriendDel_Account:a=[],PendencyAdd:c=[],FrienPencydDel_Account:u=[],FriendUpInfo:l=[]}=e,p=l.map((e=>({userID:e.Friend_Account,tagValueList:[...e.SNS]})));return{pushType:t,from:r,to:i,reportTime:o,addedBlacklist:n,removedBlacklist:s,addedFriendList:d,removedFriendList:a,addedApplicationList:c.map((e=>({userID:e.PendencyAdd_Account,source:e.AddSource,time:e.AddTime,wording:e.AddWording,nick:e.ProfileImNick}))),friendUpdateInfo:p,removedApplicationList:u}}reset(){console.log(`${t} reset`),b.reset(),L.reset(),C.reset(),$.reset()}dispose(){console.log(`${t} dispose`);const{notificationCenter:e,InnerEvent:r}=this._core;e.unSubscribeInnerEvent(r.LOGOUT,this.reset,this),e.unSubscribeInnerEvent(r.MESSAGE_PUSH,e.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this),b.dispose(),L.dispose(),C.dispose(),$.dispose()}}}));
@@ -1 +1 @@
1
- function r(r,o,t,e){return new(t||(t=Promise))((function(i,n){function s(r){try{a(e.next(r))}catch(r){n(r)}}function c(r){try{a(e.throw(r))}catch(r){n(r)}}function a(r){var o;r.done?i(r.value):(o=r.value,o instanceof t?o:new t((function(r){r(o)}))).then(s,c)}a((e=e.apply(r,o||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const o="group";var t=new class{init(r){this._core=r;const{helper:o}=r;o.registerApi("searchGroupByID",this),o.registerApi("getGroupList",this),o.registerApi("getGroupApplicationList",this)}searchGroupByID(t){return r(this,void 0,void 0,(function*(){try{console.log(`${o} searchGroupByID: groupID: ${t}`);const e=yield function(o,t){return r(this,void 0,void 0,(function*(){try{const{helper:r,channel:e}=t,i="group_open_http_svc.get_group_public_info",n={GroupIdList:[o]},s=r.generateProtocolData({servcmd:i,data:n}),c=`${s.head.seq}${i}`;return yield e.sendPacket(s,{requestId:c})}catch(r){throw console.warn("searchGroupByID error:",r),r}}))}(t,this._core);return this._parseSearchGroupByIDResponse(e),{code:0,data:{group:{groupID:t}}}}catch(r){throw console.warn(`${o} searchGroupByID error:`,r),r}}))}getGroupList(){return r(this,void 0,void 0,(function*(){return console.log(`${o} getGroupList`),{code:0,data:{groupList:[]}}}))}getGroupApplicationList(){return r(this,void 0,void 0,(function*(){return console.log(`${o} getGroupApplicationList`),{code:0,data:{applicationList:[]}}}))}_parseSearchGroupByIDResponse(r){var o;const t=null===(o=r.GroupInfo)||void 0===o?void 0:o[0];if(0!==(null==t?void 0:t.ErrorCode))throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:null==t?void 0:t.ErrorCode,message:null==t?void 0:t.ErrorCode});return r}};var e=new class{init(r){this._core=r}};var i=new class{init(r){this._core=r}};var n=new class{init(r){this._core=r}};var s=new class{init(r){this._core=r}};const c={searchGroupByID:[{key:"groupID",required:!0,rules:["string"],allowEmpty:!1}]},a={getGroupList:!0,searchGroupByID:!0,getGroupApplicationList:!0};var u=new class{install(r){t.init(r),e.init(r),i.init(r),n.init(r),s.init(r),r.helper.registerValidateConfig({auth:a,params:c})}};export{u as default};
1
+ const e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],i=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],n=["Role","JoinTime","MsgFlag","MsgSeq"],s=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],u=0,a=1,c="@TGS#_",p="@TOPIC#_",l="notStart",h="resolved",m="rejected",d=10018,g=11e3,_=2,f=["Owner","Admin","Member"],G=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],b=0,v=1,I=2,y=4,C=1,M=2,A=1,D=2,L=3,S=4,O=5,w=1,T=0,N=4,$=6,E=1,R=2,P=3,U=4,k=5,q=6,F=400,j=300,x={from:!0,groupID:!0,groupName:!0,to:!0},K={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},V=2,J=4,B=5,H=7,Y=8,W=15,Q=20,z=2600,X=2602,Z=2603,ee=2620,te=2621,oe=2623,re=2660,ie=2661,ne=2681,se=2683,ue=2684,ae=2685,ce=2687,pe=3122,le=t=>t===e.core.OuterConstant.GRP_PUBLIC,he=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,me=({type:t,groupID:o})=>t===e.core.OuterConstant.GRP_COMMUNITY||`${o}`.startsWith(c)&&!`${o}`.includes(p),de=(t,o)=>{const{isArray:r}=e.core.utils;if(!r(t)||!r(o))return!1;let i=!1;return o.forEach((({key:e,value:o})=>{const r=t.find((t=>t.key===e));r?r.value!==o&&(r.value=o,i=!0):(t.push({key:e,value:o}),i=!0)})),i},ge=e=>{const t=[];if(!e)return t;for(let o=0,r=e.length;o<r;o++){const{Key:r,Value:i}=e[o];t.push({key:r,value:i})}return t},_e=e=>{const t=[];for(let o=0,r=e.length;o<r;o++){const{key:r,value:i}=e[o];t.push({Key:r,Value:i})}return t},fe=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class Ge{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberNum=0,this.memberCount=0,this.maxMemberNum=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}_initGroup(e){for(const t in e)fe.indexOf(t)<0||("selfInfo"!==t?"isSupportTopic"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),this[t]=e[t]):this.isSupportTopic=1===e[t]:this.updateSelfInfo(e[t]))}updateGroup(t){const{utils:{isArray:o,isUndefined:r,isNumber:i},common:{deepMerge:n}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);const s=JSON.parse(JSON.stringify(t));s.lastMsgTime&&(this.lastMessage.lastTime=s.lastMsgTime),r(s.muteAllMembers)||(s.muteAllMembers="On"===s.muteAllMembers),s.groupCustomField&&de(this.groupCustomField,s.groupCustomField),r(s.memberNum)||(this.memberCount=s.memberNum),r(s.maxMemberNum)||(this.maxMemberCount=s.maxMemberNum),r(s.isSupportTopic)||(this.isSupportTopic=i(s.isSupportTopic)?1===s.isSupportTopic:s.isSupportTopic),n(this,s,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),o(s.members)&&s.members.length>0&&s.members.forEach((e=>{e.userID===this.selfInfo.userID&&n(this.selfInfo,e,["sequence"])}))}updateSelfInfo(t){const{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u}=t,{common:{deepMerge:a}}=e.core;a(this.selfInfo,{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var be=new class{constructor(){this._name="GroupDataHandler"}init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap(),console.log(`${this._name}.init`)}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){const{common:{getCurrentUserID:t}}=this._core;let o;e.forEach((e=>{var t;o=e.groupID,this.hasLocalGroup(o)?null===(t=this.getLocalGroup(o))||void 0===t||t.updateGroup(e):this._groupMap.set(o,new Ge(e))}));const r=t();for(const[,e]of this._groupMap)e.selfInfo.userID=r,"Owner"===e.selfInfo.role&&(e.ownerID=r)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){return[...this._groupMap.values()]}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){const e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:o}=this._core;o.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core,r=`${o}${e}`;if(t.getConversation(r)){const o=this.getLocalGroup(e);t.updateConversation(r,{groupProfile:o})}}reset(){this.clearLocalGroup()}};function ve(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(o[r[i]]=e[r[i]])}return o}function Ie(e,t,o,r){return new(o||(o=Promise))((function(i,n){function s(e){try{a(r.next(e))}catch(e){n(e)}}function u(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))}function ye(e,t,o){return Ie(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}"function"==typeof SuppressedError&&SuppressedError;const Ce=function(e){return{code:0,data:e||{}}};var Me=new class{constructor(){this._name="GetGroupList",this._pagingStatus=l,this.PAGING_GRP_COUNT_LIMIT=200}init(e){this._core=e;const{helper:t,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:r}}=e;t.registerApi({apiName:"getGroupList",context:this}),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,r.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return Ie(this,void 0,void 0,(function*(){if(console.log(`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===m||this._pagingStatus===l)return this._syncGroupList().then((()=>{const e=be.getLocalGroupList();return Ce({groupList:e,isSyncCompleted:this._isSyncCompleted()})})).catch((e=>{throw console.error(`${this._name}.getGroupList fail:`,e),e}));const e=be.getLocalGroupList();return console.log(`${this._name}.getGroupList return group count:${e.length}`),Ce({groupList:e,isSyncCompleted:this._isSyncCompleted()})}))}_syncGroupList(){return Ie(this,void 0,void 0,(function*(){this._pagingStatus===l&&be.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=h,this._groupListTreeShaking(t),be.updateLocalGroup(t);const o=be.getLocalGroupList().length;return console.log(`${this._name}._syncGroupList ok, count:${o}`),be.emitGroupListUpdate(),t}catch(e){throw this._pagingStatus=m,console.error(`${this._name}._syncGroupList fail:`,e),e}}))}_pagingGetGroupList(e){return Ie(this,void 0,void 0,(function*(){const{isCommunityRelay:t=!1,groupList:o}=e;let i,{limit:s,offset:u}=e;const a=[...r];t&&(i=this._core.OuterConstant.GRP_COMMUNITY,a.push("AtInfoList"));try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{type:o,limit:r,offset:i,memberAccount:n,responseFilter:s}=e;return ye(o?"million_group_open_http_svc.get_joined_group_list":"group_open_http_svc.get_joined_group_list",{Limit:r,Offset:i,Member_Account:n,ResponseFilter:s,SupportTopic:0,NeedAppDefineData:1},t)}))}({type:i,limit:s,offset:u,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:a,SelfInfoFilter:[...n]}},this._core),{GroupIdList:r=[],TotalCount:c=0}=e||{},p=this._convertGroupKey(r);o.push(...p);const l=u+s,h=!(c>l),m=`offset:${u} limit:${s} total:${c} isCompleted:${h} current:${o.length} isCommunityRelay:${t}`;return console.log(`${this._name}._pagingGetGroupList ok. ${m}`),t?h?o:(u=l,this._pagingGetGroupList({isCommunityRelay:!0,limit:s,offset:u,groupList:o})):h?(console.log(`${this._name}._pagingGetGroupList start to get community list`),u=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:s,offset:u,groupList:o})):(u=l,this._pagingGetGroupList({limit:s,offset:u,groupList:o}))}catch(e){if(e.ErrorCode===d)return console.warn(`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${s}`),s=50,this._pagingGetGroupList({isCommunityRelay:t,limit:s,offset:u,groupList:o});if(t)return e.code===g&&console.log(`${this._name}._pagingGetGroupList ok. community unavailable`),o;throw e}}))}_groupListTreeShaking(e){const t=new Map([...be.getLocalGroupList()]);for(let o=0,r=e.length;o<r;o++)t.delete(e[o].groupID);const o=[...t.keys()];for(let e=0,t=o.length;e<t;e++)be.deleteLocalGroup(o[e])}_isSyncCompleted(){return this._pagingStatus===h}_convertGroupKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,Introduction:a,InviteJoinOption:c,LastInfoTime:p,LastMsgTime:l,MaxMemberNum:h,MuteAllMember:m,Name:d,NextMsgSeq:g,Notification:_,Owner_Account:f,ShutUpAllMember:G,Type:b,LastRecallTime:v,SelfInfo:I}=e[o],y=ge(r),C=this._convertSelfInfo(I);t.push({groupCustomField:y,joinOption:i,createTime:n,avatar:s,groupID:u,introduction:a,inviteOption:c,lastInfoTime:p,lastMsgTime:l,maxMemberNum:h,muteAllMember:m,name:d,nextMessageSeq:g,notification:_,ownerID:f,shutUpAllMember:G,type:b,_lastRevokedTime:v,selfInfo:C})}return t}_convertSelfInfo(e){const{JoinTime:t,MsgFlag:o,MsgSeq:r,NoUnreadSeqList:i,Role:n}=e;return{joinTime:t,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i,role:n}}};var Ae=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return Ie(this,void 0,void 0,(function*(){var t;this._preCheckParams(e),console.log(`${this._name}.createGroup options:`,e);try{const{utils:{isEmpty:o},common:{getCurrentUserID:r}}=this._core,i=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{name:o,type:r,groupID:i,introduction:n,notification:s,avatar:u,maxMemberNum:a,joinOption:c,inviteOption:p,memberList:l,groupCustomField:h,isSupportTopic:m}=e;let d;return l&&(d=l.map((e=>{const{userID:t,memberCustomField:o}=e;return{Member_Account:t,AppMemberDefinedData:o?_e(o):void 0}}))),ye("group_open_http_svc.create_group",{Name:o,Type:r,GroupId:i,Introduction:n,Notification:s,FaceUrl:u,MaxMemberCount:a,ApplyJoinOption:c,InviteJoinOption:p,MemberList:d,AppDefinedData:h,SupportTopic:m,webPushFlag:1},t)}))}(Object.assign(Object.assign({},e),{ownerID:r()}),this._core),{GroupId:n,OverJoinedGroupLimit_Account:s=[]}=i||{};if(console.log(`${this._name}.createGroup ok, groupType:${e.type} groupID:${n} overLimitUserIDList:${s}`),o(e.memberList)||o(s)||(e.memberList=null===(t=e.memberList)||void 0===t?void 0:t.filter((e=>s.includes(e.userID)))),this._notNeedUpdateLocalGroup(e))return Ce({group:new Ge(e)});be.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:n})]),this._sendCustomMessage(n,e.type);const u=be.getLocalGroup(n);return be.emitGroupListUpdate(),Ce({group:u})}catch(e){throw console.error(`${this._name}.createGroup fail:`,e),e}}))}_preCheckParams(t){const{type:o,groupID:r}=t,{utils:{isEmpty:i,isUndefined:n}}=this._core,s=!i(r);if(!(()=>{const{GRP_PUBLIC:t,GRP_WORK:o,GRP_MEETING:r,GRP_AVCHATROOM:i,GRP_COMMUNITY:n}=e.core.OuterConstant;return[t,o,r,i,n]})().includes(o))throw new this._core.helper.ChatError({code:z});if(!me({type:o})){if(s&&me({groupID:r}))throw new this._core.helper.ChatError({code:X});n(t.isSupportTopic)||(t.isSupportTopic=void 0)}if(this._canIUseMemberList(o)||n(t.memberList)||(t.memberList=void 0),this._canIUseJoinOption(o)||n(t.joinOption)||(t.joinOption=void 0),this._canIUseTopic(t)&&(t.isSupportTopic=!0===t.isSupportTopic?1:0),me({type:o})&&s&&!me({groupID:r}))throw new this._core.helper.ChatError({code:X})}_canIUseMemberList(e){return!he(e)}_canIUseJoinOption(e){return le(e)||me({type:e})}_canIUseTopic(e){const{type:t,isSupportTopic:o}=e,{utils:{isUndefined:r}}=this._core;return me({type:t})&&r(o)}_notNeedUpdateLocalGroup(e){const{type:t,isSupportTopic:o}=e,{OuterConstant:r}=this._core;return t===r.GRP_AVCHATROOM||t===r.GRP_COMMUNITY&&1===o}_sendCustomMessage(e,t){var o,r,i,n,s,c;const{OuterConstant:p}=this._core;let l="Create Group",h=u;t===p.GRP_COMMUNITY&&(l="Create Community",h=a);const m={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:l,cmd:h,opUser:this._core.store.get("login").userId,version:4})}},d=null===(i=null===(r=null===(o=this._core)||void 0===o?void 0:o.message)||void 0===r?void 0:r.messageFactory)||void 0===i?void 0:i.createCustomMessage(m);null===(c=null===(s=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===s?void 0:s.messageSender)||void 0===c||c.sendMessage(d,{})}};var De=new class{constructor(){this._name="DismissGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"dismissGroup",context:this})}dismissGroup(e){return Ie(this,void 0,void 0,(function*(){console.log(`${this._name}.dismissGroup groupID:${e}`);try{return yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("group_open_http_svc.destroy_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.dismissGroup ok.`),be.deleteLocalGroup(e),be.emitGroupListUpdate(),Ce({groupID:e})}catch(e){throw console.error(`${this._name}.dismissGroup fail:`,e),e}}))}};var Le=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return Ie(this,void 0,void 0,(function*(){const{groupID:t,groupCustomFieldFilter:o}=e,i={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...r],AppDefinedDataFilter_Group:o,MemberInfoFilter:[...s]}};try{const e=yield this.getGroupProfileAdvance(i),{successGroupList:o,failureGroupList:r}=e;if(r.length>0)throw r[0];let n;return!be.hasLocalGroup(t)&&he(o[0].type)?n=new Ge(o[0]):(be.updateLocalGroup(o),n=be.getLocalGroup(t)),n.isSupportTopic||be.updateConversationGroupProfile(t),console.log(`${this._name}.getGroupProfile ok.`),Ce({group:n})}catch(e){throw console.error(`${this._name}.getGroupProfile fail:`,e),e}}))}getGroupProfileAdvance(e){return Ie(this,void 0,void 0,(function*(){const{groupIDList:t}=e,o=t.filter((e=>!me({groupID:e}))),r=t.filter((e=>me({groupID:e})));o.length>50&&(o.length=50),r.length>50&&(r.length=50);const i=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:o})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:r,isCommunityProfile:!0}))]),n=[],s=[];return i.forEach((e=>{n.push(...e.successGroupList),s.push(...e.failureGroupList)})),{successGroupList:n,failureGroupList:s}}))}_getGroupProfileAdvance(e){return Ie(this,void 0,void 0,(function*(){const{isCommunityProfile:t=!1}=e,o=ve(e,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupIDList:o,responseFilter:r}=e;return ye("group_open_http_svc.get_group_self_member_info",{GroupIdList:o,ResponseFilter:r},t)}))}(o,this._core),{GroupInfo:t=[]}=e||{},r=this._convertGroupProfileKey(t),{utils:{isUndefined:i}}=this._core,n=r.filter((e=>i(e.errorCode)||0===e.errorCode)),s=r.filter((e=>e.errorCode&&0!==e.errorCode)).map((e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})));return console.log(`${this._name}._getGroupProfileAdvance ok, groupID:${o.groupIDList.join(",")}`),{successGroupList:n,failureGroupList:s}}catch(e){if(t)return{successGroupList:[],failureGroupList:[]};throw e}}))}_convertGroupProfileKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,InfoSeq:a,Introduction:c,InviteJoinOption:p,LastInfoTime:l,LastMsgTime:h,MaxMemberNum:m,MemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:G,Owner_Account:b,ShutUpAllMember:v,ShutUpUntil:I,Type:y,MemberList:C,ErrorCode:M,ErrorInfo:A}=e[o],D=ge(r),L=this._convertMembers(C);t.push({groupCustomField:D,joinOption:i,createTime:n,avatar:s,groupID:u,infoSequence:a,introduction:c,inviteOption:p,lastInfoTime:l,lastMsgTime:h,maxMemberNum:m,memberNum:d,muteAllMember:g,name:_,nextMessageSeq:f,notification:G,ownerID:b,shutUpAllMember:v,muteUntil:I,type:y,members:L,errorCode:M,errorInfo:A})}return t}_convertMembers(e){if(!e)return[];const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,MsgFlag:s,MsgSeq:u,NameCard:a,Role:c}=e[o],p=ge(r);t.push({memberCustomField:p,joinTime:i,userID:n,messageRemindType:s,sequence:u,nameCard:a,role:c})}return t}};var Se=new class{constructor(){this._name="JoinGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"joinGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}joinGroup(e){return Ie(this,void 0,void 0,(function*(){const{groupID:t}=e;try{if(be.hasLocalGroup(t))try{return yield Le.getGroupProfile({groupID:t}),Ce({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS})}catch(o){console.warn(`${this._name}.joinGroup ${t} was unjoined, start to join!`),be.deleteLocalGroup(t);return yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(e){throw console.error(`${this._name}.joinGroup fail:`,e),e}}))}_applyJoinGroup(e){return Ie(this,void 0,void 0,(function*(){const{OuterConstant:t,helper:r}=this._core,{groupID:i}=e,n=Object.assign({},e),s=r.checkBusinessCapabilityBits(o);s&&(n.historyMessageFlag=1);const u=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,applyMessage:r,historyMessageFlag:i}=e;return ye("group_open_http_svc.apply_join_group",{GroupId:o,ApplyMsg:r,HugeGroupHistoryMsgFlag:i},t)}))}(n,this._core),{JoinedStatus:a,LongPollingKey:c,StartSeq:p,HugeGroupFlag:l,AVChatRoomKey:h,RspMsgList:m=[]}=u||{},d=`groupID:${i} joinedStatus:${a} longPollingKey:${c} startSeq:${p} avChatRoomFlag:${l} canGetAVChatRoomHistoryMsg:${s}, historyMessageCount:${m.length}`;if(console.log(`${this._name}._applyJoinGroup ok, ${d}`),a===t.JOIN_STATUS_WAIT_APPROVAL)return{code:0,data:{status:t.JOIN_STATUS_WAIT_APPROVAL}};if(a===t.JOIN_STATUS_SUCCESS){let e=null;try{e=(yield Le.getGroupProfile({groupID:i})).data.group}catch(t){e=new Ge({groupID:i}),console.warn(`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${i}, errorCode:`,null==t?void 0:t.code)}return this._handleJoinResult({group:e,avChatRoomFlag:l,longPollingKey:c,startSequence:p,avChatRoomKey:h,historyMessageList:m})}throw new this._core.helper.ChatError({code:re})}))}_handleJoinResult(e){const{group:t,avChatRoomFlag:o}=e;return 1===o?Ce(e):(be.updateLocalGroup([t]),be.emitGroupListUpdate(),Ce({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}};var Oe=new class{constructor(){this._name="QuitGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"quitGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}quitGroup(e){return Ie(this,void 0,void 0,(function*(){if(!be.hasLocalGroup(e))throw new this._core.helper.ChatError({code:oe});try{yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("group_open_http_svc.quit_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.quitGroup ok, groupID:${e}`);const{type:t}=be.getLocalGroup(e);return be.deleteLocalGroup(e),be.emitGroupListUpdate(),Ce({groupID:e,type:t})}catch(e){throw console.error(`${this._name}.quitGroup fail:`,e),e}}))}};var we=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return Ie(this,void 0,void 0,(function*(){console.log(`${this._name}.searchGroupByID groupID:${e}`);try{const t=yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("group_open_http_svc.get_group_public_info",{GroupIdList:[e],GroupBasePublicInfoFilter:[...i]},t)}))}(e,this._core),{GroupInfo:o=[]}=t||{},{AppDefinedData:r=[],ApplyJoinOption:n,CreateTime:s,FaceUrl:u,Introduction:a,InviteJoinOption:c,MaxMemberNum:p,MemberNum:l,Name:h,Owner_Account:m,Type:d,ErrorCode:g,ErrorInfo:_}=o[0];if(0!==g)throw new this._core.helper.ChatError({code:g,message:_});console.log(`${this._name}.searchGroupByID ok.`);const f=ge(r),G=new Ge({groupID:e,name:h,avatar:u,introduction:a,joinOption:n,inviteOption:c,maxMemberNum:p,memberNum:l,type:d,ownerID:m,createTime:s,groupCustomField:f});return Ce({group:G})}catch(e){throw console.error(`${this._name}.searchGroupByID fail:`,e),e}}))}};var Te=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return Ie(this,void 0,void 0,(function*(){const{groupID:t}=e,{utils:{isUndefined:o}}=this._core;let r=be.getLocalGroup(t);if(r){const{type:t}=r;this._canIUseJoinOption(t)||o(e.joinOption)||(console.warn(`${this._name}.updateGroupProfile joinOption is unavailable for Work/Meeting/AVChatRoom`),e.joinOption=void 0)}o(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off");try{return yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,name:r,avatar:i,introduction:n,notification:s,muteAllMembers:u,joinOption:a,inviteOption:c,groupCustomField:p}=e;return ye("group_open_http_svc.modify_group_base_info",{GroupId:o,Name:r,FaceUrl:i,Introduction:n,Notification:s,ShutUpAllMember:u,ApplyJoinOption:a,InviteJoinOption:c,AppDefinedData:p?_e(p):void 0},t)}))}(e,this._core),console.log(`${this._name}.updateGroupProfile groupID:${t} ok.`),r?(r.updateGroup(e),be.emitGroupListUpdate()):r=new Ge(e),Ce({group:r})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}}))}_canIUseJoinOption(e){return le(e)||me({type:e})}};var Ne=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return Ie(this,void 0,void 0,(function*(){const t="changeGroupOwner",{groupID:o,newOwnerID:r}=e,i=be.getLocalGroup(o),{helper:n,OuterConstant:s,common:{getCurrentUserID:u}}=this._core;if((null==i?void 0:i.type)===s.GRP_AVCHATROOM)throw new n.ChatError({functionName:t,code:ee});if(r===u())throw new n.ChatError({functionName:t,code:te});console.log(`${this._name}.${t} groupID:${o} newOwnerID:${r}`);try{return yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,newOwnerID:r}=e;return ye("group_open_http_svc.change_group_owner",{GroupId:o,NewOwner_Account:r},t)}))}(e,this._core),console.log(`${this._name}.${t} ok.`),i.ownerID=r,be.emitGroupListUpdate(),Ce({group:i})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var $e=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupOnlineMemberCount",context:this})}getGroupOnlineMemberCount(e){return Ie(this,void 0,void 0,(function*(){const t="getGroupOnlineMemberCount",o=be.hasLocalGroup(e);if(console.log(`${this._name}.${t} groupID:${e} isAVChatRoom:false hasGroup:${o}`),!o)return Ce({memberCount:0});const r=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:o=0,memberCount:i=0}=t||{};if(r-o<=6e4)return Ce({memberCount:i})}try{const o=yield function(e,t){return Ie(this,void 0,void 0,(function*(){return ye("group_open_http_svc.get_online_member_num",{GroupId:e},t)}))}(e,this._core),{OnlineMemberNum:r=0}=o||{};return this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:r}),console.log(`${this._name}.${t} ok. groupID:${e} memberCount:${r}`),Ce({memberCount:r})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var Ee=new class{init(e,t){console.log("GroupAction.init"),Me.init(e),Ae.init(e),De.init(e),Se.init(e,t),Oe.init(e,t),we.init(e),Le.init(e),Te.init(e),Ne.init(e),$e.init(e)}joinGroup(e){return Se.joinGroup(e)}quitGroup(e){return Oe.quitGroup(e)}};function Re(e,t,o){return Ie(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}var Pe=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return Ie(this,void 0,void 0,(function*(){const e="getGroupApplicationList";try{const t=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);console.log(`${this._name}.${e} ok.`);const o=this._handleGroupApplicationResult([...t[0],...t[1]]);return Ce({applicationList:o})}catch(t){const o=new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo});throw console.error(`${this._name}.${e} fail:`,o),o}}))}_getGroupApplicationList(e){return Ie(this,void 0,void 0,(function*(){const{type:t,startTime:o=0,limit:r=20}=e||{},{common:i}=this._core;let n;try{n=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{type:o,startTime:r,limit:i,handleAccount:n}=e;return Re(me({type:o})?"million_group_open_http_svc.get_pendency":"group_open_http_svc.get_pendency",{StartTime:r,Limit:i,Handle_Account:n},t)}))}({type:t,startTime:o,limit:r,handleAccount:i.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;n={}}const{NextStartTime:s=0,PendencyList:u=[]}=n||{};if(0===s)return u;const a=yield this._getGroupApplicationList(Object.assign(Object.assign({},e),{startTime:s}));return[...u,...a]}))}_handleGroupApplicationResult(e){const t=[];return e.forEach((e=>{const o=this._convertApplicationData(e),{handled:r}=o,i=ve(o,["handled"]);0===r&&t.push(i)})),t}_convertApplicationData(e){const{Handled:t,AddTime:o,ApplyInviteMsg:r,Authentication:i,FromUserNickName:n,From_Account:s,GroupId:u,GroupName:a,PendencyType:c,To_Account:p}=e;return{handled:t,messageKey:o,applicant:s,applicantNick:n,groupID:u,groupName:a,authentication:i,applicationType:c,userID:p,note:r}}};var Ue=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return Ie(this,void 0,void 0,(function*(){const t="handleGroupApplication",{application:o}=e,r=this._handleParams(e);try{(null==o?void 0:o.applicationType)===_?yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,invitee:u}=e;return Re(me({groupID:o})?"million_group_open_http_svc.handle_invite_join_permission_group":"group_open_http_svc.handle_invite_join_permission_group",{GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,Invited_Account:u},t)}))}(r,this._core):yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,messageKey:u}=e;return Re(me({groupID:o})?"million_group_open_http_svc.handle_apply_join_group":"group_open_http_svc.handle_apply_join_group",{GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,MsgKey:u},t)}))}(r,this._core),console.log(`${this._name}.${t} ok.`);const e=be.getLocalGroup(r.groupID);return Ce({group:e})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_handleParams(e){var t;const{handleAction:o,handleMessage:r,message:i,application:n}=e;let s,u,a,c,p;if(i){const{payload:e}=i||{};s=e.operatorID,u=null===(t=e.groupProfile)||void 0===t?void 0:t.groupID,a=e.authentication,c=e.messageKey}else s=(null==n?void 0:n.applicant)||"",u=(null==n?void 0:n.groupID)||"",a=(null==n?void 0:n.authentication)||"",c=(null==n?void 0:n.messageKey)||0;return(null==n?void 0:n.applicationType)===_&&(p=n.userID),{handleAction:o,handleMessage:r,applicant:s,invitee:p,groupID:u,authentication:a,messageKey:c}}};var ke=new class{init(e){console.log("GroupApplication.init"),Pe.init(e),Ue.init(e)}};let qe=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(t){const{core:{utils:{isUndefined:o},common:{deepMerge:r}}}=e;o(t.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*t.muteTime)/1e3)),o(t.onlineStatus)||(this.isOnline="Online"===t.onlineStatus);const i=[null,void 0,"",0,NaN];t.memberCustomField&&de(this.memberCustomField,t.memberCustomField),r(this,t,["memberCustomField","marks","onlineStatus","muteTime"],i)}};function Fe(e,t,o){return Ie(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}function je(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,userID:r,muteTime:i,role:n,nameCard:s,memberCustomField:u}=e;let a;u&&(a=_e(u));return Fe("group_open_http_svc.modify_group_member_info",{GroupId:o,Member_Account:r,ShutUpTime:i,Role:n,NameCard:s,AppMemberDefinedData:a},t)}))}var xe=new class{constructor(){this._name="GetGroupMemberList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberList",context:this})}getGroupMemberList(e){return Ie(this,void 0,void 0,(function*(){const t="getGroupMemberList",{groupID:o,offset:r=0,count:i=100,role:n="",filter:s=""}=e;console.log(`${this._name}.${t} groupID:${o} offset:${r} count:${i} role:${n} filter:${s}`);const u=be.getLocalGroup(o);u&&he(u.type);const a=i>100?100:i,c={groupID:o,offset:r,limit:a,memberRoleFilter:f.includes(n)?[n]:void 0,memberInfoFilter:G};try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,offset:r,limit:i,memberRoleFilter:n,memberInfoFilter:s}=e;return Fe("group_open_http_svc.get_group_member_info",{GroupId:o,Offset:r,Limit:i,MemberRoleFilter:n,MemberInfoFilter:s},t)}))}(c,this._core),{MemberList:i,MemberNum:n,Next:s}=e||{};console.log(`${this._name}.${t} ok, totalMemberCount:${n} next:${s}`);const{utils:{isArray:p,isEmpty:l}}=this._core;if(u&&(u.memberNum=n),!p(i)||0===i.length)return Ce({memberList:[],offset:0});let h=r+a;me({groupID:o})&&(h=l(s)?0:s),i.length<a&&(h=0);let m=this._convertMemberInfo(i);m=yield this._patchAvatarAndNick(m);const d=this._generateGroupMember(m);return Ce({memberList:d,offset:h})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a}=e[o],c=ge(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_patchAvatarAndNick(e){return Ie(this,void 0,void 0,(function*(){var t;const o=e.map((e=>e.userID)),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map((e=>[e.userID,e])));return e.forEach((e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}})),e}))}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new qe(e[o]);t.push(r)}return t}};var Ke=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return Ie(this,void 0,void 0,(function*(){const t="getGroupMemberProfile",{groupID:o,userIDList:r,memberCustomFieldFilter:i}=e,n=be.getLocalGroup(o),{helper:s,utils:{isArray:u}}=this._core;if(n&&he(n.type))throw new s.ChatError({functionName:t,code:ce});r.length>50&&(console.warn(`${this._name}.${t} userIDList length:${r.length} exceeds limit 50`),r.splice(50));try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,memberInfoFilter:i,memberCustomFieldFilter:n}=e;return Fe("group_open_http_svc.get_specified_group_member_info",{GroupId:o,Member_List_Account:r,MemberInfoFilter:i,AppDefinedDataFilter_GroupMember:n},t)}))}({groupID:o,userIDList:r,memberCustomFieldFilter:i,memberInfoFilter:[...G]},this._core);console.log(`${this._name}.${t} ok.`);const{MemberList:n}=e||{};if(!u(n)||0===n.length)return Ce({memberList:[]});let s=this._convertMemberInfo(n);s=yield this._getMemberAvatarAndNick(s);const a=this._generateGroupMember(s);return Ce({memberList:a})}catch(e){const o=new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a}=e[o],c=ge(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_getMemberAvatarAndNick(e){return Ie(this,void 0,void 0,(function*(){var t;const o=e.map((e=>e.userID)),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map((e=>[e.userID,e])));return e.forEach((e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}})),e}))}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new qe(e[o]);t.push(r)}return t}};var Ve=new class{constructor(){this._name="AddGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(e){return Ie(this,void 0,void 0,(function*(){const t="addGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n}=this._core;if(i&&he(i.type))throw new n.ChatError({functionName:t,code:ie});const s=r.map((e=>({Member_Account:e})));try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r}=e;return Fe("group_open_http_svc.add_group_member",{GroupId:o,MemberList:r},t)}))}({groupID:o,userIDList:s},this._core),{MemberList:r=[]}=e||{},{failureUserIDList:n,successUserIDList:u,existedUserIDList:a,overLimitUserIDList:c}=this._handleResult(r);return console.log(`${this._name}.${t} groupID:${o} ok, successUserIDList:${u} failureUserIDList:${n} existedUserIDList:${a} overLimitUserIDList:${c}`),Ce({failureUserIDList:n,successUserIDList:u,existedUserIDList:a,overLimitUserIDList:c,group:i})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_handleResult(e){const t=[],o=[],r=[],i=[];return e.forEach((e=>{const{Result:n,Member_Account:s}=e;n===b?t.push(s):n===v?o.push(s):n===I?r.push(s):n===y&&i.push(s)})),{failureUserIDList:t,successUserIDList:o,existedUserIDList:r,overLimitUserIDList:i}}};var Je=new class{constructor(){this._name="DeleteGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupMember",context:this})}deleteGroupMember(e){return Ie(this,void 0,void 0,(function*(){const t="deleteGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n,utils:{isUndefined:s}}=this._core;if(s(i))throw new n.ChatError({functionName:t,code:Z});if(he(i.type))throw new n.ChatError({functionName:t,code:pe});r.length>20&&(console.warn(`${this._name}.${t} userIDList length:${r.length} exceeds limit 20`),r.splice(20));try{return yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,reason:i}=e;return Fe("group_open_http_svc.delete_group_member",{GroupId:o,MemberToDel_Account:r,Reason:i},t)}))}({groupID:o,userIDList:r},this._core),console.log(`${this._name}.${t} ok, groupID:${o} userIDList length:${r.length}`),Ce({group:i,userIDList:r})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var Be=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupMemberMuteTime",{helper:o}=this._core;this._preCheckSettingMuteParams(e);try{yield je(e,this._core);const{groupID:o,userID:r,muteTime:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} muteTime:${i}`);const n=be.getLocalGroup(o),s=new qe({userID:r,muteTime:i});return Ce({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingMuteParams(e){const{userID:t}=e,{store:o,helper:r}=this._core;if(t===o.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberMuteTime",code:ae})}};var He=new class{constructor(){this._name="SetGroupMemberRole"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupMemberRole",{helper:o}=this._core;this._preCheckSettingRoleParams(e);try{yield je(e,this._core);const{groupID:o,userID:r,role:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} role:${i}`);const n=be.getLocalGroup(o),s=new qe({userID:r,role:i});return Ce({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingRoleParams(e){var t;const{groupID:o,userID:r,role:i}=e,{store:n,helper:s,OuterConstant:u}=this._core,a=be.getLocalGroup(o);if((null===(t=null==a?void 0:a.selfInfo)||void 0===t?void 0:t.role)!==u.GRP_MBR_ROLE_OWNER)throw new s.ChatError({functionName:"setGroupMemberRole",code:ne});if(r===n.get("login").userId)throw new s.ChatError({functionName:"setGroupMemberRole",code:ue});const c=[...f];if(me({groupID:o})&&c.push(u.GRP_MBR_ROLE_CUSTOM),!c.includes(i))throw new s.ChatError({functionName:"setGroupMemberRole",code:se})}};var Ye=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupMemberNameCard",{helper:o}=this._core;this._preCheckSettingNameCardParams(e);try{yield je(e,this._core);const{groupID:o,userID:r,nameCard:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} nameCard:${i}`);const n=be.getLocalGroup(o),s=new qe({userID:r,nameCard:i});return Ce({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:o}=this._core,r=be.getLocalGroup(t);if(he(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberNameCard",code:ce})}};var We=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupMemberCustomField",{helper:o}=this._core;this._preCheckSettingCustomFiledParams(e);try{yield je(e,this._core);const{groupID:o,userID:r,memberCustomField:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} memberCustomField:${JSON.stringify(i)}`);const n=be.getLocalGroup(o),s=new qe({userID:r,memberCustomField:i});return Ce({group:n,member:s})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:o}=this._core,r=be.getLocalGroup(t);if(he(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberCustomField",code:ce})}};var Qe=new class{constructor(){this._name="MarkGroupMemberList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"markGroupMemberList",context:this})}markGroupMemberList(e){return Ie(this,void 0,void 0,(function*(){const t="markGroupMemberList",{helper:o}=this._core,{groupID:r,markType:i,enableMark:n,userIDList:s=[]}=e;s.length>500&&(console.warn(`${this._name}.${t} userIDList length:${s.length} exceeds limit 500`),s.splice(500));const u=s.map((e=>({Member_Account:e,Marks:[i]}))),a=n?C:M;try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,operationType:r,memberList:i}=e;return Fe("group_open_avchatroom_http_svc.modify_user_info",{GroupId:o,CommandType:r,MemberList:i},t)}))}({groupID:r,memberList:u,operationType:a},this._core),{MemberList:o=[]}=e||{},{successUserIDList:i,failureUserIDList:n}=this._handleResult(o,s);return console.log(`${this._name}.${t} ok, groupID:${r} success count:${i.length} fail count:${n.length}`),Ce({successUserIDList:i,failureUserIDList:n})}catch(e){const r=new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,r),r}}))}_handleResult(e,t){const o=[],r=[];return e.length===t.length?(o.push(...t),{successUserIDList:o,failureUserIDList:r}):(t.forEach((t=>{e.find((e=>e.Member_Account===t))?o.push(t):r.push(t)})),{successUserIDList:o,failureUserIDList:r})}};var ze=new class{init(e){console.log("GroupMember.init"),xe.init(e),Ke.init(e),Ve.init(e),Je.init(e),Be.init(e),He.init(e),Ye.init(e),We.init(e),Qe.init(e)}};var Xe=new class{init(e){this._core=e}};function Ze(e,t,o){return Ie(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}var et=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){this._core=e;const{helper:t,constants:o}=e;t.registerWorkflowStep(o.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,o.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach((e=>{e.localMainSequence=0}))}isGroupAttributesUpdated(e){const{elements:{newGroupProfile:t}}=e,{utils:{isEmpty:o,isUndefined:r}}=this._core;return!r(t)&&!o(t.groupAttributeOption)}handleGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:o}=e,{serverMainSequence:r,groupAttributeList:i=[],operation:n}=o;console.log(`${this._name}.handleGroupAttributesUpdated groupID:${t} operation:${n}`);const{utils:{isUndefined:s}}=this._core;s(n)||(this.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:i,operation:n}),this.emitGroupAttributesUpdated(t))}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:o}=e;this._groupAttributesCache.set(t,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:o,values:new Map}),console.log(`${this._name}.initGroupAttributesCache. groupID:${t} avChatRoomKey:${o}`)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}refreshGroupAttributesCache(e){const{groupID:t,serverMainSequence:o,groupAttributeList:r,operation:i}=e;if(this.hasGroupAttributesCache(t)){const e=this.getGroupAttributesCache(t),{localMainSequence:n}=e;i!==O&&o-n!=1||(e.serverMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:r,operation:i})),o-n>1&&(e.serverMainSequence=o),this._groupAttributesCache.set(t,e),console.log(`${this._name}.refreshGroupAttributesCache. operation:${i} localMainSequence:${n} serverMainSequence:${o}`)}}_updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:o=[],operation:r}=e;r!==L?r!==S?(r===A&&t.values.clear(),o.forEach((e=>{const{key:o,value:r,sequence:i}=e;t.values.set(o,{value:r,sequence:i})}))):o.forEach((e=>{t.values.delete(e.key)})):t.values.clear()}getGroupAttributesCacheValues(e){var t;const{groupID:o,keyList:r=[]}=e,i={};if(this.hasGroupAttributesCache(o)){const{values:e}=this.getGroupAttributesCache(o);if(0===r.length){for(const o of e.keys())i[o]=(null===(t=e.get(o))||void 0===t?void 0:t.value)||"";return i}return r.forEach((t=>{var o;e.has(t)&&(i[t]=(null===(o=e.get(t))||void 0===o?void 0:o.value)||"")})),i}return i}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t;const o=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:r,deletedKeyList:i}=this._computeValuesChangedData(o);console.log(`${this._name}.emitGroupAttributesUpdated update count:${r.length}, delete count:${i.length}`),0===r.length&&0===i.length||this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:o,updatedKeyList:r,deletedKeyList:i}})}_computeValuesChangedData(e){const{utils:{isUndefined:t}}=this._core,o=[],r=[];return Object.keys(e).forEach((t=>{e[t]!==this._groupAttributesCacheValuesCopy[t]&&o.push(t)})),Object.keys(this._groupAttributesCacheValuesCopy).forEach((o=>{t(e[o])&&r.push(o)})),this._groupAttributesCacheValuesCopy={},{updatedKeyList:o,deletedKeyList:r}}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(e){const t=[];return Object.keys(e).forEach((o=>{t.push({key:o,value:e[o]})})),t}};var tt=new class{constructor(){this._name="InitGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="initGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n}=et.getGroupAttributesCache(o),s=et.convertKeyValueMapToList(r);try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ze("group_open_http_svc.set_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:o,avChatRoomKey:n,groupAttributeList:s,mainSequence:i},this._core),{AttrMainSeq:u,GroupAttr:a}=e||{};console.log(`${this._name}.${t} ok. groupID:${o} serverMainSequence:${u}`);const c=a.map((e=>{const{Key:t,seq:o}=e;return{key:t,value:r[t],sequence:o}}));return et.saveGroupAttributesCacheValuesCopy(o),et.refreshGroupAttributesCache({groupID:o,serverMainSequence:u,groupAttributeList:c,operation:A}),et.emitGroupAttributesUpdated(o),Ce({groupAttributes:r})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var ot=new class{constructor(){this._name="SetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="setGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n,values:s}=et.getGroupAttributesCache(o),u=et.convertKeyValueMapToList(r).map((e=>{var t;const{key:o,value:r}=e;return{key:o,value:r,seq:(null===(t=s.get(e.key))||void 0===t?void 0:t.sequence)||0}}));try{const e=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ze("group_open_http_svc.modify_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:o,avChatRoomKey:n,groupAttributeList:u,mainSequence:i},this._core),{AttrMainSeq:s,GroupAttr:a}=e||{};console.log(`${this._name}.${t} ok. groupID:${o} serverMainSequence:${s}`);const c=a.map((e=>{const{Key:t,seq:o}=e;return{key:t,value:r[t],sequence:o}}));return et.saveGroupAttributesCacheValuesCopy(o),et.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:c,operation:D}),et.emitGroupAttributesUpdated(o),Ce({groupAttributes:r})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var rt=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="deleteGroupAttributes",{groupID:o,keyList:r=[]}=e;try{let e;e=0===r.length?yield this._clearGroupAttributes(o):yield this._deleteGroupAttributes(o,r);const{resultList:i,serverMainSequence:n,operation:s,groupAttributeList:u}=e||{};return console.log(`${this._name}.${t} ok. groupID:${o} operation: ${s}`),et.saveGroupAttributesCacheValuesCopy(o),et.refreshGroupAttributesCache({groupID:o,serverMainSequence:n,groupAttributeList:u,operation:s}),et.emitGroupAttributesUpdated(o),Ce({keyList:i})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_deleteGroupAttributes(e,t){return Ie(this,void 0,void 0,(function*(){const{serverMainSequence:o,avChatRoomKey:r,values:i}=et.getGroupAttributesCache(e),n=[],s=[];t.forEach((e=>{if(i.has(e)){const{sequence:t=0}=i.get(e)||{};s.push({key:e,seq:t}),n.push(e)}}));const u=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ze("group_open_http_svc.delete_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:e,avChatRoomKey:r,groupAttributeList:s,mainSequence:o},this._core),{AttrMainSeq:a}=u||{};return{resultList:n,serverMainSequence:a,groupAttributeList:s,operation:S}}))}_clearGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const{serverMainSequence:t,avChatRoomKey:o,values:r}=et.getGroupAttributesCache(e),i=[...r.keys()],n=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,avChatRoomKey:i}=e;return Ze("group_open_http_svc.clear_group_attr",{GroupId:o,AttrMainSeq:r,BytesKey:i,AttrControl:["RaceConflict"]},t)}))}({groupID:e,avChatRoomKey:o,mainSequence:t},this._core),{AttrMainSeq:s}=n||{};return{resultList:i,serverMainSequence:s,operation:L}}))}};var it=new class{constructor(){this._name="GetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(e){return Ie(this,void 0,void 0,(function*(){const t="getGroupAttributes",{groupID:o}=e,{avChatRoomKey:r,lastUpdateTime:i,localMainSequence:n,serverMainSequence:s}=et.getGroupAttributesCache(o);if(Date.now()-i>=3e4||n<s)try{yield this.getGroupAttributesFromServer({groupID:o,avChatRoomKey:r});const i=et.getGroupAttributesCacheValues(e);return console.log(`${this._name}.${t} from server. groupID:${o}`),Ce({groupAttributes:i})}catch(e){const o=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}const u=et.getGroupAttributesCacheValues(e);return console.log(`${this._name}.${t} from cache. groupID:${o}`),Ce({groupAttributes:u})}))}getGroupAttributesFromServer(e){return Ie(this,void 0,void 0,(function*(){const{utils:{isUndefined:t}}=this._core,{groupID:o,avChatRoomKey:r}=e,i=t(r)?T:w,n=yield function(e,t){return Ie(this,void 0,void 0,(function*(){const{groupID:o,groupType:r,avChatRoomKey:i}=e;return Ze("group_open_attr_http_svc.get_group_attr",{GroupId:o,GroupType:r,Key:i},t)}))}({groupID:o,avChatRoomKey:r,groupType:i},this._core),{AttrMainSeq:s,GroupAttrAry:u}=n||{};if(console.log(`${this._name}._getGroupAttributesFromServer ok. groupID:${o} serverMainSequence:${s}`),!t(s)){const e=u.map((e=>{const{key:t,value:o,seq:r}=e;return{key:t,value:o,sequence:r}}));et.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:e,operation:O})}}))}};var nt=new class{init(e){console.log("GroupAttribute.init"),tt.init(e),ot.init(e),rt.init(e),it.init(e),et.init(e)}isGroupAttributesUpdated(e){return et.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){const{to:t,elements:{newGroupProfile:o}}=e,{groupAttributeOption:r}=o,{serverMainSequence:i,withChangedAttributeInfo:n}=r,{localMainSequence:s}=et.getGroupAttributesCache(t),u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:${u}`),0!==u)if(et.saveGroupAttributesCacheValuesCopy(t),1!==n||1!==u){if(et.hasGroupAttributesCache(t)){const{avChatRoomKey:e}=et.getGroupAttributesCache(t);it.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then((()=>{et.emitGroupAttributesUpdated(t)})).catch((()=>{}))}}else et.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:r})}};function st(e,t="tips"){const{ClientSeq:o,From_Account:r,MsgClientTime:i,MsgPriority:n,MsgRandom:s,MsgSeq:u,MsgTimeStamp:a,TinyId:c,ToGroupId:p,GroupInfo:l,MsgBody:h}=e,m=function(e){const{GroupCode:t,GroupId:o,GroupName:r,GroupType:i,MsgFrom_AccountExtraInfo:n,From_Account:s,To_Account:u}=e;return{groupCode:t,groupID:o,groupName:r,type:i,messageFromAccountExtraInformation:n,from:s,to:u}}(l);return{clientSequence:o,from:r,clientTime:i,priority:n,random:s,sequence:u,time:a,tinyID:c,to:p,groupProfile:m,elements:"tips"===t?ut(h):function(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"MsgKey":t.messageKey=e[o];break;case"Operator_Account":t.operatorID=e[o];break;case"ReportType":t.operationType=e[o];break;case"Authentication":t.authentication=e[o];break;case"MsgFlag":t.messageRemindType=e[o];break;case"UserDefinedField":t.userDefinedField=e[o];break;case"RemarkInfo":t.remarkInfo=e[o];break;case"BanDuration":t.duration=e[o]}})),t}(h)}}function ut(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"MemberNum":t.memberNum=e[o];break;case"OpType":t.operationType=e[o];break;case"Operator_Account":t.operatorID=e[o];break;case"List_Account":t.userIDList=e[o];break;case"MsgMemberExtraInfo":t.memberInfoList=e[o].map((e=>at(e)));break;case"MsgOperatorMemberExtraInfo":t.operatorInfo=at(e[o]);break;case"MsgGroupNewInfo":t.newGroupProfile=function(e){const t={};return Object.keys(e).forEach((o=>{switch(o){case"GroupIntroduction":t.introduction=e[o];break;case"GroupName":t.groupName=e[o];break;case"GroupFaceUrl":t.avatar=e[o];break;case"GroupNotification":t.notification=e[o];break;case"ApplyJoinOption":t.joinOption=e[o];break;case"InviteJoinOption":t.inviteOption=e[o];break;case"ShutupAll":t.muteAllMembers=e[o];break;case"Owner_Account":t.ownerID=e[o];break;case"GroupAttrOption":t.groupAttributeOption=function(e){const{BytesChangedKeys:t,GroupAttrSeq:o,OpType:r,PushChangedAttrValFlag:i,GroupAttrInfo:n}=e,s=n.map((e=>{const{Key:t,Val:o,SubKeySeq:r}=e;return{key:t,value:o,sequence:r}}));return{changedKeyList:t,groupAttributeList:s,serverMainSequence:o,operation:r,withChangedAttributeInfo:i}}(e[o])}})),t}(e[o]);break;case"MsgMemberInfo":t.msgMemberInfo=e[o].map((e=>function(e){const{ShutupTime:t,User_Account:o}=e;return{muteTime:t,userID:o}}(e)));break;case"OnlineMemberInfo":t.onlineMemberInfo=function(e){const{ExpireTime:t,OnlineMemberNum:o}=e;return{expireTime:t,onlineMemberNum:o}}(e[o])}})),t}function at(e){const{ImageUrl:t,NickName:o,Role:r,UserId:i}=e;return{avatar:t,nick:o,role:r,userID:i}}class ct{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(t)}static parseServerPushElement(e){const t=ut(e);return new ct(t)}_initContent(e){Object.keys(e).forEach((t=>{switch(t){case"groupProfile":this._initGroupProfile(e[t]);break;case"operatorInfo":this._initOperatorInfo(e[t]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"memberNum":this.content.memberNum=e[t],this.content.memberCount=e[t];break;case"newGroupProfile":this._initNewGroupProfile(e[t]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[t]=e[t]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];x[r]&&(this.content.groupProfile[r]=e[r])}}_initOperatorInfo(e){this.content.operatorInfo={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];this.content.operatorInfo[r]=e[r]}}_updateMemberList(e){this.content.memberList?this.content.memberList.forEach((t=>{e.forEach((e=>{t.userID===e.userID&&Object.assign(t,e)}))})):this.content.memberList=e}_initNewGroupProfile(e){this.content.newGroupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];"muteAllMembers"!==r?this.content.newGroupProfile[r]=e[r]:this.content.newGroupProfile.muteAllMembers=1===e.muteAllMembers}}}var pt=new class{constructor(){this._name="GroupTipsNotification"}init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:o}=e;null==t||t.registerElementClass(o.MSG_GRP_TIP,ct)}onNewGroupTips(e){console.log(`${this._name}.onNewGroupTips options:${JSON.stringify(e)}`);const{messageList:t}=this._handleGroupTips(e),{notificationCenter:o,OuterEvent:r}=this._core;t.length>0&&(o.emitOuterEvent(r.MESSAGE_RECEIVED,{name:r.MESSAGE_RECEIVED,data:t}),this._handleGroupTipMessage(t))}_handleGroupTips(e){const{Event:t,GroupTips:o}=e,r=new Map,i=[],n=[];for(let e=0,i=o.length;e<i;e++){const i=st(o[e],"tips");if(t===$&&nt.isGroupAttributesUpdated(i)){nt.handleGroupAttributesUpdated(i);continue}const{groupProfile:{groupID:s}}=i;if(!be.hasLocalGroup(s))continue;const u=this._assembleMessage(i);if(t===$&&(u._onlineOnlyFlag=!0,n.push(u)),t===N){if(!this._core.message.messageDataHandler.storeConversationMessage(u))continue;n.push(u)}this._handleConversationOptions(r,u)}return i.push(...r.values()),{conversationUpdateFieldList:i,messageList:n}}_assembleMessage(e){const{OuterConstant:t,message:{messageFactory:o}}=this._core;e.flow="in",e.conversationType=t.CONV_GROUP;const r=o.createMessage(e);this._patchNickAndAvatar(e.elements,r);const i=new ct(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));return r.setElement(i),r.isSystemMessage=!1,r}_patchNickAndAvatar(e,t){const{utils:{isEmpty:o}}=this._core,{operationType:r,memberInfoList:i,operatorInfo:n}=e;let s={};if(o(i)?o(n)||(s=n):r!==E&&r!==P&&r!==U&&r!==k||(s=Object.assign({},i[0])),!o(s)){const{nick:e,avatar:o}=s;t.nick=e,t.avatar=o}}_handleConversationOptions(e,t){const{conversationID:o,conversationType:r}=t;let i;if(e.has(o))i=e.get(o),"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||i.unreadCount++),i.type=r,i.lastMessage=t._isExcludedFromLastMessage?"":t;else{let e=0;"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1)),i={conversationID:o,unreadCount:e,type:r,lastMessage:t._isExcludedFromLastMessage?"":t}}e.set(o,i)}_handleGroupTipMessage(e){e.forEach((e=>{const{operationType:t}=e.payload;switch(t){case E:this._handleNewMemberJoined(e);break;case R:this._handleMemberQuitted(e);break;case P:this._handleMemberKicked(e);break;case q:this._handleGroupProfileUpdated(e)}}))}_handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}_handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}_handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}_handleGroupProfileUpdated(e){var t;const{newGroupProfile:o,groupProfile:r,operatorInfo:i}=e.payload,{groupID:n}=r,s=be.getLocalGroup(n);Object.keys(o).forEach((e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(n,o);break;case"groupName":s.name=o[e];break;default:s[e]=o[e]}}));const{utils:{isUndefined:u}}=this._core;u(i)||(null===(t=null==s?void 0:s.selfInfo)||void 0===t?void 0:t.userID)!==i.userID||Object.keys(i).forEach((e=>{"nameCard"===e&&s.updateSelfInfo({nameCard:i[e]}),"role"===e&&this._updateSelfRole(s,i[e])})),be.emitGroupListUpdate(),be.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){const{common:o,OuterConstant:r}=this._core,i=be.getLocalGroup(e),n=o.getCurrentUserID(),{ownerID:s}=t;n===s&&i.updateGroup({ownerID:s,selfInfo:{role:r.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(e,t){const{OuterConstant:o}=this._core;let r=o.GRP_MBR_ROLE_MEMBER;t===F?r=o.GRP_MBR_ROLE_OWNER:t===j&&(r=o.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:r})}_handleGroupMemberCountUpdated(e){const{memberCount:t,groupProfile:{groupID:o}}=e.payload,r=be.getLocalGroup(o),{utils:{isNumber:i}}=this._core;r&&i(t)&&r.memberCount!==t&&(r.memberCount=t,be.emitGroupListUpdate(),be.updateConversationGroupProfile(o))}};class lt{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}_initContent(e){Object.keys(e).forEach((t=>{switch(t){case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this._initGroupProfile(e[t]);break;case"memberInfoList":break;default:this.content[t]=e[t]}}))}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];K[r]&&(this.content.groupProfile[r]=e[r])}}}var ht=new class{constructor(){this._name="GroupSystemNotification"}init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:{MSG_GRP_SYS_NOTICE:o}}=e;null==t||t.registerElementClass(o,lt)}onNewGroupSystemNotification(e){const{GroupTips:t=[],isInstantMessage:o=!0}=e;console.log(`${this._name}.onNewGroupSystemNotification count:${t.length} isInstantMessage:${o}`);const{conversationUpdateFieldList:r,messageList:i}=this._handleGroupSystemNotification(t,o),{notificationCenter:n,OuterEvent:s}=this._core;r.length>0&&this._handleGroupSysTemMessage(o,i),!0===o&&i.length>0&&n.emitOuterEvent(s.MESSAGE_RECEIVED,{name:s.MESSAGE_RECEIVED,data:i})}_handleGroupSystemNotification(e,t){const o=[];let r={};for(let i=0;i<e.length;i++){const n=st(e[i],"system"),{elements:{operationType:s}}=n;if(s===W)continue;const u=this._assembleMessage(n);this._core.message.messageDataHandler.storeConversationMessage(u)&&(o.push(u),r=this._handleConversationOptions(u,t))}return r.lastMessage=o[o.length-1],{conversationUpdateFieldList:o.length>0?[r]:[],messageList:o}}_assembleMessage(e){const{message:{messageFactory:t},OuterConstant:o,utils:{randomInt:r}}=this._core;e.flow="in",e.conversationType=o.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=o.CONV_SYSTEM;const i=t.createMessage(e),n=new lt(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));i.setElement(n),i.isSystemMessage=!0;const s=1===i.sequence&&1===i.random,u=2===i.sequence&&2===i.random;return(s||u)&&(i.sequence=r(),i.random=r(),i.generateMessageID()),i}_handleConversationOptions(e,t){const{OuterConstant:o}=this._core,r={conversationID:o.CONV_SYSTEM,unreadCount:0,type:o.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&r.unreadCount++,r}_handleGroupSysTemMessage(e,t){e&&t.forEach((e=>{const{operationType:t}=e.payload;switch(t){case V:this._handleGroupJoinResult(e);break;case J:this._handleMemberKicked(e);break;case B:this._handleGroupDismissed(e);break;case H:this._handleGroupInvitedResult(e);break;case Y:this._handleGroupQuitResult(e);break;case Q:this._handleMessageRemindTypeSynced(e)}}))}_handleGroupJoinResult(e){const{groupProfile:t}=e.payload,{groupID:o,type:r}=t,i=be.hasLocalGroup(o);console.log(`${this._name}._handleGroupJoinResult groupID:${o} type:${r} hasLocalGroup:${i}`),i||he(r)||(be.updateLocalGroup([Object.assign({},t)]),be.emitGroupListUpdate())}_handleMemberKicked(e){const{groupProfile:{groupID:t,type:o}}=e.payload;be.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupDismissed(e){const{groupProfile:{groupID:t,type:o}}=e.payload;be.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupInvitedResult(e){const{groupProfile:t}=e.payload,{groupID:o}=t,r=be.hasLocalGroup(o);console.log(`${this._name}._handleGroupInvitedResult groupID:${o} hasLocalGroup:${r}`),r||(be.updateLocalGroup([Object.assign({},t)]),be.emitGroupListUpdate())}_handleGroupQuitResult(e){const{groupProfile:{groupID:t,type:o}}=e.payload,r=be.hasLocalGroup(t);console.log(`${this._name}._handleGroupQuitResult groupID:${t} type:${o} hasLocalGroup:${r}`),r&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleMessageRemindTypeSynced(e){const{groupProfile:{groupID:t},messageRemindType:o}=e.payload;this._updateConversationProfile(t,{messageRemindType:o})}_deleteLocalGroup(e,t){if(he(t)){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core;t.deleteConversation(`${o}${e}`)}be.deleteLocalGroup(e),be.emitGroupListUpdate()}_updateConversationProfile(e,t){const{appStore:{conversationStore:o},OuterConstant:{CONV_GROUP:r}}=this._core,i=`${r}${e}`;o.getConversation(i)&&o.updateConversation(i,t)}};var mt=new class{init(e){this._core=e,console.log("GroupNotificationHandler.init"),pt.init(e),ht.init(e);const{notificationCenter:t,InnerEvent:o}=e,{InnerEventSubType:r}=t;t.subscribeInnerEvent(o.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),t.subscribeInnerEvent(o.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(e){pt.onNewGroupTips(e)}_onNewGroupSystemNotification(e){ht.onNewGroupSystemNotification(e)}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:o}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,o.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,o.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};const dt={required:!0,rules:["string"],allowEmpty:!1},gt={required:!0,rules:["number"],allowEmpty:!1},_t={required:!0,rules:["array"],allowEmpty:!1},ft={required:!0,rules:["object"],allowEmpty:!1},Gt={createGroup:{name:dt,type:dt},dismissGroup:[Object.assign({key:"groupID"},dt)],joinGroup:{groupID:dt,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},dt)],searchGroupByID:[Object.assign({key:"groupID"},dt)],getGroupProfile:{groupID:dt,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:dt,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:dt,newOwnerID:dt},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},dt)],handleGroupApplication:{handleAction:dt},getGroupMemberList:{groupID:dt},getGroupMemberProfile:{groupID:dt,userIDList:_t,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:dt,userIDList:_t},deleteGroupMember:{groupID:dt,userIDList:_t},setGroupMemberMuteTime:{groupID:dt,userID:dt,muteTime:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:dt,userID:dt,role:dt},setGroupMemberNameCard:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:dt},setGroupMemberCustomField:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:_t},markGroupMemberList:{groupID:dt,markType:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:_t},initGroupAttributes:{groupID:dt,groupAttributes:ft},setGroupAttributes:{groupID:dt,groupAttributes:ft},deleteGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})},getGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})}},bt={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0};var vt=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=be,this.groupAction=Ee,this.groupAttribute=nt}install(t,o=[]){this._core=t,e.init(t),be.init(t),Ee.init(t,this),ke.init(t),ze.init(t),Xe.init(t),nt.init(t),mt.init(t),t.helper.registerValidateConfig({auth:bt,params:Gt}),this._installSubPlugins(o);const{notificationCenter:r,InnerEvent:i}=t;r.subscribeInnerEvent(i.LOGOUT,this._reset,this),r.subscribeInnerEvent(i.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(e){const{utils:{isArray:t}}=this._core;e&&t(e)&&e.forEach((e=>{var t;null===(t=e.install)||void 0===t||t.call(e,this._core,this),this._installedSubPlugins.push(e.name)}))}_reset(){be.reset()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};export{vt as default};
package/plugins/group.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatGroup=r()}(this,(function(){"use strict";function e(e,r,o,t){return new(o||(o=Promise))((function(i,n){function s(e){try{u(t.next(e))}catch(e){n(e)}}function c(e){try{u(t.throw(e))}catch(e){n(e)}}function u(e){var r;e.done?i(e.value):(r=e.value,r instanceof o?r:new o((function(e){e(r)}))).then(s,c)}u((t=t.apply(e,r||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const r="group";var o=new class{init(e){this._core=e;const{helper:r}=e;r.registerApi("searchGroupByID",this),r.registerApi("getGroupList",this),r.registerApi("getGroupApplicationList",this)}searchGroupByID(o){return e(this,void 0,void 0,(function*(){try{console.log(`${r} searchGroupByID: groupID: ${o}`);const t=yield function(r,o){return e(this,void 0,void 0,(function*(){try{const{helper:e,channel:t}=o,i="group_open_http_svc.get_group_public_info",n={GroupIdList:[r]},s=e.generateProtocolData({servcmd:i,data:n}),c=`${s.head.seq}${i}`;return yield t.sendPacket(s,{requestId:c})}catch(e){throw console.warn("searchGroupByID error:",e),e}}))}(o,this._core);return this._parseSearchGroupByIDResponse(t),{code:0,data:{group:{groupID:o}}}}catch(e){throw console.warn(`${r} searchGroupByID error:`,e),e}}))}getGroupList(){return e(this,void 0,void 0,(function*(){return console.log(`${r} getGroupList`),{code:0,data:{groupList:[]}}}))}getGroupApplicationList(){return e(this,void 0,void 0,(function*(){return console.log(`${r} getGroupApplicationList`),{code:0,data:{applicationList:[]}}}))}_parseSearchGroupByIDResponse(e){var r;const o=null===(r=e.GroupInfo)||void 0===r?void 0:r[0];if(0!==(null==o?void 0:o.ErrorCode))throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:null==o?void 0:o.ErrorCode,message:null==o?void 0:o.ErrorCode});return e}};var t=new class{init(e){this._core=e}};var i=new class{init(e){this._core=e}};var n=new class{init(e){this._core=e}};var s=new class{init(e){this._core=e}};const c={searchGroupByID:[{key:"groupID",required:!0,rules:["string"],allowEmpty:!1}]},u={getGroupList:!0,searchGroupByID:!0,getGroupApplicationList:!0};return new class{install(e){o.init(e),t.init(e),i.init(e),n.init(e),s.init(e),e.helper.registerValidateConfig({auth:u,params:c})}}}));
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)}}}));