"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5193],{35058:function(a,b,c){c.d(b,{"$":function(){return bD},G:function(){return a$},H:function(){return o},I:function(){return aP},J:function(){return bW},K:function(){return bE},L:function(){return G},N:function(){return aJ},P:function(){return k},R:function(){return aL},S:function(){return m},T:function(){return aU},V:function(){return J},W:function(){return K},X:function(){return b2},Y:function(){return b1},Z:function(){return b6},"_":function(){return b5},a:function(){return E},b:function(){return ca},c:function(){return aN},d:function(){return P},e:function(){return R},f:function(){return S},g:function(){return N},h:function(){return O},i:function(){return H},s:function(){return I},t:function(){return aR},v:function(){return Q}});var d,e=c(84663),f=c(89531),g=c(82861),h=c(80812),i=c(50926);(d=j||(j={})).NONE="none",d.JOINED="joined",d.INVITED="invited",d.LEFT="left";var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.state=null,d.role=null,d.isMuted=!1,d.isBlockedByMe=!1,d.isBlockingMe=!1,d.joinedAt=0,d.state=(0,e.a5)(j,c.state)?c.state:null,d.role=(0,e.a5)(e.ai,c.role)?c.role:null,"boolean"==typeof c.is_muted&&(d.isMuted=c.is_muted),"boolean"==typeof c.is_blocked_by_me&&(d.isBlockedByMe=c.is_blocked_by_me),"boolean"==typeof c.is_blocking_me&&(d.isBlockingMe=c.is_blocking_me),"number"==typeof c.joined_ts&&(d.joinedAt=1e3*c.joined_ts),d}return(0,e.c)(b,a),b.payloadify=function(b){return(0,e.f)((0,e.g)((0,e.d)((0,e.d)({},a.payloadify.call(this,b)),{state:b.state,role:b.role,is_muted:b.isMuted,is_blocked_by_me:b.isBlockedByMe,is_blocking_me:b.isBlockingMe,joined_ts:b.joinedAt/1e3})))},b}(f.H),B=function(a){function b(b,c){var d,f,g=this;return(g=a.call(this,b)||this).channelUrl=null!==(d=c.channel_url)&& void 0!==d?d:"",g.channelType=null!==(f=c.channel_type)&& void 0!==f?f:e.C.GROUP,g.member=new e.U(g._iid,c.user),g.deliveryAt=c.ts,g}return(0,e.c)(b,a),b}(e.aK);(s=k||(k={})).ALL="all",s.PUBLIC="public",s.PRIVATE="private",(t=l||(l={})).ALL="all",t.JOINED="joined_only",t.INVITED="invited_only",t.INVITED_BY_FRIEND="invited_by_friend",t.INVITED_BY_NON_FRIEND="invited_by_non_friend",(u=m||(m={})).ALL="all",u.SUPER="super",u.NON_SUPER="nonsuper",u.BROADCAST_ONLY="broadcast_only",u.EXCLUSIVE_ONLY="exclusive_only",(v=n||(n={})).ALL="all",v.UNREAD_MESSAGE="unread_message",(w=o||(o={})).ALL="all",w.UNHIDDEN="unhidden_only",w.HIDDEN="hidden_only",w.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",w.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",(x=p||(p={})).ALL="all",x.OPERATOR="operator",x.NONOPERATOR="nonoperator",(y=q||(q={})).AND="AND",y.OR="OR",(z=r||(r={})).MEMBER_NICKNAME="member_nickname",z.CHANNEL_NAME="channel_name";var C,D,E=function(){function a(a){var b,c,d,e,f,g,h,i,j,p,q,r,s,t,u,v,w,x,y,z;this._searchFilter=null,this._userIdsFilter=null,this.metadataKey=null,this.metadataValues=null,this.metadataValueStartsWith=null,this.includeEmpty=null!==(b=null==a?void 0:a.includeEmpty)&& void 0!==b&&b,this.nicknameContainsFilter=null!==(c=null==a?void 0:a.nicknameContainsFilter)&& void 0!==c?c:null,this.nicknameStartsWithFilter=null!==(d=null==a?void 0:a.nicknameStartsWithFilter)&& void 0!==d?d:null,this.nicknameExactMatchFilter=null!==(e=null==a?void 0:a.nicknameExactMatchFilter)&& void 0!==e?e:null,this.channelNameContainsFilter=null!==(f=null==a?void 0:a.channelNameContainsFilter)&& void 0!==f?f:"",this.myMemberStateFilter=null!==(g=null==a?void 0:a.myMemberStateFilter)&& void 0!==g?g:l.ALL,this.customTypesFilter=null!==(h=null==a?void 0:a.customTypesFilter)&& void 0!==h?h:null,this.channelUrlsFilter=null!==(i=null==a?void 0:a.channelUrlsFilter)&& void 0!==i?i:null,this.superChannelFilter=null!==(j=null==a?void 0:a.superChannelFilter)&& void 0!==j?j:m.ALL,this.publicChannelFilter=null!==(p=null==a?void 0:a.publicChannelFilter)&& void 0!==p?p:k.ALL,this.customTypeStartsWithFilter=null!==(q=null==a?void 0:a.customTypeStartsWithFilter)&& void 0!==q?q:null,this.unreadChannelFilter=null!==(r=null==a?void 0:a.unreadChannelFilter)&& void 0!==r?r:n.ALL,this.hiddenChannelFilter=null!==(s=null==a?void 0:a.hiddenChannelFilter)&& void 0!==s?s:o.UNHIDDEN,this.includeFrozen=null===(t=null==a?void 0:a.includeFrozen)|| void 0===t||t,this.metadataKey=null!==(u=null==a?void 0:a.metadataKey)&& void 0!==u?u:null,this.metadataValues=null!==(v=null==a?void 0:a.metadataValues)&& void 0!==v?v:null,this.metadataValueStartsWith=null!==(w=null==a?void 0:a.metadataValueStartsWith)&& void 0!==w?w:null,this._userIdsFilter=null!==(x=null==a?void 0:a.userIdsFilter)&& void 0!==x?x:null,this._searchFilter=null!==(y=null==a?void 0:a.searchFilter)&& void 0!==y?y:null,(null==a?void 0:a.createdAfter)&&(this.createdAfter=a.createdAfter),(null==a?void 0:a.createdBefore)&&(this.createdBefore=a.createdBefore),this.includeMetaData=null===(z=null==a?void 0:a.includeMetaData)|| void 0===z||z}return a.prototype._isFriend=function(a){return!(!a|| !a.friendDiscoveryKey&&!a.friendName)},Object.defineProperty(a.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),a.prototype.setSearchFilter=function(a,b){Array.isArray(a)&&0!==a.length&&"string"==typeof b&&b&&(this._searchFilter={query:b,fields:a})},Object.defineProperty(a.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),a.prototype.setUserIdsFilter=function(a,b,c){void 0===c&&(c=q.AND),this._userIdsFilter={userIds:a,includeMode:b,queryType:c}},a.prototype.clone=function(){var b,c=new a;this.searchFilter&&c.setSearchFilter(this.searchFilter.fields,null!==(b=this.searchFilter.query)&& void 0!==b?b:void 0),this.userIdsFilter&&c.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var d=JSON.parse(JSON.stringify(this));return Object.keys(d).forEach(function(a){c[a]=d[a]}),c},a.prototype.match=function(a,b){var c;if(this._searchFilter){var d=this._searchFilter,f=d.query,g=d.fields;if(f&&g&&g.length>0&&!g.some(function(b){switch(b){case r.CHANNEL_NAME:return a.name.toLowerCase().includes(f.toLowerCase());case r.MEMBER_NICKNAME:return a.members.some(function(a){return a.nickname.toLowerCase().includes(f.toLowerCase())});default:return!0}}))return!1}if(this._userIdsFilter){var h=this._userIdsFilter,i=h.userIds,j=h.includeMode,p=h.queryType,s=a.members.map(function(a){return a.userId});if(j){if(i.length>0)switch(p){case q.AND:if(i.some(function(a){return!s.includes(a)}))return!1;break;case q.OR:if(i.every(function(a){return!s.includes(a)}))return!1}}else if(i.includes(b)||i.push(b),a.members.length>i.length||!(0,e.bp)(i,s))return!1}if(!this.includeEmpty&&!a.lastMessage|| !this.includeFrozen&&a.isFrozen||this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(a.customType)||this.customTypeStartsWithFilter&&!RegExp("^".concat(this.customTypeStartsWithFilter)).test(a.customType)||this.channelNameContainsFilter&&!a.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var t=this.nicknameContainsFilter.toLowerCase();if(!a.members.some(function(a){return a.userId!==b&&a.nickname.toLowerCase().includes(t)}))return!1}if(this.nicknameStartsWithFilter){var u=this.nicknameStartsWithFilter.toLowerCase();if(!a.members.some(function(a){return a.userId!==b&&a.nickname.toLowerCase().startsWith(u)}))return!1}if(this.nicknameExactMatchFilter){var v=this.nicknameExactMatchFilter.toLowerCase();if(!a.members.some(function(a){return a.userId!==b&&a.nickname.toLowerCase()!=v}))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(a.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case l.ALL:if("none"===a.myMemberState)return!1;break;case l.JOINED:if("joined"!==a.myMemberState)return!1;break;case l.INVITED:if("invited"!==a.myMemberState)return!1;break;case l.INVITED_BY_FRIEND:if("invited"!==a.myMemberState||!this._isFriend(a.inviter))return!1;break;case l.INVITED_BY_NON_FRIEND:if("invited"!==a.myMemberState||this._isFriend(a.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case o.UNHIDDEN:if(a.isHidden||"unhidden"!==a.hiddenState)return!1;break;case o.HIDDEN:if(!a.isHidden)return!1;break;case o.HIDDEN_ALLOW_AUTO_UNHIDE:if(!a.isHidden||"hidden_allow_auto_unhide"!==a.hiddenState)return!1;break;case o.HIDDEN_PREVENT_AUTO_UNHIDE:if(!a.isHidden||"hidden_prevent_auto_unhide"!==a.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===n.UNREAD_MESSAGE&&0===a.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case k.PUBLIC:if(!a.isPublic)return!1;break;case k.PRIVATE:if(a.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case m.SUPER:if(!a.isSuper)return!1;break;case m.NON_SUPER:if(a.isSuper)return!1}return(!this.includeMetaData||!this.metadataKey|| void 0!==(null===(c=a.cachedMetaData)|| void 0===c?void 0:c[this.metadataKey])&&(!this.metadataValues||!!this.metadataValues.includes(a.cachedMetaData[this.metadataKey]))&&(!this.metadataValueStartsWith||!!a.cachedMetaData[this.metadataKey].startsWith(this.metadataValueStartsWith)))&&!(this.createdAfter&&a.createdAtthis.createdBefore)},a}(),F={},G=function(a){function b(b,c){var d=c.sdkState,e=c.cacheContext,f=a.call(this,b)||this;return f._channels=new Map,f._sdkState=d,f._cacheContext=e,f}return(0,e.c)(b,a),b.of=function(a){if(!F[a]){var c=e.V.of(a),d=c.sdkState,f=c.cacheContext;F[a]=new b(a,{sdkState:d,cacheContext:f})}return F[a]},b.clear=function(a){F[a]&&(F[a].clear(),delete F[a])},Object.defineProperty(b.prototype,"collection",{get:function(){var a=this._cacheContext.nestdb;return(0,e.p)(!!a).throw(e.q.databaseError),a.collection(f.a)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),b.prototype._serialize=function(a,b){return void 0===b&&(b=0),(0,e.d)((0,e.d)({},a.serialize()),{lastMessageUpdatedAt:a.lastMessage?a.lastMessage.createdAt:0,syncIndex:b})},b.prototype._deserialize=function(a){return a$.of(this._iid).buildGroupChannelFromSerializedData(a)},Object.defineProperty(b.prototype,"channels",{get:function(){return(0,e.s)([],(0,e.t)(this._channels.values()),!1)},enumerable:!1,configurable:!0}),b.prototype.isCachedInMemory=function(a){return this._channels.has(a)},b.prototype.filterOffsetChanged=function(a){var b=this;return a.filter(function(a){if(b._channels.has(a.url))return b._channels.get(a.url).messageOffsetTimestamp0)return d--,!1;if(b)switch(o){case g.G.CHANNEL_NAME_ALPHABETICAL:if(!k&&0>a.name.localeCompare(b)||k&&a.name.localeCompare(b)>0)return!1;break;case g.G.CHRONOLOGICAL:if(!k&&a.createdAt>b||k&&a.createdAtb||k&&a.lastMessageUpdatedAta._messageCollectionLastAccessedAt&&(a._messageCollectionLastAccessedAt=d._messageCollectionLastAccessedAt),a.cachedMetaData instanceof Map&&a.cachedMetaData.size>0&&b&&(d._updateCachedMetaData(a.cachedMetaData,b).isUpdated||Object.assign(a,{_cachedMetaData:d.cachedMetaData})),d._update(a),c.push(d)}else g._channels.set(a.url,a),c.push(a)}),!this.localCacheEnabled)return[3,2];for(d=[],f=0;f0?[4,this.upsert(d)]:[3,2];case 1:x.sent(),x.label=2;case 2:return[2]}})})},b.prototype.block=function(a,b){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(c){switch(c.label){case 0:return[4,this._setBlockStateOfAllChannels(a,b,!0)];case 1:return c.sent(),[2]}})})},b.prototype.unblock=function(a,b){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(c){switch(c.label){case 0:return[4,this._setBlockStateOfAllChannels(a,b,!1)];case 1:return c.sent(),[2]}})})},b.prototype.markAsRead=function(a,b){return void 0===b&&(b=(0,e.s)([],(0,e.t)(this._channels.keys()),!1)),(0,e._)(this,void 0,void 0,function(){var c,d,f,g,h,i,j,k;return(0,e.b)(this,function(l){switch(l.label){case 0:c=[],l.label=1;case 1:l.trys.push([1,6,7,8]),f=(d=(0,e.x)(b)).next(),l.label=2;case 2:return f.done?[3,5]:(g=f.value,[4,this.get(g)]);case 3:(null==(h=l.sent())?void 0:h._updateUnreadMemberState(this._sdkState.userId,a))&&(h._updateUnreadCount(0,0),c.push(h)),l.label=4;case 4:return f=d.next(),[3,2];case 5:return[3,8];case 6:return j={error:i=l.sent()},[3,8];case 7:try{f&&!f.done&&(k=d.return)&&k.call(d)}finally{if(j)throw j.error}return[7];case 8:return c.length>0?[4,this.upsert(c)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}})})},b}(e.aK),H=(0,e.d)({},e.ab),I=function(a){return a.startsWith("EVENT_")||a===e.ab.SYNC_CHANNEL_CHANGELOGS||a===e.ab.REFRESH_CHANNEL},J=function(a){function b(b){var c=b.channels,d=b.context,e=b.isWebSocketEventComing,f=b.ts,g=a.call(this)||this;return g.channels=c,g.context=d,g.isWebSocketEventComing=void 0!==e&&e,g.ts=f,g}return(0,e.c)(b,a),b}(e.bk),K=function(a){function b(b){var c=b.channelUrls,d=b.context,e=b.isWebSocketEventComing,f=a.call(this)||this;return f.channelUrls=c,f.context=d,f.isWebSocketEventComing=void 0!==e&&e,f}return(0,e.c)(b,a),b}(e.bk),L=function(a){function b(b){var c=b.channel,d=a.call(this)||this;return d.channel=c,d}return(0,e.c)(b,a),b}(e.bk),M=function(){function a(a){var b=a.groupChannelCache,c=a.userInfoCache,d=a.messageCache,f=a.unsentMessageCache,h=a.dispatcher,i=this;this._observers=new Map,h.on(function(a){return(0,e._)(i,void 0,void 0,function(){var i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,F,G=this;return(0,e.b)(this,function(H){switch(H.label){case 0:if(!(a instanceof J))return[3,19];if(A=a.channels,u=a.context,v=a.isWebSocketEventComing,i=A.filter(function(a){return a instanceof ca}),u.source!==e.ab.EVENT_CHANNEL_RESET_HISTORY&&u.source!==e.ab.EVENT_CHANNEL_HIDDEN)return[3,9];H.label=1;case 1:H.trys.push([1,6,7,8]),k=(j=(0,e.x)(i)).next(),H.label=2;case 2:return k.done?[3,5]:(q=k.value,[4,d.removeUnderOffset(q.url,q.messageOffsetTimestamp)]);case 3:H.sent(),H.label=4;case 4:return k=j.next(),[3,2];case 5:return[3,8];case 6:return B={error:l=H.sent()},[3,8];case 7:try{k&&!k.done&&(C=j.return)&&C.call(j)}finally{if(B)throw B.error}return[7];case 8:return[3,17];case 9:m=b.filterOffsetChanged(i),H.label=10;case 10:H.trys.push([10,15,16,17]),p=(n=(0,e.x)(m)).next(),H.label=11;case 11:return p.done?[3,14]:(q=p.value,[4,d.removeUnderOffset(q.url,q.messageOffsetTimestamp)]);case 12:H.sent(),H.label=13;case 13:return p=n.next(),[3,11];case 14:return[3,17];case 15:return D={error:r=H.sent()},[3,17];case 16:try{p&&!p.done&&(F=n.return)&&F.call(n)}finally{if(D)throw D.error}return[7];case 17:return[4,b.upsert(i,a.ts)];case 18:return s=H.sent(),v||this._broadcastUpdateEvent(s,u),[3,30];case 19:return a instanceof K?(t=a.channelUrls,u=a.context,v=a.isWebSocketEventComing,[4,b.remove(t)]):[3,22];case 20:return H.sent(),[4,(0,e.J)(function(){return(0,e._)(G,void 0,void 0,function(){var a,b,c,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:j.trys.push([0,6,7,8]),b=(a=(0,e.x)(t)).next(),j.label=1;case 1:return b.done?[3,5]:(c=b.value,[4,d.removeMessagesOfChannel(c)]);case 2:return j.sent(),[4,f.removeMessagesOfChannel(c)];case 3:j.sent(),j.label=4;case 4:return b=a.next(),[3,1];case 5:return[3,8];case 6:return h={error:g=j.sent()},[3,8];case 7:try{b&&!b.done&&(i=a.return)&&i.call(a)}finally{if(h)throw h.error}return[7];case 8:return[2]}})})})];case 21:return H.sent(),v||this._broadcastRemoveEvent(t,u),[3,30];case 22:if(!(a instanceof g.D))return[3,30];w=100,x=Number.MAX_SAFE_INTEGER,y=new Set,z=!0,H.label=23;case 23:return z?[4,b.fetch({token:x,limit:w,order:g.G.CHRONOLOGICAL,filter:new E({includeEmpty:!0,includeMetaData:!0,hiddenChannelFilter:o.ALL}),excludeChannelUrls:y})]:[3,28];case 24:return 0!==(A=H.sent()).length?[3,25]:(z=!1,[3,27]);case 25:return A.forEach(function(a){return y.add(a.url)}),x=A[A.length-1].createdAt,[4,(0,e.aU)(10)];case 26:H.sent(),H.label=27;case 27:return[3,23];case 28:return[4,c.fetch({limit:Number.MAX_SAFE_INTEGER})];case 29:H.sent(),e.V.of(a._iid).sdkState.userId===a.userId&&h.dispatch(new g.R),H.label=30;case 30:return[2]}})})})}return a.prototype._broadcastUpdateEvent=function(a,b){var c,d;try{for(var f=(0,e.x)(this._observers.values()),g=f.next();!g.done;g=f.next()){var h=g.value;h.onUpdate&&h.onUpdate(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=f.return)&&d.call(f)}finally{if(c)throw c.error}}},a.prototype._broadcastRemoveEvent=function(a,b){var c,d;try{for(var f=(0,e.x)(this._observers.values()),g=f.next();!g.done;g=f.next()){var h=g.value;h.onRemove&&h.onRemove(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=f.return)&&d.call(f)}finally{if(c)throw c.error}}},a.prototype.subscribe=function(a,b){this._observers.set(a,b)},a.prototype.unsubscribe=function(a){this._observers.delete(a)},a.prototype.unsubscribeAll=function(){this._observers.clear()},a}(),N={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},O=function(a){return(0,e.a2)("string",a.invitedUserIds,!0)&&(0,e.a)("string",a.channelUrl,!0)&&(0,e.a)("string",a.coverUrl,!0)&&((0,e.i)(a.coverImage)||(0,e.a)("string",a.coverImage,!0))&&(0,e.a)("boolean",a.isDistinct,!0)&&(0,e.a)("boolean",a.isSuper,!0)&&(0,e.a)("boolean",a.isBroadcast,!0)&&(0,e.a)("boolean",a.isExclusive,!0)&&(0,e.a)("boolean",a.isPublic,!0)&&(0,e.a)("boolean",a.isStrict,!0)&&(0,e.a)("boolean",a.isDiscoverable,!0)&&(0,e.a)("boolean",a.isEphemeral,!0)&&(0,e.a)("string",a.accessCode,!0)&&(0,e.a)("string",a.name,!0)&&(0,e.a)("string",a.data,!0)&&(0,e.a)("string",a.customType,!0)&&(0,e.a2)("string",a.operatorUserIds,!0)&&(0,e.a)("number",a.messageSurvivalSeconds,!0)},P={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1},Q=function(a){return(0,e.a2)("string",a.customTypes,!0)&&(0,e.a)("boolean",a.includeEmpty,!0)&&(0,e.a)("boolean",a.includeFrozen,!0)&&(0,e.a)("boolean",a.includeMetaData,!0)&&(0,e.a)("boolean",a.includeChatNotification,!0)},R={myMemberStateFilter:l.ALL},S=function(a){return(0,e.a5)(l,a.myMemberStateFilter)};(D=C||(C={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",D.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",D.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",D.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",D.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",D.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",D.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",D.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",D.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var T,U={keys:[C.GROUP_CHANNEL_UNREAD_MENTION_COUNT,C.NONSUPER_UNREAD_MENTION_COUNT,C.SUPER_UNREAD_MENTION_COUNT,C.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,C.NONSUPER_UNREAD_MESSAGE_COUNT,C.SUPER_UNREAD_MESSAGE_COUNT,C.GROUP_CHANNEL_INVITATION_COUNT,C.NONSUPER_INVITATION_COUNT,C.SUPER_INVITATION_COUNT],customTypeFilters:void 0,customTypesFilter:void 0},V={channelCustomTypesFilter:void 0,superChannelFilter:m.ALL},W=function(a){return(0,e.a2)("string",a.channelCustomTypesFilter,!0)&&(0,e.a5)(m,a.superChannelFilter)},X={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.au.ALL},Y=function(a){function b(b){var c=b.userId,d=b.ts,f=b.token,g=b.filter,h=b.includeChatNotification,i=void 0!==h&&h,j=a.call(this)||this,k=(0,e.d)((0,e.d)({},P),g),l=k.customTypes,m=k.includeEmpty,n=k.includeFrozen;return j.method=e.A.GET,j.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/my_group_channels/changelogs"),j.params=(0,e.f)((0,e.g)({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:d||null,token:f,custom_types:l,show_empty:m,show_frozen:n,include_chat_notification:i})),j}return(0,e.c)(b,a),b}(e.h),Z=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.updatedChannels=c.updated.map(function(a){return new ca(b,Object.assign(a,{ts:c.ts}))}),d.deletedChannelUrls=c.deleted,d.hasMore=c.has_more,d.token=c.next,d.ts=c.ts,d}return(0,e.c)(b,a),b}(e.j),$=function(a){function b(b){var c=b.channelUrl,d=b.isInternalCall,f=b.showLatestMessage,g=a.call(this)||this;return g.method=e.A.GET,g.path="".concat(d?e.bq:e.aW,"/").concat(encodeURIComponent(c)),g.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_latest_message:null!=f&&f,show_conversation:!0},g}return(0,e.c)(b,a),b}(e.h),_=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.channel=new ca(b,c),d}return(0,e.c)(b,a),b}(e.j),aa={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:l.ALL,unreadChannelFilter:n.ALL,superChannelFilter:m.ALL,publicChannelFilter:k.ALL,hiddenChannelFilter:o.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:q.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:g.G.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},ab=function(a){function b(b){var c=this,d=b.userId,f=b.token,g=b.limit,h=b.order,i=b.includeEmpty,j=b.myMemberStateFilter,k=b.superChannelFilter,l=b.publicChannelFilter,m=b.unreadChannelFilter,n=b.nicknameContainsFilter,o=b.nicknameStartsWithFilter,p=b.nicknameExactMatchFilter,q=b.channelNameContainsFilter,r=b.channelUrlsFilter,s=b.customTypesFilter,t=b.customTypeStartsWithFilter,u=b.hiddenChannelFilter,v=b.metadataOrderKeyFilter,w=b.metadataKey,x=b.metadataValues,y=b.metadataValueStartsWith,z=b.includeFrozen,A=b.includeMetaData,B=b.searchFilter,C=b.userIdsFilter,D=b.includeChatNotification,E=b.includeLeftChannel,F=b.createdAfter,G=b.createdBefore;return(c=a.call(this)||this).method=e.A.GET,c.path="".concat(e.k,"/").concat(encodeURIComponent(d),"/my_group_channels"),c.params=(0,e.f)({token:f,limit:g,order:null!=h?h:aa.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=i?i:aa.includeEmpty,member_state_filter:null!=j?j:aa.myMemberStateFilter,super_mode:null!=k?k:aa.superChannelFilter,public_mode:null!=l?l:aa.publicChannelFilter,unread_filter:null!=m?m:aa.unreadChannelFilter,members_nickname_contains:n,members_nickname_startswith:o,members_nickname:p,name_contains:q,channel_urls:r,custom_types:s,custom_type_startswith:t,hidden_mode:u,metadata_order_key:v,metadata_key:w,metadata_values:x,metadata_value_startswith:y,show_frozen:z,show_metadata:A,include_chat_notification:void 0!==D&&D,include_left_channel:void 0!==E&&E,created_after:F,created_before:G}),B&&B.query&&B.fields&&(c.params.search_query=B.query,c.params.search_fields=B.fields),C&&C.userIds&&C.userIds.length>0&&(C.includeMode?(c.params.members_include_in=C.userIds,c.params.query_type=C.queryType.toUpperCase()):c.params.members_exactly_in=C.userIds),c}return(0,e.c)(b,a),b}(e.h),ac=function(a){function b(b,c){var d=a.call(this,b,c)||this;d.channels=[];var e=c.next,f=c.channels,g=c.ts;return d.token=e,f&&f.length>0&&(d.channels=f.map(function(a){return a.ts=g,new ca(b,a)})),d.ts=null!=g?g:0,d}return(0,e.c)(b,a),b}(e.j),ad=function(a){function b(b){var c=b.userId,d=b.filter,f=a.call(this)||this,g=d.myMemberStateFilter;return f.method=e.A.GET,f.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/group_channel_count"),f.params={state:null!=g?g:l.ALL},f}return(0,e.c)(b,a),b}(e.h),ae=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.groupChannelCount=c.group_channel_count,d}return(0,e.c)(b,a),b}(e.j),af=function(a){function b(b){var c=b.userId,d=b.filter,f=a.call(this)||this,g=d.keys,h=d.customTypeFilters,i=d.customTypesFilter;return f.method=e.A.GET,f.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/unread_item_count"),f.params=(0,e.f)({item_keys:g,custom_types:null!=i?i:h}),f}return(0,e.c)(b,a),b}(e.h),ag=function(a){function b(b,c){var d=a.call(this,b,c)||this;return"number"==typeof c[C.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(d.groupChannelUnreadMentionCount=c[C.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof c[C.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(d.groupChannelUnreadMessageCount=c[C.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof c[C.GROUP_CHANNEL_INVITATION_COUNT]&&(d.groupChannelInvitationCount=c[C.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof c[C.SUPER_UNREAD_MENTION_COUNT]&&(d.superGroupChannelUnreadMentionCount=c[C.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof c[C.SUPER_UNREAD_MESSAGE_COUNT]&&(d.superGroupChannelUnreadMessageCount=c[C.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof c[C.SUPER_INVITATION_COUNT]&&(d.superGroupChannelInvitationCount=c[C.SUPER_INVITATION_COUNT]),"number"==typeof c[C.NONSUPER_UNREAD_MENTION_COUNT]&&(d.nonSuperGroupChannelUnreadMentionCount=c[C.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof c[C.NONSUPER_UNREAD_MESSAGE_COUNT]&&(d.nonSuperGroupChannelUnreadMessageCount=c[C.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof c[C.NONSUPER_INVITATION_COUNT]&&(d.nonSuperGroupChannelInvitationCount=c[C.NONSUPER_INVITATION_COUNT]),d}return(0,e.c)(b,a),b}(e.j),ah=function(a){function b(b){var c=b.userId,d=a.call(this)||this;return d.method=e.A.GET,d.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/unread_channel_count"),d}return(0,e.c)(b,a),b}(e.h),ai=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.unreadCount=c.unread_count,d}return(0,e.c)(b,a),b}(e.j),aj=function(a){function b(b){var c=b.userId,d=b.filter,f=b.includeFeedChannel,g=a.call(this)||this,h=d.channelCustomTypesFilter,i=d.superChannelFilter;return g.method=e.A.GET,g.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/unread_message_count"),g.params={super_mode:null!=i?i:m.ALL,custom_types:h,include_feed_channel:void 0!==f&&f},g}return(0,e.c)(b,a),b}(e.h),ak=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.unreadCount=c.unread_count,d.unreadFeedCount=c.unread_feed_count,d}return(0,e.c)(b,a),b}(e.j),al=function(a){function b(b){var c=b.channelUrl,d=b.scheduledStatus,f=b.messageTypeFilter,g=a.call(this)||this;return g.method=e.A.GET,g.path="".concat(e.bm,"/count"),g.params={channel_url:c,status:an(d)},f&&(g.params.message_type=f),g}return(0,e.c)(b,a),b}(e.h),am=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.count=c.count,d}return(0,e.c)(b,a),b}(e.j),an=function(a){if(!a)return[];var b=[];return a.forEach(function(a){switch(a){case f.ai.PENDING:b.push(f.am.PENDING);break;case f.ai.SENT:b.push(f.am.IN_QUEUE),b.push(f.am.SENT);break;case f.ai.CANCELED:b.push(f.am.CANCELED);break;case f.ai.FAILED:b.push(f.am.FAILED)}}),b},ao=function(a){function b(b){var c=this,d=b.userId,f=b.channelUrl,g=b.coverUrl,h=b.coverImage,i=b.isDistinct,j=b.isSuper,k=b.isBroadcast,l=b.isPublic,m=b.isExclusive,n=b.isDiscoverable,o=b.isStrict,p=b.isEphemeral,q=b.accessCode,r=b.name,s=b.data,t=b.customType,u=b.messageSurvivalSeconds,v=b.invitedUserIds,w=b.operatorUserIds;return(c=a.call(this)||this).method=e.A.POST,c.path=e.aW,c.params=(0,e.f)({user_ids:(0,e.s)([d],(0,e.t)(null!=v?v:[]),!1).filter(function(a,b,c){return b===c.indexOf(a)}),channel_url:f,cover_url:g,cover_file:h,is_distinct:i,is_super:j,is_broadcast:k,is_exclusive:m,is_public:l,is_discoverable:n,strict:o,is_ephemeral:p,access_code:q,name:r,data:s,custom_type:t,operator_ids:w,message_survival_seconds:u}),c}return(0,e.c)(b,a),b}(e.h),ap=function(a){function b(b,c){var d,e=this;return(e=a.call(this,b,c)||this).channel=new ca(b,c),e.isCreated=null===(d=c.is_created)|| void 0===d||d,e}return(0,e.c)(b,a),b}(e.j),aq=function(a){function b(b){var c=b.userId,d=b.channelUrls,f=a.call(this)||this;return f.method=e.A.PUT,f.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/mark_as_read_all"),f.params={channel_urls:d},f}return(0,e.c)(b,a),b}(e.h);T=e.j,(0,e.c)(function(){return null!==T&&T.apply(this,arguments)||this},T);var ar,as=function(a){function b(b){var c=this,d=b.channelUrl,f=b.userId,g=b.accessCode;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/join"),c.params={user_id:f,access_code:g},c}return(0,e.c)(b,a),b}(e.h),at=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.channel=new ca(b,c),d}return(0,e.c)(b,a),b}(e.j),au=function(a){function b(b,c,d){var e=a.call(this,b,c,d)||this,f=d.data,g=f.member_count,h=f.joined_member_count,i=f.users,j=void 0===i?null:i;return e.memberCount=void 0===g?0:g,e.joinedMemberCount=void 0===h?0:h,e.members=Array.isArray(j)?j.map(function(a){return new A(b,a)}):[new A(b,d.data)],e}return(0,e.c)(b,a),b}(i.C),av=function(a){function b(b){var c=this,d=b.channelUrl,f=b.userId,g=b.shouldRemoveOperatorStatus;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/leave"),c.params={user_id:f,should_remove_operator_status:g},c}return(0,e.c)(b,a),b}(e.h);ar=e.j,(0,e.c)(function(a,b){return ar.call(this,a,b)||this},ar);var aw,ax=function(a){function b(b,c,d){var e=a.call(this,b,c,d)||this,f=d.data,g=f.member_count,h=f.joined_member_count;return e.memberCount=void 0===g?0:g,e.joinedMemberCount=void 0===h?0:h,e.member=new A(e._iid,d.data),e}return(0,e.c)(b,a),b}(i.C),ay=function(a){function b(b){var c=this,d=b.channelUrl,f=b.userIds;return(c=a.call(this)||this).method=e.A.POST,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/invite"),c.params={user_ids:f},c}return(0,e.c)(b,a),b}(e.h),az=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.channel=new ca(b,c),d}return(0,e.c)(b,a),b}(e.j),aA=function(a){function b(b,c,d){var f=a.call(this,b,c,d)||this;f.inviter=null;var g=d.data,h=g.member_count,i=g.joined_member_count,j=g.inviter,k=g.invitees;return f.memberCount=void 0===h?0:h,f.joinedMemberCount=void 0===i?0:i,j&&Object.keys(j).length>0&&(f.inviter=new e.U(b,j)),f.invitees=(void 0===k?[]:k).map(function(a){return new A(b,a)}),f}return(0,e.c)(b,a),b}(i.C),aB=function(a){function b(b){var c=this,d=b.channelUrl,f=b.userId;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/decline"),c.params={user_id:f},c}return(0,e.c)(b,a),b}(e.h);aw=e.j,(0,e.c)(function(a,b){var c=aw.call(this,a,b)||this;return c.channel=new ca(a,b),c.channel.myMemberState=j.NONE,c},aw);var aC,aD=function(a){function b(b,c,d){var f=a.call(this,b,c,d)||this,g=d.data,h=g.member_count,i=g.joined_member_count,j=g.inviter,k=g.invitee;return f.memberCount=null!=h?h:0,f.joinedMemberCount=null!=i?i:0,f.inviter=new e.U(b,j),f.invitee=new A(b,k),f}return(0,e.c)(b,a),b}(i.C),aE={hidePreviousMessages:!1,allowAutoUnhide:!0},aF=function(a){function b(b){var c=this,d=b.channelUrl,f=b.userId,g=b.hidePreviousMessages,h=b.allowAutoUnhide;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/hide"),c.params={user_id:f,hide_previous_messages:null!=g?g:aE.hidePreviousMessages,allow_auto_unhide:null!=h?h:aE.allowAutoUnhide},c}return(0,e.c)(b,a),b}(e.h),aG=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.ts_message_offset;return d.messageOffsetTimestamp=e,d}return(0,e.c)(b,a),b}(e.j),aH=function(a){function b(b,c,d){var e,f,g,h=this;return(h=a.call(this,b,"SYEV",d)||this).allowAutoUnhide=null,h.hidePreviousMessages=null,h.messageOffsetTimestamp=null,d.data&&(h.allowAutoUnhide=null!==(e=d.data.allow_auto_unhide)&& void 0!==e?e:null,h.hidePreviousMessages=null!==(f=d.data.hide_previous_messages)&& void 0!==f?f:null),h.messageOffsetTimestamp=null!==(g=d.ts_message_offset)&& void 0!==g?g:null,h}return(0,e.c)(b,a),b}(e.W),aI=function(a){function b(b){var c=b.channelUrl,d=b.time;return a.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:c,time:d}})||this}return(0,e.c)(b,a),b}(e.aN),aJ=function(a){function b(b,c,d){var f=a.call(this,b,"SYEV",d)||this;return f.user=new e.U(b,d.data),f}return(0,e.c)(b,a),b}(e.W),aK=function(a){function b(b){var c=b.channelUrl,d=b.time;return a.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:c,time:d}})||this}return(0,e.c)(b,a),b}(e.aN),aL=function(a){function b(b,c,d){var f=a.call(this,b,"SYEV",d)||this;return f.user=new e.U(b,d.data),f}return(0,e.c)(b,a),b}(e.W),aM=function(a){function b(b){var c=b.channelUrl,d=b.messageId;return a.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:c,msg_id:d}})||this}return(0,e.c)(b,a),b}(e.aN),aN=function(a){function b(b,c){var d,e,f,h,i,j,p,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H=this;return(H=a.call(this,b,c)||this).includeEmpty=!1,H.includeFrozen=!0,H.includeMetaData=!0,H.includeChatNotification=!1,H.channelUrlsFilter=null,H.customTypesFilter=null,H.customTypeStartsWithFilter=null,H.nicknameContainsFilter=null,H.nicknameStartsWithFilter=null,H.nicknameExactMatchFilter=null,H.channelNameContainsFilter="",H.myMemberStateFilter=l.ALL,H.unreadChannelFilter=n.ALL,H.superChannelFilter=m.ALL,H.publicChannelFilter=k.ALL,H.hiddenChannelFilter=o.UNHIDDEN,H.searchFilter={fields:[],query:null},H.userIdsFilter={userIds:[],includeMode:!0,queryType:q.AND},H.metadataKey=null,H.metadataValues=null,H.metadataOrderKeyFilter=null,H.metadataValueStartsWith=null,H.order=g.G.LATEST_LAST_MESSAGE,H.includeEmpty=null!==(d=c.includeEmpty)&& void 0!==d&&d,H.includeFrozen=null===(e=c.includeFrozen)|| void 0===e||e,H.includeMetaData=null===(f=c.includeMetaData)|| void 0===f||f,H.includeChatNotification=null!==(h=c.includeChatNotification)&& void 0!==h&&h,H.channelUrlsFilter=null!==(i=c.channelUrlsFilter)&& void 0!==i?i:null,H.customTypesFilter=null!==(j=c.customTypesFilter)&& void 0!==j?j:null,H.customTypeStartsWithFilter=null!==(p=c.customTypeStartsWithFilter)&& void 0!==p?p:"",H.nicknameContainsFilter=null!==(r=c.nicknameContainsFilter)&& void 0!==r?r:null,H.nicknameStartsWithFilter=null!==(s=c.nicknameStartsWithFilter)&& void 0!==s?s:null,H.nicknameExactMatchFilter=null!==(t=c.nicknameExactMatchFilter)&& void 0!==t?t:null,H.channelNameContainsFilter=null!==(u=c.channelNameContainsFilter)&& void 0!==u?u:"",H.myMemberStateFilter=null!==(v=c.myMemberStateFilter)&& void 0!==v?v:l.ALL,H.unreadChannelFilter=null!==(w=c.unreadChannelFilter)&& void 0!==w?w:n.ALL,H.superChannelFilter=null!==(x=c.superChannelFilter)&& void 0!==x?x:m.ALL,H.publicChannelFilter=null!==(y=c.publicChannelFilter)&& void 0!==y?y:k.ALL,H.hiddenChannelFilter=null!==(z=c.hiddenChannelFilter)&& void 0!==z?z:o.UNHIDDEN,H.searchFilter=null!==(A=c.searchFilter)&& void 0!==A?A:{fields:[],query:null},H.userIdsFilter=null!==(B=c.userIdsFilter)&& void 0!==B?B:{userIds:[],includeMode:!0,queryType:q.AND},H.metadataKey=null!==(C=c.metadataKey)&& void 0!==C?C:null,H.metadataValues=null!==(D=c.metadataValues)&& void 0!==D?D:null,H.metadataOrderKeyFilter=null!==(E=c.metadataOrderKeyFilter)&& void 0!==E?E:null,H.metadataValueStartsWith=null!==(F=c.metadataValueStartsWith)&& void 0!==F?F:null,H.order=null!==(G=c.order)&& void 0!==G?G:g.G.LATEST_LAST_MESSAGE,c.createdAfter&&(H.createdAfter=c.createdAfter),c.createdBefore&&(H.createdBefore=c.createdBefore),H}return(0,e.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,e.a)("boolean",this.includeEmpty)&&(0,e.a)("boolean",this.includeFrozen)&&(0,e.a)("boolean",this.includeMetaData)&&(0,e.a)("string",this.channelNameContainsFilter)&&(0,e.a2)("string",this.channelUrlsFilter,!0)&&(0,e.a2)("string",this.customTypesFilter,!0)&&(0,e.a)("string",this.customTypeStartsWithFilter)&&(0,e.a)("string",this.nicknameContainsFilter,!0)&&(0,e.a)("string",this.nicknameStartsWithFilter,!0)&&(0,e.a)("string",this.nicknameExactMatchFilter,!0)&&(0,e.a5)(l,this.myMemberStateFilter)&&(0,e.a5)(m,this.superChannelFilter)&&(0,e.a5)(k,this.publicChannelFilter)&&(0,e.a5)(n,this.unreadChannelFilter)&&(0,e.a5)(o,this.hiddenChannelFilter)&&(0,e.a2)(r,this.searchFilter.fields)&&(0,e.a)("string",this.searchFilter.query,!0)&&(0,e.a2)("string",this.userIdsFilter.userIds)&&(0,e.a)("boolean",this.userIdsFilter.includeMode)&&(0,e.a5)(q,this.userIdsFilter.queryType)&&(0,e.a5)(g.G,this.order)&&(0,e.a)("string",this.metadataOrderKeyFilter,!0)&&(0,e.a)("string",this.metadataKey,!0)&&(0,e.a2)("string",this.metadataValues,!0)&&(0,e.a)("string",this.metadataValueStartsWith,!0)&&(0,e.br)(this.createdAfter,!0)&&(0,e.br)(this.createdBefore,!0)},b.prototype.serialize=function(){return(0,e.aM)(this)},b.prototype.next=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c;return(0,e.b)(this,function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,a$.of(this._iid).getMyGroupChannels(this._token,(0,e.g)((0,e.d)({},this)),this.limit,e.ab.REQUEST_CHANNEL,!0)]):[3,2]:[3,5];case 1:return b=(a=d.sent()).channels,c=a.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,b];case 2:return[2,[]];case 3:throw e.q.queryInProgress;case 4:return[3,6];case 5:throw e.q.invalidParameters;case 6:return[2]}})})},b}(e.ap),aO=function(a){function b(b){var c=this,d=b.userId,f=b.token,h=b.limit,i=b.order,j=b.customType;return(c=a.call(this)||this).method=e.A.GET,c.path="".concat(e.k,"/").concat(encodeURIComponent(d),"/my_group_channels/inactive_channels"),c.params=(0,e.f)({token:f,limit:h,order:null!=i?i:g.I.LATEST,custom_type:null!=j?j:void 0}),c}return(0,e.c)(b,a),b}(e.h),aP=function(a){function b(b,c){var d,e,f=this;return(f=a.call(this,b,c)||this).order=g.I.LATEST,f.customType=null,f.order=null!==(d=c.order)&& void 0!==d?d:g.I.LATEST,f.customType=null!==(e=c.customType)&& void 0!==e?e:null,f}return(0,e.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,e.a5)(g.I,this.order)&&(0,e.a)("string",this.customType,!0)},b.prototype.serialize=function(){return(0,e.aM)(this)},b.prototype.next=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:if(!this._validate())return[3,7];if(this._isLoading)return[3,5];if(!this._hasNext)return[3,4];this._isLoading=!0,j.label=1;case 1:return j.trys.push([1,,3,4]),b=(a=e.V.of(this._iid)).sdkState,c=a.requestQueue,d=new aO({userId:b.userId,token:this._token,limit:this.limit,order:this.order,customType:this.customType}),[4,c.send(d)];case 2:return h=(g=(f=j.sent()).as(ac)).channels,i=g.token,this._token=i,this._hasNext=!!i,[2,h];case 3:return this._isLoading=!1,[7];case 4:return[2,[]];case 5:throw e.q.queryInProgress;case 6:return[3,8];case 7:throw e.q.invalidParameters;case 8:return[2]}})})},b}(e.ap),aQ=function(a){function b(b){var c=b.channelUrl,d=b.userId,f=a.call(this)||this;return f.method=e.A.PUT,f.path="".concat(e.aW,"/").concat(encodeURIComponent(c),"/messages/mark_as_delivered"),f.params=(0,e.f)({user_id:d}),f}return(0,e.c)(b,a),b}(e.h);aC=e.j,(0,e.c)(function(){return null!==aC&&aC.apply(this,arguments)||this},aC);var aR,aS,aT=function(a){function b(b,c,d){var e=a.call(this,b,"DLVR",d)||this;return e.channelUrl=d.channel_url,e.deliveredStateUpdate=d.updated,e}return(0,e.c)(b,a),b}(e.W),aU=function(){function a(a){var b=a.top,c=void 0===b?Number.MAX_SAFE_INTEGER:b,d=a.bottom,e=void 0===d?0:d;this.top=c,this.bottom=e}return a.prototype.includes=function(){for(var a=this,b=[],c=0;c0&&(g=d.map(function(a){return a.createdAt}),(null===(q=this._metadata)|| void 0===q?void 0:(i=q.range).intersect.apply(i,(0,e.s)([],(0,e.t)(g),!1)))?this.extendRange(d):this._metadata={range:new aU({top:Math.min.apply(Math,(0,e.s)([],(0,e.t)(g),!1)),bottom:Math.max.apply(Math,(0,e.s)([],(0,e.t)(g),!1))}),previousComplete:!1}),b.hasNext=d.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(b.nextToken=this._metadata.range.top,this._metadata.previousComplete=d.length0&&(g=d.map(function(a){return a.createdAt}),(null===(p=this._metadata)|| void 0===p?void 0:(i=p.range).intersect.apply(i,(0,e.s)([],(0,e.t)(g),!1)))?this.extendRange(d):this._metadata={range:new aU({top:Math.min.apply(Math,(0,e.s)([],(0,e.t)(g),!1)),bottom:Math.max.apply(Math,(0,e.s)([],(0,e.t)(g),!1))}),previousComplete:!1}),b.hasNext=d.length>=this._limit,this._metadata&&(b.nextToken=this._metadata.range.bottom),n.debug("message background next sync progress",b),[4,this.saveMetadata()];case 4:return s.sent(),[3,7];case 5:throw h=s.sent(),n.debug("message background next sync error",h),h;case 6:return o.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:c.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(r=null===(q=l.localCacheConfig)|| void 0===q?void 0:q.maxSize)&& void 0!==r?r:0,use_local_cache:l.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[2,b]}})})})];case 1:return[2,d.sent()]}})})}),this._connectionEventContext=m.on(function(a){a instanceof e.K?a.stateType===e.M.CONNECTED?i.resume():i.pause():a instanceof g.F&&i.resume()})}return a.of=function(b,c){return aV[b]||(aV[b]={}),aV[b][c.url]||(aV[b][c.url]=new a({_iid:b,channel:c})),aV[b][c.url].ref++,aV[b][c.url]},a.clear=function(a,b){aV[a]&&aV[a][b]&&(aV[a][b].close(),0===Object.keys(aV[a]).length&&delete aV[a])},Object.defineProperty(a.prototype,"range",{get:function(){var a,b;return null!==(b=null===(a=this._metadata)|| void 0===a?void 0:a.range)&& void 0!==b?b:new aU({})},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"previousComplete",{get:function(){var a;return!!(null===(a=this._metadata)|| void 0===a?void 0:a.previousComplete)},enumerable:!1,configurable:!0}),a.prototype.isWrappingMessages=function(a){var b;return null===(b=this.range)|| void 0===b?void 0:b.includes.apply(b,(0,e.s)([],(0,e.t)(a.map(function(a){return a.createdAt})),!1))},a.prototype.extendRange=function(a){var b;this._metadata&&(b=this._metadata.range).extends.apply(b,(0,e.s)([],(0,e.t)(a.map(function(a){return a.createdAt})),!1))},a.prototype.loadMetadata=function(){return(0,e._)(this,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return this._metadata?[3,2]:[4,e.V.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:a=b.sent(),this._metadata=a?{range:new aU(a.range),previousComplete:a.previousComplete}:{range:new aU({}),previousComplete:!1},b.label=2;case 2:return[2,this._metadata]}})})},a.prototype.saveMetadata=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return this._metadata?[4,e.V.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return a.sent(),[2,!0];case 2:return[2,!1]}})})},a.prototype.clearMetadata=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return[4,e.V.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return a.sent(),this._metadata=void 0,[2]}})})},a.prototype.resume=function(a){void 0===a&&(a=Date.now());var b,c,d,f,g=e.V.of(this._iid),h=g.logger,i=g.sessionManager;g.cacheContext.localCacheEnabled&&i.session.hasSession&&(h.debug("message background sync resume()"),this._prevSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(c=null===(b=this._metadata)|| void 0===b?void 0:b.range.top)&& void 0!==c?c:a),this._nextSync.start(null!==(f=null===(d=this._metadata)|| void 0===d?void 0:d.range.bottom)&& void 0!==f?f:a))},a.prototype.pause=function(){e.V.exists(this._iid)&&e.V.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},a.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete aV[this._iid][this._channel.url])},a}(),aY=function(){function a(a){var b=a._iid,c=a.cacheContext,d=a.groupChannelCache,e=a.messageCache,f=a.unsentMessageCache,g=a.activeChannelCount;this._iid=b,this._cacheContext=c,this._groupChannelCache=d,this._messageCache=e,this._unsentMessageCache=f,this.activeChannelCount=void 0===g?2e3:g}return a.prototype.removeChannelMessages=function(a){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,this._messageCache.removeMessagesOfChannel(a)];case 1:return b.sent(),[4,this._unsentMessageCache.removeMessagesOfChannel(a)];case 2:return b.sent(),[2]}})})},Object.defineProperty(a.prototype,"channelRotationEnabled",{get:function(){var a,b,c=e.V.of(this._iid).appInfo;return null!==(b=null===(a=null==c?void 0:c.channelRotationInfo)|| void 0===a?void 0:a.enabled)&& void 0!==b&&b},enumerable:!1,configurable:!0}),a.prototype.removeChannelsByRotation=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f,h,i,j,k=this;return(0,e.b)(this,function(l){switch(l.label){case 0:return b=(a=e.V.of(this._iid)).appInfo,c=a.connectedAt,(null==b?void 0:b.channelRotationInfo)&&b.channelRotationInfo.enabled?(f=(d=b.channelRotationInfo).orderBy,h=d.excludeRecentHours,i=d.bufferRatio,"LAST_MESSAGE_TS_EXCLUDING_RECENT_JOINS"===f?[3,1]:[3,5]):[3,5];case 1:return[4,this._groupChannelCache.fetch({token:0,order:g.G.LATEST_LAST_MESSAGE,offset:this.activeChannelCount*i,limit:Number.MAX_SAFE_INTEGER})];case 2:return j=l.sent(),"number"==typeof h&&(j=j.filter(function(a){return 1e3*a.joinedAt0&&this._dispatcher.dispatch(new J({channels:c,context:{source:e.ab.EVENT_CHANNEL_UPDATED}})),[2]}})})},b.prototype._expandMessageChunk=function(a){var b;return(0,e._)(this,void 0,void 0,function(){var c,d,g,h,i,j,k,l,m;return(0,e.b)(this,function(n){switch(n.label){case 0:return c=e.V.of(this._iid).cacheContext,d=a.previousMessageId,g=a.messageCreatedAt,h=a.channelUrl,c.localCacheEnabled&&(null===(b=c.nestdb)|| void 0===b?void 0:b.state)===f.s.OPENED&&d?[4,this.getMessageFromCache(d)]:[2];case 1:return i=n.sent(),j=aW(this._sdkState.userId,h),[4,c.preference.get(j)];case 2:return(k=n.sent())?[3,5]:i?(l={range:new aU({top:i.createdAt,bottom:g}),previousComplete:!1},[4,c.preference.set(j,l)]):[3,4];case 3:n.sent(),n.label=4;case 4:return[3,7];case 5:return m={range:new aU({top:k.range.top,bottom:k.range.bottom}),previousComplete:k.previousComplete},i&&m.range.includes(i.createdAt)?(m.range.extends(i.createdAt,g),[4,c.preference.set(j,m)]):[3,7];case 6:n.sent(),n.label=7;case 7:return[2]}})})},b.prototype._isSuperGroupMackDisabled=function(a){var b=e.V.of(this._iid).appInfo;return!(!a.isSuper||a.isBroadcast||!(null==b?void 0:b.disableSuperGroupMack))},b.prototype._getCachedUserInfo=function(a){return this._userInfoCache.getUserInfoFromCache(a)},b.prototype._upsertCachedUserInfo=function(a,b){e.V.of(this._iid).useMemberInfoInMessage&&this._userInfoCache.upsert(a,b)},b.prototype._handleEvent=function(a){var b,c;return(0,e._)(this,void 0,void 0,function(){var d,h,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,av,aw,ay,az,aB,aC,aE,aF,aG,aI,aK,aN,aO,aP,aQ,aR,aS,aU,aV,aW,aX,aY,aZ,a$,a_,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw,bx,by,bz,bA,bB,bC,bD,bE,bF,bG,bH,bI,bJ,bK,bL,bM,bN,bO,bP,bQ,bR,bS,bU,bV,bW,bX,bY,bZ,b$,b_,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck=this;return(0,e.b)(this,function(cl){switch(cl.label){case 0:switch(cl.trys.push([0,88,,89]),a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"READ":return[3,10];case"DLVR":return[3,13];case"MRCT":return[3,15];case"MTHD":return[3,27];case"MCNT":return[3,31];case"PEDI":return[3,40];case"VOTE":return[3,43];case"SYEV":return[3,46];case"USEV":return[3,86]}return[3,87];case 1:return q=null,"MESG"===a.code?q=a.as(f.aC):"FILE"===a.code?q=a.as(f.aD):"ADMM"!==a.code&&"BRDM"!=a.code||(q=a.as(i.A)),q?(d=q.message,h=q.isMentioned,k=q.forceUpdateLastMessage,d.channelType!==e.C.GROUP?[3,3]:(V=this._groupChannelCache.isCachedInMemory(d.channelUrl),H=d instanceof f.az&&d.sender.userId===this._sdkState.userId,[4,this.getChannel(d.channelUrl,!0)])):[3,3];case 2:if(l=cl.sent(),u=(m=e.V.of(this._iid)).useMemberInfoInMessage,bV=m.requestDeduplicator,this._forceDisableMack||this._isSuperGroupMackDisabled(l)||d instanceof f.X||H||(0,e.J)(function(){return(0,e._)(ck,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return a=new aM(d),[4,this._requestQueue.send(a)];case 1:return b.sent(),[2]}})})}),d instanceof f.az){n=d.sender,l.isSuper&&this._upsertCachedUserInfo(n,d.createdAt);try{for(p=(o=(0,e.x)(l.members)).next();!p.done;p=o.next())if((bo=p.value).userId===d.sender.userId){u&&(bo.nickname=d.sender.nickname,bo.plainProfileUrl=d.sender.plainProfileUrl,bo.metaData=d.sender.metaData,bo.isBlockedByMe=d.sender.isBlockedByMe);break}}catch(cm){b0={error:cm}}finally{try{p&&!p.done&&(b1=o.return)&&b1.call(o)}finally{if(b0)throw b0.error}}u&&h&&(null===(b=d.mentionedUsers)|| void 0===b||b.forEach(function(a){var b,c;try{for(var d=(0,e.x)(l.members),f=d.next();!f.done;f=d.next()){var g=f.value;if(a.userId===g.userId){g.nickname=a.nickname,g.plainProfileUrl=a.plainProfileUrl,g.metaData=a.metaData;break}}}catch(h){b={error:h}}finally{try{f&&!f.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}})),H&&(z=this._sessionManager.currentUser)&&(z.nickname=d.sender.nickname,z.plainProfileUrl=d.sender.plainProfileUrl,z.metaData=d.sender.metaData)}d.silent&&!H||(l.isEphemeral||V)&&(l._updateLastMessage(d),H||l._shouldUpdateUnreadCountWith(d)&&l._updateUnreadCount(l.unreadMessageCount+1,l.unreadMentionCount+(h?1:0))),k&&l._updateLastMessage(d),bV.updatePendingResponse(l,Date.now()),this._dispatcher.dispatch(new J({channels:[l],context:{source:e.ab.EVENT_MESSAGE_RECEIVED}})),d.silent&&!H||(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onChannelChanged&&c.onChannelChanged(l)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),this._dispatcher.dispatch(new e.aP({messages:[d],source:e.ab.EVENT_MESSAGE_RECEIVED})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,f,g;return(0,e.b)(this,function(i){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onMessageReceived&&c.onMessageReceived(l,d),h&&c.onMentionReceived&&c.onMentionReceived(l,d)}catch(j){f={error:j}}finally{try{b&&!b.done&&(g=a.return)&&g.call(a)}finally{if(f)throw f.error}}return[2]})})}),cl.label=3;case 3:return[3,87];case 4:return q=null,"MEDI"===a.code?q=a.as(f.aA):"FEDI"===a.code?q=a.as(f.aB):"AEDI"===a.code&&(q=a.as(i.b)),q?(r=q.message,s=q.mentionCountChange,t=e.V.of(this._iid),u=t.useMemberInfoInMessage,bV=t.requestDeduplicator,r.threadInfo&&(r.threadInfo.unreadReplyCount=void 0),r.channelType!==e.C.GROUP?[3,6]:(V=this._groupChannelCache.isCachedInMemory(r.channelUrl),[4,this.getChannel(r.channelUrl,!0)])):[3,6];case 5:if(v=cl.sent(),H=!1,r instanceof f.az){H=r.sender.userId===this._sdkState.userId,v.isSuper&&this._upsertCachedUserInfo(r.sender,r.updatedAt);try{for(x=(w=(0,e.x)(v.members)).next();!x.done;x=w.next())if((bo=x.value).userId===r.sender.userId){u&&(bo.nickname=r.sender.nickname,bo.plainProfileUrl=r.sender.plainProfileUrl,bo.metaData=r.sender.metaData,bo.isBlockedByMe=r.sender.isBlockedByMe);break}}catch(cn){b2={error:cn}}finally{try{x&&!x.done&&(b3=w.return)&&b3.call(w)}finally{if(b2)throw b2.error}}}R=!1,H?(y=r.sender,(z=this._sessionManager.currentUser)&&(z.nickname=y.nickname,z.plainProfileUrl=y.plainProfileUrl,z.metaData=y.metaData)):v.isReadMessage(r)||0!==s&&!r.silent&&V&&(v._updateUnreadCount(v.unreadMessageCount,v.unreadMentionCount+s),R=!0),v._updateLastMessage(r)?R=!0:(null===(c=v.lastMessage)|| void 0===c?void 0:c.isIdentical(r))&&(V?v._updateLastMessage(r)&&(R=!0):R=!0),A=!1,v.lastPinnedMessage&&v.lastPinnedMessage.messageId===r.messageId&&(v.lastPinnedMessage=r,R=!0,A=!0),R&&(bV.updatePendingResponse(v,Date.now()),this._dispatcher.dispatch(new J({channels:[v],context:{source:A?e.ab.EVENT_PINNED_MESSAGE_UPDATED:e.ab.EVENT_MESSAGE_UPDATED}})),r.silent&&!H||(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onChannelChanged&&c.onChannelChanged(v)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),A&&(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onPinnedMessageUpdated&&c.onPinnedMessageUpdated(v)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})})),this._dispatcher.dispatch(new e.aP({messages:[r],source:e.ab.EVENT_MESSAGE_UPDATED})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onMessageUpdated&&c.onMessageUpdated(v,r),s>0&&c.onMentionReceived&&c.onMentionReceived(v,r)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),cl.label=6;case 6:return[3,87];case 7:return az=(B=a.as(e.bt)).channelUrl,aB=B.channelType,C=B.messageId,D=B.silent,E=B.messageCreatedAt,F=B.senderId,aB!==e.C.GROUP?[3,9]:[4,this.getChannel(az,!0)];case 8:G=cl.sent(),H=F===this._sdkState.userId,D||H||E>0&&G.myLastRead0&&(G._updateUnreadCount(G.unreadMessageCount-1,0),(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(G,Date.now())),this._dispatcher.dispatch(new e.bh({messageIds:[C],source:e.ab.EVENT_MESSAGE_DELETED})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onMessageDeleted&&c.onMessageDeleted(G,C)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),cl.label=9;case 9:return[3,87];case 10:return(I=a.as(f.ay).readStatus).channelType!==e.C.GROUP?[3,12]:(V=this._groupChannelCache.isCachedInMemory(I.channelUrl),[4,this.getChannel(I.channelUrl,!0)]);case 11:if(L=cl.sent(),M=I.reader.userId===this._sdkState.userId,N=!0,V&&(N=L._updateUnreadMemberState(I.reader.userId,I.readAt,I.isExcluded)),I.isExcluded){if(N){try{for(P=(O=(0,e.x)(this._groupChannelHandlers.values())).next();!P.done;P=O.next())(Q=P.value).onUserMarkedUnread!==e.aX&&Q.onUserMarkedUnread(L,[I.reader.userId]),Q.onUnreadMemberStatusUpdated!==e.aX&&Q.onUnreadMemberStatusUpdated(L)}catch(co){b4={error:co}}finally{try{P&&!P.done&&(b5=O.return)&&b5.call(O)}finally{if(b4)throw b4.error}}this._dispatcher.dispatch(new J({channels:[L],context:{source:e.ab.EVENT_CHANNEL_UNREAD,userIds:[I.reader.userId]}}))}}else R=!0,M&&(V?L.unreadMentionCount>0||L.unreadMessageCount>0?L._updateUnreadCount(0,0):R=!1:0!==L.unreadMessageCount&&0!==L.unreadMentionCount&&(R=!1)),R&&(this._dispatcher.dispatch(new J({channels:[L],context:{source:N?e.ab.EVENT_CHANNEL_READ:e.ab.EVENT_CHANNEL_UPDATED,userIds:[I.reader.userId]}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())c=b.value,M?c.onChannelChanged!==e.aX&&c.onChannelChanged(L):N&&(c.onUserMarkedRead!==e.aX&&c.onUserMarkedRead(L,[I.reader.userId]),c.onUnreadMemberStatusUpdated!==e.aX&&c.onUnreadMemberStatusUpdated(L))}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}));cl.label=12;case 12:return[3,87];case 13:return az=(S=a.as(aT)).channelUrl,T=S.deliveredStateUpdate,U=void 0===T?{}:T,V=this._groupChannelCache.isCachedInMemory(az),[4,this.getChannel(az,!0)];case 14:return W=cl.sent(),V&&Object.keys(U).forEach(function(a){W._updateUndeliveredMemberState(a,U[a])}),Object.keys(U).some(function(a){return a!==ck._sdkState.userId})&&(this._dispatcher.dispatch(new J({channels:[W],context:{source:e.ab.EVENT_CHANNEL_DELIVERED}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onUndeliveredMemberStatusUpdated&&c.onUndeliveredMemberStatusUpdated(W)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})})),[3,87];case 15:return az=(X=a.as(i.R)).channelUrl,aB=X.channelType,Y=X.event,aB!==e.C.GROUP?[3,26]:[4,this.getChannel(az,!0)];case 16:return Z=cl.sent(),[4,this.getMessageFromCache(Y.messageId)];case 17:if(ag=cl.sent(),!Z.isSuper)return[3,25];cl.label=18;case 18:cl.trys.push([18,23,24,25]),_=($=(0,e.x)(Object.keys(Y._sampledUserInfoList))).next(),cl.label=19;case 19:return _.done?[3,22]:(aa=_.value,[4,this._userInfoCache.get(aa)]);case 20:(ab=cl.sent())?(ab.plainProfileUrl=Y._sampledUserInfoList[aa].profile_url,ab.nickname=Y._sampledUserInfoList[aa].nickname,this._upsertCachedUserInfo(ab,Y.updatedAt)):(ac=new e.U(this._iid,{user_id:aa,nickname:Y._sampledUserInfoList[aa].nickname,profile_url:Y._sampledUserInfoList[aa].profile_url,require_auth_for_profile_image:Y._sampledUserInfoList[aa].require_auth_for_profile_image}),this._upsertCachedUserInfo(ac,Y.updatedAt)),cl.label=21;case 21:return _=$.next(),[3,19];case 22:return[3,25];case 23:return b6={error:ad=cl.sent()},[3,25];case 24:try{_&&!_.done&&(b7=$.return)&&b7.call($)}finally{if(b6)throw b6.error}return[7];case 25:ag?ag instanceof f.V&&(ag.applyReactionEvent(Y),this._dispatcher.dispatch(new e.aP({messages:[ag],source:e.ab.EVENT_MESSAGE_REACTION_UPDATED}))):this._dispatcher.dispatch(new e.bb({event:Y,source:e.ab.EVENT_MESSAGE_REACTION_UPDATED})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onReactionUpdated&&c.onReactionUpdated(Z,Y)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),cl.label=26;case 26:return[3,87];case 27:return(ae=a.as(i.T).event).channelType!==e.C.GROUP?[3,30]:[4,this.getChannel(ae.channelUrl,!0)];case 28:return af=cl.sent(),[4,this.getMessageFromCache(ae.targetMessageId)];case 29:if((ag=cl.sent())?ag instanceof f.V&&(ag.applyThreadInfoUpdateEvent(ae),this._dispatcher.dispatch(new e.aP({messages:[ag],source:e.ab.EVENT_MESSAGE_THREADINFO_UPDATED}))):this._dispatcher.dispatch(new e.bc({event:ae,source:e.ab.EVENT_MESSAGE_THREADINFO_UPDATED})),af.isSuper)try{for(ai=(ah=(0,e.x)(ae.threadInfo.mostRepliedUsers)).next();!ai.done;ai=ah.next())bi=ai.value,this._upsertCachedUserInfo(bi,ae.threadInfo.updatedAt)}catch(cp){b8={error:cp}}finally{try{ai&&!ai.done&&(b9=ah.return)&&b9.call(ah)}finally{if(b8)throw b8.error}}(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onThreadInfoUpdated&&c.onThreadInfoUpdated(af,ae)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),cl.label=30;case 30:return[3,87];case 31:aj=a.as(i.M).groupChannelMemberCounts,ak=[],cl.label=32;case 32:cl.trys.push([32,37,38,39]),am=(al=(0,e.x)(aj)).next(),cl.label=33;case 33:return am.done?[3,36]:(az=(an=am.value).channelUrl,bc=an.memberCount,bd=an.joinedMemberCount,ao=an.updatedAt,[4,this.getChannelFromCache(az)]);case 34:(ap=cl.sent())&&ap._setLatestMemberCount(bc,bd,ao)&&ak.push(ap),cl.label=35;case 35:return am=al.next(),[3,33];case 36:return[3,39];case 37:return ca={error:aq=cl.sent()},[3,39];case 38:try{am&&!am.done&&(cb=al.return)&&cb.call(al)}finally{if(ca)throw ca.error}return[7];case 39:return ak.length>0&&(this._dispatcher.dispatch(new J({channels:ak,context:{source:e.ab.EVENT_CHANNEL_MEMBER_COUNT_UPDATED}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onChannelMemberCountChanged&&c.onChannelMemberCountChanged(ak)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})})),[3,87];case 40:return as=(ar=a.as(i.P)).event,at=ar.status,az=ar.channelUrl,aB=ar.channelType,az&&aB===e.C.GROUP?[4,this.getChannel(az,!0)]:[3,42];case 41:av=cl.sent(),this._dispatcher.dispatch(new e.be({event:as,source:e.ab.EVENT_POLL_UPDATED})),(0,e.N)(at===e.bu?function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onPollDeleted&&c.onPollDeleted(av,as.pollId)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}:function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onPollUpdated&&c.onPollUpdated(av,as)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),cl.label=42;case 42:return[3,87];case 43:return ay=(aw=a.as(f.ax)).event,az=aw.channelUrl,aB=aw.channelType,az&&aB===e.C.GROUP?[4,this.getChannel(az,!0)]:[3,45];case 44:aC=cl.sent(),this._dispatcher.dispatch(new e.b6({event:ay,source:e.ab.EVENT_POLL_VOTED})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onPollVoted&&c.onPollVoted(aC,ay)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),cl.label=45;case 45:return[3,87];case 46:if(!(aE=a.as(i.C).event).isGroupChannelEvent)return[3,85];switch(aE.category){case i.a.CHANNEL_JOIN:return[3,47];case i.a.CHANNEL_LEAVE:return[3,49];case i.a.CHANNEL_OPERATOR_UPDATE:return[3,53];case i.a.CHANNEL_INVITE:return[3,55];case i.a.CHANNEL_DECLINE_INVITE:return[3,57];case i.a.TYPING_START:case i.a.TYPING_END:return[3,59];case i.a.USER_CHANNEL_MUTE:case i.a.USER_CHANNEL_UNMUTE:return[3,61];case i.a.USER_CHANNEL_BAN:return[3,63];case i.a.USER_CHANNEL_UNBAN:return[3,67];case i.a.CHANNEL_FREEZE:case i.a.CHANNEL_UNFREEZE:return[3,69];case i.a.CHANNEL_HIDE:return[3,71];case i.a.CHANNEL_UNHIDE:return[3,73];case i.a.CHANNEL_DELETED:return[3,75];case i.a.CHANNEL_PROP_CHANGED:return[3,76];case i.a.CHANNEL_META_DATA_CHANGED:return[3,79];case i.a.CHANNEL_META_COUNTERS_CHANGED:return[3,81];case i.a.PINNED_MESSAGE_CHANGED:return[3,83]}return[3,85];case 47:case 50:return[4,this.getChannel(aE.channelUrl,!0)];case 48:if(aF=cl.sent(),aI=(aG=a.as(au)).memberCount,aK=aG.joinedMemberCount,aN=aG.members,aO=!1,aN.forEach(function(a){aF.isExclusive||aF.isSuper||aF.isBroadcast?aO=aO||aF._setLatestMemberCount(aI,aK,aE.ts):(a.state=j.JOINED,aF.addMember(a,aE.ts),ck._updateJoinedMemberCount(aF)),a.userId===ck._sdkState.userId&&(aF.myMemberState=j.JOINED)}),aF.isSuper)try{for(aQ=(aP=(0,e.x)(aN)).next();!aQ.done;aQ=aP.next())bo=aQ.value,this._upsertCachedUserInfo(bo,aE.ts)}catch(cq){cc={error:cq}}finally{try{aQ&&!aQ.done&&(cd=aP.return)&&cd.call(aP)}finally{if(cc)throw cc.error}}return(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(aF,Date.now()),this._dispatcher.dispatch(new J({channels:[aF],context:{source:e.ab.EVENT_CHANNEL_JOINED,users:aN}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){var b,c;try{for(var d=(0,e.x)(aN),f=d.next();!f.done;f=d.next()){var g=f.value;a.onUserJoined&&a.onUserJoined(aF,g)}}catch(h){b={error:h}}finally{try{f&&!f.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}aF.isBroadcast&&aO&&a.onChannelMemberCountChanged&&a.onChannelMemberCountChanged([aF])}),[2]})})}),[3,85];case 49:return(bp=this._leftChannels.get(aE.channelUrl))?(aS=bp.channel,[3,52]):[3,50];case 51:aS=cl.sent(),cl.label=52;case 52:return aR=aS,bc=(aU=a.as(ax)).memberCount,bd=aU.joinedMemberCount,aV=aU.member,aW=!1,aX=e.V.of(this._iid),aY=aX.appInfo,bV=aX.requestDeduplicator,aR.isExclusive||aR.isSuper||aR.isBroadcast?aW=aR._setLatestMemberCount(bc,bd,aE.ts):((null==aY?void 0:aY.enabledChannelMemberShipHistory)?((aZ=aR.members.find(function(a){return a.userId===aV.userId}))&&(aZ.state=j.LEFT),aR.memberCount=bc):aR.removeMember(aV),this._updateJoinedMemberCount(aR)),aV.userId===this._sdkState.userId?(aR.myMemberState=j.NONE,aR.invitedAt=0,aR.joinedAt=0,aR._updateUnreadCount(0,0),aR.isPublic?this._dispatcher.dispatch(new J({channels:[aR],context:{source:e.ab.EVENT_CHANNEL_LEFT,user:aV}})):(this._markAsLeave(aR),this._dispatcher.dispatch(new K({channelUrls:[aR.url],context:{source:e.ab.EVENT_CHANNEL_LEFT,user:aV}})))):this._dispatcher.dispatch(new J({channels:[aR],context:{source:e.ab.EVENT_CHANNEL_LEFT,user:aV}})),bV.updatePendingResponse(aR,Date.now()),aR.isSuper&&this._upsertCachedUserInfo(aV,aE.ts),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onUserLeft&&a.onUserLeft(aR,aV),aR.isBroadcast&&aW&&a.onChannelMemberCountChanged&&a.onChannelMemberCountChanged([aR])}),[2]})})}),[3,85];case 53:case 55:case 57:case 59:case 61:case 64:return[4,this.getChannel(aE.channelUrl,!0)];case 54:a$=cl.sent(),a0=(a_=a.as(i.O).operators).map(function(a){return a.userId});try{for(a2=(a1=(0,e.x)(a$.members)).next();!a2.done;a2=a1.next())(bo=a2.value).role=a0.includes(bo.userId)?e.ai.OPERATOR:e.ai.NONE}catch(cr){ce={error:cr}}finally{try{a2&&!a2.done&&(cf=a1.return)&&cf.call(a1)}finally{if(ce)throw ce.error}}return a$.myRole=a0.includes(this._sdkState.userId)?e.ai.OPERATOR:e.ai.NONE,(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(a$,Date.now()),this._dispatcher.dispatch(new J({channels:[a$],context:{source:e.ab.EVENT_CHANNEL_OPERATOR_UPDATED,operators:a_}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onOperatorUpdated&&a.onOperatorUpdated(a$,a_)}),[2]})})}),[3,85];case 56:a3=cl.sent(),bc=(a4=a.as(aA)).memberCount,bd=a4.joinedMemberCount,a5=a4.inviter,(a6=a4.invitees).forEach(function(a){return a.state=j.INVITED});try{for(a8=(a7=(0,e.x)(a6)).next();!a8.done;a8=a7.next())a9=a8.value,a3.isExclusive||a3.isSuper||a3.isBroadcast?(a3.isSuper&&this._userInfoCache.upsert(a9,aE.ts),a3._setLatestMemberCount(bc,bd,aE.ts)):a3.addMember(a9,aE.ts),this._sdkState.userId===a9.userId&&(a3.hiddenState=bT.UNHIDDEN,a3.myMemberState!==j.JOINED&&(a3.myMemberState=j.INVITED),a3.invitedAt=aE.ts)}catch(cs){cg={error:cs}}finally{try{a8&&!a8.done&&(ch=a7.return)&&ch.call(a7)}finally{if(cg)throw cg.error}}return(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(a3,Date.now()),this._dispatcher.dispatch(new J({channels:[a3],context:{source:e.ab.EVENT_CHANNEL_INVITED,inviter:a5,invitees:a6}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onUserReceivedInvitation&&a.onUserReceivedInvitation(a3,a5,a6)}),[2]})})}),[3,85];case 58:return ba=cl.sent(),bc=(bb=a.as(aD)).memberCount,bd=bb.joinedMemberCount,be=bb.inviter,bf=bb.invitee,ba.isExclusive||ba.isSuper||ba.isBroadcast?(ba.isSuper&&this._userInfoCache.upsert(bf,aE.ts),ba._setLatestMemberCount(bc,bd,aE.ts)):ba.removeMember(bf),this._sdkState.userId===bf.userId?(ba.invitedAt=0,ba.myMemberState=j.NONE,ba.isPublic?this._dispatcher.dispatch(new J({channels:[ba],context:{source:e.ab.EVENT_CHANNEL_DECLINED_INVITE,inviter:be,invitee:bf}})):this._dispatcher.dispatch(new K({channelUrls:[ba.url],context:{source:e.ab.EVENT_CHANNEL_DECLINED_INVITE,inviter:be,invitee:bf}}))):this._dispatcher.dispatch(new J({channels:[ba],context:{source:e.ab.EVENT_CHANNEL_DECLINED_INVITE,inviter:be,invitee:bf}})),(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(ba,Date.now()),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onUserDeclinedInvitation&&a.onUserDeclinedInvitation(ba,be,bf)}),[2]})})}),[3,85];case 60:return bg=cl.sent(),bh=aE.category===i.a.TYPING_START,bi=a.as(bh?aJ:aL).user,bg._updateTypingStatus(bi,bh?aE.ts:0),(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(bg,Date.now()),this._dispatcher.dispatch(new J({channels:[bg],context:{source:e.ab.EVENT_CHANNEL_TYPING_STATUS_UPDATE}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onTypingStatusUpdated&&a.onTypingStatusUpdated(bg)}),[2]})})}),[3,85];case 62:bj=cl.sent(),bk=aE.category===i.a.USER_CHANNEL_MUTE,(bl=a.as(bk?f.av:f.aw).user).userId===this._sdkState.userId&&(bj.myMutedState=bk?e.bo.MUTED:e.bo.UNMUTED,bj._myMutedRemainingTime=bl.restrictionInfo.remainingDuration);try{for(bn=(bm=(0,e.x)(bj.members)).next();!bn.done;bn=bm.next())if((bo=bn.value).userId===bl.userId){bo.isMuted=bk;break}}catch(ct){ci={error:ct}}finally{try{bn&&!bn.done&&(cj=bm.return)&&cj.call(bm)}finally{if(ci)throw ci.error}}return bj.isSuper&&this._userInfoCache.upsert(bl,aE.ts),(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(bj,Date.now()),this._dispatcher.dispatch(new J({channels:[bj],context:{source:bk?e.ab.EVENT_CHANNEL_MUTED:e.ab.EVENT_CHANNEL_UNMUTED,user:bl}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){bk?a.onUserMuted&&a.onUserMuted(bj,bl):a.onUserUnmuted&&a.onUserUnmuted(bj,bl)}),[2]})})}),[3,85];case 63:return(bp=this._leftChannels.get(aE.channelUrl))?(br=bp.channel,[3,66]):[3,64];case 65:br=cl.sent(),cl.label=66;case 66:return bq=br,this._markAsLeave(bq),bv=(bs=a.as(f.au).user).userId===this._sdkState.userId,bq.isSuper&&this._userInfoCache.upsert(bs,aE.ts),bv&&this._dispatcher.dispatch(new K({channelUrls:[bq.url],context:{source:e.ab.EVENT_CHANNEL_BANNED,user:bs}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onUserBanned&&a.onUserBanned(bq,bs)}),[2]})})}),[3,85];case 67:case 69:case 71:case 73:case 79:case 81:case 83:return[4,this.getChannel(aE.channelUrl,!0)];case 68:return bt=cl.sent(),bv=(bu=a.as(f.at).user).userId===this._sdkState.userId,bt.isSuper&&this._userInfoCache.upsert(bu,aE.ts),bv&&this._dispatcher.dispatch(new K({channelUrls:[bt.url],context:{source:e.ab.EVENT_CHANNEL_UNBANNED,user:bu}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onUserUnbanned&&a.onUserUnbanned(bt,bu)}),[2]})})}),[3,85];case 70:return bw=cl.sent(),bx=a.as(f.as).freeze,bw.isFrozen=bx,(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(bw,Date.now()),this._dispatcher.dispatch(new J({channels:[bw],context:{source:bx?e.ab.EVENT_CHANNEL_FROZEN:e.ab.EVENT_CHANNEL_UNFROZEN}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){bx?a.onChannelFrozen&&a.onChannelFrozen(bw):a.onChannelUnfrozen&&a.onChannelUnfrozen(bw)}),[2]})})}),[3,85];case 72:return by=cl.sent(),bA=(bz=a.as(aH)).allowAutoUnhide,bB=bz.hidePreviousMessages,bC=bz.messageOffsetTimestamp,null!==bA&&(by.hiddenState=bA?bT.HIDDEN_ALLOW_AUTO_UNHIDE:bT.HIDDEN_PREVENT_AUTO_UNHIDE),null!==bB&&bB&&by._updateUnreadCount(0,0),null!==bC&&(by.messageOffsetTimestamp=bC),(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(by,Date.now()),this._dispatcher.dispatch(new J({channels:[by],context:{source:e.ab.EVENT_CHANNEL_HIDDEN}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onChannelHidden&&a.onChannelHidden(by)}),[2]})})}),[3,85];case 74:return(bD=cl.sent()).hiddenState=bT.UNHIDDEN,(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(bD,Date.now()),this._dispatcher.dispatch(new J({channels:[bD],context:{source:e.ab.EVENT_CHANNEL_UNHIDDEN}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onChannelChanged&&a.onChannelChanged(bD)}),[2]})})}),[3,85];case 75:return this._dispatcher.dispatch(new K({channelUrls:[aE.channelUrl],context:{source:e.ab.EVENT_CHANNEL_DELETED}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onChannelDeleted&&a.onChannelDeleted(aE.channelUrl,e.C.GROUP)}),[2]})})}),[3,85];case 76:return[4,(0,e.aU)(50)];case 77:return cl.sent(),[4,this.getChannelWithoutCache(aE.channelUrl,!0,!1)];case 78:return bE=cl.sent(),this._dispatcher.dispatch(new J({channels:[bE],context:{source:e.ab.EVENT_CHANNEL_UPDATED}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onChannelChanged&&a.onChannelChanged(bE)}),[2]})})}),[3,85];case 80:return bF=cl.sent(),bH=(bG=a.as(f.ar)).created,bI=bG.updated,bJ=bG.deleted,bH&&(bF._upsertCachedMetaData(bH,aE.ts),this._dispatcher.dispatch(new J({channels:[bF],context:{source:e.ab.EVENT_CHANNEL_METADATA_CREATED,metaData:bH},ts:aE.ts}))),bI&&(bF._upsertCachedMetaData(bI,aE.ts),this._dispatcher.dispatch(new J({channels:[bF],context:{source:e.ab.EVENT_CHANNEL_METADATA_UPDATED,metaData:bI},ts:aE.ts}))),bJ&&(bF._removeFromCachedMetaData(bJ,aE.ts),this._dispatcher.dispatch(new J({channels:[bF],context:{source:e.ab.EVENT_CHANNEL_METADATA_DELETED,metaDataKeys:bJ},ts:aE.ts}))),(bH||bI||bJ)&&(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(bF,Date.now()),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){bH&&a.onMetaDataCreated&&a.onMetaDataCreated(bF,bH),bI&&a.onMetaDataUpdated&&a.onMetaDataUpdated(bF,bI),bJ&&a.onMetaDataDeleted&&a.onMetaDataDeleted(bF,bJ)}),[2]})})}),[3,85];case 82:return bK=cl.sent(),bM=(bL=a.as(f.aq)).created,bN=bL.updated,bO=bL.deleted,bM&&this._dispatcher.dispatch(new J({channels:[bK],context:{source:e.ab.EVENT_CHANNEL_METACOUNTER_CREATED,metaCounters:bM}})),bN&&this._dispatcher.dispatch(new J({channels:[bK],context:{source:e.ab.EVENT_CHANNEL_METACOUNTER_UPDATED,metaCounters:bN}})),bO&&this._dispatcher.dispatch(new J({channels:[bK],context:{source:e.ab.EVENT_CHANNEL_METACOUNTER_DELETED,metaCounterKeys:bO}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){bM&&a.onMetaCounterCreated&&a.onMetaCounterCreated(bK,bM),bN&&a.onMetaCounterUpdated&&a.onMetaCounterUpdated(bK,bN),bO&&a.onMetaCounterDeleted&&a.onMetaCounterDeleted(bK,bO)}),[2]})})}),[3,85];case 84:return bP=cl.sent(),bR=(bQ=a.as(i.U)).pinnedMessageIds,bS=bQ.latestPinnedMessage,(bU=bQ.ts)>bP._pinnedMessagesUpdatedAt&&(bP.pinnedMessageIds=null!=bR?bR:[],bP.lastPinnedMessage=bS,bP._pinnedMessagesUpdatedAt=bU,(bV=e.V.of(this._iid).requestDeduplicator).updatePendingResponse(bP,Date.now()),this._dispatcher.dispatch(new J({channels:[bP],context:{source:e.ab.EVENT_PINNED_MESSAGE_UPDATED}})),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){try{for(b=(a=(0,e.x)(this._groupChannelHandlers.values())).next();!b.done;b=a.next())(c=b.value).onChannelChanged&&c.onChannelChanged(bP)}catch(h){d={error:h}}finally{try{b&&!b.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return[2]})})}),(0,e.N)(function(){return(0,e._)(ck,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._groupChannelHandlers.forEach(function(a){a.onPinnedMessageUpdated&&a.onPinnedMessageUpdated(bP)}),[2]})})})),[3,85];case 85:return[3,87];case 86:switch((bW=a.as(g.U).event).category){case g.a.USER_BLOCK:bZ=(bX=g.b.getDataAsUserBlockEvent(this._iid,bW)).blocker,b$=bX.blockee,this._groupChannelCache.block(bZ.userId,b$.userId);break;case g.a.USER_UNBLOCK:bZ=(bY=g.b.getDataAsUserBlockEvent(this._iid,bW)).blocker,b$=bY.blockee,this._groupChannelCache.unblock(bZ.userId,b$.userId)}return[3,87];case 87:return[3,89];case 88:if(b_=cl.sent(),(0,e.a1)(b_))throw b_;return[3,89];case 89:return[2]}})})},b.prototype._markAsLeave=function(a){var b,c=this,d=null!==(b=this._leftChannels.get(a.url))&& void 0!==b?b:{channel:a,ref:0};d.ref++,this._leftChannels.set(a.url,d),setTimeout(function(){d.ref--,0===d.ref&&c._leftChannels.delete(a.url)},1e4)},b.prototype.addHandler=function(a,b){this._groupChannelHandlers.set(a,b)},b.prototype.removeHandler=function(a){this._groupChannelHandlers.delete(a)},b.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},b.prototype.subscribeChannelEvent=function(a,b){this._groupChannelBroadcast.subscribe(a,b)},b.prototype.unsubscribeChannelEvent=function(a){this._groupChannelBroadcast.unsubscribe(a)},b.prototype._updateJoinedMemberCount=function(a){a.joinedMemberCount=a.members.filter(function(a){return a.state===j.JOINED}).length},b.prototype.getChannel=function(a,b){return void 0===b&&(b=!1),(0,e._)(this,void 0,void 0,function(){var c;return(0,e.b)(this,function(d){switch(d.label){case 0:(0,e.p)((0,e.a)("string",a)).throw(e.q.invalidParameters),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this.getChannelFromCache(a)];case 2:return(c=d.sent())?[2,c]:[3,4];case 3:return d.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(a,b)];case 5:return[2,d.sent()]}})})},b.prototype.getChannelWithoutCache=function(a,b,c){return void 0===b&&(b=!1),void 0===c&&(c=!0),(0,e._)(this,void 0,void 0,function(){var d,f,g,h,i,j,k,l,m,n,o,p,q,r=this;return(0,e.b)(this,function(s){switch(s.label){case 0:return(0,e.p)((0,e.a)("string",a)).throw(e.q.invalidParameters),d=e.V.of(this._iid).requestDeduplicator,f=new $({channelUrl:a,isInternalCall:b}),[4,d.requestGetChannel(f.path,function(){return r._requestQueue.send(f)},f.params,c)];case 1:switch(i=(h=(g=s.sent()).as(_).channel).unreadMessageCount,j=h.unreadMentionCount,h.myCountPreference){case bS.UNREAD_MESSAGE_COUNT_ONLY:j=0;break;case bS.UNREAD_MENTION_COUNT_ONLY:i=0;break;case bS.OFF:i=0,j=0}h._updateUnreadCount(i,j),k=this._groupChannelCache.filterOffsetChanged([h]),s.label=2;case 2:s.trys.push([2,7,8,9]),m=(l=(0,e.x)(k)).next(),s.label=3;case 3:return m.done?[3,6]:(n=m.value,[4,this._messageCache.removeUnderOffset(n.url,n.messageOffsetTimestamp)]);case 4:s.sent(),s.label=5;case 5:return m=l.next(),[3,3];case 6:return[3,9];case 7:return p={error:o=s.sent()},[3,9];case 8:try{m&&!m.done&&(q=l.return)&&q.call(l)}finally{if(p)throw p.error}return[7];case 9:return[4,this._groupChannelCache.upsert([h])];case 10:return[2,s.sent()[0]]}})})},b.prototype.refreshChannel=function(a,b,c,d){return void 0===b&&(b=!0),void 0===c&&(c=e.ab.REFRESH_CHANNEL),void 0===d&&(d=!1),(0,e._)(this,void 0,void 0,function(){var f,g,h,i,k,l,m=this;return(0,e.b)(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),f=e.V.of(this._iid).requestDeduplicator,g=new $({channelUrl:a,isInternalCall:b,showLatestMessage:d}),[4,f.requestGetChannel(g.path,function(){return m._requestQueue.send(g)},g.params,!1)];case 1:return(i=(h=n.sent()).as(_).channel).myMemberState!==j.NONE?[3,2]:(this._dispatcher.dispatch(new K({channelUrls:[i.url],context:{source:c}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:k=n.sent(),this._dispatcher.dispatch(new J({channels:k,context:{source:c}})),n.label=4;case 4:return[3,6];case 5:return(l=n.sent()).code!==e.F.NON_AUTHORIZED&&l.code!==e.F.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new K({channelUrls:[a],context:{source:c}})),[3,6];case 6:return[2]}})})},b.prototype.getMyGroupChannels=function(a,b,c,d,f){return void 0===d&&(d=e.ab.REQUEST_CHANNEL),void 0===f&&(f=!1),(0,e._)(this,void 0,void 0,function(){var g,h,i,j,k,l,m,n,o;return(0,e.b)(this,function(p){switch(p.label){case 0:return b.createdAfter&&(b.createdAfter=Math.floor(b.createdAfter/1e3)),b.createdBefore&&(b.createdBefore=Math.floor(b.createdBefore/1e3)),g=!1,f&&(i=(h=e.V.of(this._iid)).appInfo,(j=h.cacheContext)&&!j.localCacheEnabled&&(null==i?void 0:i.enabledChannelMemberShipHistory)&&(null==i?void 0:i.applicationAttributes.includes("left_user_view_support"))&&(g=!0)),k=new ab((0,e.d)((0,e.d)({},b),{userId:this._sdkState.userId,token:a,limit:c,includeLeftChannel:f&&g})),[4,this._requestQueue.send(k)];case 1:return n=(m=(l=p.sent()).as(ac)).channels,o=m.token,this._dispatcher.dispatch(new J({channels:n,context:{source:d}})),[2,{channels:n,token:o}]}})})},b.prototype.getMyGroupChannelChangeLogs=function(a,b,c){return void 0===c&&(c=e.ab.REQUEST_CHANNEL_CHANGELOGS),(0,e._)(this,void 0,void 0,function(){var d,f,g,h,i,j,k,l;return(0,e.b)(this,function(m){switch(m.label){case 0:return d=(0,e.d)((0,e.d)({},P),b),(0,e.p)(((0,e.a)("string",a)||(0,e.a)("number",a))&&Q(d)).throw(e.q.invalidParameters),f=new Y((0,e.g)({userId:this._sdkState.userId,ts:"number"==typeof a?a:null,token:"string"==typeof a?a:null,filter:d})),[4,this._requestQueue.send(f)];case 1:return i=(h=(g=m.sent()).as(Z)).updatedChannels,j=h.deletedChannelUrls,k=h.hasMore,l=h.ts,i.length>0&&this._dispatcher.dispatch(new J({channels:i,context:{source:c},ts:l})),j.length>0&&this._dispatcher.dispatch(new K({channelUrls:j,context:{source:c}})),[2,{updatedChannels:i,deletedChannelUrls:j,hasMore:k,token:h.token}]}})})},b.prototype.getGroupChannelCount=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d;return(0,e.b)(this,function(f){switch(f.label){case 0:return b=(0,e.d)((0,e.d)({},R),a),(0,e.p)(S(b)).throw(e.q.invalidParameters),c=new ad({userId:this._sdkState.userId,filter:b}),[4,this._requestQueue.send(c)];case 1:return[2,(d=f.sent()).as(ae).groupChannelCount]}})})},b.prototype.getUnreadItemCount=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r;return(0,e.b)(this,function(s){switch(s.label){case 0:var t;return b=(0,e.d)((0,e.d)({},U),a),(0,e.p)((t=b,(0,e.a2)(C,t.keys)&&(0,e.a2)("string",t.customTypeFilters,!0)&&(0,e.a2)("string",t.customTypesFilter,!0))).throw(e.q.invalidParameters),c=e.V.of(this._iid),d=c.sdkState,f=c.requestQueue,g=new af({userId:d.userId,filter:b}),[4,f.send(g)];case 1:return j=(i=(h=s.sent()).as(ag)).groupChannelUnreadMentionCount,k=i.groupChannelUnreadMessageCount,l=i.groupChannelInvitationCount,m=i.superGroupChannelUnreadMentionCount,n=i.superGroupChannelUnreadMessageCount,o=i.superGroupChannelInvitationCount,p=i.nonSuperGroupChannelUnreadMentionCount,q=i.nonSuperGroupChannelUnreadMessageCount,r=i.nonSuperGroupChannelInvitationCount,[2,(0,e.f)({groupChannelUnreadMentionCount:j,groupChannelUnreadMessageCount:k,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:m,superGroupChannelUnreadMessageCount:n,superGroupChannelInvitationCount:o,nonSuperGroupChannelUnreadMentionCount:p,nonSuperGroupChannelUnreadMessageCount:q,nonSuperGroupChannelInvitationCount:r})]}})})},b.prototype.getTotalUnreadChannelCount=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){switch(g.label){case 0:return b=(a=e.V.of(this._iid)).sdkState,c=a.requestQueue,d=new ah({userId:b.userId}),[4,c.send(d)];case 1:return[2,(f=g.sent()).as(ai).unreadCount]}})})},b.prototype.getTotalUnreadMessageCount=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h;return(0,e.b)(this,function(i){switch(i.label){case 0:return b=(0,e.d)((0,e.d)({},V),a),(0,e.p)(W(b)).throw(e.q.invalidParameters),c=e.V.of(this._iid),d=c.sdkState,f=c.requestQueue,g=new aj({userId:d.userId,filter:b}),[4,f.send(g)];case 1:return[2,(h=i.sent()).as(ak).unreadCount]}})})},b.prototype.getTotalScheduledMessageCount=function(a){return void 0===a&&(a={}),(0,e._)(this,void 0,void 0,function(){var b,c,d,g;return(0,e.b)(this,function(h){switch(h.label){case 0:var i;return b=(0,e.d)((0,e.d)({},X),a),(0,e.p)((i=b,(0,e.a)("string",i.channelUrl,!0)&&(0,e.a2)(f.ai,i.scheduledStatus,!0)&&(0,e.a5)(e.au,i.messageTypeFilter))).throw(e.q.invalidParameters),c=e.V.of(this._iid).requestQueue,d=new al(b),[4,c.send(d)];case 1:return[2,(g=h.sent()).as(am).count]}})})},b.prototype.getSubscribedTotalUnreadMessageCount=function(){var a=e.V.of(this._iid).subscribedUnreadMessageCount;return a.all>=0?a.all:0},b.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var a=0,b=e.V.of(this._iid).subscribedUnreadMessageCount;return Object.keys(b.customTypes).forEach(function(c){a+=b.customTypes[c]}),a},b.prototype.getSubscribedCustomTypeUnreadMessageCount=function(a){var b;return null!==(b=e.V.of(this._iid).subscribedUnreadMessageCount.customTypes[a])&& void 0!==b?b:0},b.prototype.createChannel=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f;return(0,e.b)(this,function(g){switch(g.label){case 0:return b=(0,e.d)((0,e.d)({},N),a),(0,e.p)(O(b)).throw(e.q.invalidParameters),b.isPublic||(b.accessCode=void 0),c=new ao((0,e.d)({userId:this._sdkState.userId},b)),[4,this._requestQueue.send(c)];case 1:return f=(d=g.sent()).as(ap).channel,[4,this.upsertChannelsToCache([f])];case 2:return g.sent(),[2,f]}})})},b.prototype.markAsReadAll=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:return a=Date.now(),(0,e.p)(a-this._markAsReadAllLastSentAt>=1e3).throw(e.q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=a,b=new aq({userId:this._sdkState.userId}),[4,this._requestQueue.send(b)];case 1:j.sent(),c=this._groupChannelCache.channels;try{for(f=(d=(0,e.x)(c)).next();!f.done;f=d.next())(g=f.value)._updateUnreadMemberState(this._sdkState.userId,a),g._updateUnreadCount(0,0)}catch(k){h={error:k}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(h)throw h.error}}return c.length>0?[4,this.upsertChannelsToCache(c)]:[3,3];case 2:j.sent(),j.label=3;case 3:return[2]}})})},b.prototype.markAsReadWithChannelUrls=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i,j,k;return(0,e.b)(this,function(l){switch(l.label){case 0:return b=Date.now(),(0,e.p)((0,e.a2)("string",a)&&b-this._markAsReadAllLastSentAt>=1e3).throw(e.q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=b,c=new aq({userId:this._sdkState.userId,channelUrls:a}),[4,this._requestQueue.send(c)];case 1:l.sent(),d=this._groupChannelCache.channels,f=[];try{for(h=(g=(0,e.x)(d)).next();!h.done;h=g.next())i=h.value,a.includes(i.url)&&(i._updateUnreadMemberState(this._sdkState.userId,b),i._updateUnreadCount(0,0),f.push(i))}catch(m){j={error:m}}finally{try{h&&!h.done&&(k=g.return)&&k.call(g)}finally{if(j)throw j.error}}return f.length>0?[4,this.upsertChannelsToCache(f)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}})})},b.prototype.markAsDelivered=function(a){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,this.getChannel(a)];case 1:return[4,b.sent().markAsDelivered()];case 2:return b.sent(),[2]}})})},b.prototype.getMessageFromCache=function(a){var b;return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(c){switch(c.label){case 0:return[4,this._messageCache.get(a)];case 1:return[2,null!==(b=c.sent())&& void 0!==b?b:null]}})})},b.prototype.getExactlyMatchingMessagesForTokenFromCache=function(a,b,c,d){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.fetch({channelUrl:a,token:b,filter:c,exactMatch:!0,isRestoreIndexedDB:d})];case 1:return[2,e.sent()]}})})},b.prototype.getMessagesFromCache=function(a,b,c,d,g,h,i){return void 0===g&&(g=f.aE),void 0===h&&(h=!0),void 0===i&&(i=!1),(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.fetch({channelUrl:a,token:b,limit:g,filter:d,backward:"next"===c,inclusive:h,isRestoreIndexedDB:i})];case 1:return[2,e.sent()]}})})},b.prototype.getPollMessagesFromCache=function(a,b,c,d){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.fetch({channelUrl:a,token:b,limit:d,filter:c,backward:!1,isPollOnly:!0})];case 1:return[2,e.sent()]}})})},b.prototype.getCachedMessageCountBetween=function(a,b,c,d){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.countBetween(a,b,new aU({top:c,bottom:d}))];case 1:return[2,e.sent()]}})})},b.prototype.getUnsentMessagesFromCache=function(a,b){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(c){switch(c.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:a,filter:b})];case 1:return[2,c.sent()]}})})},b.prototype.removeFailedMessageFromCache=function(a){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,this._unsentMessageCache.remove([a])];case 1:return b.sent(),[2]}})})},b}(i.B),a_=function(a,b){return b instanceof f.az?a.findIndex(function(a){return a instanceof f.az&&b.isIdentical(a)}):a.findIndex(function(a){return a.isIdentical(b)})},a0=function(a,b){return a.findIndex(function(a){return a instanceof f.V?a.messageId===b:a instanceof f.W?a.notificationId===b:void 0})},a1=function(a,b){if(a.length>0){for(var c=0,d=a.length-1,e=Math.floor((c+d)/2);c0)e=Math.floor((c+(d=e))/2);else{if(!(f<0))return e;e=Math.floor(((c=e+1)+d)/2)}}return a[e].createdAt>b.createdAt?e:e+1}return a.length},a2={},a3=function(){function a(a){var b=a._iid,c=a.channel,d=a.includeParams,h=this;this.ref=0,this._iid=b,this._channel=c,this._includeParams=d;var i,j,k,l,m=e.V.of(this._iid),n=m.logger,o=m.sdkState,p=m.dispatcher;this._metadataKey=(i=o.userId,j=c.url,"sendbird:".concat(i,"@groupchannel/").concat(j,"/message/changelogs.meta"));var q=(k=o.userId,l=this._channel.url,"sendbird:".concat(k,"@groupchannel/").concat(l,"/message/changelogs"));this._sync=new g.c(q,function(){return(0,e._)(h,void 0,void 0,function(){var a,b,c,d,g,h,i,j,k;return(0,e.b)(this,function(l){switch(l.label){case 0:return a={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),n.debug("message changelog sync from",null===(k=this._metadata)|| void 0===k?void 0:k.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,f.T.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,(0,e.d)({replyType:e.aw.ALL},this._includeParams),e.ab.SYNC_MESSAGE_CHANGELOGS)];case 3:return c=(b=l.sent()).updatedMessages,d=b.deletedMessageIds,g=b.hasMore,h=b.token,i=b.forceUseNextToken,a.hasNext=g,a.nextToken=h,c.length>0||d.length>0?this._metadata&&(this._metadata.token=h):i&&this._metadata&&(this._metadata.token=h),n.debug("message changelog sync progress",a),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return j=l.sent(),n.debug("message changelog sync error",j),j instanceof e.q&&j.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw j;case 8:return[2,a]}})})}),this._connectionEventContext=p.on(function(a){a instanceof e.K?a.stateType===e.M.CONNECTED?h.resume():h.pause():a instanceof g.F&&h.resume()})}return a.of=function(b,c,d){return a2[b]||(a2[b]={}),a2[b][c.url]||(a2[b][c.url]=new a({_iid:b,channel:c,includeParams:d})),a2[b][c.url].ref++,a2[b][c.url]},a.clear=function(a,b){a2[a]&&a2[a][b]&&(a2[a][b].close(),0===Object.keys(a2[a]).length&&delete a2[a])},a.prototype.loadMetadata=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d;return(0,e.b)(this,function(f){switch(f.label){case 0:return this._metadata?[3,2]:(b=(a=e.V.of(this._iid)).cacheContext,c=a.firstConnectedAt,[4,b.preference.get(this._metadataKey)]);case 1:d=f.sent(),this._metadata={token:d?d.token:c},f.label=2;case 2:return[2,this._metadata]}})})},a.prototype.saveMetadata=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return this._metadata?[4,e.V.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return a.sent(),[2,!0];case 2:return[2,!1]}})})},a.prototype.clearMetadata=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return[4,e.V.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return a.sent(),this._metadata=void 0,[2]}})})},a.prototype.resume=function(){var a=e.V.of(this._iid),b=a.logger;a.sessionManager.session.hasSession&&(b.debug("message changelog sync resume()"),this._sync.start(0))},a.prototype.pause=function(){e.V.exists(this._iid)&&e.V.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},a.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete a2[this._iid][this._channel.url])},a}(),a4={},a5=function(){function a(a){var b=a._iid,c=a.channel,d=a.hasPollMessage,f=this;this.ref=0,this._iid=b,this._channel=c;var h,i,j,k,l=e.V.of(this._iid),m=l.logger,n=l.sdkState,o=l.dispatcher;this._metadataKey=(h=n.userId,i=c.url,"sendbird:".concat(h,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var p=(j=n.userId,k=this._channel.url,"sendbird:".concat(j,"@groupchannel/").concat(k,"/poll/changelogs"));this._sync=new g.c(p,function(){return(0,e._)(f,void 0,void 0,function(){var a,b,c,f,g,h,i,j;return(0,e.b)(this,function(k){switch(k.label){case 0:return a={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return k.sent(),m.debug("poll changelog sync from",null===(j=this._metadata)|| void 0===j?void 0:j.token),(b=!this._metadata||!this._metadata.token)?[4,d()]:[3,3];case 2:b=!k.sent(),k.label=3;case 3:if(b)return[2,{hasNext:!1,nextToken:0}];this._metadata||(c=e.V.of(this._iid).firstConnectedAt,this._metadata={token:c}),k.label=4;case 4:return k.trys.push([4,7,,10]),[4,e.ay.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return g=(f=k.sent()).hasMore,h=f.token,a.hasNext=g,a.nextToken=h,this._metadata.token=h,m.debug("poll changelog sync progress",a),[4,this.saveMetadata()];case 6:return k.sent(),[3,10];case 7:return i=k.sent(),m.debug("poll changelog sync error",i),i instanceof e.q&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:k.sent(),k.label=9;case 9:throw i;case 10:return[2,a]}})})}),this._connectionEventContext=o.on(function(a){a instanceof e.K&&(a.stateType===e.M.CONNECTED?f.resume():f.pause())})}return a.of=function(b,c,d){return a4[b]||(a4[b]={}),a4[b][c.url]||(a4[b][c.url]=new a({_iid:b,channel:c,hasPollMessage:d})),a4[b][c.url].ref++,a4[b][c.url]},a.prototype.loadMetadata=function(){return(0,e._)(this,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return this._metadata?[3,2]:[4,e.V.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:a=b.sent(),this._metadata=a?{token:a.token}:void 0,b.label=2;case 2:return[2]}})})},a.prototype.saveMetadata=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return this._metadata?[4,e.V.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},a.prototype.clearMetadata=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return[4,e.V.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return a.sent(),this._metadata=void 0,[2]}})})},a.prototype.resume=function(){e.V.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},a.prototype.pause=function(){e.V.exists(this._iid)&&e.V.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},a.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete a4[this._iid][this._channel.url])},a}(),a6=function(a){function b(b){var c,d,f,g,h,i,j,k,l,m,n=this;return(n=a.call(this)||this).method=e.A.GET,n.path="".concat((0,e.aO)(b.channelType),"/").concat(b.channelUrl,"/messages_gap"),n.params=(0,e.f)({prev_start_ts:b.prevStart,prev_end_ts:b.prevEnd,prev_cache_count:b.prevCount,next_start_ts:b.nextStart,next_end_ts:b.nextEnd,next_cache_count:b.nextCount,huge_gap_threshold:null!==(c=b.threshold)&& void 0!==c?c:null,reverse:!0,custom_types:null!==(d=b.customTypes)&& void 0!==d?d:["*"],message_type:null!==(f=b.messageType)&& void 0!==f?f:null,include_reply_type:null!==(g=b.replyType)&& void 0!==g?g:e.aw.NONE,include_reactions_summary:null===(h=b.includeReactions)|| void 0===h||h,include_meta_array:null===(i=b.includeMetaArray)|| void 0===i||i,include_thread_info:null===(j=b.includeThreadInfo)|| void 0===j||j,include_parent_message_info:null===(k=b.includeParentMessageInfo)|| void 0===k||k,with_sorted_meta_array:null===(l=b.includeMetaArray)|| void 0===l||l,show_subchannel_messages_only:null!==(m=b.showSubchannelMessagesOnly)&& void 0!==m&&m,include_poll_details:!0,checking_continuous_messages:b.checkingContinuousMessages}),n}return(0,e.c)(b,a),b}(e.h),a7=function(a){function b(b,c){var d,e,g,h,i,j,k=this;return(k=a.call(this,b,c)||this).isHugeGap=c.is_huge_gap,k.prevMessages=(null!==(d=c.prev_messages)&& void 0!==d?d:[]).map(function(a){return(0,f.Q)(b,a)}),k.prevHasMore=null!==(e=c.prev_hasmore)&& void 0!==e&&e,k.isContinuousPrevMessages=null!==(g=c.is_continuous_prev_messages)&& void 0!==g&&g,k.nextMessages=(null!==(h=c.next_messages)&& void 0!==h?h:[]).map(function(a){return(0,f.Q)(b,a)}),k.nextHasmore=null!==(i=c.next_hasmore)&& void 0!==i&&i,k.isContinuousNextMessages=null!==(j=c.is_continuous_next_messages)&& void 0!==j&&j,k}return(0,e.c)(b,a),b}(e.j),a8={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};(aS=aR||(aR={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var a9,ba,bb,bc,bd,be,bf=function(){function a(){this._onCacheResult=e.aX,this._onApiResult=e.aX}return a.prototype._invokeResponse=function(a,b,c){var d=this;(0,e.N)(function(){return(0,e._)(d,void 0,void 0,function(){return(0,e.b)(this,function(d){switch(a){case"local":this._onCacheResult(b,c);break;case"remote":this._onApiResult(b,c)}return[2]})})})},a.prototype.onCacheResult=function(a){return this._onCacheResult=a,this},a.prototype.onApiResult=function(a){return this._onApiResult=a,this},a}(),bg=function(a){function b(b,c){return a.call(this,b,(0,e.d)((0,e.d)({},c),{channelManager:a$.of(b)}))||this}return(0,e.c)(b,a),b.prototype.keyOf=function(a){return a.messageId},b.prototype.initialize=function(b){return a.prototype.initialize.call(this,b)},b.prototype.setMessageCollectionHandler=function(a){this._setBaseMessageCollectionHandler(a)},b.prototype._addMessagesToView=function(a,b){var c,d,g=this,h=this._filterUnderOffsetMessage(a),i=[],j=[];try{for(var k=(0,e.x)(h),l=k.next();!l.done;l=k.next()){var m,n=l.value;if(b===e.ab.SYNC_MESSAGE_FILL){if(n.messageId>0){if((m=a_(this._messages,n))<0){0>a_(this._unsentMessages,n)&&i.push(n);var o=a1(this._messages,n);this._messages.splice(o,0,n)}}else n instanceof f.az&&(m=a_(this._unsentMessages,n))<0&&0>a_(this._messages,n)&&(this._unsentMessages.push(n),i.push(n))}else if(n.messageId>0){if((m=a_(this._messages,n))<0){var p=a_(this._unsentMessages,n);p<0?i.push(n):(this._unsentMessages.splice(p,1),j.push(n)),o=a1(this._messages,n),this._messages.splice(o,0,n)}else j.push(n),this._messages[m]=n;if(n.updatedAt>0){var q=this._updateChildMessagesInView(n);j.push.apply(j,(0,e.s)([],(0,e.t)(q),!1))}}else n instanceof f.az&&((m=a_(this._unsentMessages,n))<0?0>a_(this._messages,n)&&(this._unsentMessages.push(n),i.push(n)):(j.push(n),this._unsentMessages[m]=n))}}catch(r){c={error:r}}finally{try{l&&!l.done&&(d=k.return)&&d.call(k)}finally{if(c)throw c.error}}(0,e.bv)(b)&&(0,e.N)(function(){return(0,e._)(g,void 0,void 0,function(){var a,c,d,f,g;return(0,e.b)(this,function(e){return a={source:b},i.length>0&&(null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesAdded)|| void 0===d||d.call(c,a,this.channel,i)),j.length>0&&(null===(g=null===(f=this._handler)|| void 0===f?void 0:f.onMessagesUpdated)|| void 0===g||g.call(f,a,this.channel,j)),[2]})})})},b.prototype._updateMessagesToView=function(a,b){var c,d,g=this,h=[],i=[],j=[];try{for(var k=(0,e.x)(a),l=k.next();!l.done;l=k.next()){var m,n=l.value;if(n.messageId>0){if((m=a_(this._messages,n))>=0)i.push(n),this._messages[m]=n;else{var o=a_(this._unsentMessages,n);if(o>=0){var p=(0,e.t)(this._unsentMessages.splice(o,1),1)[0];if(this.hasNext&&p)j.push(p);else{i.push(n);var q=a1(this._messages,n);this._messages.splice(q,0,n)}}else{var r=this._messages.map(function(a){return a.createdAt});(n.createdAtMath.max.apply(Math,(0,e.s)([],(0,e.t)(r),!1))&&!this._hasNext)&&h.push(n)}}}else n instanceof f.az&&(m=a_(this._unsentMessages,n))>=0&&(i.push(n),this._unsentMessages[m]=n)}}catch(s){c={error:s}}finally{try{l&&!l.done&&(d=k.return)&&d.call(k)}finally{if(c)throw c.error}}return(0,e.bv)(b)&&(0,e.N)(function(){return(0,e._)(g,void 0,void 0,function(){var a,c,d,f,g;return(0,e.b)(this,function(e){return a={source:b},i.length>0?null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesUpdated)|| void 0===d||d.call(c,a,this.channel,i):j.length>0?null===(g=null===(f=this._handler)|| void 0===f?void 0:f.onMessagesDeleted)|| void 0===g||g.call(f,a,this.channel,[],j):h.length>0&&this._addMessagesToView(h,b),[2]})})}),i},b}(function(){function a(a,b){var c=b.filter,d=b.startingPoint,h=b.limit,i=b.prevResultLimit,k=b.nextResultLimit,l=b.channel,m=b.channelManager,n=b.disableBackgroundSync,o=this;this._messages=[],this._unsentMessages=[],this._isLoadingPrevious=!1,this._isLoadingNext=!1,this._isInitializing=!1,this._pendingInitMessages=null,this._iid=a,this._key="mc-".concat((0,e.u)()),this._isDisposed=!1,this.filter=null!=c?c:new f.ag,this._channel=l,this._syncRange=new aU({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof d&&Number.isFinite(d)?d:Number.MAX_SAFE_INTEGER,this._limit=h||f.aE,this._prevResultLimit=null!=i?i:Math.floor(this._limit/2),this._nextResultLimit=null!=k?k:Math.floor(this._limit/2),this._channelManager=m;var p=e.V.of(this._iid).statManager;this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(a,b){var c=b.source,d=a.findIndex(function(a){return a.isIdentical(o.channel)});d>=0&&(o._replaceChannelOfCollection(a[d]),o.channel._runIfHandleableWithGroupChannel(function(a){switch(c){case e.ab.EVENT_CHANNEL_UPDATED:for(var d=!1,f=0;f=a.messageOffsetTimestamp){d=!0;var g=f;if(g>0){var h=o._messages.splice(0,g);o._removeMessagesFromView(h.map(function(a){return o.keyOf(a)}),e.ab.EVENT_MESSAGE_OFFSET_UPDATED)}break}!d&&o._messages.length>0&&o._removeMessagesFromView(o._messages.map(function(a){return o.keyOf(a)}),e.ab.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.ab.EVENT_CHANNEL_UNMUTED:var i=e.V.of(o._iid).sdkState,j=b.user;i.userId===j.userId&&o._clearCheckMyMutedTimer();break;case e.ab.EVENT_CHANNEL_MUTED:i=e.V.of(o._iid).sdkState,j=b.user,i.userId===j.userId&& -1!==a._myMutedRemainingTime&&o._startCheckMyMutedTimer(a._myMutedRemainingTime);break;case e.ab.EVENT_CHANNEL_LEFT:a.isPublic&&o._clearCheckMyMutedTimer()}(0,e.N)(function(){return(0,e._)(o,void 0,void 0,function(){var a;return(0,e.b)(this,function(d){return I(c)&&(null===(a=this._handler)|| void 0===a?void 0:a.onChannelUpdated)&&this._handler.onChannelUpdated(b,this.channel),[2]})})})}),o._postprocessChannelUpdateEvent(a[d],c))},onRemove:function(a,b){var c=a.indexOf(o.channel.url);c>=0&&o._channel._runIfHandleableWithGroupChannel(function(d){d.myMemberState=j.NONE,o._clearCheckMyMutedTimer(),(0,e.N)(function(){return(0,e._)(o,void 0,void 0,function(){var a;return(0,e.b)(this,function(c){return(null===(a=this._handler)|| void 0===a?void 0:a.onChannelDeleted)&&this._handler.onChannelDeleted(b,this.channel.url),[2]})})}),o._postprocessChannelRemoveEvent(a[c])})}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(a,b){var c,d,f=[],g=[];try{for(var h=(0,e.x)(a),i=h.next();!i.done;i=h.next()){var j=i.value;j.channelUrl===o._channel.url&&(o.filter.match(j)?f.push(j):g.push(o.keyOf(j)))}}catch(k){c={error:k}}finally{try{i&&!i.done&&(d=h.return)&&d.call(h)}finally{if(c)throw c.error}}if((0,e.bv)(b)){if(f.length>0)switch(b){case e.ab.LOCAL_MESSAGE_CANCELED:case e.ab.LOCAL_MESSAGE_RESEND_STARTED:case e.ab.EVENT_MESSAGE_SENT_FAILED:case e.ab.EVENT_MESSAGE_UPDATED:case e.ab.EVENT_MESSAGE_THREADINFO_UPDATED:case e.ab.EVENT_MESSAGE_REACTION_UPDATED:case e.ab.EVENT_MESSAGE_FEEDBACK_ADDED:case e.ab.EVENT_MESSAGE_FEEDBACK_UPDATED:case e.ab.EVENT_MESSAGE_FEEDBACK_DELETED:o._updateMessagesToView(f,b);break;case e.ab.EVENT_MESSAGE_SENT_SUCCESS:case e.ab.SYNC_MESSAGE_CHANGELOGS:o._isInitializing?o._pendingInitMessages.push({messages:(0,e.s)([],(0,e.t)(f),!1),source:b}):o._updateMessagesToView(f,b);break;case e.ab.EVENT_MESSAGE_SENT_PENDING:o._addMessagesToView(f,b);break;case e.ab.EVENT_MESSAGE_RECEIVED:o._isInitializing?o._pendingInitMessages.push({messages:(0,e.s)([],(0,e.t)(f),!1),source:b}):o.hasNext||o._addMessagesToView(f,b);break;case e.ab.SYNC_MESSAGE_FILL:o._addMessagesToView(f,b)}g.length>0&&o._removeMessagesFromView(g,b)}o._postprocessMessageUpdateEvent(a,b)},onRemove:function(a,b){o._removeMessagesFromView(a,b),o._postprocessMessageRemoveEvent(a)},onRemoveUnsent:function(a,b){o._removeUnsentMessageFromView(a,b)},onPollChangeLogUpdate:function(a,b){o._updatePollsToView(a,b)},onPollUpdate:function(a,b){o._applyPollUpdateEventToView(a,b)},onPollVote:function(a,b){o._applyPollVoteEventToView(a,b)},onReactionUpdate:function(a,b){o._applyReactionEventToView(a,b)},onThreadInfoUpdate:function(a,b){o._applyThreadInfoEventToView(a,b)},onDeletedByRetentionPolicy:function(a,b,c){b===o.channel.url&&o._messageRetention(a,c)}});var q=e.V.of(this._iid),r=q.cacheContext,s=q.dispatcher,t=q.messageBackgroundSyncThrottleController;this._channel._updateMessageCollectionLastAccessedAt(),s.dispatch(new J({channels:[this._channel],context:{source:e.ab.CHANNEL_LASTACCESSEDAT_UPDATED}})),this._backgroundSync=aX.of(this._iid,this._channel),!(void 0!==n&&n)&&this._shouldStartBackgroundSync()&&this._backgroundSync.resume(this._startingPoint),this._changelogSync=a3.of(this._iid,this._channel,this.changelogIncludeParams),this._changelogSync.resume(),this._pollChangelogSync=a5.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new g.c(this._key,function(a){return(0,e._)(o,void 0,void 0,function(){var b=this;return(0,e.b)(this,function(c){switch(c.label){case 0:return[4,t.run("message-fill-sync-".concat(l.url,"-prev"),function(){return(0,e._)(b,void 0,void 0,function(){var b,c,d,g,h,i,j;return(0,e.b)(this,function(k){switch(k.label){case 0:return[4,this._getRemoteMessages(a,{prevLimit:this._prevResultLimit,source:e.ab.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled,sdkSource:f.an.INTERNAL_FILL_GAP})];case 1:return c=(b=k.sent()).messages,d=b.isContinuousMessages,c.length>0?(g=Math.min.apply(Math,(0,e.s)([],(0,e.t)(c.map(function(a){return a.createdAt})),!1)),this._syncRange.extends(g),d&&(null===(h=this._backgroundSync)|| void 0===h||h.range.extends(g)),[2,{hasNext:c.length>=this._prevResultLimit&&this.viewTop0?(h=Math.max.apply(Math,(0,e.s)([],(0,e.t)(c.map(function(a){return a.createdAt})),!1)),this._syncRange.extends(h),d&&(null===(i=this._backgroundSync)|| void 0===i||i.range.extends(h)),[2,{hasNext:g,nextToken:this._syncRange.bottom}]):(r.localCacheEnabled&&p.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(k=null===(j=r.localCacheConfig)|| void 0===j?void 0:j.maxSize)&& void 0!==k?k:0,use_local_cache:r.localCacheEnabled,starting_point:0,message_init_policy:""}})),[2,{hasNext:!1,nextToken:0}])}})})})];case 1:return[2,c.sent()]}})})}),this._connectionEventContext=s.on(function(a){if(a instanceof e.K)switch(a.stateType){case e.M.CONNECTED:(0,e.J)(function(){return(0,e._)(o,void 0,void 0,function(){return(0,e.b)(this,function(a){return this._activate(),[2]})})});break;case e.M.LOGOUT:o.dispose();break;default:o._clearCheckMyMutedTimer(),o._prevFill.stop(),o._nextFill.stop()}else a instanceof g.F&&o._activate()})}return a.prototype.keyOf=function(a){return 0},Object.defineProperty(a.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),a.prototype._postprocessChannelUpdateEvent=function(a,b){},a.prototype._postprocessChannelRemoveEvent=function(a){},a.prototype._postprocessMessageUpdateEvent=function(a,b){},a.prototype._postprocessMessageRemoveEvent=function(a){},Object.defineProperty(a.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"succeededMessages",{get:function(){return(0,e.s)([],(0,e.t)(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter(function(a){return a.sendingStatus===e.ax.FAILED})},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter(function(a){return a.sendingStatus===e.ax.PENDING})},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"viewTop",{get:function(){return Math.min.apply(Math,(0,e.s)((0,e.s)([],(0,e.t)(this._messages.map(function(a){return a.createdAt})),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,(0,e.s)((0,e.s)([],(0,e.t)(this._messages.map(function(a){return a.createdAt})),!1),[0],!1))},enumerable:!1,configurable:!0}),a.prototype._activate=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return e.V.of(this._iid).logger.debug("check huge gap"),this._checkHugeGap(),[4,this._refreshChannel(e.ab.SYNC_CHANNEL_CHANGELOGS)];case 1:return a.sent(),[2]}})})},a.prototype._replaceChannelOfCollection=function(a){this._channel.isGroupChannel()?this._channel=a:this._channel.isFeedChannel()&&(this._channel._groupChannel=a._groupChannel)},a.prototype._shouldStartBackgroundSync=function(){var a=e.V.of(this._iid).cacheContext;return this.channel.isGroupChannel()?a.localCacheEnabled&&!this.channel.isSuper:a.localCacheEnabled},a.prototype._setBaseMessageCollectionHandler=function(a){this._handler=a},a.prototype._filterUnderOffsetMessage=function(a){var b;return this._channel._runIfHandleableWithGroupChannel(function(c){b=a.filter(function(a){return a.createdAt>=c.messageOffsetTimestamp})}),void 0!==b?b:a},a.prototype._flushPendingInitMessages=function(a){var b,c,d,f,g,h,i=this._pendingInitMessages;if(this._pendingInitMessages=null,i&&!this._isDisposed)try{for(var j=(0,e.x)(i),k=j.next();!k.done;k=j.next()){var l=k.value,m=l.messages;switch(l.source){case e.ab.EVENT_MESSAGE_RECEIVED:if(!this.hasNext)try{for(var n=(d=void 0,(0,e.x)(m)),o=n.next();!o.done;o=n.next()){var p=o.value;(r=a_(a,p))>=0?p.updatedAt>a[r].updatedAt&&(a[r]=p):a.push(p)}}catch(q){d={error:q}}finally{try{o&&!o.done&&(f=n.return)&&f.call(n)}finally{if(d)throw d.error}}break;case e.ab.EVENT_MESSAGE_SENT_SUCCESS:case e.ab.SYNC_MESSAGE_CHANGELOGS:try{for(var r,s=(g=void 0,(0,e.x)(m)),t=s.next();!t.done;t=s.next())p=t.value,(r=a_(a,p))>=0?p.updatedAt>a[r].updatedAt&&(a[r]=p):this.hasNext||a.push(p)}catch(u){g={error:u}}finally{try{t&&!t.done&&(h=s.return)&&h.call(s)}finally{if(g)throw g.error}}}}}catch(v){b={error:v}}finally{try{k&&!k.done&&(c=j.return)&&c.call(j)}finally{if(b)throw b.error}}},a.prototype._updateChildMessagesInView=function(a){var b=[];return this._messages.forEach(function(c){c instanceof f.V&&c.parentMessageId===a.messageId&&c.applyParentMessage(a)&&b.push(c)}),b},a.prototype._updatePollsToView=function(a,b){var c,d,f=this,g=[];try{for(var h=(0,e.x)(a),i=h.next();!i.done;i=h.next()){var j=i.value,k=a0(this._messages,j.messageId);if(k>=0){var l=this._messages[k];l.isUserMessage()&&l.applyPoll(j),g.push(l)}}}catch(m){c={error:m}}finally{try{i&&!i.done&&(d=h.return)&&d.call(h)}finally{if(c)throw c.error}}return g.length>0&&(0,e.bv)(b)&&(0,e.N)(function(){return(0,e._)(f,void 0,void 0,function(){var a,c,d;return(0,e.b)(this,function(e){return a={source:b},g.length>0&&(null===(d=(c=this._handler).onMessagesUpdated)|| void 0===d||d.call(c,a,this.channel,g)),[2]})})}),g},a.prototype._applyPollUpdateEventToView=function(a,b){var c=this,d=a0(this._messages,a.messageId);if(d>=0){var f=this._messages[d];f&&f.isUserMessage()&&f.poll&&f.poll.applyPollUpdateEvent(a)&&(0,e.bv)(b)&&(0,e.N)(function(){return(0,e._)(c,void 0,void 0,function(){var a,c,d;return(0,e.b)(this,function(e){return a={source:b},null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesUpdated)|| void 0===d||d.call(c,a,this.channel,[f]),[2]})})})}},a.prototype._applyPollVoteEventToView=function(a,b){var c=this,d=a0(this._messages,a.messageId);if(d>=0){var f=this._messages[d];f&&f.isUserMessage()&&f.poll&&f.poll.applyPollVoteEvent(a)&&(0,e.bv)(b)&&(0,e.N)(function(){return(0,e._)(c,void 0,void 0,function(){var a,c,d;return(0,e.b)(this,function(e){return a={source:b},null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesUpdated)|| void 0===d||d.call(c,a,this.channel,[f]),[2]})})})}},a.prototype._applyReactionEventToView=function(a,b){var c=this,d=a0(this._messages,a.messageId);if(d>=0){var f=this._messages[d];f&&(f.isUserMessage()||f.isFileMessage()||f.isMultipleFilesMessage())&&(0,e.bv)(b)&&(f.applyReactionEvent(a),(0,e.N)(function(){return(0,e._)(c,void 0,void 0,function(){var a,c,d;return(0,e.b)(this,function(e){return a={source:b},null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesUpdated)|| void 0===d||d.call(c,a,this.channel,[f]),[2]})})}))}},a.prototype._applyThreadInfoEventToView=function(a,b){var c=this,d=a0(this._messages,a.targetMessageId);if(d>=0){var f=this._messages[d];f&&(f.isUserMessage()||f.isFileMessage()||f.isMultipleFilesMessage())&&(0,e.bv)(b)&&(f.applyThreadInfoUpdateEvent(a),(0,e.N)(function(){return(0,e._)(c,void 0,void 0,function(){var a,c,d;return(0,e.b)(this,function(e){return a={source:b},null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesUpdated)|| void 0===d||d.call(c,a,this.channel,[f]),[2]})})}))}},a.prototype._removeMessagesFromView=function(a,b){var c,d,f=this,g=[],h=[],i=function(a){var b=j._messages.findIndex(function(b){return f.keyOf(b)===a});if(b>=0){var c=j._messages[b];g.push(j.keyOf(c)),h.push(c),j._messages.splice(b,1)}},j=this;try{for(var k=(0,e.x)(a),l=k.next();!l.done;l=k.next())i(l.value)}catch(m){c={error:m}}finally{try{l&&!l.done&&(d=k.return)&&d.call(k)}finally{if(c)throw c.error}}return(0,e.bv)(b)&&h.length>0&&(0,e.N)(function(){return(0,e._)(f,void 0,void 0,function(){var a,c,d;return(0,e.b)(this,function(e){return a={source:b},null===(d=null===(c=this._handler)|| void 0===c?void 0:c.onMessagesDeleted)|| void 0===d||d.call(c,a,this.channel,g,h),[2]})})}),g},a.prototype._messageRetention=function(a,b){var c,d,f=[];try{for(var g=(0,e.x)(this._messages),h=g.next();!h.done;h=g.next()){var i=h.value;i.createdAt<=a&&f.push(this.keyOf(i))}}catch(j){c={error:j}}finally{try{h&&!h.done&&(d=g.return)&&d.call(g)}finally{if(c)throw c.error}}f.length>0&&this._removeMessagesFromView(f,b)},a.prototype._removeUnsentMessageFromView=function(a,b){var c=this._unsentMessages.findIndex(function(b){return b.reqId===a});c>=0&&this._unsentMessages.splice(c,1)},a.prototype._getLocalMessages=function(a,b){var c=b.prevLimit,d=void 0===c?0:c,f=b.nextLimit,g=void 0===f?0:f,h=b.inclusive,i=void 0===h||h,j=b.isRestoreIndexedDB,k=void 0!==j&&j;return(0,e._)(this,void 0,void 0,function(){var b,c,f,h,j;return(0,e.b)(this,function(l){switch(l.label){case 0:return b=[],i?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,a,this.filter,k)]:[3,2];case 1:b=l.sent(),l.label=2;case 2:return d>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,a,"prev",this.filter,d,!1,k)]:[3,4];case 3:return f=l.sent(),[3,5];case 4:f=[],l.label=5;case 5:return c=f,g>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,a,"next",this.filter,g,!1,k)]:[3,7];case 6:return j=l.sent(),[3,8];case 7:j=[],l.label=8;case 8:return h=j,[2,{messages:(0,e.s)((0,e.s)((0,e.s)([],(0,e.t)(b),!1),(0,e.t)(c),!1),(0,e.t)(h),!1).sort(function(a,b){return b.createdAt-a.createdAt}),prevMessagesCount:c.length,nextMessagesCount:h.length}]}})})},a.prototype._getRemoteMessages=function(a,b){var c=b.prevLimit,d=void 0===c?0:c,g=b.nextLimit,h=void 0===g?0:g,i=b.source,j=void 0===i?e.ab.REQUEST_MESSAGE:i,k=b.reverse,l=void 0!==k&&k,m=b.checkingHasNext,n=void 0!==m&&m,o=b.checkingContinuousMessages,p=void 0!==o&&o,q=b.sdkSource;return(0,e._)(this,void 0,void 0,function(){var b,c;return(0,e.b)(this,function(g){switch(g.label){case 0:return b=f.T.of(this._iid),d>0||h>0?[4,b._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,a,(0,e.g)((0,e.d)((0,e.d)((0,e.d)({},this.filter),a8),{isInclusive:!0,reverse:l,prevResultSize:d,nextResultSize:h})),j,n,p,q)]:[3,2];case 1:return c=g.sent(),[3,3];case 2:c={messages:[],isContinuousMessages:!1},g.label=3;case 3:return[2,c]}})})},a.prototype._checkHugeGap=function(){var a,b,c,d,g;return(0,e._)(this,void 0,void 0,function(){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G=this;return(0,e.b)(this,function(H){switch(H.label){case 0:return i=(h=e.V.of(this._iid)).dispatcher,j=h.requestQueue,k=h.cacheContext,l=h.statManager,m=h.logger,this._messages.length>0?(n=this._syncRange.top,o=this.viewTop,p=this._syncRange.bottom,q=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,o,n)]):[3,8];case 1:return r=H.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,p,q)];case 2:s=H.sent(),H.label=3;case 3:return H.trys.push([3,5,6,7]),[4,(0,e.bw)(function(){return(0,e._)(G,void 0,void 0,function(){var a,b,c,d,f,g,h,l,m,t,u,v,w,x,y,z,A,B=this;return(0,e.b)(this,function(C){switch(C.label){case 0:return a=new a6((0,e.d)((0,e.d)({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:o,prevEnd:n,prevCount:r,nextStart:p,nextEnd:q,nextCount:s,checkingContinuousMessages:k.localCacheEnabled},this.filter),a8)),[4,j.send(a)];case 1:return d=(c=(b=C.sent()).as(a7)).isHugeGap,f=c.prevMessages,g=void 0===f?[]:f,h=c.prevHasMore,l=c.isContinuousPrevMessages,m=c.nextMessages,t=void 0===m?[]:m,u=c.nextHasmore,v=c.isContinuousNextMessages,d?(0,e.N)(function(){return(0,e._)(B,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){return(null===(a=this._handler)|| void 0===a?void 0:a.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]})})}):(w=this.viewTop,x=this.viewBottom,y=Math.min.apply(Math,(0,e.s)([Number.MAX_SAFE_INTEGER,w],(0,e.t)(g.map(function(a){return a.createdAt})),!1)),z=Math.max.apply(Math,(0,e.s)([0,x],(0,e.t)(t.map(function(a){return a.createdAt})),!1)),i.dispatch(new e.aP({messages:g,source:e.ab.SYNC_MESSAGE_FILL})),i.dispatch(new e.aP({messages:t,source:e.ab.SYNC_MESSAGE_FILL})),this._syncRange.extends(y,z),(l||v)&&(null===(A=this._backgroundSync)|| void 0===A||A.range.extends(y,z)),h&&this._prevFill.start(y),u&&this._nextFill.start(z)),[2]}})})},1)];case 4:return H.sent(),[3,7];case 5:return t=H.sent(),m.debug("Failed HugeGap Check ",t),[3,7];case 6:return k.localCacheEnabled&&l.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(b=null===(a=k.localCacheConfig)|| void 0===a?void 0:a.maxSize)&& void 0!==b?b:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 7:return[3,13];case 8:u=Date.now(),H.label=9;case 9:return H.trys.push([9,11,12,13]),[4,this._getRemoteMessages(u,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,source:e.ab.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:k.localCacheEnabled,sdkSource:f.an.INTERNAL_FILL_GAP})];case 10:if(w=(v=H.sent()).messages,x=v.isContinuousMessages,y=v.hasNext,w.length>0){for(z=w.map(function(a){return a.createdAt}),A=0,B=0,C=0;C=u&&B++;this._hasPrevious=A>=this._prevResultLimit,this._hasNext=null!=y?y:B>=this._nextResultLimit,(F=this._syncRange).extends.apply(F,(0,e.s)([],(0,e.t)(z),!1)),x&&(null===(c=this._backgroundSync)|| void 0===c||c.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(w,e.ab.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,13];case 11:return(E=H.sent())instanceof e.q&&E.code===e.F.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,13];case 12:return k.localCacheEnabled&&l.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(g=null===(d=k.localCacheConfig)|| void 0===d?void 0:d.maxSize)&& void 0!==g?g:0,use_local_cache:k.localCacheEnabled,starting_point:0,message_init_policy:""}})),[7];case 13:return[2]}})})},a.prototype._loadUnsentMessages=function(){return(0,e._)(this,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return a=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return a._unsentMessages=b.sent(),[2]}})})},a.prototype._hasPollMessage=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){switch(a.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return a.sent().length>0?[2,!0]:[2,!1]}})})},a.prototype._refreshChannel=function(a,b){return void 0===b&&(b=!1),(0,e._)(this,void 0,void 0,function(){var c,d,f=this;return(0,e.b)(this,function(g){switch(g.label){case 0:c=e.V.of(this._iid).logger,g.label=1;case 1:return g.trys.push([1,3,,4]),[4,this._channelManager.refreshChannel(this.channel.url,!0,a,b)];case 2:return g.sent(),this.channel._runIfHandleableWithGroupChannel(function(a){a.myMutedState===e.bo.MUTED&&(0,e.J)(function(){return(0,e._)(f,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(a=b.sent()).isMuted&& -1!==a.remainingDuration&&this._startCheckMyMutedTimer(a.remainingDuration),[2]}})})})}),[3,4];case 3:return d=g.sent(),c.warn("Failed to refresh channel",d),[3,4];case 4:return[2]}})})},a.prototype._startCheckMyMutedTimer=function(a){var b=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout(function(){return(0,e._)(b,void 0,void 0,function(){var a,b,c,d=this;return(0,e.b)(this,function(f){switch(f.label){case 0:this._checkMyMutedStateTimer=void 0,a=!0,f.label=1;case 1:return f.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return a=!(b=f.sent()).isMuted,[3,5];case 3:return f.sent(),a=!0,[3,5];case 4:return a&&(c=e.V.of(this._iid).sessionManager,this.channel._runIfHandleableWithGroupChannel(function(a){a.myMutedState=e.bo.UNMUTED;var b,f,g={source:e.ab.EVENT_CHANNEL_UNMUTED,user:c.currentUser};null===(f=null===(b=d._handler)|| void 0===b?void 0:b.onChannelUpdated)|| void 0===f||f.call(b,g,d.channel)})),[7];case 5:return[2]}})})},a+1e3)},a.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},a.prototype._setHasNextAndHasPrevious=function(a,b){for(var c=a.map(function(a){return a.createdAt}),d=0,e=0,f=0;fthis._startingPoint&&e++}this._hasPrevious=d>=this._prevResultLimit,this._hasNext=null!=b?b:e>=this._nextResultLimit},a.prototype.initialize=function(a){var b=this,c=new bf;this._messages=[],this._unsentMessages=[],this._syncRange=new aU({}),this._hasNext=!0,this._hasPrevious=!0,this._isInitializing=!0,this._pendingInitMessages=[];var d=[],g={messages:[],prevMessagesCount:0,nextMessagesCount:0};return(0,e.N)(function(){return(0,e._)(b,void 0,void 0,function(){var b,h,i,j,k,l=this;return(0,e.b)(this,function(m){switch(m.label){case 0:return[4,null===(k=this._backgroundSync)|| void 0===k?void 0:k.loadMetadata()];case 1:return b=m.sent(),i=(h=e.V.of(this._iid)).cacheContext,j=h.statManager,a===aR.CACHE_AND_REPLACE_BY_API&&this._getLocalMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,isRestoreIndexedDB:!0}).then(function(a){return(0,e._)(l,void 0,void 0,function(){return(0,e.b)(this,function(b){switch(b.label){case 0:return g=a,d=this._filterUnderOffsetMessage(g.messages),this._addMessagesToView(d,e.ab.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return b.sent(),c._invokeResponse("local",null,d),[2]}})})}).catch(function(a){if((0,e.a1)(a))throw a;c._invokeResponse("local",a,null)}).finally(function(){return(0,e._)(l,void 0,void 0,function(){var h,i,k,l,m,n,o,p=this;return(0,e.b)(this,function(q){switch(q.label){case 0:return h=e.V.of(this._iid).cacheContext,i=!0,k=!0,l=!1,h.localCacheEnabled&&(d.length>0&&(m=b.range).includes.apply(m,(0,e.s)([],(0,e.t)(d.map(function(a){return a.createdAt})),!1))?!b.previousComplete&&g.prevMessagesCountb.range.bottom||g.nextMessagesCount=a._latestMessageInfo.createdAt&&(k=!1)}),k?(i=!1,this._getRemoteMessages(this._startingPoint,{prevLimit:this._prevResultLimit,nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled,sdkSource:f.an.EXTERNAL_COLLECTION}).then(function(a){var b,d,f,g=a.messages,h=a.isContinuousMessages,i=a.hasNext,j=p._filterUnderOffsetMessage(g);p._messages=[],j.length>0?(p._setHasNextAndHasPrevious(j,i),(b=p._syncRange).extends.apply(b,(0,e.s)([],(0,e.t)(j.map(function(a){return a.createdAt})),!1)),h&&(null===(d=p._backgroundSync)|| void 0===d?void 0:d.range.overlap(p._syncRange))&&(null===(f=p._backgroundSync)|| void 0===f||f.range.extends(p._syncRange.top,p._syncRange.bottom))):(p._hasPrevious=!1,p._hasNext=!1),p._isInitializing=!1,p._flushPendingInitMessages(j),j.length>0&&p._addMessagesToView(j,e.ab.REQUEST_MESSAGE),c._invokeResponse("remote",null,j)}).catch(function(a){if(p._isInitializing=!1,p._pendingInitMessages=null,(0,e.a1)(a))throw a;c._invokeResponse("remote",a,null)})):(this._setHasNextAndHasPrevious(d),this._isInitializing=!1,this._flushPendingInitMessages(d),d.length>0&&this._addMessagesToView(d,e.ab.REQUEST_MESSAGE),c._invokeResponse("remote",null,d)),h.localCacheEnabled&&j.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:i?"cache_hit":"cache_miss",max_db_size:null!==(o=null===(n=h.localCacheConfig)|| void 0===n?void 0:n.maxSize)&& void 0!==o?o:0,message_init_policy:a,use_local_cache:h.localCacheEnabled,collection_id:this._key}})),[2]}})})}),j.put(new e.bl({type:e.D.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:a,message:!0}}})),[2]}})})}),c},a.prototype.loadPrevious=function(){var a,b,c;return(0,e._)(this,void 0,void 0,function(){var d,g,h,i,j,k,l,m,n=this;return(0,e.b)(this,function(o){switch(o.label){case 0:if(this._isDisposed)throw new e.q({code:e.F.COLLECTION_DISPOSED,message:"Collection has been disposed."});return g=(d=e.V.of(this._iid)).cacheContext,h=d.statManager,i=d.logger,this._hasPrevious?this._isLoadingPrevious?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingPrevious=!0,j=this.viewTop,k=[],[4,(0,e.J)(function(){return(0,e._)(n,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,this._getLocalMessages(j,{prevLimit:this._prevResultLimit,inclusive:!1})];case 1:return a=b.sent(),k=this._filterUnderOffsetMessage(a.messages),[2]}})})})]):[2,[]];case 1:return o.sent(),l=k.length>=this._prevResultLimit,g.localCacheEnabled&&h.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:l?"cache_hit":"cache_miss",max_db_size:null!==(b=null===(a=g.localCacheConfig)|| void 0===a?void 0:a.maxSize)&& void 0!==b?b:0,use_local_cache:g.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(c=this._backgroundSync)|| void 0===c?void 0:c.isWrappingMessages(k))?[3,3]:(m=!1,[4,(0,e.J)(function(){return(0,e._)(n,void 0,void 0,function(){var a,b,c,d,g,i,l,n=this;return(0,e.b)(this,function(o){switch(o.label){case 0:return a=e.V.of(this._iid).cacheContext,[4,this._getRemoteMessages(j,{prevLimit:this._prevResultLimit,reverse:!0,checkingContinuousMessages:a.localCacheEnabled,sdkSource:f.an.EXTERNAL_COLLECTION})];case 1:return b=o.sent(),(k=this._filterUnderOffsetMessage(b.messages)).length>0&&((c=this._syncRange).extends.apply(c,(0,e.s)([],(0,e.t)(k.map(function(a){return a.createdAt})),!1)),(null===(d=this._backgroundSync)|| void 0===d?void 0:d.range.overlap(this._syncRange))&&b.isContinuousMessages&&(m=!0,null===(g=this._backgroundSync)|| void 0===g||g.range.extends(this._syncRange.top))),k=k.filter(function(a){return 0>a_(n._messages,a)}),this._hasPrevious=k.length>=this._prevResultLimit,a.localCacheEnabled&&m&&h.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(l=null===(i=a.localCacheConfig)|| void 0===i?void 0:i.maxSize)&& void 0!==l?l:0,use_local_cache:a.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}})})})]);case 2:return o.sent(),this._addMessagesToView(k,e.ab.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=k.length>=this._prevResultLimit,k.length>0&&this._addMessagesToView(k,e.ab.REQUEST_MESSAGE),o.label=4;case 4:return this._isLoadingPrevious=!1,[2,k]}})})},a.prototype.loadNext=function(){var a,b,c;return(0,e._)(this,void 0,void 0,function(){var d,g,h,i,j,k,l,m,n=this;return(0,e.b)(this,function(o){switch(o.label){case 0:if(this._isDisposed)throw new e.q({code:e.F.COLLECTION_DISPOSED,message:"Collection has been disposed."});return g=(d=e.V.of(this._iid)).cacheContext,h=d.statManager,i=d.logger,this._hasNext?this._isLoadingNext?(i.warn("Messages are already fetching."),[2,[]]):(this._isLoadingNext=!0,j=this.viewBottom,k=[],[4,(0,e.J)(function(){return(0,e._)(n,void 0,void 0,function(){var a;return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,this._getLocalMessages(j,{nextLimit:this._nextResultLimit,inclusive:!1})];case 1:return a=b.sent(),k=this._filterUnderOffsetMessage(a.messages),[2]}})})})]):[2,[]];case 1:return o.sent(),l=k.length>=this._nextResultLimit,g.localCacheEnabled&&h.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:l?"cache_hit":"cache_miss",max_db_size:null!==(b=null===(a=g.localCacheConfig)|| void 0===a?void 0:a.maxSize)&& void 0!==b?b:0,use_local_cache:g.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),l&&(null===(c=this._backgroundSync)|| void 0===c?void 0:c.isWrappingMessages(k))?[3,3]:(m=!1,[4,(0,e.J)(function(){return(0,e._)(n,void 0,void 0,function(){var a,b,c,d,g,i,l,n,o=this;return(0,e.b)(this,function(p){switch(p.label){case 0:return a=e.V.of(this._iid).cacheContext,[4,this._getRemoteMessages(j,{nextLimit:this._nextResultLimit,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:a.localCacheEnabled,sdkSource:f.an.EXTERNAL_COLLECTION})];case 1:return b=p.sent(),(k=this._filterUnderOffsetMessage(b.messages)).length>0&&((c=this._syncRange).extends.apply(c,(0,e.s)([],(0,e.t)(k.map(function(a){return a.createdAt})),!1)),(null===(d=this._backgroundSync)|| void 0===d?void 0:d.range.overlap(this._syncRange))&&b.isContinuousMessages&&(m=!0,null===(g=this._backgroundSync)|| void 0===g||g.range.extends(this._syncRange.bottom))),k=k.filter(function(a){return 0>a_(o._messages,a)}),this._hasNext=null!==(i=b.hasNext)&& void 0!==i?i:k.length>=this._nextResultLimit,a.localCacheEnabled&&m&&h.put(new e.B({type:e.D.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(n=null===(l=a.localCacheConfig)|| void 0===l?void 0:l.maxSize)&& void 0!==n?n:0,use_local_cache:a.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),[2]}})})})]);case 2:return o.sent(),this._addMessagesToView(k,e.ab.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=k.length>=this._nextResultLimit,k.length>0&&this._addMessagesToView(k,e.ab.REQUEST_MESSAGE),o.label=4;case 4:return this._isLoadingNext=!1,[2,k]}})})},a.prototype.removeFailedMessage=function(a){return(0,e._)(this,void 0,void 0,function(){var b;return(0,e.b)(this,function(c){switch(c.label){case 0:if(this._isDisposed)throw new e.q({code:e.F.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.removeFailedMessageFromCache(a)];case 1:return c.sent(),(b=this._unsentMessages.findIndex(function(b){return b.reqId===a}))> -1&&this._unsentMessages.splice(b,1),[2]}})})},a.prototype.dispose=function(){var a,b,c,d=this;if(!this._isDisposed){if(this._isDisposed=!0,this._messages=[],this._clearCheckMyMutedTimer(),e.V.exists(this._iid)){var f=e.V.of(this._iid),g=f.cacheContext,h=f.dispatcher;this._channel._runIfHandleableWithGroupChannel(function(a){a.myMemberState!==j.NONE&&(d._channel._updateMessageCollectionLastAccessedAt(),h.dispatch(new J({channels:[d._channel],context:{source:e.ab.CHANNEL_LASTACCESSEDAT_UPDATED}})))}),g.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop())}null===(a=this._backgroundSync)|| void 0===a||a.close(),null===(b=this._changelogSync)|| void 0===b||b.close(),null===(c=this._pollChangelogSync)|| void 0===c||c.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},a}()),bh={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},bi=function(a){function b(b){var c=this,d=b.channelUrl,f=b.token,g=b.limit,h=b.order,i=b.mutedMemberFilter,j=b.memberStateFilter,k=b.nicknameStartsWithFilter,l=b.operatorFilter;return(c=a.call(this)||this).method=e.A.GET,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/members"),c.params={token:f,limit:g,order:h,muted_member_filter:i,member_state_filter:j,nickname_startswith:k,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},c}return(0,e.c)(b,a),b}(e.h),bj=function(a){function b(b,c){var d=a.call(this,b,c)||this;d.members=[];var e=c.next,f=c.members;return d.token=e,f&&f.length>0&&(d.members=f.map(function(a){return new A(b,a)})),d}return(0,e.c)(b,a),b}(e.j);(bc=a9||(a9={})).ALL="all",bc.MUTED="muted",bc.UNMUTED="unmuted",(bd=ba||(ba={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",bd.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",(be=bb||(bb={})).ALL="all",be.JOINED="joined_only",be.INVITED="invited_only",be.INVITED_BY_FRIEND="invited_by_friend",be.INVITED_BY_NON_FRIEND="invited_by_non_friend";var bk,bl=function(a){function b(b,c,d){var f,g,h,i,j=this;return(j=a.call(this,b,c,e.C.GROUP,d)||this).mutedMemberFilter=a9.ALL,j.memberStateFilter=bb.ALL,j.nicknameStartsWithFilter=null,j.operatorFilter=p.ALL,j.order=ba.MEMBER_NICKNAME_ALPHABETICAL,j.mutedMemberFilter=null!==(f=d.mutedMemberFilter)&& void 0!==f?f:a9.ALL,j.memberStateFilter=null!==(g=d.memberStateFilter)&& void 0!==g?g:bb.ALL,j.nicknameStartsWithFilter=null!==(h=d.nicknameStartsWithFilter)&& void 0!==h?h:null,j.order=null!==(i=d.order)&& void 0!==i?i:ba.MEMBER_NICKNAME_ALPHABETICAL,j}return(0,e.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,e.a5)(a9,this.mutedMemberFilter)&&(0,e.a5)(bb,this.memberStateFilter)&&((0,e.a)("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&(0,e.a5)(p,this.operatorFilter)&&(0,e.a5)(ba,this.order)},b.prototype.next=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f,g;return(0,e.b)(this,function(h){switch(h.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=e.V.of(this._iid).requestQueue,b=new bi((0,e.g)((0,e.d)((0,e.d)({},this),{token:this._token}))),[4,a.send(b)]):[3,2]:[3,5];case 1:return f=(d=(c=h.sent()).as(bj)).members,g=d.token,this._token=g,this._hasNext=!!g,this._isLoading=!1,[2,f];case 2:return[2,[]];case 3:throw e.q.queryInProgress;case 4:return[3,6];case 5:throw e.q.invalidParameters;case 6:return[2]}})})},b}(e.aY),bm=function(a){function b(b){var c=this,d=b.channelUrl,f=b.userId,g=b.accessCode;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/accept"),c.params={user_id:f,access_code:g},c}return(0,e.c)(b,a),b}(e.h),bn=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.channel=new ca(b,c),d.channel.myMemberState=j.JOINED,d}return(0,e.c)(b,a),b}(e.j),bo=function(a){function b(b){var c=this,d=b.channelUrl,f=b.isDistinct,g=b.isPublic,h=b.isDiscoverable,i=b.coverUrl,j=b.coverImage,k=b.accessCode,l=b.name,m=b.data,n=b.customType,o=b.operatorUserIds,p=b.messageSurvivalSeconds;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d)),c.params=(0,e.f)({is_distinct:f,is_public:g,is_discoverable:h,name:l,data:m,custom_type:n,cover_url:i,cover_file:j,access_code:k,operator_ids:o,message_survival_seconds:p}),c}return(0,e.c)(b,a),b}(e.h),bp=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.channel=new ca(b,c),d}return(0,e.c)(b,a),b}(e.j),bq=function(a){function b(b){var c=this,d=b.channelUrl;return(c=a.call(this)||this).method=e.A.DELETE,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d)),c}return(0,e.c)(b,a),b}(e.h);bk=e.j,(0,e.c)(function(a,b){return bk.call(this,a,b)||this},bk);var br,bs=function(a){function b(b){var c=this,d=b.channelUrl;return(c=a.call(this)||this).method=e.A.DELETE,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/hide"),c}return(0,e.c)(b,a),b}(e.h);br=e.j,(0,e.c)(function(){return null!==br&&br.apply(this,arguments)||this},br);var bt,bu=function(a){function b(b){var c=b.userId,d=b.channelUrl,f=b.countPreference,g=a.call(this)||this;return g.method=e.A.PUT,g.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/count_preference/").concat(encodeURIComponent(d)),g.params={count_preference:f},g}return(0,e.c)(b,a),b}(e.h),bv=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.countPreference=c.count_preference,d}return(0,e.c)(b,a),b}(e.j),bw=function(a){function b(b){var c=this,d=b.channelUrl,f=b.locale;return(c=a.call(this)||this).method=e.A.PUT,c.path="".concat(e.aW,"/").concat(encodeURIComponent(d),"/reset_user_history"),c.params=(0,e.f)({locale:f}),c}return(0,e.c)(b,a),b}(e.h),bx=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.ts_message_offset;return d.messageOffsetTimestamp=e,d}return(0,e.c)(b,a),b}(e.j),by=(0,e.d)((0,e.d)({},f.aF),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),bz=(0,e.d)((0,e.d)({},f.aH),{scheduledAt:void 0}),bA=function(a){function b(b){var c,d,g=this;g=a.call(this)||this;var h=[];b.mentionType===e.ar.USERS&&(b.mentionedUserIds?h=b.mentionedUserIds:b.mentionedUsers&&(h=b.mentionedUsers.map(function(a){return a.userId})));var i=b.channelType,j=b.channelUrl,k=b.scheduledMessageId;return g.method=e.A.PUT,g.path="".concat((0,e.aO)(i),"/").concat(encodeURIComponent(j),"/scheduled_messages/").concat(encodeURIComponent(k)),g.params=(0,e.f)((0,e.g)({req_id:b.reqId,scheduled_at:b.scheduledAt,message_type:e.b0.FILE,url:b.fileUrl,file_name:b.fileName,file_size:b.fileSize,file_type:b.mimeType,thumbnails:null===(c=b._thumbnails)|| void 0===c?void 0:c.map(function(a){return f.ad.payloadify(a)}),custom_type:b.customType,data:b.data,require_auth:b.requireAuth,mention_type:b.mentionType,mentioned_user_ids:h,sorted_metaarray:null===(d=b.metaArrays)|| void 0===d?void 0:d.map(function(a){return f._.payloadify(a)}),apple_critical_alert_options:b.appleCriticalAlertOptions?f.Y.payloadify(b.appleCriticalAlertOptions):null,push_option:b.pushNotificationDeliveryOption})),g}return(0,e.c)(b,a),b}(e.h),bB=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.message=new f.Z(b,c),d}return(0,e.c)(b,a),b}(e.j),bC=function(a){function b(b){var c,d=this;d=a.call(this)||this;var g=[];b.mentionType===e.ar.USERS&&(b.mentionedUserIds?g=b.mentionedUserIds:b.mentionedUsers&&(g=b.mentionedUsers.map(function(a){return a.userId})));var h=b.channelType,i=b.channelUrl,j=b.scheduledMessageId;return d.method=e.A.PUT,d.path="".concat((0,e.aO)(h),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(j)),d.params=(0,e.f)((0,e.g)({req_id:b.reqId,scheduled_at:b.scheduledAt,message_type:e.b0.USER,message:b.message,custom_type:b.customType,data:b.data,mention_type:b.mentionType,mentioned_user_ids:g,sorted_metaarray:null===(c=b.metaArrays)|| void 0===c?void 0:c.map(function(a){return f._.payloadify(a)}),apple_critical_alert_options:b.appleCriticalAlertOptions?f.Y.payloadify(b.appleCriticalAlertOptions):null,target_langs:b.translationTargetLanguages,push_option:b.pushNotificationDeliveryOption})),d}return(0,e.c)(b,a),b}(e.h);bt=e.j,(0,e.c)(function(a,b){var c=bt.call(this,a,b)||this;return c.message=new f.af(a,b),c},bt);var bD,bE,bF,bG,bH=function(a){function b(b){var c=a.call(this)||this,d=b.channelType,f=b.channelUrl,g=b.scheduledMessageId;return c.method=e.A.DELETE,c.path="".concat((0,e.aO)(d),"/").concat(encodeURIComponent(f),"/scheduled_messages/").concat(encodeURIComponent(g)),c}return(0,e.c)(b,a),b}(e.h),bI=function(a){function b(b){var c=a.call(this)||this,d=b.channelType,f=b.channelUrl,g=b.scheduledMessageId;return c.method=e.A.POST,c.path="".concat((0,e.aO)(d),"/").concat(encodeURIComponent(f),"/scheduled_messages/").concat(encodeURIComponent(g),"/send_now"),c}return(0,e.c)(b,a),b}(e.h),bJ=function(a){function b(b){var c=b.userId,d=b.channelUrl,f=b.pushTriggerOption,g=a.call(this)||this;return g.method=e.A.PUT,g.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/push_preference/").concat(encodeURIComponent(d)),g.params={push_trigger_option:f},g}return(0,e.c)(b,a),b}(e.h),bK=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.pushTriggerOption=c.push_trigger_option,d.enabled=c.enable,d}return(0,e.c)(b,a),b}(e.j),bL=function(a){function b(b){var c=b.userId,d=b.channelUrl,f=a.call(this)||this;return f.method=e.A.GET,f.path="".concat(e.k,"/").concat(encodeURIComponent(c),"/push_preference/").concat(encodeURIComponent(d)),f}return(0,e.c)(b,a),b}(e.h),bM=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.pushTriggerOption=c.push_trigger_option,d.enabled=c.enable,d}return(0,e.c)(b,a),b}(e.j),bN=function(a){function b(b){var c=this,d=b.channelUrl,f=b.channelType;return(c=a.call(this)||this).method=e.A.GET,c.path="".concat((0,e.aO)(f),"/").concat(encodeURIComponent(d),"/message_purge_offset"),c}return(0,e.c)(b,a),b}(e.h),bO=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.message_purge_offset;return d.messageDeletionTimestamp=e,d}return(0,e.c)(b,a),b}(e.j),bP=function(){function a(a){this.url=a.channel_url,this.lastMessageTs=a.last_message_ts}return a.payloadify=function(a){return{channel_url:a.url,last_message_ts:a.lastMessageTs}},a}(),bQ=function(){function a(a){var b,c,d,e;this.type=a.type,this.ticketId=null!==(b=a.ticket_id)&& void 0!==b?b:void 0,this.timestamp=null!==(c=a.timestamp)&& void 0!==c?c:void 0,this.estimatedAgentJoinAt=null!==(d=a.estimated_agent_join_at)&& void 0!==d?d:void 0,this.requestedAt=null!==(e=a.requested_at)&& void 0!==e?e:void 0}return a.payloadify=function(a){return(0,e.f)({type:a.type,ticket_id:a.ticketId,timestamp:a.timestamp,estimated_agent_join_at:a.estimatedAgentJoinAt,requested_at:a.requestedAt})},a}(),bR=function(){function a(a){this.isResolved=a.is_resolved,this.determinedBy=a.determined_by}return a.payloadify=function(a){return{is_resolved:a.isResolved,determined_by:a.determinedBy}},a}();(bF=bD||(bD={})).DEFAULT="default",bF.PROACTIVE="proactive",(bG=bE||(bE={})).OPEN="open",bG.CLOSED="closed",bG.INITIALIZED="initialized";var bS,bT,bU,bV,bW=function(){function a(a){var b,c,d,e,f,g,h,i,j;this.id=a.id,this.aiAgentId=a.ai_agent_id,this.type=a.conversation_type,this.status=a.status,this.channelInfo=new bP(a.channel),this.title=null!==(b=a.title)&& void 0!==b?b:void 0,this.summary=null!==(c=a.summary_text)&& void 0!==c?c:void 0,this.csat=null!==(d=a.csat)&& void 0!==d?d:void 0,this.csatReason=null!==(e=a.csat_reason)&& void 0!==e?e:void 0,this.csatExpireAt=null!==(f=a.csat_expire_at)&& void 0!==f?f:void 0,this.resolution=a.resolution?new bR(a.resolution):void 0,this.topics=null!==(g=a.topics)&& void 0!==g?g:[],this.handoff=a.handoff?new bQ(a.handoff):void 0,this.handedOverAt=null!==(h=a.handed_over_at)&& void 0!==h?h:void 0,this.context=null!==(j=null===(i=a.ai_agent_context)|| void 0===i?void 0:i.context)&& void 0!==j?j:void 0}return a.payloadify=function(a){return(0,e.f)((0,e.g)({id:a.id,ai_agent_id:a.aiAgentId,conversation_type:a.type,status:a.status,channel:bP.payloadify(a.channelInfo),title:a.title,summary_text:a.summary,csat:a.csat,csat_reason:a.csatReason,csat_expire_at:a.csatExpireAt,resolution:a.resolution&&bR.payloadify(a.resolution),topics:a.topics,handoff:a.handoff&&bQ.payloadify(a.handoff),handed_over_at:a.handedOverAt,ai_agent_context:a.context?{context:a.context}:void 0}))},a}(),bX=function(a){function b(b){var c=this,d=b.channelUrl;return(c=a.call(this)||this).method=e.A.POST,c.path="".concat(e.bx,"/").concat(encodeURIComponent(d),"/submit_csat"),c.params=(0,e.f)({csat:b.csat,csat_reason:b.csatReason,csat_type:b.csatType,is_resolved:b.isResolved,resolution_score:b.resolutionScore,csat_started_at:b.csatStartedAt}),c}return(0,e.c)(b,a),b}(e.h),bY=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.conversation=new bW(c.conversation),d}return(0,e.c)(b,a),b}(e.j),bZ=function(a){function b(b){var c=this,d=b.channelUrl;return(c=a.call(this)||this).method=e.A.POST,c.path="".concat(e.bx,"/").concat(encodeURIComponent(d),"/handoff"),c.params={},c}return(0,e.c)(b,a),b}(e.h),b$=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.conversation=new bW(c.conversation),d}return(0,e.c)(b,a),b}(e.j),b_=function(a){function b(b){var c=this,d=b.channelUrl;return(c=a.call(this)||this).method=e.A.POST,c.path="".concat(e.bx,"/").concat(encodeURIComponent(d),"/close_conversation"),c.params={},c}return(0,e.c)(b,a),b}(e.h),b0=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.conversation=new bW(c.conversation),d}return(0,e.c)(b,a),b}(e.j),b1=function(a){function b(b){var c=b.aiAgentId,d=b.channelUrl,f=b.context,g=a.call(this)||this;return g.method=e.A.PUT,g.path="".concat(e.by,"/ai_agents/").concat(encodeURIComponent(c),"/channels/").concat(encodeURIComponent(d),"/ai_agent_context"),g.params=(0,e.f)((0,e.g)({context:f})),g}return(0,e.c)(b,a),b}(e.h),b2=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.contextObject=c,d}return(0,e.c)(b,a),b}(e.j),b3=function(a){function b(b){var c=b.aiAgentId,d=b.channelUrl,f=a.call(this)||this;return f.method=e.A.GET,f.path="".concat(e.by,"/ai_agents/").concat(encodeURIComponent(c),"/channels/").concat(encodeURIComponent(d),"/ai_agent_context"),f}return(0,e.c)(b,a),b}(e.h),b4=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.contextObject=c,d}return(0,e.c)(b,a),b}(e.j),b5=function(a){function b(b){var c=b.aiAgentId,d=b.channelUrl,f=b.context,g=a.call(this)||this;return g.method=e.A.PATCH,g.path="".concat(e.by,"/ai_agents/").concat(encodeURIComponent(c),"/channels/").concat(encodeURIComponent(d),"/ai_agent_context"),g.params=(0,e.f)((0,e.g)({context:f})),g}return(0,e.c)(b,a),b}(e.h),b6=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.contextObject=c,d}return(0,e.c)(b,a),b}(e.j),b7=function(){function a(a){this.type=a.type,this.ticketStatus=a.ticket_status}return a.payloadify=function(a){return(0,e.f)({type:a.type,ticket_status:a.ticketStatus})},a}(),b8=function(a){function b(b){var c=b.aiAgentId,d=b.channelUrl,f=b.initialUserMessage,g=a.call(this)||this;return g.method=e.A.POST,g.path="".concat(e.by,"/ai_agents/").concat(encodeURIComponent(c),"/conversations"),g.params=(0,e.f)({channel_url:d,initial_user_message:f}),g}return(0,e.c)(b,a),b}(e.h),b9=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.conversation=new bW(c),d}return(0,e.c)(b,a),b}(e.j);(bU=bS||(bS={})).ALL="all",bU.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",bU.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",bU.OFF="off",(bV=bT||(bT={})).UNHIDDEN="unhidden",bV.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",bV.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var ca=function(a){function b(b,c){var d,g,h,i,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,B,C=this;return(C=a.call(this,b,c)||this)._unreadMemberStateMap=new Map,C._undeliveredMemberStateMap=new Map,C._typingStatus=new Map,C._lastMemberCountUpdated=0,C._typingStarted=0,C._typingEnded=0,C._aiAgentAdditionalData={},C.isDistinct=!1,C.isSuper=!1,C.isBroadcast=!1,C.isExclusive=!1,C.isPublic=!1,C.isDiscoverable=!0,C.isChatNotification=!1,C.isAccessCodeRequired=!1,C.isPushEnabled=!1,C.unreadMessageCount=0,C.unreadMentionCount=0,C.totalUnreadReplyCount=0,C.members=[],C.memberCount=0,C.joinedMemberCount=0,C.hiddenState=bT.UNHIDDEN,C.lastMessage=null,C.messageOffsetTimestamp=0,C.messageSurvivalSeconds=-1,C.myMemberState=j.NONE,C.myRole=e.ai.NONE,C.myMutedState=e.bo.UNMUTED,C.myLastRead=0,C.myCountPreference=bS.ALL,C.myPushTriggerOption=e.a8.DEFAULT,C.inviter=null,C.invitedAt=0,C.joinedAt=0,C.lastPinnedMessage=null,C.conversation=null,C.helpdeskInfo=null,C._latestMessageInfo=null,C._pinnedMessagesUpdatedAt=0,C._myMutedRemainingTime=-1,C._messageDeletionTimestamp=0,C.channelType=e.C.GROUP,C.isDistinct=null!==(g=c.is_distinct)&& void 0!==g&&g,C.isSuper=null!==(h=c.is_super)&& void 0!==h&&h,C.isBroadcast=null!==(i=c.is_broadcast)&& void 0!==i&&i,C.isExclusive=null!==(k=c.is_exclusive)&& void 0!==k&&k,C.isPublic=null!==(l=c.is_public)&& void 0!==l&&l,C.isDiscoverable=null!==(m=c.is_discoverable)&& void 0!==m?m:C.isPublic,C.isChatNotification=null!==(n=c.is_chat_notification)&& void 0!==n&&n,C.isAccessCodeRequired=null!==(o=c.is_access_code_required)&& void 0!==o&&o,C.isPushEnabled=null!==(p=c.is_push_enabled)&& void 0!==p&&p,Array.isArray(c.members)&&(d=C.members).push.apply(d,(0,e.s)([],(0,e.t)(c.members.map(function(a){return new A(C._iid,a)})),!1)),C.memberCount=null!==(q=c.member_count)&& void 0!==q?q:0,C.joinedMemberCount=null!==(r=c.joined_member_count)&& void 0!==r?r:0,C.hiddenState=(0,e.a5)(bT,c.hidden_state)?c.hidden_state:bT.UNHIDDEN,C.messageOffsetTimestamp=null!==(s=c.ts_message_offset)&& void 0!==s?s:0,C.messageSurvivalSeconds=null!==(t=c.message_survival_seconds)&& void 0!==t?t:-1,C.lastMessage=c.last_message?(0,f.Q)(C._iid,(0,e.d)({channel_type:C.channelType},c.last_message)):null,c.read_receipt&&Object.keys(c.read_receipt).forEach(function(a){(0,e.a)("number",c.read_receipt[a])&&C._updateUnreadMemberState(a,c.read_receipt[a])}),c.delivery_receipt&&Object.keys(c.delivery_receipt).forEach(function(a){(0,e.a)("number",c.delivery_receipt[a])&&C._updateUndeliveredMemberState(a,c.delivery_receipt[a])}),C.myMemberState=(0,e.a5)(j,c.member_state)?c.member_state:j.NONE,C.myRole=(0,e.a5)(e.ai,c.my_role)?c.my_role:e.ai.NONE,(0,e.a5)(e.bo,c.is_muted)?C.myMutedState=c.is_muted:(0,e.a)("boolean",c.is_muted)?C.myMutedState=c.is_muted?e.bo.MUTED:e.bo.UNMUTED:C.myMutedState=e.bo.UNMUTED,C.myCountPreference=(0,e.a5)(bS,c.count_preference)?c.count_preference:bS.ALL,C.myPushTriggerOption=(0,e.a5)(e.a8,c.push_trigger_option)?c.push_trigger_option:e.a8.ALL,C.myLastRead=null!==(u=c.user_last_read)&& void 0!==u?u:0,C.inviter=c.inviter?new e.U(C._iid,c.inviter):null,C.invitedAt=null!==(v=c.invited_at)&& void 0!==v?v:0,C.joinedAt=null!==(w=c.joined_ts)&& void 0!==w?w:0,C._updateUnreadCount(null!==(x=c.unread_message_count)&& void 0!==x?x:0,null!==(y=c.unread_mention_count)&& void 0!==y?y:0),C.totalUnreadReplyCount=null!==(z=c.total_unread_thread_message_count)&& void 0!==z?z:0,C.lastPinnedMessage=c.latest_pinned_message?(0,f.Q)(C._iid,(0,e.d)({channel_type:C.channelType},c.latest_pinned_message)):null,C.conversation=c.conversation?new bW(c.conversation):null,C.helpdeskInfo=c.helpdesk_info?new b7(c.helpdesk_info):null,c.latest_message&&(C._latestMessageInfo={messageId:c.latest_message.message_id,createdAt:c.latest_message.created_at}),C._aiAgentAdditionalData={hasBot:c.has_bot,hasAIBot:c.has_ai_bot,isAIAgent:c.is_ai_agent_channel,isDesk:c.is_desk_channel},C._messageDeletionTimestamp=null!==(B=c.message_purge_offset)&& void 0!==B?B:0,C}return(0,e.c)(b,a),Object.defineProperty(b.prototype,"isHidden",{get:function(){return this.hiddenState!==bT.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"cachedUnreadMemberState",{get:function(){var a,b,c={};try{for(var d=(0,e.x)(this._unreadMemberStateMap),f=d.next();!f.done;f=d.next()){var g=(0,e.t)(f.value,2),h=g[0],i=g[1];c[h]=i}}catch(j){a={error:j}}finally{try{f&&!f.done&&(b=d.return)&&b.call(d)}finally{if(a)throw a.error}}return c},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"cachedUndeliveredMemberState",{get:function(){var a,b,c={};try{for(var d=(0,e.x)(this._undeliveredMemberStateMap),f=d.next();!f.done;f=d.next()){var g=(0,e.t)(f.value,2),h=g[0],i=g[1];c[h]=i}}catch(j){a={error:j}}finally{try{f&&!f.done&&(b=d.return)&&b.call(d)}finally{if(a)throw a.error}}return c},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasBot",{get:function(){return!!this._aiAgentAdditionalData.hasBot},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasAiBot",{get:function(){return!!this._aiAgentAdditionalData.hasAIBot},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isDesk",{get:function(){return!!this._aiAgentAdditionalData.isDesk},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isAIAgent",{get:function(){return!!this._aiAgentAdditionalData.isAIAgent},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"messageDeletionTimestamp",{get:function(){return this._messageDeletionTimestamp},enumerable:!1,configurable:!0}),b.payloadify=function(b,c){void 0===c&&(c=!1);var d,g,h,i,j=(0,e.d)((0,e.d)({},a.payloadify.call(this,b,c)),{is_access_code_required:b.isAccessCodeRequired,is_distinct:b.isDistinct,is_super:b.isSuper,is_broadcast:b.isBroadcast,is_exclusive:b.isExclusive,is_public:b.isPublic,is_discoverable:b.isDiscoverable,is_muted:b.myMutedState,is_push_enabled:b.isPushEnabled,unread_message_count:b.unreadMessageCount,unread_mention_count:b.unreadMentionCount,total_unread_thread_message_count:b.totalUnreadReplyCount,push_trigger_option:b.myPushTriggerOption,count_preference:b.myCountPreference,hidden_state:b.hiddenState,member_count:b.memberCount,joined_member_count:b.joinedMemberCount,member_state:b.myMemberState,my_role:b.myRole,user_last_read:b.myLastRead,ts_message_offset:b.messageOffsetTimestamp,message_survival_seconds:b.messageSurvivalSeconds,read_receipt:b.cachedUnreadMemberState,delivery_receipt:b.cachedUndeliveredMemberState,members:b.members.map(function(a){return A.payloadify(a)}),last_message:b.lastMessage?(0,f.aJ)(b.lastMessage):null,inviter:b.inviter?e.U.payloadify(b.inviter):null,invited_at:b.invitedAt,joined_ts:b.joinedAt,latest_pinned_message:b.lastPinnedMessage?(0,f.aJ)(b.lastPinnedMessage):null,latest_message:b._latestMessageInfo?{message_id:b._latestMessageInfo.messageId,created_at:b._latestMessageInfo.createdAt}:null,has_bot:null===(d=b._aiAgentAdditionalData)|| void 0===d?void 0:d.hasBot,has_ai_bot:null===(g=b._aiAgentAdditionalData)|| void 0===g?void 0:g.hasAIBot,is_desk_channel:null===(h=b._aiAgentAdditionalData)|| void 0===h?void 0:h.isDesk,is_ai_agent_channel:null===(i=b._aiAgentAdditionalData)|| void 0===i?void 0:i.isAIAgent,message_purge_offset:b.messageDeletionTimestamp,conversation:b.conversation?bW.payloadify(b.conversation):null,helpdesk_info:b.helpdeskInfo?b7.payloadify(b.helpdeskInfo):null});return c?j:(0,e.f)((0,e.g)(j))},b.prototype._shouldUpdateLastMessageWith=function(a){if(a.silent)return!1;var b=e.V.of(this._iid).appInfo;switch(null==b?void 0:b.lastMessageThreadingPolicy){case e.af.NONE:case e.af.INCLUDE_REPLY:break;case e.af.EXCLUDE_REPLY:if(a.parentMessageId>0)return!1;break;case e.af.INCLUDE_REPLY_TO_CHANNEL:if(a instanceof f.az&&a.parentMessageId>0&&!a.replyToChannel)return!1}return!this.lastMessage||this.lastMessage.createdAt0)return!1;break;case e.ak.INCLUDE_REPLY_TO_CHANNEL:if(a instanceof f.az&&a.parentMessageId>0&&!a.replyToChannel)return!1}return!0},b.prototype._updateLastMessage=function(a){return!!this._shouldUpdateLastMessageWith(a)&&(this.lastMessage=a,!0)},b.prototype._updateUnreadCount=function(a,b){if("number"==typeof a&&a>=0){if(this.myCountPreference===bS.ALL||this.myCountPreference===bS.UNREAD_MESSAGE_COUNT_ONLY){if(this.isExclusive||this.isSuper||this.isBroadcast){var c=e.V.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=c&&a>=c?c:a}else this.unreadMessageCount=a}else this.unreadMessageCount=0}else this.unreadMessageCount=0;"number"==typeof b&&b>=0&&(this.myCountPreference===bS.ALL||this.myCountPreference===bS.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=b:this.unreadMentionCount=0},b.prototype._updateUnreadMemberState=function(a,b,c){void 0===c&&(c=!1);var d=this._unreadMemberStateMap.get(a);return!!(!d||c|| !c&&d0?this._typingStatus.set(a.userId,{user:a,ts:b}):this._typingStatus.delete(a.userId)},b.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},b.prototype._update=function(b){b._typingStatus=this._typingStatus,b._typingStarted=this._typingStarted,b._typingEnded=this._typingEnded,a.prototype._update.call(this,b)},b.prototype._setLatestMemberCount=function(a,b,c){var d=!1;return c>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=c,d=a!==this.memberCount||b!==this.joinedMemberCount,this.memberCount=a,this.joinedMemberCount=b),d},b.prototype.isReadMessage=function(a){var b=e.V.of(this._iid).sdkState,c=this._unreadMemberStateMap.get(b.userId);return!!c&&c>=a.createdAt},b.prototype.serialize=function(){var a=this;return(0,e.aM)(this,function(b){b.cachedUnreadMemberState=a.cachedUnreadMemberState,b.cachedUndeliveredMemberState=a.cachedUndeliveredMemberState,Object.assign(b,a._serializeCachedMetaData())})},b.prototype.createMessageCollection=function(a){return void 0===a&&(a={}),new bg(this._iid,(0,e.d)((0,e.d)({},a),{channel:this}))},b.prototype.createMemberListQuery=function(a){return void 0===a&&(a={}),new bl(this._iid,this.url,a)},b.prototype.createThreadedParentMessageListQuery=function(a){return void 0===a&&(a={}),new h.T(this._iid,this.url,this.channelType,a)},b.prototype.addMember=function(a,b){if(void 0===b&&(b=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var c=this.members.findIndex(function(b){return b.userId===a.userId});if(c> -1){var d=this.members[c];d.state===j.JOINED&&(a.state=d.state),this.members.splice(c,1),this.memberCount--}this.members.push(a),this.memberCount++,this._updateUnreadMemberState(a.userId,b),this._updateUndeliveredMemberState(a.userId,b)}},b.prototype.removeMember=function(a){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var b=a instanceof A?a.userId:a,c=this.members.findIndex(function(a){return a.userId===b});if(c> -1)return this.members.splice(c,1),this.memberCount--,!0}return!1},b.prototype.getUnreadMemberCount=function(a){var b,c;if(a instanceof f.az&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var d=e.V.of(this._iid).sdkState,g=a.createdAt,h=0;try{for(var i=(0,e.x)(this.members),k=i.next();!k.done;k=i.next()){var l=k.value;d.userId!==l.userId&&l.state===j.JOINED&&a.sender.userId!==l.userId&&(this.cachedUnreadMemberState[l.userId]||0)=a.createdAt&&h.push(e)}}),h},b.prototype.getUnreadMembers=function(a,b){var c=this;void 0===b&&(b=!1);var d=e.V.of(this._iid).sdkState;if(!d.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var g=a instanceof f.az?a.sender:null,h=[];return this.members.forEach(function(e){if(b||e.userId!==d.userId&&e.userId!==(null==g?void 0:g.userId)){var f=c._unreadMemberStateMap.get(e.userId);f&&f=b&&(a._typingStatus.delete(f),d=!0)}),d},b.prototype.refresh=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(a){return[2,this._refresh()]})})},b.prototype._refresh=function(a){return void 0===a&&(a=!1),(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h;return(0,e.b)(this,function(i){switch(i.label){case 0:return c=(b=e.V.of(this._iid)).requestQueue,d=b.dispatcher,f=new $({channelUrl:this.url}),[4,c.send(f)];case 1:return h=(g=i.sent()).as(_).channel,this._update(h),a||d.dispatch(new J({channels:[h],context:{source:e.ab.REFRESH_CHANNEL}})),[2,this]}})})},b.prototype.freeze=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,a.prototype.freeze.call(this)];case 1:return b.sent(),e.V.of(this._iid).dispatcher.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_FROZEN},isWebSocketEventComing:!0})),[2]}})})},b.prototype.unfreeze=function(){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(b){switch(b.label){case 0:return[4,a.prototype.unfreeze.call(this)];case 1:return b.sent(),e.V.of(this._iid).dispatcher.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_UNFROZEN},isWebSocketEventComing:!0})),[2]}})})},b.prototype.updateChannel=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:var k;return b=(0,e.d)((0,e.d)({},bh),a),(0,e.p)((k=b,(0,e.a)("string",k.coverUrl,!0)&&((0,e.i)(k.coverImage)||(0,e.a)("string",k.coverImage,!0))&&(0,e.a)("boolean",k.isDistinct,!0)&&(0,e.a)("boolean",k.isPublic,!0)&&(0,e.a)("boolean",k.isDiscoverable,!0)&&(0,e.a)("string",k.accessCode,!0)&&(0,e.a)("string",k.name,!0)&&(0,e.a)("string",k.data,!0)&&(0,e.a)("string",k.customType,!0)&&(0,e.a2)("string",k.operatorUserIds,!0)&&(0,e.a)("number",k.messageSurvivalSeconds,!0))).throw(e.q.invalidParameters),c=e.V.of(this._iid),d=c.dispatcher,f=c.requestQueue,g=new bo((0,e.d)({channelUrl:this.url},b)),[4,f.send(g)];case 1:return i=(h=j.sent()).as(bp).channel,this._update(i),d.dispatch(new J({channels:[i],context:{source:e.ab.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,this]}})})},b.prototype.invite=function(a){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(b){return(0,e.p)(a.every(function(a){return a instanceof e.U})).throw(e.q.invalidParameters),[2,this.inviteWithUserIds(a.map(function(a){return a.userId}))]})})},b.prototype.inviteWithUserIds=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:return(0,e.p)((0,e.a2)("string",a)).throw(e.q.invalidParameters),c=(b=e.V.of(this._iid)).dispatcher,d=b.requestQueue,f=b.sessionManager,g=new ay({channelUrl:this.url,userIds:a}),[4,d.send(g)];case 1:return i=(h=j.sent()).as(az).channel,this._update(i),c.dispatch(new J({channels:[i],context:{source:e.ab.EVENT_CHANNEL_INVITED,inviter:f.currentUser,invitees:[]},isWebSocketEventComing:!0})),[2,this]}})})},b.prototype.join=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i;return(0,e.b)(this,function(k){switch(k.label){case 0:return(0,e.p)((0,e.a)("string",a,!0)).throw(e.q.invalidParameters),c=(b=e.V.of(this._iid)).dispatcher,d=b.sdkState,f=b.requestQueue,g=new as({channelUrl:this.url,userId:d.userId,accessCode:a}),[4,f.send(g)];case 1:return(i=(h=k.sent()).as(at).channel).myMemberState=this.myMemberState=j.JOINED,this._update(i),c.dispatch(new J({channels:[i],context:{source:e.ab.EVENT_CHANNEL_JOINED,users:[]},isWebSocketEventComing:!0})),[2,this]}})})},b.prototype.leave=function(a){return void 0===a&&(a=!1),(0,e._)(this,void 0,void 0,function(){var b,c,d,f;return(0,e.b)(this,function(g){switch(g.label){case 0:return c=(b=e.V.of(this._iid)).sdkState,d=b.requestQueue,f=new av({channelUrl:this.url,userId:c.userId,shouldRemoveOperatorStatus:a}),[4,d.send(f)];case 1:return g.sent(),this.myMemberState=j.NONE,[2]}})})},b.prototype.acceptInvitation=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i;return(0,e.b)(this,function(k){switch(k.label){case 0:return(0,e.p)((0,e.a)("string",a,!0)).throw(e.q.invalidParameters),c=(b=e.V.of(this._iid)).dispatcher,d=b.sdkState,f=b.requestQueue,g=new bm({channelUrl:this.url,userId:d.userId,accessCode:a}),[4,f.send(g)];case 1:return(i=(h=k.sent()).as(bn).channel).myMemberState=this.myMemberState=j.JOINED,this._update(i),c.dispatch(new J({channels:[i],context:{source:e.ab.EVENT_CHANNEL_ACCEPTED_INVITE},isWebSocketEventComing:!0})),[2,this]}})})},b.prototype.declineInvitation=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d;return(0,e.b)(this,function(f){switch(f.label){case 0:return b=(a=e.V.of(this._iid)).sdkState,c=a.requestQueue,d=new aB({channelUrl:this.url,userId:b.userId}),[4,c.send(d)];case 1:return f.sent(),this.myMemberState=j.NONE,[2,this]}})})},b.prototype.sendUserMessage=function(b){var c=this,d=new f.$,h=e.V.of(this._iid).dispatcher,i=g.A.of(this._iid);return a.prototype.sendUserMessage.call(this,b).onPending(function(a){i.completeCurrentAndProcessNextAutoResend(a),d._trigger(a)}).onFailed(function(a,b){b&&i.completeCurrentAndProcessNextAutoResend(b),d._triggerFailed(a,b)}).onSucceeded(function(a){i.completeCurrentAndProcessNextAutoResend(a),c._updateLastMessage(a),a$.of(c._iid).handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(c)}),h.dispatch(new J({channels:[c],context:{source:e.ab.EVENT_MESSAGE_SENT}})),d._trigger(a)}),d},b.prototype.updateUserMessage=function(b,c){return(0,e._)(this,void 0,void 0,function(){var d,f,g,h,i=this;return(0,e.b)(this,function(j){switch(j.label){case 0:return d=e.V.of(this._iid).dispatcher,[4,a.prototype.updateUserMessage.call(this,b,c)];case 1:return f=j.sent(),g=this._updateLastMessage(f),h=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===f.messageId&&(this.lastPinnedMessage=f,g=!0,h=!0),g&&(a$.of(this._iid).handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(i)}),d.dispatch(new J({channels:[this],context:{source:h?e.ab.EVENT_PINNED_MESSAGE_UPDATED:e.ab.EVENT_MESSAGE_UPDATED}}))),h&&a$.of(this._iid).handlers.map(function(a){a.onPinnedMessageUpdated&&a.onPinnedMessageUpdated(i)}),d.dispatch(new e.aP({messages:[f],source:e.ab.EVENT_MESSAGE_UPDATED})),[2,f]}})})},b.prototype._autoResendUserMessage=function(b){var c=this,d=new f.$,h=e.V.of(this._iid).dispatcher,i=g.A.of(this._iid);return a.prototype._autoResendUserMessage.call(this,b).onPending(function(a){i.completeCurrentAndProcessNextAutoResend(a),d._trigger(a)}).onFailed(function(a,b){i.completeCurrentAndProcessNextAutoResend(b),d._triggerFailed(a,b)}).onSucceeded(function(a){var b=a$.of(c._iid);i.completeCurrentAndProcessNextAutoResend(a),c._updateLastMessage(a),b.handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(c)}),h.dispatch(new J({channels:[c],context:{source:e.ab.EVENT_MESSAGE_SENT}})),d._trigger(a)}),d},b.prototype.sendFileMessage=function(b){var c=this,d=new f.$,h=e.V.of(this._iid).dispatcher,i=g.A.of(this._iid);return a.prototype.sendFileMessage.call(this,b).onPending(function(a){i.completeCurrentAndProcessNextAutoResend(a),d._trigger(a)}).onFailed(function(a,b){b&&i.completeCurrentAndProcessNextAutoResend(b),d._triggerFailed(a,b)}).onSucceeded(function(a){var b=a$.of(c._iid);i.completeCurrentAndProcessNextAutoResend(a),c._updateLastMessage(a),b.handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(c)}),h.dispatch(new J({channels:[c],context:{source:e.ab.EVENT_MESSAGE_SENT}})),d._trigger(a)}),d},b.prototype.sendMultipleFilesMessage=function(b){var c=this,d=new f.a2,g=e.V.of(this._iid).dispatcher;return a.prototype.sendMultipleFilesMessage.call(this,b).onPending(function(a){d._trigger(a)}).onFailed(function(a,b){d._triggerFailed(a,b)}).onSucceeded(function(a){var b=a$.of(c._iid);c._updateLastMessage(a),b.handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(c)}),g.dispatch(new J({channels:[c],context:{source:e.ab.EVENT_MESSAGE_SENT}})),d._trigger(a)}).onFileUploaded(function(a,b,c,e){d._triggerOnFileUploaded(a,b,c,e)}),d},b.prototype.updateFileMessage=function(b,c){return(0,e._)(this,void 0,void 0,function(){var d,f,g,h,i=this;return(0,e.b)(this,function(j){switch(j.label){case 0:return d=e.V.of(this._iid).dispatcher,[4,a.prototype.updateFileMessage.call(this,b,c)];case 1:return f=j.sent(),g=this._updateLastMessage(f),h=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===f.messageId&&(this.lastPinnedMessage=f,g=!0,h=!0),g&&(a$.of(this._iid).handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(i)}),d.dispatch(new J({channels:[this],context:{source:h?e.ab.EVENT_PINNED_MESSAGE_UPDATED:e.ab.EVENT_MESSAGE_UPDATED}}))),h&&a$.of(this._iid).handlers.map(function(a){a.onPinnedMessageUpdated&&a.onPinnedMessageUpdated(i)}),d.dispatch(new e.aP({messages:[f],source:e.ab.EVENT_MESSAGE_UPDATED})),[2,f]}})})},b.prototype._autoResendFileMessage=function(b){var c=this,d=new f.$,h=e.V.of(this._iid).dispatcher,i=g.A.of(this._iid);return a.prototype._autoResendFileMessage.call(this,b).onPending(function(a){i.completeCurrentAndProcessNextAutoResend(a),d._trigger(a)}).onFailed(function(a,b){i.completeCurrentAndProcessNextAutoResend(b),d._triggerFailed(a,b)}).onSucceeded(function(a){var b=a$.of(c._iid);i.completeCurrentAndProcessNextAutoResend(a),c._updateLastMessage(a),b.handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(c)}),h.dispatch(new J({channels:[c],context:{source:e.ab.EVENT_MESSAGE_SENT}})),d._trigger(a)}),d},b.prototype.deleteMessage=function(b){return(0,e._)(this,void 0,void 0,function(){return(0,e.b)(this,function(c){switch(c.label){case 0:return[4,a.prototype.deleteMessage.call(this,b)];case 1:return c.sent(),0===b.messageId&&b instanceof f.az&&e.V.of(this._iid).dispatcher.dispatch(new e.bg({reqId:b.reqId,source:e.ab.EVENT_MESSAGE_DELETED})),[2]}})})},b.prototype.hide=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i,j;return(0,e.b)(this,function(k){switch(k.label){case 0:var l;return b=(0,e.d)((0,e.d)({},aE),a),(0,e.p)((l=b,(0,e.a)("boolean",l.hidePreviousMessages,!0)&&(0,e.a)("boolean",l.allowAutoUnhide,!0))).throw(e.q.invalidParameters),c=e.V.of(this._iid),d=c.dispatcher,f=c.sdkState,g=c.requestQueue,h=new aF((0,e.d)({channelUrl:this.url,userId:f.userId},b)),[4,g.send(h)];case 1:return j=(i=k.sent()).as(aG).messageOffsetTimestamp,this.hiddenState=b.allowAutoUnhide?bT.HIDDEN_ALLOW_AUTO_UNHIDE:bT.HIDDEN_PREVENT_AUTO_UNHIDE,b.hidePreviousMessages&&this._updateUnreadCount(0,0),j&&(this.messageOffsetTimestamp=j),d.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_HIDDEN},isWebSocketEventComing:!0})),[2,this]}})})},b.prototype.unhide=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d;return(0,e.b)(this,function(f){switch(f.label){case 0:return b=(a=e.V.of(this._iid)).dispatcher,c=a.requestQueue,d=new bs({channelUrl:this.url}),[4,c.send(d)];case 1:return f.sent(),this.hiddenState=bT.UNHIDDEN,b.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_UNHIDDEN},isWebSocketEventComing:!0})),[2,this]}})})},b.prototype.delete=function(){return(0,e._)(this,void 0,void 0,function(){var a,b;return(0,e.b)(this,function(c){switch(c.label){case 0:return a=e.V.of(this._iid).requestQueue,b=new bq({channelUrl:this.url}),[4,a.send(b)];case 1:return c.sent(),[2]}})})},b.prototype.markAsRead=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,g,h,i,j=this;return(0,e.b)(this,function(k){switch(k.label){case 0:return b=(a=e.V.of(this._iid)).dispatcher,c=a.requestQueue,d=new f.aU({channelUrl:this.url}),[4,c.send(d)];case 1:return h=(g=k.sent()).as(f.ay).readStatus,this._updateUnreadMemberState(h.reader.userId,h.readAt),i=!1,(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),i=!0),a$.of(this._iid).handlers.map(function(a){i&&a.onChannelChanged&&a.onChannelChanged(j),a.onUserMarkedRead&&a.onUserMarkedRead(j,[h.reader.userId])}),b.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_READ,userIds:[h.reader.userId]}})),[2]}})})},b.prototype.markAsUnread=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,g,h,i,j,k,l,m,n,o,p=this;return(0,e.b)(this,function(q){switch(q.label){case 0:return c=(b=e.V.of(this._iid)).sdkState,d=b.dispatcher,g=b.requestQueue,h=new f.aW({channelUrl:this.url,channelType:this.channelType,messageId:a.messageId,userId:c.userId,isExcluded:!0,uniqueId:"read-".concat((0,e.u)())}),[4,g.send(h)];case 1:return k=(j=(i=q.sent()).as(f.aV)).readAt,l=j.unreadMessageCount,m=j.userId,n=j.isExcluded,o=j.totalUnreadCount,this._updateUnreadMemberState(m,k,n),this._updateUnreadCount(l,this.unreadMentionCount),d.dispatch(new e.O(o)),a$.of(this._iid).handlers.map(function(a){a.onChannelChanged&&a.onChannelChanged(p),a.onUserMarkedUnread&&a.onUserMarkedUnread(p,[m])}),d.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_UNREAD,userIds:[m]}})),[2]}})})},b.prototype.markAsDelivered=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d;return(0,e.b)(this,function(f){switch(f.label){case 0:return b=(a=e.V.of(this._iid)).sdkState,c=a.requestQueue,d=new aQ({channelUrl:this.url,userId:b.userId}),[4,c.send(d)];case 1:return f.sent(),[2]}})})},b.prototype.startTyping=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){switch(g.label){case 0:return b=(a=e.V.of(this._iid)).requestQueue,c=a.typingIndicatorThrottle,(d=(new Date).getTime())-this._typingStarted>=c?(this._typingStarted=d,this._typingEnded=0,f=new aI({channelUrl:this.url,time:this._typingStarted}),[4,b.send(f)]):[3,2];case 1:g.sent(),g.label=2;case 2:return[2]}})})},b.prototype.endTyping=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f;return(0,e.b)(this,function(g){switch(g.label){case 0:return b=(a=e.V.of(this._iid)).requestQueue,c=a.typingIndicatorThrottle,(d=(new Date).getTime())-this._typingEnded>=c?(this._typingStarted=0,this._typingEnded=d,f=new aK({channelUrl:this.url,time:this._typingStarted}),[4,b.send(f)]):[3,2];case 1:g.sent(),g.label=2;case 2:return[2]}})})},b.prototype.createScheduledUserMessage=function(a){a=(0,e.d)((0,e.d)({},f.aK),a),(0,e.p)((0,f.aL)(a)).throw(e.q.invalidParameters);var b=new f.$;return this._createScheduledUserMessage(a,b),b},b.prototype.updateScheduledUserMessage=function(a,b){return(0,e._)(this,void 0,void 0,function(){var c,d,g,h;return(0,e.b)(this,function(i){switch(i.label){case 0:var j;return c=(0,e.d)((0,e.d)({},bz),b),(0,e.p)((j=c,(0,f.aI)(j)&&(0,e.a)("number",j.scheduledAt,!0))).throw(e.q.invalidParameters),d=e.V.of(this._iid).requestQueue,g=new bC((0,e.d)({reqId:this._generateRequestId(),scheduledMessageId:a,channelType:this.channelType,channelUrl:this.url},c)),[4,d.send(g)];case 1:return[2,(h=i.sent()).as(f.aX).message]}})})},b.prototype.createScheduledFileMessage=function(a){var b=this;a=(0,e.d)((0,e.d)({},f.aM),a),(0,e.p)((0,f.aN)(a)).throw(e.q.invalidParameters);var c=Date.now(),d=this._generateRequestId(),g=new f.$;return(0,e.aU)(f.aY).then(function(){var f=b._createPendingScheduledFileMessage(a,d,c);(0,e.N)(function(){return(0,e._)(b,void 0,void 0,function(){return(0,e.b)(this,function(a){return[2,g._trigger(f)]})})})}),(0,e.i)(a.file)?this._uploadFileAndUpdateParams(a).then(function(){return b._createScheduledFileMessage(a,g,d,c)}):this._createScheduledFileMessage(a,g,d,c),g},b.prototype.updateScheduledFileMessage=function(a,b){return(0,e._)(this,void 0,void 0,function(){var c,d,g;return(0,e.b)(this,function(h){switch(h.label){case 0:var i;return c=(0,e.d)((0,e.d)({},by),b),(0,e.p)((i=c,(0,f.aG)(i)&&(0,e.a)("number",i.scheduledAt,!0)&&((0,e.i)(i.file)||(0,e.a)("string",i.fileUrl))&&(0,e.a)("string",i.fileName,!0)&&(0,e.a)("string",i.mimeType,!0)&&(0,e.a)("number",i.fileSize,!0)&&(null===i.thumbnailSizes|| void 0===i.thumbnailSizes||i.thumbnailSizes.every(function(a){return(0,e.a)("object",a)&&a.maxWidth>0&&a.maxHeight>0})))).throw(e.q.invalidParameters),(0,e.i)(c.file)?[4,this._uploadFileAndUpdateParams(c)]:[3,2];case 1:h.sent(),h.label=2;case 2:return d=new bA((0,e.d)({reqId:this._generateRequestId(),scheduledMessageId:a,channelType:this.channelType,channelUrl:this.url},c)),[4,e.V.of(this._iid).requestQueue.send(d)];case 3:return[2,(g=h.sent()).as(bB).message]}})})},b.prototype.cancelScheduledMessage=function(a){return(0,e._)(this,void 0,void 0,function(){var b;return(0,e.b)(this,function(c){switch(c.label){case 0:return b=new bH({scheduledMessageId:a,channelType:this.channelType,channelUrl:this.url}),[4,e.V.of(this._iid).requestQueue.send(b)];case 1:return c.sent(),[2]}})})},b.prototype.sendScheduledMessageNow=function(a){return(0,e._)(this,void 0,void 0,function(){var b;return(0,e.b)(this,function(c){switch(c.label){case 0:return b=new bI({scheduledMessageId:a,channelType:this.channelType,channelUrl:this.url}),[4,e.V.of(this._iid).requestQueue.send(b)];case 1:return c.sent(),[2]}})})},b.prototype.getMyPushTriggerOption=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f,g;return(0,e.b)(this,function(h){switch(h.label){case 0:return b=(a=e.V.of(this._iid)).sdkState,c=a.requestQueue,d=new bL({userId:b.userId,channelUrl:this.url}),[4,c.send(d)];case 1:return g=(f=h.sent()).as(bM).pushTriggerOption,this.myPushTriggerOption=g,[2,g]}})})},b.prototype.setMyPushTriggerOption=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:return(0,e.p)((0,e.a5)(e.a8,a)).throw(e.q.invalidParameters),c=(b=e.V.of(this._iid)).dispatcher,d=b.sdkState,f=b.requestQueue,g=new bJ({userId:d.userId,channelUrl:this.url,pushTriggerOption:a}),[4,f.send(g)];case 1:return i=(h=j.sent()).as(bK).pushTriggerOption,this.myPushTriggerOption=i,c.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,i]}})})},b.prototype.setMyCountPreference=function(a){return(0,e._)(this,void 0,void 0,function(){var b,c,d,f,g,h,i;return(0,e.b)(this,function(j){switch(j.label){case 0:return(0,e.p)((0,e.a5)(bS,a)).throw(e.q.invalidParameters),c=(b=e.V.of(this._iid)).dispatcher,d=b.sdkState,f=b.requestQueue,g=new bu({channelUrl:this.url,userId:d.userId,countPreference:a}),[4,f.send(g)];case 1:return i=(h=j.sent()).as(bv).countPreference,this.myCountPreference=i,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),c.dispatch(new J({channels:[this],context:{source:e.ab.EVENT_CHANNEL_UPDATED},isWebSocketEventComing:!0})),[2,i]}})})},b.prototype.resetMyHistory=function(){return(0,e._)(this,void 0,void 0,function(){var a,b,c,d,f,g;return(0,e.b)(this,function(h){switch(h.label){case 0:return b=(a=e.V.of(this._iid)).dispatcher,c=a.requestQueue,d=new bw({channelUrl:this.url}),[4,c.send(d)];case 1:return g=(f=h.sent()).as(bx).messageOffsetTimestamp,this.messageOffsetTimestamp=g,this.lastMessage&&this.lastMessage.createdAt