diff --git a/CHANGELOG.md b/CHANGELOG.md index 0035941..fa47838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,57 @@ # Changelog +## v4.9.8 (Aug 9, 2023) +### **Features** +- Added `BaseChannel.copyMessage()` that supports user, file, and multiple files message +- Added `BaseChannel.resendMessage()` that supports user, file, and multiple files message + +```typescript +// Copy a succeeded multiple files message. +channelA.copyMessage(channelB, multipleFilesMessageToCopy) + .onPending((message: MultipleFilesMessage) => { + // ... + }) + .onFailed((err: SendbirdError, message: MultipleFilesMessage) => { + // ... + }) + .onSucceeded((message: MultipleFilesMessage) => { + // ... + }); + +// Resend a failed or canceled multiple files message. +channel.resendMessage(failedOrCanceledMultipleFilesMessage) + .onPending((message: MultipleFilesMessage) => { + // ... + }) + .onFailed((err: SendbirdError, message: MultipleFilesMessage) => { + // ... + }) + .onSucceeded((message: MultipleFilesMessage) => { + // ... + }) + .onFileUploaded(( + requestId: string, + index: number, + uploadableFileInfo: UploadableFileInfo, + err?: Error + ) => { + // ... + }); +``` + +### **Deprecated** +- Deprecated `BaseChannel.copyUserMessage()` +- Deprecated `BaseChannel.copyFileMessage()` +- Deprecated `BaseChannel.resendUserMessage()` +- Deprecated `BaseChannel.resendFileMessage()` + +### **Improvements** +- Changed `MessageHandler`, `FailedMessageHandler`, `MessageRequestHandler`, and `MultipleFilesMessageRequestHandler` to have generic message type +- Fixed the bug where reply messages were not being automatically resent +- Fixed the bug where initializing the message collection without result handler throws an error +- Fixed the bug where message collection updating the left group channel +- Added `createdAfter` and `createdBefore` filters in `GroupChannelListQuery` + ## v4.9.7 (Aug 3, 2023) ### **Improvements** - Fixed a bug where `HugeGabCheck` in `MessageCollection` has missed some filters diff --git a/cjs/feedChannel.js b/cjs/feedChannel.js index 72189d7..3f6e3dc 100644 --- a/cjs/feedChannel.js +++ b/cjs/feedChannel.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-c176c59f.js"),n=require("./lib/__bundle-a4005096.js"),t=require("./lib/__bundle-218bea1d.js"),s=require("./lib/__bundle-4bc3a029.js"),a=require("./lib/__bundle-86b43237.js"),i=require("./lib/__bundle-617167af.js"),r=require("./lib/__bundle-7ee4a5eb.js");require("./lib/__bundle-f5cc59df.js");class o extends e.InstancedObject{constructor(e,{sdkState:n,cacheContext:t,channelManager:s}){super(e),this._channels=new Map,this._sdkState=n,this._cacheContext=t,this._channelManager=s}get collection(){const{nestdb:n}=this._cacheContext;return e.unless(!!n).throw(e.SendbirdError.databaseError),n.collection(s.NESTDB_FEEDCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,n=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:n})}_deserialize(e){return this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(n){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(n))return this._channels.get(n);if(this.localCacheEnabled){const e=yield this.collection.getByKey(n);if(e)return this._channels.set(n,this._deserialize(e)),this._channels.get(n)}}))}fetch({token:n,limit:t=s.DEFAULT_FEED_LIMIT,backward:i=!1,order:r="latest_last_message",borderlineChannelUrl:o}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(n&&"latest_last_message"===r){if(!i&&e.lastMessageUpdatedAt>n||i&&e.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=[];if(n.forEach((n=>{if(this._channels.has(n.url)){const s=this._channels.get(n.url),a=e.deundefined(n);Object.assign(s,a,{_iid:this._iid}),t.push(s)}else this._channels.set(n.url,n),t.push(n)})),this.localCacheEnabled){const e=[];for(const n in t)e.push(this._serialize(t[n],parseInt(n)));yield this.collection.upsertMany(e)}return t}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)this._channels.delete(e),this.localCacheEnabled&&(yield this.collection.remove(e))}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this.clearMemoryCache(),this.localCacheEnabled&&(yield this.collection.clear())}))}clearMemoryCache(){this._channels.clear()}}const d=!1;class l extends e.APIRequestCommand{constructor(n){super();const{userId:t,token:s,limit:a,includeEmpty:i}=n;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=e.deundefined({token:s,limit:a,show_empty:null!=i?i:d,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class h extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:s,ts:a}=n;this.token=t,this.ts=null!=a?a:0,this.channels=(null!=s?s:[]).map((n=>(n.ts=a,new T(e,n))))}}class c{constructor({feedChannelCache:n,messageCache:s,unsentMessageCache:a,dispatcher:r}){this._observers=new Map,r.on((r=>e.__awaiter(this,void 0,void 0,(function*(){if(r instanceof t.FeedChannelUpdateEventCommand){const{channels:e,source:t,isWebSocketEventComing:s,data:a}=r,i=e.filter((e=>e instanceof T)),o=yield n.upsert(i);s||this._broadcastUpdateEvent(o,t,a)}else if(r instanceof t.FeedChannelRemoveEventCommand){const{channelUrls:t,source:i,isWebSocketEventComing:o}=r;yield n.remove(t),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)yield s.removeMessagesOfChannel(e),yield a.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(t,i)}else r instanceof i.DatabaseOpenCommand&&(yield n.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,n,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,n,t)}_broadcastRemoveEvent(e,n){for(const t of this._observers.values())t.onRemove&&t.onRemove(e,n)}subscribe(e,n){this._observers.set(e,n)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class u extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(n)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class C extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}const _={includeEmpty:!0},m=n=>e.isTypeOf("boolean",n.includeEmpty);class p extends e.APIRequestCommand{constructor({userId:n,ts:t,token:s,params:a}){super();const{includeEmpty:i}=Object.assign(Object.assign({},_),a);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:i,change_ts:t||null,token:s}))}}class E extends e.APIResponseCommand{constructor(e,n){super(e,n),this.updatedChannels=n.updated.map((n=>new T(e,n))),this.deletedChannelUrls=n.deleted,this.hasMore=n.has_more,this.token=n.next}}class g extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class v extends e.APIResponseCommand{constructor(e,n){super(e,n),this.jsonString=JSON.stringify(n)}}const f=20;class b extends e.APIRequestCommand{constructor(n){const{reverse:t=!1,keys:s,limit:a=f,token:i}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:i,keys:s,limit:a,reverse:t,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class M extends e.APIResponseCommand{constructor(n,t){super(n,t);const{next:s,has_more:a=!1}=t,i=e.__rest(t,["next","has_more"]);this.nextToken=s,this.hasMore=a,this.notificationTemplateList={jsonString:JSON.stringify(i)}}}const y={reverse:!1,keys:void 0,limit:20};class I extends e.APIRequestCommand{constructor(n){const{key:t}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${t}`,this.params=e.deundefined({key:t})}}class U extends e.APIResponseCommand{constructor(e,n){super(e,n),this.jsonString=JSON.stringify(n)}}const S={};class A extends r.BaseChannelManager{constructor(n,t){var a;super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.FEED})),this._disableMack=!1,this._disableMack=null!==(a=t.disableMack)&&void 0!==a&&a,this._feedChannelHandlers=new Map,this._feedChannelCache=new o(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new c({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,messageCache:s.MessageCache.of(n),unsentMessageCache:s.UnsentMessageCache.of(n)}),this._dispatcher.on((n=>{n instanceof e.WebSocketEventCommand&&this._handleEvent(n)})),S[n]||(S[n]=this)}static of(n){return S[n]||(S[n]=new A(n,e.Vault.of(n))),S[n]}static clear(e){S[e]&&delete S[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(n){const t=e.deserialize(n);return new T(this._iid,T.payloadify(t))}addHandler(e,n){this._feedChannelHandlers.set(e,n)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(n,t,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new l(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:n,limit:s})),a=yield this._requestQueue.send(e),{channels:i,token:r}=a.as(h);return{channels:i,token:r}}))}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n,t)}))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters),null!==(t=yield this._feedChannelCache.get(n))&&void 0!==t?t:null}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const s=new u({channelUrl:n,isInternalCall:t}),a=yield this._requestQueue.send(s),{channel:i}=a.as(C),[r]=yield this.upsertChannelsToCache([i]);return r}))}getMyFeedChannelChangeLogs(n,s,a=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_),s);e.unless((e.isTypeOf("string",n)||e.isTypeOf("number",n))&&m(i)).throw(e.SendbirdError.invalidParameters);const r=new p(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,params:i})),o=yield this._requestQueue.send(r),{updatedChannels:d,deletedChannelUrls:l,hasMore:h,token:c}=o.as(E);return d.length>0&&this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:d,source:a})),l.length>0&&this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:l,source:a})),{updatedChannels:d,deletedChannelUrls:l,hasMore:h,token:c}}))}getTotalUnreadMessageCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.TotalUnreadMessageCountParamsDefault),n);e.unless(t.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:i}=e.Vault.of(this._iid),r=new t.GetTotalUnreadMessageCountRequestCommand({userId:a.userId,filter:s,includeFeedChannel:!0}),o=yield i.send(r),{unreadFeedCount:d=0}=o.as(t.GetTotalUnreadMessageCountResponseCommand);return d}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new g,n=yield this._requestQueue.send(e),{jsonString:t}=n.as(v);return{jsonString:t}}))}getNotificationTemplateListByToken(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},y),t);e.unless(e.isTypeOf("string",n)&&(n=>e.isTypeOf("boolean",n.reverse,!0)&&e.isArrayOf("string",n.keys,!0)&&e.isTypeOf("number",n.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const a=new b({token:n,keys:s.keys,reverse:s.reverse,limit:s.limit}),i=yield this._requestQueue.send(a),{hasMore:r,nextToken:o,notificationTemplateList:d}=i.as(M);return{hasMore:r,token:o,notificationTemplateList:d}}))}getNotificationTemplate(n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const t=new I({key:n}),s=yield this._requestQueue.send(t),{jsonString:a}=s.as(U);return{jsonString:a}}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(n)}))}refreshChannel(n,s=!0,a=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new u({channelUrl:n,isInternalCall:s}),i=yield this._requestQueue.send(e),{channel:r}=i.as(C);if(r.myMemberState===t.MemberState.NONE)this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[r.url],source:a}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:e,source:a}))}}catch(s){s.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&s.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[n],source:a}))}}))}subscribeChannelEvent(e,n){this._feedChannelBroadcast.subscribe(e,n)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{const i="MESG"===a.code?a.as(n.UserMessageEventCommand):"FILE"===a.code?a.as(s.FileMessageEventCommand):"ADMM"===a.code||"BRDM"===a.code?a.as(r.AdminMessageEventCommand):null;if(i&&i.message.channelType===this._channelType){const{message:n,isMentioned:a,forceUpdateLastMessage:r}=i;this._disableMack||e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const e=new t.MessageAckCommand(n);this._requestQueue.send(e)}))));const o=yield this.getChannel(n.channelUrl,!0);o._runIfHandleableWithGroupChannel((i=>{var d;const l=this._feedChannelCache.isCachedInMemory(n.channelUrl),h=n instanceof s.SendableMessage&&n.sender.userId===this._sdkState.userId;if(i.hiddenState===t.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(i.hiddenState=t.HiddenState.UNHIDDEN),n instanceof s.SendableMessage){const{useMemberInfoInMessage:t}=e.Vault.of(this._iid);for(const e of i.members)if(e.userId===n.sender.userId){t||(n.sender.nickname=e.nickname,n.sender.plainProfileUrl=e.plainProfileUrl,n.sender.metaData=e.metaData,n.sender.isBlockedByMe=e.isBlockedByMe);break}if(!t&&a&&(null===(d=n.mentionedUsers)||void 0===d||d.forEach((e=>{for(const n of i.members)if(e.userId===n.userId){e.nickname=n.nickname,e.plainProfileUrl=n.plainProfileUrl,e.metaData=n.metaData;break}}))),h){const{currentUser:e}=this._sessionManager;e&&(e.nickname=n.sender.nickname,e.plainProfileUrl=n.sender.plainProfileUrl,e.metaData=n.sender.metaData)}}n.silent&&!h||(i.isEphemeral||l)&&((!i.lastMessage||i.lastMessage.createdAte.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(o)})))),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(o,n),a&&e.onMentionReceived&&e.onMentionReceived(o,n)}))))}))}break}case"MEDI":case"FEDI":case"AEDI":{const i="MEDI"===a.code?a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code?a.as(r.UpdateAdminMessageEventCommand):null;if(i&&i.message.channelType===this._channelType){const{message:n,mentionCountChange:a}=i,r=this._feedChannelCache.isCachedInMemory(n.channelUrl),o=yield this.getChannel(n.channelUrl,!0);o._runIfHandleableWithGroupChannel((i=>{const d=n instanceof s.SendableMessage&&n.sender.userId===this._sdkState.userId;let l=!1;if(d){const e=n.sender,{currentUser:t}=this._sessionManager;t&&(t.nickname=e.nickname,t.plainProfileUrl=e.plainProfileUrl,t.metaData=e.metaData)}else i.isReadMessage(n)||0!==a&&!n.silent&&r&&(i._updateUnreadCount(i.unreadMessageCount,i.unreadMentionCount+a),l=!0);!i.lastMessage||i.lastMessage.createdAte.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(o)}))))),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageUpdated&&e.onMessageUpdated(o,n),0!==a&&e.onMentionReceived&&e.onMentionReceived(o,n)}))))}))}break}case"DELM":{const t="DELM"===a.code?a.as(n.DeleteMessageEventCommand):null;if(t&&t.channelType===this._channelType){const{channelUrl:n,messageId:s}=t,a=yield this.getChannel(n,!0);this._dispatcher.dispatch(new e.MessageRemoveEventCommand({messageIds:[s],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageDeleted&&e.onMessageDeleted(a,s)}))))}break}case"READ":{const n="READ"===a.code?a.as(t.ReadEventCommand):null;if(n){const{readStatus:s}=n,a=this._feedChannelCache.isCachedInMemory(s.channelUrl),i=yield this.getChannel(s.channelUrl,!0);i._runIfHandleableWithGroupChannel((n=>{a&&n._updateUnreadMemberState(s.reader.userId,s.readAt),s.reader.userId===this._sdkState.userId?a?(n.unreadMessageCount>0||n.unreadMentionCount>0)&&(n._updateUnreadCount(0,0),this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[i],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==n.unreadMessageCount&&0!==n.unreadMentionCount||(this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[i],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):(this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[i],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(i)})))))}))}break}case"SYEV":{const n="SYEV"===a.code?a.as(r.ChannelEventCommand):null;if(n&&n.event.channelType===this._channelType){const{event:s}=n;switch(s.category){case r.ChannelEventCategory.CHANNEL_INVITE:{const n=yield this.getChannel(s.channelUrl,!0);n._runIfHandleableWithGroupChannel((i=>{const{memberCount:r,joinedMemberCount:o,invitees:d}=a.as(t.InviteToGroupChannelEventCommand);d.forEach((e=>e.state=t.MemberState.INVITED));for(const e of d)i.isExclusive||i.isSuper||i.isBroadcast?i._setLatestMemberCount(r,o,s.ts):i.addMember(e,s.ts),this._sdkState.userId===e.userId&&(i.hiddenState=t.HiddenState.UNHIDDEN,i.myMemberState!==t.MemberState.JOINED&&(i.myMemberState=t.MemberState.INVITED),i.invitedAt=s.ts);this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_INVITED}))}));break}case r.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const n=yield this.getChannel(s.channelUrl,!0);n._runIfHandleableWithGroupChannel((i=>{const{memberCount:r,joinedMemberCount:o,invitee:d}=a.as(t.DeclineInvitationEventCommand);i.isExclusive||i.isSuper||i.isBroadcast?i._setLatestMemberCount(r,o,s.ts):i.removeMember(d),this._sdkState.userId===d.userId?(i.invitedAt=0,i.myMemberState=t.MemberState.NONE,i.isPublic?this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[n.url],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))}));break}case r.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.channelUrl,!0);this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[s.channelUrl],source:e.CollectionEventSource.EVENT_CHANNEL_DELETED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case r.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}}}break}}}))}}class N extends t.BaseMessageCollection{constructor(e,n){super(e,Object.assign(Object.assign({},n),{channelManager:A.of(e)}))}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}}class T extends n.BaseChannel{static payloadify(e){var n;return Object.assign({},t.GroupChannel.payloadify(null!==(n=e._groupChannel)&&void 0!==n?n:e))}constructor(n,s){super(n,s),this.channelType=e.ChannelType.FEED,this._groupChannel=new t.GroupChannel(n,s)}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get lastMessage(){return this._groupChannel.lastMessage}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){return Object.assign({},this._groupChannel.serialize())}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:n,dispatcher:s,requestQueue:a}=e.Vault.of(this._iid),i=new t.ReadRequestCommand({channelUrl:this.url}),r=yield a.send(i),{readStatus:o}=r.as(t.ReadEventCommand);if(this._groupChannel._updateUnreadMemberState(n.userId,o.readAt),this._groupChannel.unreadMessageCount>0||this._groupChannel.unreadMentionCount>0){this._groupChannel._updateUnreadCount(0,0);A.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}s.dispatch(new t.FeedChannelUpdateEventCommand({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}))}createNotificationCollection(e={}){return new N(this._iid,Object.assign({channel:this},e))}}const w=["onUserMuted","onUserUnmuted","onUserBanned","onUserUnbanned","onChannelFrozen","onChannelUnfrozen","onOperatorUpdated","onMetaDataCreated","onMetaDataUpdated","onMetaDataDeleted","onMetaCounterCreated","onMetaCounterUpdated","onMetaCounterDeleted","onReactionUpdated","onThreadInfoUpdated"];class k extends r.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUnreadMemberStatusUpdated=e.noop,this.onUserMuted=e.noop,this.onUserUnmuted=e.noop,this.onUserBanned=e.noop,this.onUserUnbanned=e.noop,this.onChannelFrozen=e.noop,this.onChannelUnfrozen=e.noop,this.onOperatorUpdated=e.noop,this.onMetaDataCreated=e.noop,this.onMetaDataUpdated=e.noop,this.onMetaDataDeleted=e.noop,this.onMetaCounterCreated=e.noop,this.onMetaCounterUpdated=e.noop,this.onMetaCounterDeleted=e.noop,this.onReactionUpdated=e.noop,this.onThreadInfoUpdated=e.noop}}class D extends k{constructor(e={}){super(),Object.keys(e).forEach((n=>{Object.prototype.hasOwnProperty.call(this,n)&&-1===w.indexOf(n)&&(this[n]=e[n])}))}}class O extends e.BaseListQuery{constructor(e,n){var t;super(e,n),this.includeEmpty=d,this.includeEmpty=null!==(t=n.includeEmpty)&&void 0!==t?t:d}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const n=A.of(this._iid),t=e.undefineNullProps(Object.assign({},this)),{channels:s,token:a}=yield n.getMyFeedChannels(this._token,t,this.limit);return this._token=a,this._hasNext=!!a,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class P extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,n){super.init(e,n),this._manager=new A(e,n)}createMyFeedChannelListQuery(e={}){return new O(this._iid,e)}addFeedChannelHandler(n,t){e.unless(e.isTypeOf("string",n)&&t instanceof D).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(n,t)}removeFeedChannelHandler(n){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(n)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(n)}))}getMyFeedChannelChangeLogsByTimestamp(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},_),t);return e.unless(e.isTypeOf("number",n)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(n,s)}))}getMyFeedChannelChangeLogsByToken(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},_),t);return e.unless(e.isTypeOf("string",n)&&m(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(n,s)}))}getTotalUnreadMessageCount(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(n)}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(n,t)}))}getNotificationTemplate(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(n)}))}}exports.FeedChannelEventContext=t.FeedChannelEventContext,exports.NotificationEventContext=t.NotificationEventContext,exports.FeedChannel=T,exports.FeedChannelHandler=D,exports.FeedChannelListQuery=O,exports.FeedChannelModule=P,exports.NotificationCollection=N; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-26b86f4c.js"),n=require("./lib/__bundle-aae5735d.js"),t=require("./lib/__bundle-d5947f34.js"),s=require("./lib/__bundle-86b43237.js"),a=require("./lib/__bundle-82ee6f93.js"),i=require("./lib/__bundle-8e790a5a.js");require("./lib/__bundle-f6d4722d.js");class r extends e.InstancedObject{constructor(e,{sdkState:n,cacheContext:t,channelManager:s}){super(e),this._channels=new Map,this._sdkState=n,this._cacheContext=t,this._channelManager=s}get collection(){const{nestdb:t}=this._cacheContext;return e.unless(!!t).throw(e.SendbirdError.databaseError),t.collection(n.NESTDB_FEEDCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,n=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:n})}_deserialize(e){return this._channelManager.buildFeedChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}get(n){return e.__awaiter(this,void 0,void 0,(function*(){if(this._channels.has(n))return this._channels.get(n);if(this.localCacheEnabled){const e=yield this.collection.getByKey(n);if(e)return this._channels.set(n,this._deserialize(e)),this._channels.get(n)}}))}fetch({token:t,limit:a=n.DEFAULT_FEED_LIMIT,backward:i=!1,order:r="latest_last_message",borderlineChannelUrl:o}){return e.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const e={where:e=>{if(t&&"latest_last_message"===r){if(!i&&e.lastMessageUpdatedAt>t||i&&e.lastMessageUpdatedAtthis._deserialize(e)));return d.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),d}return[]}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=[];if(n.forEach((n=>{if(this._channels.has(n.url)){const s=this._channels.get(n.url),a=e.deundefined(n);Object.assign(s,a,{_iid:this._iid}),t.push(s)}else this._channels.set(n.url,n),t.push(n)})),this.localCacheEnabled){const e=[];for(const n in t)e.push(this._serialize(t[n],parseInt(n)));yield this.collection.upsertMany(e)}return t}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)this._channels.delete(e),this.localCacheEnabled&&(yield this.collection.remove(e))}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this.clearMemoryCache(),this.localCacheEnabled&&(yield this.collection.clear())}))}clearMemoryCache(){this._channels.clear()}}const o=!1;class d extends e.APIRequestCommand{constructor(n){super();const{userId:t,token:s,limit:a,includeEmpty:i}=n;this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=e.deundefined({token:s,limit:a,show_empty:null!=i?i:o,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"})}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:s,ts:a}=n;this.token=t,this.ts=null!=a?a:0,this.channels=(null!=s?s:[]).map((n=>(n.ts=a,new N(e,n))))}}class h{constructor({feedChannelCache:n,messageCache:s,unsentMessageCache:i,dispatcher:r}){this._observers=new Map,r.on((r=>e.__awaiter(this,void 0,void 0,(function*(){if(r instanceof t.FeedChannelUpdateEventCommand){const{channels:e,source:t,isWebSocketEventComing:s,data:a}=r,i=e.filter((e=>e instanceof N)),o=yield n.upsert(i);s||this._broadcastUpdateEvent(o,t,a)}else if(r instanceof t.FeedChannelRemoveEventCommand){const{channelUrls:t,source:a,isWebSocketEventComing:o}=r;yield n.remove(t),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of t)yield s.removeMessagesOfChannel(e),yield i.removeMessagesOfChannel(e)})))),o||this._broadcastRemoveEvent(t,a)}else r instanceof a.DatabaseOpenCommand&&(yield n.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,n,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,n,t)}_broadcastRemoveEvent(e,n){for(const t of this._observers.values())t.onRemove&&t.onRemove(e,n)}subscribe(e,n){this._observers.set(e,n)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class c extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_GROUP_CHANNELS_INTERNAL:e.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(n)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0}}}class u extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new N(e,n)}}const C={includeEmpty:!0},_=n=>e.isTypeOf("boolean",n.includeEmpty);class m extends e.APIRequestCommand{constructor({userId:n,ts:t,token:s,params:a}){super();const{includeEmpty:i}=Object.assign(Object.assign({},C),a);this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(n)}/my_group_channels/changelogs`,this.params=e.deundefined(e.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:i,change_ts:t||null,token:s}))}}class p extends e.APIResponseCommand{constructor(e,n){super(e,n),this.updatedChannels=n.updated.map((n=>new N(e,n))),this.deletedChannelUrls=n.deleted,this.hasMore=n.has_more,this.token=n.next}}class E extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/settings`}}class g extends e.APIResponseCommand{constructor(e,n){super(e,n),this.jsonString=JSON.stringify(n)}}const v=20;class f extends e.APIRequestCommand{constructor(n){const{reverse:t=!1,keys:s,limit:a=v,token:i}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates`,this.params=e.deundefined({token:i,keys:s,limit:a,reverse:t,order:"updated_at",show_ui_template:!0,show_color_variables:!0})}}class b extends e.APIResponseCommand{constructor(n,t){super(n,t);const{next:s,has_more:a=!1}=t,i=e.__rest(t,["next","has_more"]);this.nextToken=s,this.hasMore=a,this.notificationTemplateList={jsonString:JSON.stringify(i)}}}const M={reverse:!1,keys:void 0,limit:20};class y extends e.APIRequestCommand{constructor(n){const{key:t}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_NOTIFICATIONS}/templates/${t}`,this.params=e.deundefined({key:t})}}class I extends e.APIResponseCommand{constructor(e,n){super(e,n),this.jsonString=JSON.stringify(n)}}const U={};class S extends i.BaseChannelManager{constructor(t,s){var a;super(t,Object.assign(Object.assign({},s),{channelType:e.ChannelType.FEED})),this._disableMack=!1,this._disableMack=null!==(a=s.disableMack)&&void 0!==a&&a,this._feedChannelHandlers=new Map,this._feedChannelCache=new r(this._iid,{sdkState:this._sdkState,cacheContext:this._cacheContext,channelManager:this}),this._feedChannelBroadcast=new h({feedChannelCache:this._feedChannelCache,dispatcher:this._dispatcher,messageCache:n.MessageCache.of(t),unsentMessageCache:n.UnsentMessageCache.of(t)}),this._dispatcher.on((n=>{n instanceof e.WebSocketEventCommand&&this._handleEvent(n)})),U[t]||(U[t]=this)}static of(n){return U[n]||(U[n]=new S(n,e.Vault.of(n))),U[n]}static clear(e){U[e]&&delete U[e]}get handlers(){return[...this._feedChannelHandlers.values()]}buildFeedChannelFromSerializedData(n){const t=e.deserialize(n);return new N(this._iid,N.payloadify(t))}addHandler(e,n){this._feedChannelHandlers.set(e,n)}removeHandler(e){this._feedChannelHandlers.delete(e)}clearHandler(){this._feedChannelHandlers.clear()}getMyFeedChannels(n,t,s){return e.__awaiter(this,void 0,void 0,(function*(){const e=new d(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:n,limit:s})),a=yield this._requestQueue.send(e),{channels:i,token:r}=a.as(l);return{channels:i,token:r}}))}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n,t)}))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters),null!==(t=yield this._feedChannelCache.get(n))&&void 0!==t?t:null}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const s=new c({channelUrl:n,isInternalCall:t}),a=yield this._requestQueue.send(s),{channel:i}=a.as(u),[r]=yield this.upsertChannelsToCache([i]);return r}))}getMyFeedChannelChangeLogs(n,s,a=e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},C),s);e.unless((e.isTypeOf("string",n)||e.isTypeOf("number",n))&&_(i)).throw(e.SendbirdError.invalidParameters);const r=new m(e.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,params:i})),o=yield this._requestQueue.send(r),{updatedChannels:d,deletedChannelUrls:l,hasMore:h,token:c}=o.as(p);return d.length>0&&this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:d,source:a})),l.length>0&&this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:l,source:a})),{updatedChannels:d,deletedChannelUrls:l,hasMore:h,token:c}}))}getTotalUnreadMessageCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},t.TotalUnreadMessageCountParamsDefault),n);e.unless(t.validateTotalUnreadMessageCountParams(s)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:i}=e.Vault.of(this._iid),r=new t.GetTotalUnreadMessageCountRequestCommand({userId:a.userId,filter:s,includeFeedChannel:!0}),o=yield i.send(r),{unreadFeedCount:d=0}=o.as(t.GetTotalUnreadMessageCountResponseCommand);return d}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){const e=new E,n=yield this._requestQueue.send(e),{jsonString:t}=n.as(g);return{jsonString:t}}))}getNotificationTemplateListByToken(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},M),t);e.unless(e.isTypeOf("string",n)&&(n=>e.isTypeOf("boolean",n.reverse,!0)&&e.isArrayOf("string",n.keys,!0)&&e.isTypeOf("number",n.limit,!0))(s)).throw(e.SendbirdError.invalidParameters);const a=new f({token:n,keys:s.keys,reverse:s.reverse,limit:s.limit}),i=yield this._requestQueue.send(a),{hasMore:r,nextToken:o,notificationTemplateList:d}=i.as(b);return{hasMore:r,token:o,notificationTemplateList:d}}))}getNotificationTemplate(n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const t=new y({key:n}),s=yield this._requestQueue.send(t),{jsonString:a}=s.as(I);return{jsonString:a}}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._feedChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){yield this._feedChannelCache.remove(n)}))}refreshChannel(n,s=!0,a=e.CollectionEventSource.REFRESH_CHANNEL){return e.__awaiter(this,void 0,void 0,(function*(){try{const e=new c({channelUrl:n,isInternalCall:s}),i=yield this._requestQueue.send(e),{channel:r}=i.as(u);if(r.myMemberState===t.MemberState.NONE)this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[r.url],source:a}));else{const e=yield this.upsertChannelsToCache([r]);this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:e,source:a}))}}catch(s){s.code!==e.SendbirdErrorCode.NON_AUTHORIZED&&s.code!==e.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[n],source:a}))}}))}subscribeChannelEvent(e,n){this._feedChannelBroadcast.subscribe(e,n)}unsubscribeChannelEvent(e){this._feedChannelBroadcast.unsubscribe(e)}_handleEvent(s){return e.__awaiter(this,void 0,void 0,(function*(){switch(s.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{const a="MESG"===s.code?s.as(n.UserMessageEventCommand):"FILE"===s.code?s.as(n.FileMessageEventCommand):"ADMM"===s.code||"BRDM"===s.code?s.as(i.AdminMessageEventCommand):null;if(a&&a.message.channelType===this._channelType){const{message:s,isMentioned:i,forceUpdateLastMessage:r}=a;this._disableMack||e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){const e=new t.MessageAckCommand(s);this._requestQueue.send(e)}))));const o=yield this.getChannel(s.channelUrl,!0);o._runIfHandleableWithGroupChannel((a=>{var d;const l=this._feedChannelCache.isCachedInMemory(s.channelUrl),h=s instanceof n.SendableMessage&&s.sender.userId===this._sdkState.userId;if(a.hiddenState===t.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(a.hiddenState=t.HiddenState.UNHIDDEN),s instanceof n.SendableMessage){const{useMemberInfoInMessage:n}=e.Vault.of(this._iid);for(const e of a.members)if(e.userId===s.sender.userId){n||(s.sender.nickname=e.nickname,s.sender.plainProfileUrl=e.plainProfileUrl,s.sender.metaData=e.metaData,s.sender.isBlockedByMe=e.isBlockedByMe);break}if(!n&&i&&(null===(d=s.mentionedUsers)||void 0===d||d.forEach((e=>{for(const n of a.members)if(e.userId===n.userId){e.nickname=n.nickname,e.plainProfileUrl=n.plainProfileUrl,e.metaData=n.metaData;break}}))),h){const{currentUser:e}=this._sessionManager;e&&(e.nickname=s.sender.nickname,e.plainProfileUrl=s.sender.plainProfileUrl,e.metaData=s.sender.metaData)}}s.silent&&!h||(a.isEphemeral||l)&&((!a.lastMessage||a.lastMessage.createdAte.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(o)})))),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:e.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageReceived&&e.onMessageReceived(o,s),i&&e.onMentionReceived&&e.onMentionReceived(o,s)}))))}))}break}case"MEDI":case"FEDI":case"AEDI":{const a="MEDI"===s.code?s.as(n.UpdateUserMessageEventCommand):"FEDI"===s.code?s.as(n.UpdateFileMessageEventCommand):"AEDI"===s.code?s.as(i.UpdateAdminMessageEventCommand):null;if(a&&a.message.channelType===this._channelType){const{message:s,mentionCountChange:i}=a,r=this._feedChannelCache.isCachedInMemory(s.channelUrl),o=yield this.getChannel(s.channelUrl,!0);o._runIfHandleableWithGroupChannel((a=>{const d=s instanceof n.SendableMessage&&s.sender.userId===this._sdkState.userId;let l=!1;if(d){const e=s.sender,{currentUser:n}=this._sessionManager;n&&(n.nickname=e.nickname,n.plainProfileUrl=e.plainProfileUrl,n.metaData=e.metaData)}else a.isReadMessage(s)||0!==i&&!s.silent&&r&&(a._updateUnreadCount(a.unreadMessageCount,a.unreadMentionCount+i),l=!0);!a.lastMessage||a.lastMessage.createdAte.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(o)}))))),this._dispatcher.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageUpdated&&e.onMessageUpdated(o,s),0!==i&&e.onMentionReceived&&e.onMentionReceived(o,s)}))))}))}break}case"DELM":{const t="DELM"===s.code?s.as(n.DeleteMessageEventCommand):null;if(t&&t.channelType===this._channelType){const{channelUrl:n,messageId:s}=t,a=yield this.getChannel(n,!0);this._dispatcher.dispatch(new e.MessageRemoveEventCommand({messageIds:[s],source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onMessageDeleted&&e.onMessageDeleted(a,s)}))))}break}case"READ":{const n="READ"===s.code?s.as(t.ReadEventCommand):null;if(n){const{readStatus:s}=n,a=this._feedChannelCache.isCachedInMemory(s.channelUrl),i=yield this.getChannel(s.channelUrl,!0);i._runIfHandleableWithGroupChannel((n=>{a&&n._updateUnreadMemberState(s.reader.userId,s.readAt),s.reader.userId===this._sdkState.userId?a?(n.unreadMessageCount>0||n.unreadMentionCount>0)&&(n._updateUnreadCount(0,0),this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[i],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):0!==n.unreadMessageCount&&0!==n.unreadMentionCount||(this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[i],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(i)}))))):(this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[i],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._feedChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(i)})))))}))}break}case"SYEV":{const n="SYEV"===s.code?s.as(i.ChannelEventCommand):null;if(n&&n.event.channelType===this._channelType){const{event:a}=n;switch(a.category){case i.ChannelEventCategory.CHANNEL_INVITE:{const n=yield this.getChannel(a.channelUrl,!0);n._runIfHandleableWithGroupChannel((i=>{const{memberCount:r,joinedMemberCount:o,invitees:d}=s.as(t.InviteToGroupChannelEventCommand);d.forEach((e=>e.state=t.MemberState.INVITED));for(const e of d)i.isExclusive||i.isSuper||i.isBroadcast?i._setLatestMemberCount(r,o,a.ts):i.addMember(e,a.ts),this._sdkState.userId===e.userId&&(i.hiddenState=t.HiddenState.UNHIDDEN,i.myMemberState!==t.MemberState.JOINED&&(i.myMemberState=t.MemberState.INVITED),i.invitedAt=a.ts);this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_INVITED}))}));break}case i.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const n=yield this.getChannel(a.channelUrl,!0);n._runIfHandleableWithGroupChannel((i=>{const{memberCount:r,joinedMemberCount:o,invitee:d}=s.as(t.DeclineInvitationEventCommand);i.isExclusive||i.isSuper||i.isBroadcast?i._setLatestMemberCount(r,o,a.ts):i.removeMember(d),this._sdkState.userId===d.userId?(i.invitedAt=0,i.myMemberState=t.MemberState.NONE,i.isPublic?this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[n.url],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))}));break}case i.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(a.channelUrl,!0);this._dispatcher.dispatch(new t.FeedChannelRemoveEventCommand({channelUrls:[a.channelUrl],source:e.CollectionEventSource.EVENT_CHANNEL_DELETED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case i.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(a.channelUrl,!0);this._dispatcher.dispatch(new t.FeedChannelUpdateEventCommand({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._feedChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}}}break}}}))}}class A extends t.BaseMessageCollection{constructor(e,n){super(e,Object.assign(Object.assign({},n),{channelManager:S.of(e)}))}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}}class N extends n.BaseChannel{static payloadify(e){var n;return Object.assign({},t.GroupChannel.payloadify(null!==(n=e._groupChannel)&&void 0!==n?n:e))}constructor(n,s){super(n,s),this.channelType=e.ChannelType.FEED,this._groupChannel=new t.GroupChannel(n,s)}get groupChannel(){return this._groupChannel}get url(){return this._groupChannel.url}get name(){return this._groupChannel.name}set name(e){this._groupChannel.name=e}get createdAt(){return this._groupChannel.createdAt}get members(){return this._groupChannel.members}get memberCount(){return this._groupChannel.memberCount}get myMemberState(){return this._groupChannel.myMemberState}get myLastRead(){return this._groupChannel.myLastRead}get lastMessage(){return this._groupChannel.lastMessage}get unreadMessageCount(){return this._groupChannel.unreadMessageCount}serialize(){return Object.assign({},this._groupChannel.serialize())}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannel._refresh(!0),this}))}markAsRead(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:n,dispatcher:s,requestQueue:a}=e.Vault.of(this._iid),i=new t.ReadRequestCommand({channelUrl:this.url}),r=yield a.send(i),{readStatus:o}=r.as(t.ReadEventCommand);if(this._groupChannel._updateUnreadMemberState(n.userId,o.readAt),this._groupChannel.unreadMessageCount>0||this._groupChannel.unreadMentionCount>0){this._groupChannel._updateUnreadCount(0,0);S.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}s.dispatch(new t.FeedChannelUpdateEventCommand({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_READ}))}))}createNotificationCollection(e={}){return new A(this._iid,Object.assign({channel:this},e))}}const T=["onUserMuted","onUserUnmuted","onUserBanned","onUserUnbanned","onChannelFrozen","onChannelUnfrozen","onOperatorUpdated","onMetaDataCreated","onMetaDataUpdated","onMetaDataDeleted","onMetaCounterCreated","onMetaCounterUpdated","onMetaCounterDeleted","onReactionUpdated","onThreadInfoUpdated"];class w extends i.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUnreadMemberStatusUpdated=e.noop,this.onUserMuted=e.noop,this.onUserUnmuted=e.noop,this.onUserBanned=e.noop,this.onUserUnbanned=e.noop,this.onChannelFrozen=e.noop,this.onChannelUnfrozen=e.noop,this.onOperatorUpdated=e.noop,this.onMetaDataCreated=e.noop,this.onMetaDataUpdated=e.noop,this.onMetaDataDeleted=e.noop,this.onMetaCounterCreated=e.noop,this.onMetaCounterUpdated=e.noop,this.onMetaCounterDeleted=e.noop,this.onReactionUpdated=e.noop,this.onThreadInfoUpdated=e.noop}}class k extends w{constructor(e={}){super(),Object.keys(e).forEach((n=>{Object.prototype.hasOwnProperty.call(this,n)&&-1===T.indexOf(n)&&(this[n]=e[n])}))}}class D extends e.BaseListQuery{constructor(e,n){var t;super(e,n),this.includeEmpty=o,this.includeEmpty=null!==(t=n.includeEmpty)&&void 0!==t?t:o}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const n=S.of(this._iid),t=e.undefineNullProps(Object.assign({},this)),{channels:s,token:a}=yield n.getMyFeedChannels(this._token,t,this.limit);return this._token=a,this._hasNext=!!a,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="feedChannel"}init(e,n){super.init(e,n),this._manager=new S(e,n)}createMyFeedChannelListQuery(e={}){return new D(this._iid,e)}addFeedChannelHandler(n,t){e.unless(e.isTypeOf("string",n)&&t instanceof k).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(n,t)}removeFeedChannelHandler(n){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(n)}removeAllFeedChannelHandlers(){this._manager.clearHandler()}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(n)}))}getMyFeedChannelChangeLogsByTimestamp(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),t);return e.unless(e.isTypeOf("number",n)&&_(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(n,s)}))}getMyFeedChannelChangeLogsByToken(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},C),t);return e.unless(e.isTypeOf("string",n)&&_(s)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyFeedChannelChangeLogs(n,s)}))}getTotalUnreadMessageCount(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(n)}))}getGlobalNotificationChannelSetting(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getGlobalNotificationChannelSetting()}))}getNotificationTemplateListByToken(n,t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplateListByToken(n,t)}))}getNotificationTemplate(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getNotificationTemplate(n)}))}}exports.FeedChannelEventContext=t.FeedChannelEventContext,exports.NotificationEventContext=t.NotificationEventContext,exports.FeedChannel=N,exports.FeedChannelHandler=k,exports.FeedChannelListQuery=D,exports.FeedChannelModule=O,exports.NotificationCollection=A; diff --git a/cjs/groupChannel.js b/cjs/groupChannel.js index 7bffaad..bef5b4b 100644 --- a/cjs/groupChannel.js +++ b/cjs/groupChannel.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-c176c59f.js"),t=require("./lib/__bundle-218bea1d.js"),n=require("./lib/__bundle-617167af.js"),i=require("./lib/__bundle-7ee4a5eb.js"),r=require("./lib/__bundle-4bc3a029.js");require("./lib/__bundle-a4005096.js"),require("./lib/__bundle-f5cc59df.js");const s={};class a{constructor({_iid:i,limit:r=100}){this.ref=0,this._iid=i,this._limit=r;const{sdkState:s,dispatcher:a,logger:o,cacheContext:l}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/sync.meta`;const d=(e=>`sendbird:${e}@groupchannel/sync`)(s.userId);this._sync=new t.Sync(d,(()=>e.__awaiter(this,void 0,void 0,(function*(){var i,r,a,d;const h={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(i=this._metadata)||void 0===i?void 0:i.token),null===(r=this._metadata)||void 0===r?void 0:r.completed)h.hasNext=!1,h.nextToken="";else try{const i={includeEmpty:!0,order:n.GroupChannelListOrder.CHRONOLOGICAL};if(i.order===n.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));i.includeChatNotification=Boolean(t)}catch(e){i.includeChatNotification=!1}const r=t.GroupChannelManager.of(this._iid),{channels:u,token:c}=yield r.getMyGroupChannels(null!==(d=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==d?d:"",i,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);h.hasNext=u.length>=this._limit&&!!c,h.nextToken=c,this._metadata&&(this._metadata.token=c,this._metadata.range.extends(...u.map((e=>e.createdAt))),this._metadata.completed=!h.hasNext),o.debug("channel background sync progress",h),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}return h})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return s[e]||(s[e]=new a({_iid:e})),s[e].ref++,s[e]}static clear(e){s[e]&&(s[e].close(),delete s[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new i.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=e.Vault.of(this._iid),n=yield t.preference.get(this._metadataKey);this._metadata={token:n?n.token:"",range:new i.TimeRange(n?n.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!n&&n.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,connectionManager:r}=e.Vault.of(this._iid);r.isConnected&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete s[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:r,dispatcher:s,cacheContext:a}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/changelogs.meta`;const o=(e=>`sendbird:${e}@groupchannel/changelogs`)(r.userId);this._sync=new t.Sync(o,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,o;const l={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const d=t.GroupChannelManager.of(this._iid),{hasMore:h,token:u}=yield d.getMyGroupChannelChangeLogs(null!==(o=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==o?o:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);l.hasNext=h,l.nextToken=u,this._metadata&&(this._metadata.token=u),i.debug("channel changelog sync progress",l),yield this.saveMetadata()}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return l})))),this._connectionEventContext=s.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{connectionManager:t}=e.Vault.of(this._iid);t.isConnected&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let r=0,s=e.length-1,a=Math.floor((r+s)/2);for(;r0)s=a,a=Math.floor((r+s)/2);else{if(!(o<0))return{place:a,oldPosition:i};r=a+1,a=Math.floor((r+s)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,i)=>{switch(i){case n.GroupChannelListOrder.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case n.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case n.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(i,{filter:s,order:o,limit:d}){this.channels=[],this._iid=i,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=s?s:new t.GroupChannelFilter,this.order=null!=o?o:n.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=d?d:r.DEFAULT_GROUPCHANNEL_LIMIT;const{sdkState:h,cacheContext:u,dispatcher:c}=e.Vault.of(this._iid);u.localCacheEnabled&&(this._backgroundSync=a.of(i),this._backgroundSync.resume()),this._changelogSync=l.of(i),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{if(t.shouldGiveEvent(n)){const t=e.filter((e=>this.filter.match(e,h.userId))),i=e.filter((e=>!this.filter.match(e,h.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}});const{statLogCollector:p}=e.Vault.of(this._iid);p.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,i,r=!1){const s=[],a=[],o=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:l}=h(this.channels,t,this.order);if(n<0)l===this.channels.length?!r&&this._hasMore||(s.push(t),this.channels.push(t)):(s.push(t),this.channels.splice(l,0,t));else switch(i){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:l!==n&&this._hasMore&&l===this.channels.length?o.push(t):(this.channels.splice(l,0,t),a.push(t));break;default:this.channels.splice(l,0,t),a.push(t)}}if(o.length>0)for(const e of o){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(i)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,n,r;const l=new t.GroupChannelEventContext(i);s.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(l,s),a.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsUpdated)&&this._handler.onChannelsUpdated(l,a),o.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(l,o.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const r=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(r.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i)&&r.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;const n=new t.GroupChannelEventContext(i);(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,r)})))),r}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),i=this.channels.length>0?((e,t)=>{var i,r,s,a;switch(t){case n.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(r=null===(i=e.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==r?r:e.createdAt;case n.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case n.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(s=e.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(i,this.filter,this.order,this._limit,i?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:r}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{order:this.order})),this._limit);return this._token=r,this._hasMore=!!r,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,e.CollectionEventSource.REQUEST_CHANNEL,!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(this._hasMore){const{cacheContext:t,connectionManager:n}=e.Vault.of(this._iid);let i=[];if(!t.localCacheEnabled||n.isConnected&&!this._backgroundSync.completed)try{i=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){i=yield this._getLocalChannels()})))),this._hasMore=i.length>=this._limit;return this._addChannelsToView(i,e.CollectionEventSource.REQUEST_CHANNEL,!0),i}return[]}))}dispose(){var e,n;if(this._isDisposed)return;this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(n=this._changelogSync)||void 0===n||n.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:r,order:s,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:m,metadataValueStartsWith:g,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:r,order:s,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:m,metadata_value_startswith:g,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:r,ts:s}=n;this.token=i,r&&r.length>0&&(this.channels=r.map((n=>(n.ts=s,new t.GroupChannel(e,n))))),this.ts="number"==typeof s?s:0}}var m;exports.MembershipFilter=void 0,(m=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",m.JOINED="joined";class g extends e.BaseListQuery{constructor(e,i){var r,s,a,o,l,d,h,u,c,p,_,m,g,C;super(e,i),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.channelNameContainsFilter=null,this.membershipFilter=exports.MembershipFilter.ALL,this.superChannelFilter=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=n.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(r=i.includeEmpty)&&void 0!==r&&r,this.includeFrozen=null===(s=i.includeFrozen)||void 0===s||s,this.includeMetaData=null===(a=i.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=i.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=i.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=i.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=i.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=i.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=i.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=i.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=i.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(m=i.metadataOrderKeyFilter)&&void 0!==m?m:null,this.metadataValueStartsWith=null!==(g=i.metadataValueStartsWith)&&void 0!==g?g:null,this.order=null!==(C=i.order)&&void 0!==C?C:n.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(n.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t,dispatcher:n}=e.Vault.of(this._iid),i=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),r=yield t.send(i),{channels:s,token:a}=r.as(_);return this._token=a,this._hasNext=!!a,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends i.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class v extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:r,reverse:s,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:s,channel_url:a,order:r,message_type:o,status:l}))}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:n,scheduled_messages:i}=t;this.token=n,this.scheduledMessages=i.map((t=>r.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,r,s,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(r=n.order)&&void 0!==r?r:null,this.reverse=null!==(s=n.reverse)&&void 0!==s&&s,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(n.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(r.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new v(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:r,token:s}=i.as(y);return this._token=s,this._hasNext=!!s,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:r,requestQueue:s,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:r,requestQueue:s,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:r,requestQueue:s,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new g(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllGroupChannelHandlers(){this._manager.clearHandler()}buildGroupChannelFromSerializedData(e){return this._manager.buildGroupChannelFromSerializedData(e)}buildGroupChannelListQueryFromSerializedData(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}buildMemberFromSerializedData(e){return this._manager.buildMemberFromSerializedData(e)}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(r)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,r)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(r)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,r)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,r,s,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:r,data:a,customType:o});return"string"==typeof s?e.coverUrl=s:e.coverImage=s,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventContext=t.GroupChannelEventContext,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),exports.MessageEventContext=t.MessageEventContext,Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),exports.PinnedMessage=t.PinnedMessage,exports.PinnedMessageListQuery=t.PinnedMessageListQuery,Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),exports.ReadStatus=t.ReadStatus,Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return n.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return n.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return n.ScheduledMessageListOrder}}),exports.MessageFilter=r.MessageFilter,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return r.ScheduledStatus}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=g,exports.ScheduledMessageListQuery=b; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-26b86f4c.js"),t=require("./lib/__bundle-d5947f34.js"),n=require("./lib/__bundle-82ee6f93.js"),i=require("./lib/__bundle-8e790a5a.js"),r=require("./lib/__bundle-aae5735d.js");require("./lib/__bundle-f6d4722d.js");const s={};class a{constructor({_iid:i,limit:r=100}){this.ref=0,this._iid=i,this._limit=r;const{sdkState:s,dispatcher:a,logger:o,cacheContext:l}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/sync.meta`;const d=(e=>`sendbird:${e}@groupchannel/sync`)(s.userId);this._sync=new t.Sync(d,(()=>e.__awaiter(this,void 0,void 0,(function*(){var i,r,a,d;const h={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),o.debug("channel background sync from",null===(i=this._metadata)||void 0===i?void 0:i.token),null===(r=this._metadata)||void 0===r?void 0:r.completed)h.hasNext=!1,h.nextToken="";else try{const i={includeEmpty:!0,order:n.GroupChannelListOrder.CHRONOLOGICAL};if(i.order===n.GroupChannelListOrder.LATEST_LAST_MESSAGE)try{const t=yield l.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(s.appId));i.includeChatNotification=Boolean(t)}catch(e){i.includeChatNotification=!1}const r=t.GroupChannelManager.of(this._iid),{channels:u,token:c}=yield r.getMyGroupChannels(null!==(d=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==d?d:"",i,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);h.hasNext=u.length>=this._limit&&!!c,h.nextToken=c,this._metadata&&(this._metadata.token=c,this._metadata.range.extends(...u.map((e=>e.createdAt))),this._metadata.completed=!h.hasNext),o.debug("channel background sync progress",h),yield this.saveMetadata()}catch(t){throw o.debug("channel background sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetaData()),t}return h})))),this._connectionEventContext=a.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return s[e]||(s[e]=new a({_iid:e})),s[e].ref++,s[e]}static clear(e){s[e]&&(s[e].close(),delete s[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new i.TimeRange({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=e.Vault.of(this._iid),n=yield t.preference.get(this._metadataKey);this._metadata={token:n?n.token:"",range:new i.TimeRange(n?n.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!n&&n.completed}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var t,n;const{logger:i,connectionManager:r}=e.Vault.of(this._iid);r.isConnected&&(i.debug("channel background sync resume()"),this._sync.start(null!==(n=null===(t=this._metadata)||void 0===t?void 0:t.token)&&void 0!==n?n:""))}pause(){const{logger:t}=e.Vault.of(this._iid);t.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete s[this._iid])}}const o={};class l{constructor({_iid:n}){this.ref=0,this._iid=n;const{logger:i,sdkState:r,dispatcher:s,cacheContext:a}=e.Vault.of(this._iid);this._metadataKey=`sendbird:${r.userId}@groupchannel/changelogs.meta`;const o=(e=>`sendbird:${e}@groupchannel/changelogs`)(r.userId);this._sync=new t.Sync(o,(()=>e.__awaiter(this,void 0,void 0,(function*(){var n,s,o;const l={hasNext:!0,nextToken:0};yield this.loadMetadata(),i.debug("channel changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token);try{const n={includeEmpty:!0};try{const t=yield a.preference.get(e.createChangelogIncludeChatNotificationsCacheKey(r.appId));n.includeChatNotification=Boolean(t)}catch(e){n.includeChatNotification=!1}const d=t.GroupChannelManager.of(this._iid),{hasMore:h,token:u}=yield d.getMyGroupChannelChangeLogs(null!==(o=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==o?o:"",n,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);l.hasNext=h,l.nextToken=u,this._metadata&&(this._metadata.token=u),i.debug("channel changelog sync progress",l),yield this.saveMetadata()}catch(t){throw i.debug("channel changelog sync error",t),t instanceof e.SendbirdError&&t.isInvalidTokenError&&(yield this.clearMetadata()),t}return l})))),this._connectionEventContext=s.on((t=>{if(t instanceof e.ConnectionStateChangeCommand)if(t.stateType===e.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return o[e]||(o[e]=new l({_iid:e})),o[e].ref++,o[e]}static clear(e){o[e]&&(o[e].close(),delete o[e])}loadMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t,firstConnectedAt:n}=e.Vault.of(this._iid),i=yield t.preference.get(this._metadataKey);this._metadata={token:i?i.token:n}}return this._metadata}))}saveMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:t}=e.Vault.of(this._iid);return yield t.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);yield t.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{connectionManager:t}=e.Vault.of(this._iid);t.isConnected&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete o[this._iid])}}const d=(e,t)=>e.findIndex((e=>e.isIdentical(t))),h=(e,t,n)=>{if(e.length>0){const i=d(e,t);let r=0,s=e.length-1,a=Math.floor((r+s)/2);for(;r0)s=a,a=Math.floor((r+s)/2);else{if(!(o<0))return{place:a,oldPosition:i};r=a+1,a=Math.floor((r+s)/2)}}return{place:u(e[a],t,n)>=0?a:a+1,oldPosition:i}}return{place:e.length,oldPosition:-1}},u=(e,t,i)=>{switch(i){case n.GroupChannelListOrder.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case n.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case n.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const n=e.name.localeCompare(t.name);return 0===n?e.createdAt-t.createdAt:n}default:return 0}};class c{constructor(i,{filter:s,order:o,limit:d}){this.channels=[],this._iid=i,this._key=`gcc-${e.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=s?s:new t.GroupChannelFilter,this.order=null!=o?o:n.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=d?d:r.DEFAULT_GROUPCHANNEL_LIMIT;const{sdkState:h,cacheContext:u,dispatcher:c}=e.Vault.of(this._iid);u.localCacheEnabled&&(this._backgroundSync=a.of(i),this._backgroundSync.resume()),this._changelogSync=l.of(i),this._changelogSync.resume();t.GroupChannelManager.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:(e,n)=>{if(t.shouldGiveEvent(n)){const t=e.filter((e=>this.filter.match(e,h.userId))),i=e.filter((e=>!this.filter.match(e,h.userId))).map((e=>e.url));t.length>0&&this._addChannelsToView(t,n),i.length>0&&this._removeChannelsFromView(i,n)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}});const{statLogCollector:p}=e.Vault.of(this._iid);p.put(new e.DailyRecordStatLog({type:e.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((t=>{t instanceof e.ConnectionStateChangeCommand&&(t.stateType===e.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{e.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():t.stateType===e.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(n,i,r=!1){const s=[],a=[],o=[];for(const t of n){const n=d(this.channels,t);n>=0&&this.channels.splice(n,1);const{place:l}=h(this.channels,t,this.order);if(n<0)l===this.channels.length?!r&&this._hasMore||(s.push(t),this.channels.push(t)):(s.push(t),this.channels.splice(l,0,t));else switch(i){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:l!==n&&this._hasMore&&l===this.channels.length?o.push(t):(this.channels.splice(l,0,t),a.push(t));break;default:this.channels.splice(l,0,t),a.push(t)}}if(o.length>0)for(const e of o){const t=d(this.channels,e);-1!==t&&this.channels.splice(t,1)}t.shouldGiveEvent(i)&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e,n,r;const l=new t.GroupChannelEventContext(i);s.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(l,s),a.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsUpdated)&&this._handler.onChannelsUpdated(l,a),o.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(l,o.map((e=>e.url)))}))))}_removeChannelsFromView(n,i){const r=[];for(const e of n){const t=this.channels.findIndex((t=>t.url===e));t>=0&&(r.push(this.channels[t].url),this.channels.splice(t,1))}return t.shouldGiveEvent(i)&&r.length>0&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){var e;const n=new t.GroupChannelEventContext(i);(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,r)})))),r}_getLocalChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.GroupChannelManager.of(this._iid),i=this.channels.length>0?((e,t)=>{var i,r,s,a;switch(t){case n.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(r=null===(i=e.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==r?r:e.createdAt;case n.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case n.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(s=e.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(i,this.filter,this.order,this._limit,i?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return e.__awaiter(this,void 0,void 0,(function*(){const n=t.GroupChannelManager.of(this._iid),{channels:i,token:r}=yield n.getMyGroupChannels(this._token,e.undefineNullProps(Object.assign(Object.assign({},this.filter),{order:this.order})),this._limit);return this._token=r,this._hasMore=!!r,i}))}_revokeLoadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const t=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(t,e.CollectionEventSource.REQUEST_CHANNEL,!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new e.SendbirdError({code:e.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(this._hasMore){const{cacheContext:t,connectionManager:n}=e.Vault.of(this._iid);let i=[];if(!t.localCacheEnabled||n.isConnected&&!this._backgroundSync.completed)try{i=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}else yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){i=yield this._getLocalChannels()})))),this._hasMore=i.length>=this._limit;return this._addChannelsToView(i,e.CollectionEventSource.REQUEST_CHANNEL,!0),i}return[]}))}dispose(){var e,n;if(this._isDisposed)return;this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(n=this._changelogSync)||void 0===n||n.close();t.GroupChannelManager.of(this._iid).unsubscribeChannelEvent(this._key)}}class p extends e.APIRequestCommand{constructor(n){const{token:i,limit:r,order:s,includeEmpty:a,membershipFilter:o,channelNameContainsFilter:l,channelUrlsFilter:d,customTypesFilter:h,customTypeStartsWithFilter:u,superChannelFilter:c,metadataOrderKeyFilter:p,metadataKey:_,metadataValues:m,metadataValueStartsWith:g,includeFrozen:C,includeMetaData:f}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_GROUP_CHANNELS,this.params=e.deundefined(e.undefineNullProps({token:i,limit:r,order:s,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:a,public_mode:t.PublicChannelFilter.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:d,custom_types:h,custom_type_startswith:u,super_mode:c,metadata_order_key:p,metadata_key:_,metadata_values:m,metadata_value_startswith:g,show_frozen:C,show_metadata:f}))}}class _ extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:i,channels:r,ts:s}=n;this.token=i,r&&r.length>0&&(this.channels=r.map((n=>(n.ts=s,new t.GroupChannel(e,n))))),this.ts="number"==typeof s?s:0}}var m;exports.MembershipFilter=void 0,(m=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",m.JOINED="joined";class g extends e.BaseListQuery{constructor(e,i){var r,s,a,o,l,d,h,u,c,p,_,m,g,C;super(e,i),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.channelNameContainsFilter=null,this.membershipFilter=exports.MembershipFilter.ALL,this.superChannelFilter=t.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=n.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(r=i.includeEmpty)&&void 0!==r&&r,this.includeFrozen=null===(s=i.includeFrozen)||void 0===s||s,this.includeMetaData=null===(a=i.includeMetaData)||void 0===a||a,this.channelUrlsFilter=null!==(o=i.channelUrlsFilter)&&void 0!==o?o:null,this.customTypesFilter=null!==(l=i.customTypesFilter)&&void 0!==l?l:null,this.customTypeStartsWithFilter=null!==(d=i.customTypeStartsWithFilter)&&void 0!==d?d:null,this.channelNameContainsFilter=null!==(h=i.channelNameContainsFilter)&&void 0!==h?h:null,this.membershipFilter=null!==(u=i.membershipFilter)&&void 0!==u?u:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(c=i.superChannelFilter)&&void 0!==c?c:t.SuperChannelFilter.ALL,this.metadataKey=null!==(p=i.metadataKey)&&void 0!==p?p:null,this.metadataValues=null!==(_=i.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(m=i.metadataOrderKeyFilter)&&void 0!==m?m:null,this.metadataValueStartsWith=null!==(g=i.metadataValueStartsWith)&&void 0!==g?g:null,this.order=null!==(C=i.order)&&void 0!==C?C:n.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeEmpty)&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.channelNameContainsFilter,!0)&&e.isArrayOf("string",this.channelUrlsFilter,!0)&&e.isArrayOf("string",this.customTypesFilter,!0)&&e.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&e.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&e.isEnumOf(t.SuperChannelFilter,this.superChannelFilter)&&e.isEnumOf(n.PublicGroupChannelListOrder,this.order)&&e.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&e.isTypeOf("string",this.metadataKey,!0)&&e.isArrayOf("string",this.metadataValues,!0)&&e.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t,dispatcher:n}=e.Vault.of(this._iid),i=new p(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),r=yield t.send(i),{channels:s,token:a}=r.as(_);return this._token=a,this._hasNext=!!a,this._isLoading=!1,s}return t}}throw e.SendbirdError.invalidParameters}))}}class C extends i.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=e.noop,this.onUserLeft=e.noop,this.onUserReceivedInvitation=e.noop,this.onUserDeclinedInvitation=e.noop,this.onChannelHidden=e.noop,this.onUnreadMemberStatusUpdated=e.noop,this.onUndeliveredMemberStatusUpdated=e.noop,this.onTypingStatusUpdated=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class f extends C{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class v extends e.APIRequestCommand{constructor(t){const{token:n,limit:i,order:r,reverse:s,channelUrl:a,messageTypeFilter:o,scheduledStatus:l}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_SCHEDULED_MESSAGES}`,this.params=e.deundefined(e.undefineNullProps({token:n,limit:i,reverse:s,channel_url:a,order:r,message_type:o,status:l}))}}class y extends e.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:n,scheduled_messages:i}=t;this.token=n,this.scheduledMessages=i.map((t=>r.parseMessagePayload(e,t)))}}class b extends e.BaseListQuery{constructor(t,n){var i,r,s,a,o;super(t,n),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=e.MessageTypeFilter.ALL,this.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,this.order=null!==(r=n.order)&&void 0!==r?r:null,this.reverse=null!==(s=n.reverse)&&void 0!==s&&s,this.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL}_validate(){return super._validate()&&e.isTypeOf("string",this.channelUrl,!0)&&(e.isEnumOf(n.ScheduledMessageListOrder,this.order)||null===this.order)&&e.isTypeOf("boolean",this.reverse)&&(e.isArrayOf(r.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&e.isEnumOf(e.MessageTypeFilter,this.messageTypeFilter)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),n=new v(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),i=yield t.send(n),{scheduledMessages:r,token:s}=i.as(y);return this._token=s,this._hasNext=!!s,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:n,dispatcher:i,sessionManager:r,requestQueue:s,logger:a,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:n,dispatcher:i,sessionManager:r,requestQueue:s,logger:a,onlineDetector:o,cacheContext:l}),this._manager=new t.GroupChannelManager(e,{sdkState:n,cacheContext:l,dispatcher:i,sessionManager:r,requestQueue:s,logger:a})}createGroupChannelCollection(e={}){return new c(this._iid,e)}createMyGroupChannelListQuery(e={}){return new t.GroupChannelListQuery(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new g(this._iid,e)}createScheduledMessageListQuery(e={}){return new b(this._iid,e)}addGroupChannelHandler(t,n){e.unless(e.isTypeOf("string",t)&&n instanceof f).throw(e.SendbirdError.invalidParameters),this._manager.addHandler(t,n)}removeGroupChannelHandler(t){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.removeHandler(t)}removeAllGroupChannelHandlers(){this._manager.clearHandler()}buildGroupChannelFromSerializedData(e){return this._manager.buildGroupChannelFromSerializedData(e)}buildGroupChannelListQueryFromSerializedData(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}buildMemberFromSerializedData(e){return this._manager.buildMemberFromSerializedData(e)}getChannel(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannel(t)}))}getChannelWithoutCache(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(t)}))}getMyGroupChannelChangeLogsByToken(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("string",n)&&t.validateGroupChannelChangeLogsParams(r)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,r)}))}getMyGroupChannelChangeLogsByTimestamp(n,i={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.GroupChannelChangeLogsParamsDefault),i);return e.unless(e.isTypeOf("number",n)&&t.validateGroupChannelChangeLogsParams(r)).throw(e.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(n,r)}))}getGroupChannelCount(n){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCountParamsDefault),n);return e.unless(t.validateGroupChannelCountParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(i)}))}getUnreadItemCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(t)}))}getTotalUnreadChannelCount(){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(t)}))}getTotalScheduledMessageCount(t={}){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(t)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),this._manager.createChannel(i)}))}createDistinctChannelIfNotExist(n={}){return e.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),n);return e.unless(t.validateGroupChannelCreateParams(i)).throw(e.SendbirdError.invalidParameters),i&&(i.isDistinct=!0),this.createChannel(i)}))}createChannelWithUserIds(n,i=!1,r,s,a="",o=""){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t.GroupChannelCreateParamsDefault),{invitedUserIds:n,isDistinct:i,name:r,data:a,customType:o});return"string"==typeof s?e.coverUrl=s:e.coverImage=s,this.createChannel(e)}))}markAsReadAll(){return e.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(t)}))}markAsDelivered(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const n=yield this.getChannel(t);yield n.markAsDelivered()}))}}exports.MessageEventSource=e.MessageEventSource,Object.defineProperty(exports,"MutedState",{enumerable:!0,get:function(){return e.MutedState}}),Object.defineProperty(exports,"CountPreference",{enumerable:!0,get:function(){return t.CountPreference}}),exports.GroupChannel=t.GroupChannel,exports.GroupChannelEventContext=t.GroupChannelEventContext,exports.GroupChannelEventSource=t.GroupChannelEventSource,exports.GroupChannelFilter=t.GroupChannelFilter,exports.GroupChannelListQuery=t.GroupChannelListQuery,Object.defineProperty(exports,"GroupChannelSearchField",{enumerable:!0,get:function(){return t.GroupChannelSearchField}}),Object.defineProperty(exports,"HiddenChannelFilter",{enumerable:!0,get:function(){return t.HiddenChannelFilter}}),Object.defineProperty(exports,"HiddenState",{enumerable:!0,get:function(){return t.HiddenState}}),exports.Member=t.Member,Object.defineProperty(exports,"MemberListOrder",{enumerable:!0,get:function(){return t.MemberListOrder}}),exports.MemberListQuery=t.MemberListQuery,Object.defineProperty(exports,"MemberState",{enumerable:!0,get:function(){return t.MemberState}}),Object.defineProperty(exports,"MemberStateFilter",{enumerable:!0,get:function(){return t.MemberStateFilter}}),exports.MessageCollection=t.MessageCollection,exports.MessageCollectionInitHandler=t.MessageCollectionInitHandler,Object.defineProperty(exports,"MessageCollectionInitPolicy",{enumerable:!0,get:function(){return t.MessageCollectionInitPolicy}}),exports.MessageEventContext=t.MessageEventContext,Object.defineProperty(exports,"MutedMemberFilter",{enumerable:!0,get:function(){return t.MutedMemberFilter}}),Object.defineProperty(exports,"MyMemberStateFilter",{enumerable:!0,get:function(){return t.MyMemberStateFilter}}),Object.defineProperty(exports,"OperatorFilter",{enumerable:!0,get:function(){return t.OperatorFilter}}),exports.PinnedMessage=t.PinnedMessage,exports.PinnedMessageListQuery=t.PinnedMessageListQuery,Object.defineProperty(exports,"PublicChannelFilter",{enumerable:!0,get:function(){return t.PublicChannelFilter}}),Object.defineProperty(exports,"QueryType",{enumerable:!0,get:function(){return t.QueryType}}),exports.ReadStatus=t.ReadStatus,Object.defineProperty(exports,"SuperChannelFilter",{enumerable:!0,get:function(){return t.SuperChannelFilter}}),Object.defineProperty(exports,"UnreadChannelFilter",{enumerable:!0,get:function(){return t.UnreadChannelFilter}}),Object.defineProperty(exports,"UnreadItemKey",{enumerable:!0,get:function(){return t.UnreadItemKey}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return n.GroupChannelListOrder}}),Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return n.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return n.ScheduledMessageListOrder}}),exports.MessageFilter=r.MessageFilter,Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return r.ScheduledStatus}}),exports.GroupChannelCollection=c,exports.GroupChannelHandler=f,exports.GroupChannelModule=S,exports.PublicGroupChannelListQuery=g,exports.ScheduledMessageListQuery=b; diff --git a/cjs/index.js b/cjs/index.js index 0751d3c..75b6123 100644 --- a/cjs/index.js +++ b/cjs/index.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-c176c59f.js"),t=require("./message.js"),s=require("./poll.js"),n=require("./lib/__bundle-4bc3a029.js"),r=require("./lib/__bundle-617167af.js"),i=require("./lib/__bundle-86b43237.js"),o=require("./lib/__bundle-f5cc59df.js"),a=require("./lib/__bundle-a4005096.js"),d=require("./lib/__bundle-b9602cac.js");class u{constructor(e){this.key=e.key,this.url=e.url}}class c{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new u(e))):[]}}class l{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new c(e))):[]}}class h{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class m extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class f{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class g extends f{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class I extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:r,metaDataValuesFilter:i,nicknameStartsWithFilter:o}){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_USERS,this.params=e.deundefined({limit:t,token:s,user_ids:n,metadatakey:r,metadatavalues_in:i,nickname_startswith:o})}}class S extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class v extends e.BaseListQuery{constructor(e,t){var s,n,r;super(e,t),this.userIdsFilter=null,this.metaDataKeyFilter=null,this.metaDataValuesFilter=null,this.nicknameStartsWithFilter=null,this.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null,this.metaDataKeyFilter=null!==(n=t.metaDataKeyFilter)&&void 0!==n?n:null,this.metaDataValuesFilter=null!==(r=t.metaDataValuesFilter)&&void 0!==r?r:null,this.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null}_validate(){return super._validate()&&e.isArrayOf("string",this.userIdsFilter,!0)&&e.isTypeOf("string",this.metaDataKeyFilter,!0)&&e.isArrayOf("string",this.metaDataValuesFilter,!0)&&e.isTypeOf("string",this.metaDataKeyFilter,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new I(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:r,next:i}=n.as(S);return this._token=i,this._hasNext=!!i,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:r}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:r})}}class P extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class C extends e.BaseListQuery{constructor(e,t){var s;super(e,t),this.userIdsFilter=null,this.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null}_validate(){return super._validate()&&e.isArrayOf("string",this.userIdsFilter,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new y(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),r=yield s.send(n),{users:i,next:o}=r.as(P);return this._token=o,this._hasNext=!!o,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class E extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={limit:s,token:n}}}class b extends e.APIResponseCommand{constructor(t,s){super(t,s),this.hasMore=s.has_more,this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class T extends e.BaseListQuery{_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new E(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),r=yield s.send(n),{users:i,hasMore:o,next:a}=r.as(b);return this._token=a,this._hasNext=o,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}const A=6291456;class w extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=A}=t,r=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},r),{itemSizeLimit:n})),this._asyncStorage=s}_isBelonging(e){return e.startsWith(`${this.dbname}/`)}_getActualKey(e){return`${this.dbname}/${e}`}_getAllRawKeys(){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this._asyncStorage.getAllKeys()).filter((e=>this._isBelonging(e))).map((e=>e.substring(`${this.dbname}/`.length)))}))}_getRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this._asyncStorage.getItem(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];for(const s of t){const{key:t,data:n}=s;n.length<=this.adjustedItemSizeLimit&&e.push([this._getActualKey(t),JSON.stringify(s)])}yield this._asyncStorage.multiSet(e)}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._asyncStorage.multiRemove(t.map((e=>this._getActualKey(e))))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._asyncStorage)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const k={profileImage:void 0,profileUrl:void 0,nickname:void 0},R=e=>({v2:e.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[r.getGroupChannelIndexBy(r.GroupChannelListOrder.LATEST_LAST_MESSAGE),r.getGroupChannelIndexBy(r.GroupChannelListOrder.CHRONOLOGICAL),r.getGroupChannelIndexBy(r.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}]),v3:e.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[i.getFeedChannelIndexBy("latest_last_message")]}])}),U=(e,t)=>(s,n)=>{switch(s){case 1:e.clear().then((()=>{t.clear().then((()=>{R(e).v2.then((()=>n())).catch((e=>n(e)))})).catch((e=>n(e)))})).catch((e=>n(e)));break;case 2:R(e).v3.then((()=>n())).catch((e=>n(e)));break;default:n()}},O=()=>"undefined"!=typeof document?document.visibilityState:"visible";class x extends e.EventDispatcher{constructor({getVisibilityState:e=O,initialState:t="visible",isEnabled:s=!0,pauseCheckDelay:n=3e4}){super(),this._pauseCheckDelay=3e4,this._currentState="visible",this._getVisibilityState=e,this._pauseCheckDelay=n,this._currentState=t,this._isEnabled=s,this._boundToggleState=this._toggleState.bind(this)}get currentState(){return this._currentState}get isAvailable(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}_toggleState(){const e=this._getVisibilityState();"hidden"!==e?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((()=>{this._pauseDelayTimer=void 0,this.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=e}start(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}stop(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}class D{constructor({logger:e,connectionDelegate:t=null}){this._onlineWorker=()=>{var e;return null===(e=this.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=()=>{var e;return null===(e=this.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=e=>{if(this.isAvailableOnWeb)return window.addEventListener("online",e),()=>window.removeEventListener("online",e,!1)},this._offlineListener=e=>{if(this.isAvailableOnWeb)return window.addEventListener("offline",e),()=>window.removeEventListener("offline",e,!1)},this.logger=e,t&&(this.connectionDelegate=t)}get isAvailableOnWeb(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}setOnlineListener(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}setOfflineListener(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}start(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}stop(){this.unsubscribes.forEach((e=>{try{null==e||e()}catch(e){this.logger.warn(e.message)}})),this.unsubscribes=[]}isOnline(){return e.__awaiter(this,void 0,void 0,(function*(){return this.isAvailableOnWeb?navigator.onLine:new Promise((t=>{fetch("https://www.google.com",{method:e.APIRequestMethod.GET,mode:"no-cors"}).then((()=>t(!0))).catch((()=>t(!1)))}))}))}}class M extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:r,preferredLanguages:i}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({nickname:s,profile_url:n,profile_file:r,preferred_languages:i}))}}class L extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class q extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params={apns_device_token:s,always_push:!0}}}class N extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params={gcm_reg_token:s,always_push:!0}}}class V extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns/${encodeURIComponent(s)}`}}class $ extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm/${encodeURIComponent(s)}`}}class H extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class F extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class j extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:r}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:r,token:n}}}class Q extends e.APIResponseCommand{constructor(t,s){super(t,s),this.pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token}}}class z extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class B extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class G extends e.APIRequestCommand{constructor({userId:t,willAutoAccept:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`,this.params={auto_accept:s}}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class W extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class J extends e.APIResponseCommand{constructor(e,t){super(e,t),this.preference={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}}}class Y extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:r,endHour:i,endMin:o,timezone:a}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={do_not_disturb:s,start_hour:n,start_min:r,end_hour:i,end_min:o,timezone:a}}}class X extends e.APIResponseCommand{constructor(e,t){super(e,t),this.preference={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}}}class Z extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class ee extends e.APIResponseCommand{constructor(e,t){super(e,t),this.snoozePeriod={isSnoozeOn:t.snooze_enabled},"number"==typeof t.snooze_start_ts&&(this.snoozePeriod.startTs=t.snooze_start_ts),"number"==typeof t.snooze_end_ts&&(this.snoozePeriod.endTs=t.snooze_end_ts)}}class te extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:r}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={snooze_enabled:s,snooze_start_ts:n,snooze_end_ts:r}}}class se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.snoozePeriod={isSnoozeOn:t.snooze_enabled},"number"==typeof t.snooze_start_ts&&(this.snoozePeriod.startTs=t.snooze_start_ts),"number"==typeof t.snooze_end_ts&&(this.snoozePeriod.endTs=t.snooze_end_ts)}}class ne extends e.APIRequestCommand{constructor({userId:t,blockedUserId:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/block`,this.params={target_id:s}}}class re extends e.APIRequestCommand{constructor({userId:t,unblockedUserId:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/block/${encodeURIComponent(s)}`}}class ie extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t,pushTriggerOption:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={push_trigger_option:s}}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ue extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le extends e.APIRequestCommand{constructor({userId:t,templateName:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`,this.params={name:s}}}class he extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class pe extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends/changelogs`,this.params={token:s}}}class _e extends e.APIResponseCommand{constructor(t,s){super(t,s),this.changelogs={addedUsers:s.added.map((s=>new e.User(t,s))),updatedUsers:s.updated.map((s=>new e.User(t,s))),deletedUserIds:s.deleted,hasMore:s.has_more,token:s.next}}}class me extends e.APIRequestCommand{constructor({userId:t,discoveries:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friend_discoveries`,this.params={friend_discoveries:s.map((e=>({friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}}}class fe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class ge extends e.APIRequestCommand{constructor({userId:t,discoveryKeys:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friend_discoveries`,this.params={friend_discovery_keys:s}}}class Ie extends e.APIRequestCommand{constructor({userId:t,userIds:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={user_ids:s}}}class Se extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class ve extends e.APIRequestCommand{constructor({userId:t,userIds:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={user_ids:s}}}class ye extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/allow_friend_discovery`,this.params={}}}class Pe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class Ce extends e.APIRequestCommand{constructor({userId:t,allowFriendDiscovery:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${t}/allow_friend_discovery`,this.params={allow_friend_discovery:s}}}class Ee extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class be extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new l(t)}}class Te extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new c(t)}}class we extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class ke extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new u(t)}}class Re extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class Ue extends e.APIResponseCommand{constructor(e,t){var s;super(e,t);const n=null!=t?t:{};this.uikitConfiguration={string:JSON.stringify(n),json:n},this.updatedAt=null!==(s=null==t?void 0:t.updated_at)&&void 0!==s?s:0}}let Oe;class xe{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:i,cacheContext:o,dispatcher:a,sessionManager:d,requestQueue:u,logger:c,userEventHandlers:l,appStateToggleEnabled:h}=e.Vault.of(t);this._onlineDetector=new D({logger:c,connectionDelegate:{reconnect:()=>{const{sdkState:s,connectionManager:n,sessionManager:r}=e.Vault.of(t);r.auth.hasSession?"foreground"===s.appState&&n.resetAndReconnect():n.connect(r.auth.authToken)},disconnect:()=>{const{connectionManager:s}=e.Vault.of(t);s.disconnect()}}});const p=new r.AutoResendManager(t,{localCacheEnabled:o.localCacheEnabled,dispatcher:a,sdkState:i,logger:c});n.forEach((e=>{e.init(t,{sdkState:i,cacheContext:o,dispatcher:a,sessionManager:d,requestQueue:u,logger:c,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new x({isEnabled:h}),this._appStateChangeDetector.on("resume",(()=>{c.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{c.debug("the page freezes"),this.setBackgroundState()})),a.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)p.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(r.UserEventCommand);switch(n.category){case r.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=r.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l.forEach((e=>{e.onFriendsDiscovered&&e.onFriendsDiscovered(s)}))}))));break}}break}}else if(s instanceof e.SubscribedUnreadMessageCountUpdateCommand){const{subscribedUnreadMessageCount:t}=e.Vault.of(this._iid);let n=!1;const r=s.ts;if("number"==typeof r&&r>t.ts){if(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes)for(const e in s.customTypes)t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e];n=n&&t.ts>0,t.ts=r}n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(o.preference.set(this._getUserProfileCacheKey(i.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&o.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&(s.error.isSessionRevokedError||s.error.isUserAuthDeactivedError||s.error.isUserAuthDeletedOrNotFoundError)&&(c.debug("session revoked."),this.disconnect())}))}static init(r){const{appId:i,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:m=new e.LocalCacheConfig,localCacheEncryption:f,useAsyncStorageStore:g=null,appStateToggleEnabled:I=!0}=r;if(!Oe||h){const r=`su-${e.uuid()}`,h=null!=f?f:{encrypt:e=>e,decrypt:e=>e};let S=new n.MemoryStore({encryption:h});u||(S=e.isReactNative()?g?new w({AsyncStorage:g,encryption:h}):new n.MemoryStore({encryption:h}):new n.IndexedDbStore({encryption:h})),new e.Vault(r,{appId:i,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${i}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${i}.sendbird.com`,store:S,encryption:h,logLevel:p,localCacheEnabled:_,localCacheConfig:m,debugMode:u,appStateToggleEnabled:I});const v=[new t.MessageModule,new s.PollModule],y=new xe(r,d,[...a,...v]);return Oe||(Oe=y),y}return Oe}static get instance(){return Oe}static get version(){return e.version}get appId(){const{sdkState:t}=e.Vault.of(this._iid);return t.appId}get appInfo(){const{appInfo:t}=e.Vault.of(this._iid);return null!=t?t:null}get appVersion(){var t;const{sdkState:s}=e.Vault.of(this._iid);return null!==(t=s.appVersion)&&void 0!==t?t:""}get debugMode(){const{debugMode:t}=e.Vault.of(this._iid);return!!t}get logLevel(){const{logger:t}=e.Vault.of(this._iid);return t.level}set logLevel(t){const{logger:s}=e.Vault.of(this._iid);s.level=t}get isCacheEnabled(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled}get localCacheConfig(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled?t.localCacheConfig:null}get ekey(){const{sessionManager:t}=e.Vault.of(this._iid);return t.ekey}get currentUser(){var t;const{sessionManager:s}=e.Vault.of(this._iid);return null!==(t=s.currentUser)&&void 0!==t?t:null}get connectionState(){const{connectionManager:t}=e.Vault.of(this._iid);return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}get lastConnectedAt(){const{connectedAt:t,connectionManager:s}=e.Vault.of(this._iid);return s.isConnected?t:0}get fcmPushToken(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}get apnsPushToken(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}_getNestDBVersion(){return 3}_getCurrentPreferenceVersion(){return 1}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.MemoryStore?s.store:null;throw e.SendbirdError.debugModeRequired}addExtension(t,s){const{sdkState:n}=e.Vault.of(this._iid);["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(t)>-1&&n.extensions&&(n.extensions[t]=s)}addSendbirdExtensions(t,s,n){const{logger:r,sdkState:i}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return r.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return r.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return r.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return i.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}setOnlineListener(e){this._onlineDetector.setOnlineListener(e)}setOfflineListener(e){this._onlineDetector.setOfflineListener(e)}_safeInitializeStore(t){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:s}=e.Vault.of(this._iid);try{yield s.store.init(t),this._storeInitialized=!0}catch(e){s.replaceStore(new n.MemoryStore),yield this._safeInitializeStore(t)}}))}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:i,connectionManager:o,dispatcher:a,logger:d}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){yield o.logout();const u=`sendbird@${s.appId}/${t}.db`;if(i.localCacheEnabled)try{if(!i.nestdb||i.nestdb.state===n.NestDBState.CLOSED||i.nestdb.name!==u){const e=i.nestdb=new n.NestDB({name:`sendbird@${s.appId}/${t}.db`,version:this._getNestDBVersion(),store:i.store});e.on("upgrade",U(e,i.store)),e.on("storeReplaced",(t=>{i.replaceStore(t),i.localCacheEnabled=!1,e.on("upgrade",U(e,i.store))})),yield e.open(),this._storeInitialized=!0,a.dispatch(new r.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}catch(n){throw d.warn("Nest DB Open Failed. ",n),yield this._safeInitializeStore(u),s.userId=t,e.SendbirdError.databaseError}else yield this._safeInitializeStore(u),s.userId=t}}))}getCacheDataSize(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled&&t.nestdb?yield t.nestdb.estimateUsage():0}))}clearCachedData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);t.localCacheEnabled&&t.nestdb&&(yield t.nestdb.clear()),this._storeInitialized&&(yield t.preference.clear())}))}clearCachedMessages(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=n.MessageCache.of(this._iid),r=n.UnsentMessageCache.of(this._iid);s&&r&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield r.removeMessagesOfChannel(t)}))))))}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",s,!0)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,cacheContext:i,connectionManager:o,statLogCollector:a}=e.Vault.of(this._iid);try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new r.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);i.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}yield i.preference.init(this._getPreferenceCacheKey(t),this._getCurrentPreferenceVersion());const d=yield i.preference.get(this._getUserProfileCacheKey(t));if(d){new e.UserProfile(this._iid,d).apply()}yield a.init(`sendbird@${n.appId}/${t}.statlog`);try{yield o.connect(s)}finally{this._onlineDetector.start(),this._appStateChangeDetector.start()}return this.currentUser}))}reconnect(){const{connectionManager:t,sdkState:s,sessionManager:n}=e.Vault.of(this._iid),r=n.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),r}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:t,requestQueue:s}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),yield t.logout(),yield this.clearCachedData()}))}disconnectWebSocket(){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:t,requestQueue:s}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),yield t.disconnectWebSocket()}))}setBackgroundState(){const{connectionManager:t,sdkState:s,logger:n}=e.Vault.of(this._iid);"foreground"===s.appState&&(s.appState="background",n.debug("going background state"),t.background())}setForegroundState(){const{connectionManager:t,sdkState:s,logger:n}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",n.debug("going foreground state"),t.resetAndReconnect())}setSessionHandler(t){e.unless(t instanceof m).throw(e.SendbirdError.invalidParameters);const{sessionManager:s}=e.Vault.of(this._iid);s.handler=t}addUserEventHandler(t,s){e.unless(e.isTypeOf("string",t)&&s instanceof g).throw(e.SendbirdError.invalidParameters);const{userEventHandlers:n}=e.Vault.of(this._iid);n.set(t,s)}removeUserEventHandler(t){const{userEventHandlers:s}=e.Vault.of(this._iid);s.delete(t)}removeAllUserEventHandler(){const{userEventHandlers:t}=e.Vault.of(this._iid);t.clear()}addConnectionHandler(t,s){e.unless(e.isTypeOf("string",t)&&s instanceof p).throw(e.SendbirdError.invalidParameters);const{connectionHandlers:n}=e.Vault.of(this._iid);n.set(t,s)}removeConnectionHandler(t){const{connectionHandlers:s}=e.Vault.of(this._iid);s.delete(t)}removeAllConnectionHandler(){const{connectionHandlers:t}=e.Vault.of(this._iid);t.clear()}createApplicationUserListQuery(e={}){return new v(this._iid,e)}createBlockedUserListQuery(e={}){return new C(this._iid,e)}createFriendListQuery(e={}){return new T(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(e){return new o.PollListQuery(this._iid,Object.assign({},e))}createPollVoterListQuery(e){return new o.PollVoterListQuery(this._iid,Object.assign({},e))}buildUserFromSerializedData(t){const s=e.deserialize(t);return new e.User(this._iid,e.User.payloadify(s))}updateCurrentUserInfo(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},k),t);if(e.unless((t=>e.isFile(t.profileImage,!0)&&e.isTypeOf("string",t.profileUrl,!0)&&e.isTypeOf("string",t.nickname,!0))(s)).throw(e.SendbirdError.invalidParameters),this.currentUser){const{sdkState:t,requestQueue:n}=e.Vault.of(this._iid),r=new M(Object.assign({userId:t.userId},s)),i=yield n.send(r),{user:o}=i.as(L);return this.currentUser&&(s.nickname&&(this.currentUser.nickname=o.nickname),(s.profileUrl||s.profileImage)&&(this.currentUser.plainProfileUrl=o.profileUrl)),o}throw e.SendbirdError.connectionRequired}))}updateCurrentUserInfoWithPreferredLanguages(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this.currentUser){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new M({userId:s.userId,preferredLanguages:t}),i=yield n.send(r),{user:o}=i.as(L);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const i=new N({userId:n.userId,token:t});return yield r.send(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t),yield s.saveDeviceToken()})))),this._fcmPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterFCMPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid),i=new $({userId:n.userId,token:t}),{lastDeletedAt:o}=yield r.send(i);return yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.unsetDeviceToken(e.PushTokenType.FCM,t),s.setDeviceTokenDeletedAt(o),yield s.saveDeviceToken()})))),this._fcmPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterFCMPushTokenAllForCurrentUser(){return e.__awaiter(this,void 0,void 0,(function*(){if(this.currentUser){const{sessionManager:t,sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new F({userId:s.userId}),{lastDeletedAt:i}=yield n.send(r);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(i),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const i=new q({userId:n.userId,token:t});return yield r.send(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t),yield s.saveDeviceToken()})))),this._apnsPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterAPNSPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid),i=new V({userId:n.userId,token:t}),{lastDeletedAt:o}=yield r.send(i);return yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.unsetDeviceToken(e.PushTokenType.APNS,t),s.setDeviceTokenDeletedAt(o),yield s.saveDeviceToken()})))),this._apnsPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterAPNSPushTokenAllForCurrentUser(){return e.__awaiter(this,void 0,void 0,(function*(){if(this.currentUser){const{sessionManager:t,sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new H({userId:s.userId}),{lastDeletedAt:i}=yield n.send(r);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(i),yield t.saveDeviceToken()}))))}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new z({userId:t.userId}),r=yield s.send(n),{autoAccept:i}=r.as(B);return{autoAccept:i}}))}setChannelInvitationPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new G({userId:s.userId,willAutoAccept:t}),i=yield n.send(r),{autoAccept:o}=i.as(K);return{autoAccept:o}}))}getDoNotDisturb(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new W({userId:t.userId}),r=yield s.send(n),{preference:i}=r.as(J);return i}))}setDoNotDisturb(t,s=0,n=0,r=0,i=0,o=""){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)&&e.isTypeOf("number",s)&&e.isTypeOf("number",n)&&e.isTypeOf("number",r)&&e.isTypeOf("number",i)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new Y({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:r,endMin:i,timezone:o}),c=yield d.send(u),{preference:l}=c.as(X);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Z({userId:t.userId}),r=yield s.send(n),{snoozePeriod:i}=r.as(ee);return i}))}setSnoozePeriod(t,s=0,n=0){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)&&e.isTypeOf("number",s)&&e.isTypeOf("number",n)).throw(e.SendbirdError.invalidParameters);const{sdkState:r,requestQueue:i}=e.Vault.of(this._iid),o=new te({userId:r.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield i.send(o),{snoozePeriod:d}=a.as(se);return d}))}getMyPushTokensByToken(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)&&e.isEnumOf(e.PushTokenType,s)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:r,sessionManager:i}=e.Vault.of(this._iid),o=new j({userId:n.userId,type:s,token:t}),a=yield r.send(o),{pushTokens:d}=a.as(Q);for(const e of d.deviceTokens)i.setDeviceToken(d.type,e);return yield i.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ie({userId:t.userId});return(yield s.send(n)).as(oe).pushTriggerOption}))}setPushTriggerOption(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(e.PushTriggerOption,t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ae({userId:s.userId,pushTriggerOption:t});return(yield n.send(r)).as(de).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ue({userId:t.userId});return(yield s.send(n)).as(ce).name}))}setPushTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(e.PushTemplate,t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new le({userId:s.userId,templateName:t});return(yield n.send(r)).as(he).name}))}blockUser(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof e.User||e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ne({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(r)}))}blockUserWithUserId(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.blockUser(t)}))}unblockUser(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof e.User||e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new re({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(r)}))}unblockUserWithUserId(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.unblockUser(t)}))}getFriendChangeLogsByToken(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new pe({userId:s.userId,token:t}),i=yield n.send(r),{changelogs:o}=i.as(_e);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye({userId:t.userId}),r=yield s.send(n),{allowFriendDiscovery:i}=r.as(Pe);return i}))}setAllowFriendDiscovery(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new Ce({userId:s.userId,allowFriendDiscovery:t});return yield n.send(r),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new me({userId:s.userId,discoveries:t}),i=yield n.send(r),{friendDiscoveryRequestId:o}=i.as(fe);return o}))}deleteFriendDiscovery(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.deleteFriendDiscoveries([t])}))}deleteFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ge({userId:s.userId,discoveryKeys:t});yield n.send(r)}))}addFriends(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new Ie({userId:s.userId,userIds:t}),i=yield n.send(r),{users:o}=i.as(Se);return o}))}deleteFriend(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.deleteFriends([t])}))}deleteFriends(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ve({userId:s.userId,userIds:t});yield n.send(r)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Ee,n=yield t.send(s),{emojiContainer:r}=n.as(be);return r}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Te({categoryId:t}),r=yield s.send(n),{emojiCategory:i}=r.as(Ae);return i}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new we({key:t}),r=yield s.send(n),{emoji:i}=r.as(ke);return i}))}getUIKitConfiguration(){return e.__awaiter(this,void 0,void 0,(function*(){const t=e.Vault.of(this._iid);e.unless(t.hasExtension("sb_uikit")).throw(e.SendbirdError.notSupportedError);const{requestQueue:s}=t,n=new Re,r=yield s.send(n),{uikitConfiguration:i}=r.as(Ue);return i}))}}exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),exports.LocalCacheConfig=e.LocalCacheConfig,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return e.LogLevel}}),exports.NotificationInfo=e.NotificationInfo,Object.defineProperty(exports,"PushTemplate",{enumerable:!0,get:function(){return e.PushTemplate}}),Object.defineProperty(exports,"PushTokenRegistrationState",{enumerable:!0,get:function(){return e.PushTokenRegistrationState}}),Object.defineProperty(exports,"PushTokenType",{enumerable:!0,get:function(){return e.PushTokenType}}),Object.defineProperty(exports,"PushTriggerOption",{enumerable:!0,get:function(){return e.PushTriggerOption}}),Object.defineProperty(exports,"Role",{enumerable:!0,get:function(){return e.Role}}),exports.SendbirdChatOptions=e.SendbirdChatOptions,exports.SendbirdError=e.SendbirdError,Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.MemoryStore=n.MemoryStore,exports.Plugin=n.Plugin,Object.defineProperty(exports,"ReportCategory",{enumerable:!0,get:function(){return n.ReportCategory}}),exports.RestrictionInfo=n.RestrictionInfo,Object.defineProperty(exports,"RestrictionType",{enumerable:!0,get:function(){return n.RestrictionType}}),exports.BannedUserListQuery=a.BannedUserListQuery,exports.BaseChannel=a.BaseChannel,exports.MutedUserListQuery=a.MutedUserListQuery,exports.OperatorListQuery=a.OperatorListQuery,exports.RestrictedUser=a.RestrictedUser,exports.Participant=d.Participant,exports.ApplicationUserListQuery=v,exports.BlockedUserListQuery=C,exports.ConnectionHandler=p,exports.Emoji=u,exports.EmojiCategory=c,exports.EmojiContainer=l,exports.FriendListQuery=T,exports.SessionHandler=m,exports.UserEventHandler=g,exports.default=xe; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-26b86f4c.js"),t=require("./message.js"),s=require("./poll.js"),n=require("./lib/__bundle-aae5735d.js"),r=require("./lib/__bundle-82ee6f93.js"),i=require("./lib/__bundle-86b43237.js"),o=require("./lib/__bundle-722ae438.js");require("./lib/__bundle-f6d4722d.js");class a{constructor(e){this.key=e.key,this.url=e.url}}class d{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new a(e))):[]}}class u{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new d(e))):[]}}class c{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class l extends c{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class h{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class p extends h{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class _{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountChanged=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class m extends _{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class f extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:r,metaDataValuesFilter:i,nicknameStartsWithFilter:o}){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_USERS,this.params=e.deundefined({limit:t,token:s,user_ids:n,metadatakey:r,metadatavalues_in:i,nickname_startswith:o})}}class g extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class I extends e.BaseListQuery{constructor(e,t){var s,n,r;super(e,t),this.userIdsFilter=null,this.metaDataKeyFilter=null,this.metaDataValuesFilter=null,this.nicknameStartsWithFilter=null,this.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null,this.metaDataKeyFilter=null!==(n=t.metaDataKeyFilter)&&void 0!==n?n:null,this.metaDataValuesFilter=null!==(r=t.metaDataValuesFilter)&&void 0!==r?r:null,this.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null}_validate(){return super._validate()&&e.isArrayOf("string",this.userIdsFilter,!0)&&e.isTypeOf("string",this.metaDataKeyFilter,!0)&&e.isArrayOf("string",this.metaDataValuesFilter,!0)&&e.isTypeOf("string",this.metaDataKeyFilter,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new f(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:r,next:i}=n.as(g);return this._token=i,this._hasNext=!!i,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class S extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:r}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:r})}}class v extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class y extends e.BaseListQuery{constructor(e,t){var s;super(e,t),this.userIdsFilter=null,this.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null}_validate(){return super._validate()&&e.isArrayOf("string",this.userIdsFilter,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new S(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),r=yield s.send(n),{users:i,next:o}=r.as(v);return this._token=o,this._hasNext=!!o,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class P extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={limit:s,token:n}}}class C extends e.APIResponseCommand{constructor(t,s){super(t,s),this.hasMore=s.has_more,this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class E extends e.BaseListQuery{_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new P(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),r=yield s.send(n),{users:i,hasMore:o,next:a}=r.as(C);return this._token=a,this._hasNext=o,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}const T=6291456;class b extends n.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=T}=t,r=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},r),{itemSizeLimit:n})),this._asyncStorage=s}_isBelonging(e){return e.startsWith(`${this.dbname}/`)}_getActualKey(e){return`${this.dbname}/${e}`}_getAllRawKeys(){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this._asyncStorage.getAllKeys()).filter((e=>this._isBelonging(e))).map((e=>e.substring(`${this.dbname}/`.length)))}))}_getRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this._asyncStorage.getItem(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];for(const s of t){const{key:t,data:n}=s;n.length<=this.adjustedItemSizeLimit&&e.push([this._getActualKey(t),JSON.stringify(s)])}yield this._asyncStorage.multiSet(e)}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._asyncStorage.multiRemove(t.map((e=>this._getActualKey(e))))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._asyncStorage)throw n.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t,yield this._resetIfEncryptionChanged()}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getAllKeys();yield this.removeMany(e)}))}}const A={profileImage:void 0,profileUrl:void 0,nickname:void 0},w=e=>({v2:e.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[r.getGroupChannelIndexBy(r.GroupChannelListOrder.LATEST_LAST_MESSAGE),r.getGroupChannelIndexBy(r.GroupChannelListOrder.CHRONOLOGICAL),r.getGroupChannelIndexBy(r.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[n.getMessageIndexBy(n.MessageListOrder.CHANNEL_LATEST),n.getMessageIndexBy(n.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}]),v3:e.commitSchema([{collectionName:n.NESTDB_FEEDCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_FEEDCHANNEL_COLLECTION_KEY,index:[i.getFeedChannelIndexBy("latest_last_message")]}])}),k=(e,t)=>(s,n)=>{switch(s){case 1:e.clear().then((()=>{t.clear().then((()=>{w(e).v2.then((()=>n())).catch((e=>n(e)))})).catch((e=>n(e)))})).catch((e=>n(e)));break;case 2:w(e).v3.then((()=>n())).catch((e=>n(e)));break;default:n()}},R=()=>"undefined"!=typeof document?document.visibilityState:"visible";class U extends e.EventDispatcher{constructor({getVisibilityState:e=R,initialState:t="visible",isEnabled:s=!0,pauseCheckDelay:n=3e4}){super(),this._pauseCheckDelay=3e4,this._currentState="visible",this._getVisibilityState=e,this._pauseCheckDelay=n,this._currentState=t,this._isEnabled=s,this._boundToggleState=this._toggleState.bind(this)}get currentState(){return this._currentState}get isAvailable(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}_toggleState(){const e=this._getVisibilityState();"hidden"!==e?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((()=>{this._pauseDelayTimer=void 0,this.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=e}start(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}stop(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}class O{constructor({logger:e,connectionDelegate:t=null}){this._onlineWorker=()=>{var e;return null===(e=this.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=()=>{var e;return null===(e=this.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=e=>{if(this.isAvailableOnWeb)return window.addEventListener("online",e),()=>window.removeEventListener("online",e,!1)},this._offlineListener=e=>{if(this.isAvailableOnWeb)return window.addEventListener("offline",e),()=>window.removeEventListener("offline",e,!1)},this.logger=e,t&&(this.connectionDelegate=t)}get isAvailableOnWeb(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}setOnlineListener(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}setOfflineListener(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}start(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}stop(){this.unsubscribes.forEach((e=>{try{null==e||e()}catch(e){this.logger.warn(e.message)}})),this.unsubscribes=[]}isOnline(){return e.__awaiter(this,void 0,void 0,(function*(){return this.isAvailableOnWeb?navigator.onLine:new Promise((t=>{fetch("https://www.google.com",{method:e.APIRequestMethod.GET,mode:"no-cors"}).then((()=>t(!0))).catch((()=>t(!1)))}))}))}}class x extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:r,preferredLanguages:i}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({nickname:s,profile_url:n,profile_file:r,preferred_languages:i}))}}class D extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class M extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params={apns_device_token:s,always_push:!0}}}class L extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params={gcm_reg_token:s,always_push:!0}}}class q extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns/${encodeURIComponent(s)}`}}class N extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm/${encodeURIComponent(s)}`}}class V extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class $ extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class H extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:r}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:r,token:n}}}class F extends e.APIResponseCommand{constructor(t,s){super(t,s),this.pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token}}}class j extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class Q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class z extends e.APIRequestCommand{constructor({userId:t,willAutoAccept:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`,this.params={auto_accept:s}}}class B extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class G extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.preference={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}}}class W extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:r,endHour:i,endMin:o,timezone:a}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={do_not_disturb:s,start_hour:n,start_min:r,end_hour:i,end_min:o,timezone:a}}}class J extends e.APIResponseCommand{constructor(e,t){super(e,t),this.preference={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}}}class Y extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class X extends e.APIResponseCommand{constructor(e,t){super(e,t),this.snoozePeriod={isSnoozeOn:t.snooze_enabled},"number"==typeof t.snooze_start_ts&&(this.snoozePeriod.startTs=t.snooze_start_ts),"number"==typeof t.snooze_end_ts&&(this.snoozePeriod.endTs=t.snooze_end_ts)}}class Z extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:r}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={snooze_enabled:s,snooze_start_ts:n,snooze_end_ts:r}}}class ee extends e.APIResponseCommand{constructor(e,t){super(e,t),this.snoozePeriod={isSnoozeOn:t.snooze_enabled},"number"==typeof t.snooze_start_ts&&(this.snoozePeriod.startTs=t.snooze_start_ts),"number"==typeof t.snooze_end_ts&&(this.snoozePeriod.endTs=t.snooze_end_ts)}}class te extends e.APIRequestCommand{constructor({userId:t,blockedUserId:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/block`,this.params={target_id:s}}}class se extends e.APIRequestCommand{constructor({userId:t,unblockedUserId:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/block/${encodeURIComponent(s)}`}}class ne extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class re extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ie extends e.APIRequestCommand{constructor({userId:t,pushTriggerOption:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={push_trigger_option:s}}}class oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class ae extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class de extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class ue extends e.APIRequestCommand{constructor({userId:t,templateName:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`,this.params={name:s}}}class ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class le extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends/changelogs`,this.params={token:s}}}class he extends e.APIResponseCommand{constructor(t,s){super(t,s),this.changelogs={addedUsers:s.added.map((s=>new e.User(t,s))),updatedUsers:s.updated.map((s=>new e.User(t,s))),deletedUserIds:s.deleted,hasMore:s.has_more,token:s.next}}}class pe extends e.APIRequestCommand{constructor({userId:t,discoveries:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friend_discoveries`,this.params={friend_discoveries:s.map((e=>({friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}}}class _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class me extends e.APIRequestCommand{constructor({userId:t,discoveryKeys:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friend_discoveries`,this.params={friend_discovery_keys:s}}}class fe extends e.APIRequestCommand{constructor({userId:t,userIds:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={user_ids:s}}}class ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class Ie extends e.APIRequestCommand{constructor({userId:t,userIds:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={user_ids:s}}}class Se extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/allow_friend_discovery`,this.params={}}}class ve extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class ye extends e.APIRequestCommand{constructor({userId:t,allowFriendDiscovery:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${t}/allow_friend_discovery`,this.params={allow_friend_discovery:s}}}class Pe extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class Ce extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new u(t)}}class Ee extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class Te extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new d(t)}}class be extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new a(t)}}class we extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class ke extends e.APIResponseCommand{constructor(e,t){var s;super(e,t);const n=null!=t?t:{};this.uikitConfiguration={string:JSON.stringify(n),json:n},this.updatedAt=null!==(s=null==t?void 0:t.updated_at)&&void 0!==s?s:0}}let Re;class Ue{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:i,cacheContext:o,dispatcher:a,sessionManager:d,requestQueue:u,logger:c,userEventHandlers:l,appStateToggleEnabled:h}=e.Vault.of(t);this._onlineDetector=new O({logger:c,connectionDelegate:{reconnect:()=>{const{sdkState:s,connectionManager:n,sessionManager:r}=e.Vault.of(t);r.auth.hasSession?"foreground"===s.appState&&n.resetAndReconnect():n.connect(r.auth.authToken)},disconnect:()=>{const{connectionManager:s}=e.Vault.of(t);s.disconnect()}}});const p=new r.AutoResendManager(t,{localCacheEnabled:o.localCacheEnabled,dispatcher:a,sdkState:i,logger:c});n.forEach((e=>{e.init(t,{sdkState:i,cacheContext:o,dispatcher:a,sessionManager:d,requestQueue:u,logger:c,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new U({isEnabled:h}),this._appStateChangeDetector.on("resume",(()=>{c.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{c.debug("the page freezes"),this.setBackgroundState()})),a.on((s=>{var n;if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)p.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(r.UserEventCommand);switch(n.category){case r.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=r.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l.forEach((e=>{e.onFriendsDiscovered&&e.onFriendsDiscovered(s)}))}))));break}}break}}else if(s instanceof e.SubscribedUnreadMessageCountUpdateCommand){const{subscribedUnreadMessageCount:t}=e.Vault.of(this._iid);let n=!1;const r=s.ts;if("number"==typeof r&&r>t.ts){if(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes)for(const e in s.customTypes)t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e];n=n&&t.ts>0,t.ts=r}n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l.forEach((e=>{e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:t.all,feedChannelCount:t.feed,customTypeUnreadCount:t.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?(o.preference.set(this._getUserProfileCacheKey(i.userId),e.UserProfile.payloadify(s.userProfile)),(null===(n=s.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&o.preference.set(e.createChangelogIncludeChatNotificationsCacheKey(this.appId),{value:!0})):s instanceof e.SessionExpiredCommand&&s.error&&(s.error.isSessionRevokedError||s.error.isUserAuthDeactivedError||s.error.isUserAuthDeletedOrNotFoundError)&&(c.debug("session revoked."),this.disconnect())}))}static init(r){const{appId:i,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:m=new e.LocalCacheConfig,localCacheEncryption:f,useAsyncStorageStore:g=null,appStateToggleEnabled:I=!0}=r;if(!Re||h){const r=`su-${e.uuid()}`,h=null!=f?f:{encrypt:e=>e,decrypt:e=>e};let S=new n.MemoryStore({encryption:h});u||(S=e.isReactNative()?g?new b({AsyncStorage:g,encryption:h}):new n.MemoryStore({encryption:h}):new n.IndexedDbStore({encryption:h})),new e.Vault(r,{appId:i,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${i}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${i}.sendbird.com`,store:S,encryption:h,logLevel:p,localCacheEnabled:_,localCacheConfig:m,debugMode:u,appStateToggleEnabled:I});const v=[new t.MessageModule,new s.PollModule],y=new Ue(r,d,[...a,...v]);return Re||(Re=y),y}return Re}static get instance(){return Re}static get version(){return e.version}get appId(){const{sdkState:t}=e.Vault.of(this._iid);return t.appId}get appInfo(){const{appInfo:t}=e.Vault.of(this._iid);return null!=t?t:null}get appVersion(){var t;const{sdkState:s}=e.Vault.of(this._iid);return null!==(t=s.appVersion)&&void 0!==t?t:""}get debugMode(){const{debugMode:t}=e.Vault.of(this._iid);return!!t}get logLevel(){const{logger:t}=e.Vault.of(this._iid);return t.level}set logLevel(t){const{logger:s}=e.Vault.of(this._iid);s.level=t}get isCacheEnabled(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled}get localCacheConfig(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled?t.localCacheConfig:null}get ekey(){const{sessionManager:t}=e.Vault.of(this._iid);return t.ekey}get currentUser(){var t;const{sessionManager:s}=e.Vault.of(this._iid);return null!==(t=s.currentUser)&&void 0!==t?t:null}get connectionState(){const{connectionManager:t}=e.Vault.of(this._iid);return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}get lastConnectedAt(){const{connectedAt:t,connectionManager:s}=e.Vault.of(this._iid);return s.isConnected?t:0}get fcmPushToken(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}get apnsPushToken(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}_getNestDBVersion(){return 3}_getCurrentPreferenceVersion(){return 1}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof n.MemoryStore?s.store:null;throw e.SendbirdError.debugModeRequired}addExtension(t,s){const{sdkState:n}=e.Vault.of(this._iid);["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(t)>-1&&n.extensions&&(n.extensions[t]=s)}addSendbirdExtensions(t,s,n){const{logger:r,sdkState:i}=e.Vault.of(this._iid),o=new RegExp(e.SEMVER_REGEX_STRING);if(0===t.length)return r.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((e=>!o.test(e.version))))return r.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(const[e,t]of Object.entries(n))if(/&|=/.test(e)||/&|=/.test(t))return r.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1;return i.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:s,customData:n},!0}setOnlineListener(e){this._onlineDetector.setOnlineListener(e)}setOfflineListener(e){this._onlineDetector.setOfflineListener(e)}_safeInitializeStore(t){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:s}=e.Vault.of(this._iid);try{yield s.store.init(t),this._storeInitialized=!0}catch(e){s.replaceStore(new n.MemoryStore),yield this._safeInitializeStore(t)}}))}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:i,connectionManager:o,dispatcher:a,logger:d}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){yield o.logout();const u=`sendbird@${s.appId}/${t}.db`;if(i.localCacheEnabled)try{if(!i.nestdb||i.nestdb.state===n.NestDBState.CLOSED||i.nestdb.name!==u){const e=i.nestdb=new n.NestDB({name:`sendbird@${s.appId}/${t}.db`,version:this._getNestDBVersion(),store:i.store});e.on("upgrade",k(e,i.store)),e.on("storeReplaced",(t=>{i.replaceStore(t),i.localCacheEnabled=!1,e.on("upgrade",k(e,i.store))})),yield e.open(),this._storeInitialized=!0,a.dispatch(new r.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}catch(n){throw d.warn("Nest DB Open Failed. ",n),yield this._safeInitializeStore(u),s.userId=t,e.SendbirdError.databaseError}else yield this._safeInitializeStore(u),s.userId=t}}))}getCacheDataSize(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled&&t.nestdb?yield t.nestdb.estimateUsage():0}))}clearCachedData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);t.localCacheEnabled&&t.nestdb&&(yield t.nestdb.clear()),this._storeInitialized&&(yield t.preference.clear())}))}clearCachedMessages(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=n.MessageCache.of(this._iid),r=n.UnsentMessageCache.of(this._iid);s&&r&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield r.removeMessagesOfChannel(t)}))))))}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",s,!0)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,cacheContext:i,connectionManager:o,statLogCollector:a}=e.Vault.of(this._iid);try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new r.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);i.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}yield i.preference.init(this._getPreferenceCacheKey(t),this._getCurrentPreferenceVersion());const d=yield i.preference.get(this._getUserProfileCacheKey(t));if(d){new e.UserProfile(this._iid,d).apply()}yield a.init(`sendbird@${n.appId}/${t}.statlog`);try{yield o.connect(s)}finally{this._onlineDetector.start(),this._appStateChangeDetector.start()}return this.currentUser}))}reconnect(){const{connectionManager:t,sdkState:s,sessionManager:n}=e.Vault.of(this._iid),r=n.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),r}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:t,requestQueue:s}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),yield t.logout(),yield this.clearCachedData()}))}disconnectWebSocket(){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:t,requestQueue:s}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),yield t.disconnectWebSocket()}))}setBackgroundState(){const{connectionManager:t,sdkState:s,logger:n}=e.Vault.of(this._iid);"foreground"===s.appState&&(s.appState="background",n.debug("going background state"),t.background())}setForegroundState(){const{connectionManager:t,sdkState:s,logger:n}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",n.debug("going foreground state"),t.resetAndReconnect())}setSessionHandler(t){e.unless(t instanceof p).throw(e.SendbirdError.invalidParameters);const{sessionManager:s}=e.Vault.of(this._iid);s.handler=t}addUserEventHandler(t,s){e.unless(e.isTypeOf("string",t)&&s instanceof m).throw(e.SendbirdError.invalidParameters);const{userEventHandlers:n}=e.Vault.of(this._iid);n.set(t,s)}removeUserEventHandler(t){const{userEventHandlers:s}=e.Vault.of(this._iid);s.delete(t)}removeAllUserEventHandler(){const{userEventHandlers:t}=e.Vault.of(this._iid);t.clear()}addConnectionHandler(t,s){e.unless(e.isTypeOf("string",t)&&s instanceof l).throw(e.SendbirdError.invalidParameters);const{connectionHandlers:n}=e.Vault.of(this._iid);n.set(t,s)}removeConnectionHandler(t){const{connectionHandlers:s}=e.Vault.of(this._iid);s.delete(t)}removeAllConnectionHandler(){const{connectionHandlers:t}=e.Vault.of(this._iid);t.clear()}createApplicationUserListQuery(e={}){return new I(this._iid,e)}createBlockedUserListQuery(e={}){return new y(this._iid,e)}createFriendListQuery(e={}){return new E(this._iid,e)}createMessageSearchQuery(e){return new n.MessageSearchQuery(this._iid,e)}createPollListQuery(t){return new e.PollListQuery(this._iid,Object.assign({},t))}createPollVoterListQuery(t){return new e.PollVoterListQuery(this._iid,Object.assign({},t))}buildUserFromSerializedData(t){const s=e.deserialize(t);return new e.User(this._iid,e.User.payloadify(s))}updateCurrentUserInfo(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},A),t);if(e.unless((t=>e.isFile(t.profileImage,!0)&&e.isTypeOf("string",t.profileUrl,!0)&&e.isTypeOf("string",t.nickname,!0))(s)).throw(e.SendbirdError.invalidParameters),this.currentUser){const{sdkState:t,requestQueue:n}=e.Vault.of(this._iid),r=new x(Object.assign({userId:t.userId},s)),i=yield n.send(r),{user:o}=i.as(D);return this.currentUser&&(s.nickname&&(this.currentUser.nickname=o.nickname),(s.profileUrl||s.profileImage)&&(this.currentUser.plainProfileUrl=o.profileUrl)),o}throw e.SendbirdError.connectionRequired}))}updateCurrentUserInfoWithPreferredLanguages(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this.currentUser){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new x({userId:s.userId,preferredLanguages:t}),i=yield n.send(r),{user:o}=i.as(D);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const i=new L({userId:n.userId,token:t});return yield r.send(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t),yield s.saveDeviceToken()})))),this._fcmPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterFCMPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid),i=new N({userId:n.userId,token:t}),{lastDeletedAt:o}=yield r.send(i);return yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.unsetDeviceToken(e.PushTokenType.FCM,t),s.setDeviceTokenDeletedAt(o),yield s.saveDeviceToken()})))),this._fcmPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterFCMPushTokenAllForCurrentUser(){return e.__awaiter(this,void 0,void 0,(function*(){if(this.currentUser){const{sessionManager:t,sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new $({userId:s.userId}),{lastDeletedAt:i}=yield n.send(r);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(i),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const i=new M({userId:n.userId,token:t});return yield r.send(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t),yield s.saveDeviceToken()})))),this._apnsPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterAPNSPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid),i=new q({userId:n.userId,token:t}),{lastDeletedAt:o}=yield r.send(i);return yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.unsetDeviceToken(e.PushTokenType.APNS,t),s.setDeviceTokenDeletedAt(o),yield s.saveDeviceToken()})))),this._apnsPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterAPNSPushTokenAllForCurrentUser(){return e.__awaiter(this,void 0,void 0,(function*(){if(this.currentUser){const{sessionManager:t,sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new V({userId:s.userId}),{lastDeletedAt:i}=yield n.send(r);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(i),yield t.saveDeviceToken()}))))}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new j({userId:t.userId}),r=yield s.send(n),{autoAccept:i}=r.as(Q);return{autoAccept:i}}))}setChannelInvitationPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new z({userId:s.userId,willAutoAccept:t}),i=yield n.send(r),{autoAccept:o}=i.as(B);return{autoAccept:o}}))}getDoNotDisturb(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new G({userId:t.userId}),r=yield s.send(n),{preference:i}=r.as(K);return i}))}setDoNotDisturb(t,s=0,n=0,r=0,i=0,o=""){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)&&e.isTypeOf("number",s)&&e.isTypeOf("number",n)&&e.isTypeOf("number",r)&&e.isTypeOf("number",i)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new W({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:r,endMin:i,timezone:o}),c=yield d.send(u),{preference:l}=c.as(J);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Y({userId:t.userId}),r=yield s.send(n),{snoozePeriod:i}=r.as(X);return i}))}setSnoozePeriod(t,s=0,n=0){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)&&e.isTypeOf("number",s)&&e.isTypeOf("number",n)).throw(e.SendbirdError.invalidParameters);const{sdkState:r,requestQueue:i}=e.Vault.of(this._iid),o=new Z({userId:r.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield i.send(o),{snoozePeriod:d}=a.as(ee);return d}))}getMyPushTokensByToken(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)&&e.isEnumOf(e.PushTokenType,s)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:r,sessionManager:i}=e.Vault.of(this._iid),o=new H({userId:n.userId,type:s,token:t}),a=yield r.send(o),{pushTokens:d}=a.as(F);for(const e of d.deviceTokens)i.setDeviceToken(d.type,e);return yield i.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ne({userId:t.userId});return(yield s.send(n)).as(re).pushTriggerOption}))}setPushTriggerOption(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(e.PushTriggerOption,t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ie({userId:s.userId,pushTriggerOption:t});return(yield n.send(r)).as(oe).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ae({userId:t.userId});return(yield s.send(n)).as(de).name}))}setPushTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(e.PushTemplate,t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ue({userId:s.userId,templateName:t});return(yield n.send(r)).as(ce).name}))}blockUser(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof e.User||e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new te({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(r)}))}blockUserWithUserId(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.blockUser(t)}))}unblockUser(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof e.User||e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new se({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(r)}))}unblockUserWithUserId(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.unblockUser(t)}))}getFriendChangeLogsByToken(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new le({userId:s.userId,token:t}),i=yield n.send(r),{changelogs:o}=i.as(he);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Se({userId:t.userId}),r=yield s.send(n),{allowFriendDiscovery:i}=r.as(ve);return i}))}setAllowFriendDiscovery(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ye({userId:s.userId,allowFriendDiscovery:t});return yield n.send(r),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new pe({userId:s.userId,discoveries:t}),i=yield n.send(r),{friendDiscoveryRequestId:o}=i.as(_e);return o}))}deleteFriendDiscovery(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.deleteFriendDiscoveries([t])}))}deleteFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new me({userId:s.userId,discoveryKeys:t});yield n.send(r)}))}addFriends(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new fe({userId:s.userId,userIds:t}),i=yield n.send(r),{users:o}=i.as(ge);return o}))}deleteFriend(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.deleteFriends([t])}))}deleteFriends(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new Ie({userId:s.userId,userIds:t});yield n.send(r)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new Pe,n=yield t.send(s),{emojiContainer:r}=n.as(Ce);return r}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new Ee({categoryId:t}),r=yield s.send(n),{emojiCategory:i}=r.as(Te);return i}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new be({key:t}),r=yield s.send(n),{emoji:i}=r.as(Ae);return i}))}getUIKitConfiguration(){return e.__awaiter(this,void 0,void 0,(function*(){const t=e.Vault.of(this._iid);e.unless(t.hasExtension("sb_uikit")).throw(e.SendbirdError.notSupportedError);const{requestQueue:s}=t,n=new we,r=yield s.send(n),{uikitConfiguration:i}=r.as(ke);return i}))}}exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"CollectionEventSource",{enumerable:!0,get:function(){return e.CollectionEventSource}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),Object.defineProperty(exports,"DeviceOsPlatform",{enumerable:!0,get:function(){return e.DeviceOsPlatform}}),exports.LocalCacheConfig=e.LocalCacheConfig,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return e.LogLevel}}),exports.NotificationInfo=e.NotificationInfo,Object.defineProperty(exports,"PushTemplate",{enumerable:!0,get:function(){return e.PushTemplate}}),Object.defineProperty(exports,"PushTokenRegistrationState",{enumerable:!0,get:function(){return e.PushTokenRegistrationState}}),Object.defineProperty(exports,"PushTokenType",{enumerable:!0,get:function(){return e.PushTokenType}}),Object.defineProperty(exports,"PushTriggerOption",{enumerable:!0,get:function(){return e.PushTriggerOption}}),Object.defineProperty(exports,"Role",{enumerable:!0,get:function(){return e.Role}}),exports.SendbirdChatOptions=e.SendbirdChatOptions,exports.SendbirdError=e.SendbirdError,Object.defineProperty(exports,"SendbirdPlatform",{enumerable:!0,get:function(){return e.SendbirdPlatform}}),Object.defineProperty(exports,"SendbirdProduct",{enumerable:!0,get:function(){return e.SendbirdProduct}}),exports.UIKitConfigInfo=e.UIKitConfigInfo,exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,exports.MemoryStore=n.MemoryStore,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,exports.Plugin=n.Plugin,Object.defineProperty(exports,"ReportCategory",{enumerable:!0,get:function(){return n.ReportCategory}}),exports.RestrictedUser=n.RestrictedUser,exports.RestrictionInfo=n.RestrictionInfo,Object.defineProperty(exports,"RestrictionType",{enumerable:!0,get:function(){return n.RestrictionType}}),exports.Participant=o.Participant,exports.ApplicationUserListQuery=I,exports.BlockedUserListQuery=y,exports.ConnectionHandler=l,exports.Emoji=a,exports.EmojiCategory=d,exports.EmojiContainer=u,exports.FriendListQuery=E,exports.SessionHandler=p,exports.UserEventHandler=m,exports.default=Ue; diff --git a/cjs/lib/__bundle-218bea1d.js b/cjs/lib/__bundle-218bea1d.js deleted file mode 100644 index 5fbd6e1..0000000 --- a/cjs/lib/__bundle-218bea1d.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,t,s,n,i,a,r,o,l,d=require("./__bundle-c176c59f.js"),h=require("./__bundle-a4005096.js"),c=require("./__bundle-617167af.js"),u=require("./__bundle-4bc3a029.js"),_=require("./__bundle-7ee4a5eb.js"),p=require("./__bundle-f5cc59df.js");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class m extends h.RestrictedUser{constructor(e,t){super(e,t),this.state=null,this.role=null,this.isMuted=!1,this.isBlockedByMe=!1,this.isBlockingMe=!1,this.state=d.isEnumOf(exports.MemberState,t.state)?t.state:null,this.role=d.isEnumOf(d.Role,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(this.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(this.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(this.isBlockingMe=t.is_blocking_me)}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}class C extends d.InstancedObject{constructor(e,t){var s,n;super(e),this.channelUrl=null!==(s=t.channel_url)&&void 0!==s?s:"",this.channelType=null!==(n=t.channel_type)&&void 0!==n?n:d.ChannelType.GROUP,this.reader=new d.User(this._iid,t.user),this.readAt=t.ts}}exports.PublicChannelFilter=void 0,(t=exports.PublicChannelFilter||(exports.PublicChannelFilter={})).ALL="all",t.PUBLIC="public",t.PRIVATE="private",exports.MyMemberStateFilter=void 0,(s=exports.MyMemberStateFilter||(exports.MyMemberStateFilter={})).ALL="all",s.JOINED="joined_only",s.INVITED="invited_only",s.INVITED_BY_FRIEND="invited_by_friend",s.INVITED_BY_NON_FRIEND="invited_by_non_friend",exports.SuperChannelFilter=void 0,(n=exports.SuperChannelFilter||(exports.SuperChannelFilter={})).ALL="all",n.SUPER="super",n.NON_SUPER="nonsuper",n.BROADCAST_ONLY="broadcast_only",n.EXCLUSIVE_ONLY="exclusive_only",exports.UnreadChannelFilter=void 0,(i=exports.UnreadChannelFilter||(exports.UnreadChannelFilter={})).ALL="all",i.UNREAD_MESSAGE="unread_message",exports.HiddenChannelFilter=void 0,(a=exports.HiddenChannelFilter||(exports.HiddenChannelFilter={})).ALL="all",a.UNHIDDEN="unhidden_only",a.HIDDEN="hidden_only",a.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",a.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",exports.OperatorFilter=void 0,(r=exports.OperatorFilter||(exports.OperatorFilter={})).ALL="all",r.OPERATOR="operator",r.NONOPERATOR="nonoperator",exports.QueryType=void 0,(o=exports.QueryType||(exports.QueryType={})).AND="AND",o.OR="OR",exports.GroupChannelSearchField=void 0,(l=exports.GroupChannelSearchField||(exports.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",l.CHANNEL_NAME="channel_name";class g{constructor(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}_isFriend(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}get searchFilter(){return this._searchFilter}setSearchFilter(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}get userIdsFilter(){return this._userIdsFilter}setUserIdsFilter(e,t,s=exports.QueryType.AND){this._userIdsFilter={userIds:e,includeMode:t,queryType:s}}clone(){var e;const t=new g;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);const s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((e=>{t[e]=s[e]})),t}match(e,t){if(this._searchFilter){const{query:t,fields:s}=this._searchFilter;if(t&&s&&s.length>0&&!s.some((s=>{switch(s){case exports.GroupChannelSearchField.CHANNEL_NAME:return e.name.toLowerCase().includes(t.toLowerCase());case exports.GroupChannelSearchField.MEMBER_NICKNAME:return e.members.some((e=>e.nickname.toLowerCase().includes(t.toLowerCase())));default:return!0}})))return!1}if(this._userIdsFilter){const{userIds:s,includeMode:n,queryType:i}=this._userIdsFilter,a=e.members.map((e=>e.userId));if(n){if(s.length>0)switch(i){case exports.QueryType.AND:if(s.some((e=>!a.includes(e))))return!1;break;case exports.QueryType.OR:if(s.every((e=>!a.includes(e))))return!1}}else{if(s.includes(t)||s.push(t),e.members.length>s.length)return!1;if(!d.hasSameMembers(s,a))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp(`^${this.customTypeStartsWithFilter}`).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){const s=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().includes(s))))return!1}if(this.nicknameStartsWithFilter){const s=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().startsWith(s))))return!1}if(this.nicknameExactMatchFilter){const s=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase()!=s)))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case exports.MyMemberStateFilter.JOINED:if("joined"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED:if("invited"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case exports.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case exports.HiddenChannelFilter.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN:if(!e.isHidden)return!1;break;case exports.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===exports.UnreadChannelFilter.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case exports.PublicChannelFilter.PUBLIC:if(!e.isPublic)return!1;break;case exports.PublicChannelFilter.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case exports.SuperChannelFilter.SUPER:if(!e.isSuper)return!1;break;case exports.SuperChannelFilter.NON_SUPER:if(e.isSuper)return!1}return!0}}class E extends d.InstancedObject{constructor(e,{sdkState:t,cacheContext:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=s}get collection(){const{nestdb:e}=this._cacheContext;return d.unless(!!e).throw(d.SendbirdError.databaseError),e.collection(u.NESTDB_GROUPCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,t=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}_deserialize(e){return Ue.of(this._iid).buildGroupChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}filterOffsetChanged(e){return e.filter((e=>{if(this._channels.has(e.url)){return this._channels.get(e.url).messageOffsetTimestamp{if(e)switch(i){case c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;if(a&&a===t.url)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);n._pinnedMessagesUpdatedAt0&&(yield this.upsert(n))}))}block(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!0)}))}unblock(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!1)}))}markAsRead(e,t=[...this._channels.keys()]){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.get(n);(null==t?void 0:t._updateUnreadMemberState(this._sdkState.userId,e))&&(t._updateUnreadCount(0,0),s.push(t))}s.length>0&&(yield this.upsert(s))}))}}const v={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},f=e=>d.isArrayOf("string",e.invitedUserIds,!0)&&d.isTypeOf("string",e.channelUrl,!0)&&d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isSuper,!0)&&d.isTypeOf("boolean",e.isBroadcast,!0)&&d.isTypeOf("boolean",e.isExclusive,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isStrict,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("boolean",e.isEphemeral,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0),M={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},S=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty)&&d.isTypeOf("boolean",e.includeFrozen)&&d.isTypeOf("boolean",e.includeChatNotification),y={myMemberStateFilter:exports.MyMemberStateFilter.ALL},b=e=>d.isEnumOf(exports.MyMemberStateFilter,e.myMemberStateFilter);var A;exports.UnreadItemKey=void 0,(A=exports.UnreadItemKey||(exports.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",A.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",A.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",A.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",A.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",A.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",A.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",A.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",A.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";const N={keys:[]},T={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},U=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),I={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},P=Object.assign({},d.CollectionEventSource),O=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class x extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null,ts:i}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n,this.ts=i}}class R extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class w{constructor({groupChannelCache:e,messageCache:t,unsentMessageCache:s,dispatcher:n}){this._observers=new Map,n.on((n=>d.__awaiter(this,void 0,void 0,(function*(){if(n instanceof x){const{channels:s,source:i,isWebSocketEventComing:a,data:r}=n,o=s.filter((e=>e instanceof Ft)),l=e.filterOffsetChanged(o);for(const e of l)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);const d=yield e.upsert(o,n.ts);a||this._broadcastUpdateEvent(d,i,r)}else if(n instanceof R){const{channelUrls:i,source:a,isWebSocketEventComing:r}=n;yield e.remove(i),yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield t.removeMessagesOfChannel(e),yield s.removeMessagesOfChannel(e)})))),r||this._broadcastRemoveEvent(i,a)}else n instanceof c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t,s){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t,s)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class D extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},M),n);this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/my_group_channels/changelogs`,this.params=d.deundefined(d.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:t||null,token:s,custom_types:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class L extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new Ft(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${t?d.API_PATH_GROUP_CHANNELS_INTERNAL:d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class k extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}const H={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:exports.MyMemberStateFilter.ALL,unreadChannelFilter:exports.UnreadChannelFilter.ALL,superChannelFilter:exports.SuperChannelFilter.ALL,publicChannelFilter:exports.PublicChannelFilter.ALL,hiddenChannelFilter:exports.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:c.GroupChannelListOrder.LATEST_LAST_MESSAGE};class V extends d.APIRequestCommand{constructor(e){const{userId:t,token:s,limit:n,order:i,includeEmpty:a,myMemberStateFilter:r,superChannelFilter:o,publicChannelFilter:l,unreadChannelFilter:h,nicknameContainsFilter:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:C,customTypeStartsWithFilter:g,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:S,includeFrozen:y,includeMetaData:b,searchFilter:A,userIdsFilter:N,includeChatNotification:T=!1}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=d.deundefined({token:s,limit:n,order:null!=i?i:H.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:H.includeEmpty,member_state_filter:null!=r?r:H.myMemberStateFilter,super_mode:null!=o?o:H.superChannelFilter,public_mode:null!=l?l:H.publicChannelFilter,unread_filter:null!=h?h:H.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:C,custom_type_startswith:g,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:S,show_frozen:y,show_metadata:b,include_chat_notification:T}),A&&A.query&&A.fields&&(this.params.search_query=A.query,this.params.search_fields=A.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class G extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:s,channels:n,ts:i}=t;this.token=s,n&&n.length>0&&(this.channels=n.map((t=>(t.ts=i,new Ft(e,t))))),this.ts=null!=i?i:0}}class q extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{myMemberStateFilter:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/group_channel_count`,this.params={state:null!=s?s:exports.MyMemberStateFilter.ALL}}}class B extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class j extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s})}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(this.groupChannelUnreadMentionCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(this.groupChannelUnreadMessageCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(this.groupChannelInvitationCount=t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(this.superGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(this.superGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]&&(this.superGroupChannelInvitationCount=t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(this.nonSuperGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(this.nonSuperGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(this.nonSuperGroupChannelInvitationCount=t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT])}}class $ extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class z extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class Q extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Y extends d.APIRequestCommand{constructor({channelUrl:e,scheduledStatus:t,messageTypeFilter:s}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_SCHEDULED_MESSAGES}/count`,this.params={channel_url:e,status:Z(t)},s&&(this.params.message_type=s)}}class J extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const Z=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case u.ScheduledStatus.PENDING:t.push(u.InternalScheduledStatus.PENDING);break;case u.ScheduledStatus.SENT:t.push(u.InternalScheduledStatus.IN_QUEUE),t.push(u.InternalScheduledStatus.SENT);break;case u.ScheduledStatus.CANCELED:t.push(u.InternalScheduledStatus.CANCELED);break;case u.ScheduledStatus.FAILED:t.push(u.InternalScheduledStatus.FAILED)}})),t};class X extends d.APIRequestCommand{constructor(e){const{userId:t,channelUrl:s,coverUrl:n,coverImage:i,isDistinct:a,isSuper:r,isBroadcast:o,isPublic:l,isExclusive:h,isDiscoverable:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:C,customType:g,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].filter(((e,t,s)=>t===s.indexOf(e))),channel_url:s,cover_url:n,cover_file:i,is_distinct:a,is_super:r,is_broadcast:o,is_exclusive:h,is_public:l,is_discoverable:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:C,custom_type:g,operator_ids:f,message_survival_seconds:E})}}class ee extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new Ft(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class te extends d.APIRequestCommand{constructor({userId:e,channelUrls:t}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/mark_as_read_all`,this.params={channel_urls:t}}}class se extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/join`,this.params={user_id:s,access_code:n}}}class ne extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}class ie extends _.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0,users:a=null}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.members=Array.isArray(a)?a.map((t=>new m(e,t))):[new m(e,s.data)]}}class ae extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,shouldRemoveOperatorStatus:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/leave`,this.params={user_id:s,should_remove_operator_status:n}}}class re extends _.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.member=new m(this._iid,s.data)}}class oe extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userIds:s}=e;super(),this.method=d.APIRequestMethod.POST,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/invite`,this.params={user_ids:s}}}class le extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}class de extends _.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new m(e,t)))}}class he extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/decline`,this.params={user_id:s}}}class ce extends _.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n,joined_member_count:i,inviter:a,invitee:r}=s.data;this.memberCount=null!=n?n:0,this.joinedMemberCount=null!=i?i:0,this.inviter=new d.User(e,a),this.invitee=new m(e,r)}}const ue={hidePreviousMessages:!1,allowAutoUnhide:!0};class _e extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,hidePreviousMessages:n,allowAutoUnhide:i}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`,this.params={user_id:s,hide_previous_messages:null!=n?n:ue.hidePreviousMessages,allow_auto_unhide:null!=i?i:ue.allowAutoUnhide}}}class pe extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class me extends d.WebSocketEventCommand{constructor(e,t,s){var n,i,a;super(e,"SYEV",s),this.allowAutoUnhide=null,this.hidePreviousMessages=null,this.messageOffsetTimestamp=null,s.data&&(this.allowAutoUnhide=null!==(n=s.data.allow_auto_unhide)&&void 0!==n?n:null,this.hidePreviousMessages=null!==(i=s.data.hide_previous_messages)&&void 0!==i?i:null),this.messageOffsetTimestamp=null!==(a=s.ts_message_offset)&&void 0!==a?a:null}}class Ce extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ge extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ee extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPEN",ackRequired:!1,payload:{channel_url:e,time:t}})}}class ve extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class fe extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class Me extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,C,g,E,v,f,M,S,y,b,A;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter={fields:[],query:null},this.userIdsFilter={userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=c.GroupChannelListOrder.LATEST_LAST_MESSAGE,this.includeEmpty=null!==(s=t.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(n=t.includeFrozen)||void 0===n||n,this.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,this.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(C=t.superChannelFilter)&&void 0!==C?C:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(g=t.publicChannelFilter)&&void 0!==g?g:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(S=t.metadataValues)&&void 0!==S?S:null,this.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,this.metadataValueStartsWith=null!==(b=t.metadataValueStartsWith)&&void 0!==b?b:null,this.order=null!==(A=t.order)&&void 0!==A?A:c.GroupChannelListOrder.LATEST_LAST_MESSAGE}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeEmpty)&&d.isTypeOf("boolean",this.includeFrozen)&&d.isTypeOf("boolean",this.includeMetaData)&&d.isTypeOf("string",this.channelNameContainsFilter)&&d.isArrayOf("string",this.channelUrlsFilter,!0)&&d.isArrayOf("string",this.customTypesFilter,!0)&&d.isTypeOf("string",this.customTypeStartsWithFilter)&&d.isTypeOf("string",this.nicknameContainsFilter,!0)&&d.isTypeOf("string",this.nicknameStartsWithFilter,!0)&&d.isTypeOf("string",this.nicknameExactMatchFilter,!0)&&d.isEnumOf(exports.MyMemberStateFilter,this.myMemberStateFilter)&&d.isEnumOf(exports.SuperChannelFilter,this.superChannelFilter)&&d.isEnumOf(exports.PublicChannelFilter,this.publicChannelFilter)&&d.isEnumOf(exports.UnreadChannelFilter,this.unreadChannelFilter)&&d.isEnumOf(exports.HiddenChannelFilter,this.hiddenChannelFilter)&&d.isArrayOf(exports.GroupChannelSearchField,this.searchFilter.fields)&&d.isTypeOf("string",this.searchFilter.query,!0)&&d.isArrayOf("string",this.userIdsFilter.userIds)&&d.isTypeOf("boolean",this.userIdsFilter.includeMode)&&d.isEnumOf(exports.QueryType,this.userIdsFilter.queryType)&&d.isEnumOf(c.GroupChannelListOrder,this.order)&&d.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&d.isTypeOf("string",this.metadataKey,!0)&&d.isArrayOf("string",this.metadataValues,!0)&&d.isTypeOf("string",this.metadataValueStartsWith,!0)}serialize(){return d.serialize(this)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=Ue.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class Se extends d.WebSocketEventCommand{constructor(e,t,s){var n;super(e,"SYEV",s),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,s.data&&(this.pinnedMessageIds=null!==(n=s.data.pinned_message_ids)&&void 0!==n?n:[],this.latestPinnedMessage=s.data.latest_pinned_message?u.parseMessagePayload(e,Object.assign({},s.data.latest_pinned_message)):null),this.ts=s.ts}}class ye extends d.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class be extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new C(e,s)}}class Ae extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){super(),super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/messages/mark_as_delivered`,this.params=d.deundefined({userId:t})}}class Ne extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}const Te={};class Ue extends _.BaseChannelManager{constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new E(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new w({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:u.MessageCache.of(this._iid),unsentMessageCache:u.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new x({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),this._groupChannelHandlers.forEach((t=>{t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))}),1e3),this._dispatcher.on((e=>{e instanceof d.WebSocketEventCommand?this._handleEvent(e):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof u.UserMessage?s._autoResendUserMessage(t):t instanceof u.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand&&this.reduceDBSize()})),Te[e]||(Te[e]=this)}static of(e){return Te[e]||(Te[e]=new Ue(e,d.Vault.of(e))),Te[e]}static clear(e){Te[e]&&delete Te[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new Ft(this._iid,Ft.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new Me(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new m(this._iid,m.payloadify(t))}getChannelFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._groupChannelCache.get(e))&&void 0!==t?t:null}))}getChannelsFromCache(e,t,s,n,i){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.fetch({token:e,filter:t,order:s,limit:n,borderlineChannelUrl:i})}))}upsertChannelsToCache(e){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.upsert(e)}))}removeChannelsFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.remove(e)}))}clearChannelsFromCache(){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.clear()}))}reduceDBSize(){return d.__awaiter(this,void 0,void 0,(function*(){const e=u.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=u.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new fe(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof u.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0);if(r.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(r.hiddenState=exports.HiddenState.UNHIDDEN),e instanceof u.SendableMessage){const{useMemberInfoInMessage:s}=d.Vault.of(this._iid);for(const t of r.members)if(t.userId===e.sender.userId){s||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!s&&n&&(null===(t=e.mentionedUsers)||void 0===t||t.forEach((e=>{for(const t of r.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),a){const{currentUser:t}=this._sessionManager;t&&(t.nickname=e.sender.nickname,t.plainProfileUrl=e.sender.plainProfileUrl,t.metaData=e.sender.metaData)}}e.silent&&!a||(r.isEphemeral||s)&&((!r.lastMessage||r.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(r)})))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageReceived&&t.onMessageReceived(r,e),n&&t.onMentionReceived&&t.onMentionReceived(r,e)}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===e.code?t=e.as(h.UpdateUserMessageEventCommand):"FEDI"===e.code?t=e.as(h.UpdateFileMessageEventCommand):"AEDI"===e.code&&(t=e.as(_.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:s}=t;if(e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),n=yield this.getChannel(e.channelUrl,!0),i=e instanceof u.SendableMessage&&e.sender.userId===this._sdkState.userId;let a=!1;if(i){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else n.isReadMessage(e)||0!==s&&!e.silent&&t&&(n._updateUnreadCount(n.unreadMessageCount,n.unreadMentionCount+s),a=!0);!n.lastMessage||n.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),r&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(n,e),0!==s&&t.onMentionReceived&&t.onMentionReceived(n,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n}=e.as(h.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.EVENT_MESSAGE_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageDeleted&&t.onMessageDeleted(e,n)}))))}break}case"READ":{const{readStatus:t}=e.as(be);if(t.channelType===d.ChannelType.GROUP){const e=this._groupChannelCache.isCachedInMemory(t.channelUrl),s=yield this.getChannel(t.channelUrl,!0);e&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId?e?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):(this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(s)})))))}break}case"DLVR":{const{channelUrl:t,deliveredStateUpdate:s={}}=e.as(Ne),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);if(n)for(const e in s)i._updateUndeliveredMemberState(e,s[e]);Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new x({channels:[i],source:d.CollectionEventSource.EVENT_CHANNEL_DELIVERED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUndeliveredMemberStatusUpdated&&e.onUndeliveredMemberStatusUpdated(i)})))));break}case"MRCT":{const{channelUrl:t,channelType:s,event:n}=e.as(_.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onReactionUpdated&&t.onReactionUpdated(e,n)}))))}break}case"MTHD":{const{event:t}=e.as(_.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onThreadInfoUpdated&&s.onThreadInfoUpdated(e,t)}))))}break}case"MCNT":{const{groupChannelMemberCounts:t}=e.as(_.MemberCountUpdateEventCommand),s=[];for(const e of t){const{channelUrl:t,memberCount:n,joinedMemberCount:i,updatedAt:a}=e,r=yield this.getChannelFromCache(t);r&&r._setLatestMemberCount(n,i,a)&&s.push(r)}s.length>0&&(this._dispatcher.dispatch(new x({channels:s,source:d.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(s)})))));break}case"PEDI":{const{event:t,status:s,channelUrl:n,channelType:i}=e.as(_.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_UPDATED})),s===d.POLL_REMOVED_STATUS?d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollDeleted&&s.onPollDeleted(e,t.pollId)})))):d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollUpdated&&s.onPollUpdated(e,t)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:n}=e.as(h.PollVoteEventCommand);if(s&&n===d.ChannelType.GROUP){const e=yield this.getChannel(s,!0);this._dispatcher.dispatch(new d.PollVoteInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_VOTED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollVoted&&s.onPollVoted(e,t)}))))}break}case"SYEV":{const{event:t}=e.as(_.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case _.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ie);let r=!1;a.forEach((e=>{s.isExclusive||s.isSuper||s.isBroadcast?r=r||s._setLatestMemberCount(n,i,t.ts):(e.state=exports.MemberState.JOINED,s.addMember(e,t.ts),this._updateJoinedMemberCount(s)),e.userId===this._sdkState.userId&&(s.myMemberState=exports.MemberState.JOINED)})),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{for(const t of a)e.onUserJoined&&e.onUserJoined(s,t);s.isBroadcast&&r&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([s])}))}))));break}case _.ChannelEventCategory.CHANNEL_LEAVE:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0),{memberCount:i,joinedMemberCount:a,member:r}=e.as(re);let o=!1;const{appInfo:l}=d.Vault.of(this._iid);if(n.isExclusive||n.isSuper||n.isBroadcast)o=n._setLatestMemberCount(i,a,t.ts);else{if(null==l?void 0:l.enabledChannelMemberShipHistory){const e=n.members.find((t=>t.userId===e.userId));e&&(e.state=exports.MemberState.LEFT),n.memberCount=i}else n.removeMember(r);this._updateJoinedMemberCount(n)}r.userId===this._sdkState.userId?(n.myMemberState=exports.MemberState.NONE,n.invitedAt=0,n.joinedAt=0,n._updateUnreadCount(0,0),n.isPublic?this._dispatcher.dispatch(new x({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(n),this._dispatcher.dispatch(new R({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new x({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserLeft&&e.onUserLeft(n,r),n.isBroadcast&&o&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([n])}))}))));break}case _.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(_.OperatorUpdateEventCommand),i=n.map((e=>e.userId));for(const e of s.members)e.role=i.includes(e.userId)?d.Role.OPERATOR:d.Role.NONE;s.myRole=i.includes(this._sdkState.userId)?d.Role.OPERATOR:d.Role.NONE,this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case _.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(de);r.forEach((e=>e.state=exports.MemberState.INVITED));for(const e of r)s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.addMember(e,t.ts),this._sdkState.userId===e.userId&&(s.hiddenState=exports.HiddenState.UNHIDDEN,s.myMemberState!==exports.MemberState.JOINED&&(s.myMemberState=exports.MemberState.INVITED),s.invitedAt=t.ts);this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case _.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(ce);s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.removeMember(r),this._sdkState.userId===r.userId?(s.invitedAt=0,s.myMemberState=exports.MemberState.NONE,s.isPublic?this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new R({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case _.ChannelEventCategory.TYPING_START:case _.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===_.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?ge:ve);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onTypingStatusUpdated&&e.onTypingStatusUpdated(s)}))}))));break}case _.ChannelEventCategory.USER_CHANNEL_MUTE:case _.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===_.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.MutedState.UNMUTED,s._myMutedRemainingTime=i.restrictionInfo.remainingDuration);for(const e of s.members)if(e.userId===i.userId){e.isMuted=n;break}this._dispatcher.dispatch(new x({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,data:i.userId})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onUserMuted&&e.onUserMuted(s,i):e.onUserUnmuted&&e.onUserUnmuted(s,i)}))}))));break}case _.ChannelEventCategory.USER_CHANNEL_BAN:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0);this._markAsLeave(n);const{user:i}=e.as(h.BanUserEventCommand);i.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_BANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case _.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new R({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case _.ChannelEventCategory.CHANNEL_FREEZE:case _.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new x({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onChannelFrozen&&e.onChannelFrozen(s):e.onChannelUnfrozen&&e.onChannelUnfrozen(s)}))}))));break}case _.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(me);null!==n&&(s.hiddenState=n?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==i&&i&&s._updateUnreadCount(0,0),null!==a&&(s.messageOffsetTimestamp=a),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case _.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new x({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case _.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new R({channelUrls:[t.channelUrl],source:d.CollectionEventSource.EVENT_CHANNEL_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelDeleted&&t.onChannelDeleted(e.url,e.channelType)}))}))));break}case _.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new x({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case _.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaDataEventCommand);n&&(s._upsertCachedMetaData(n,t.ts),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaDataCreated&&e.onMetaDataCreated(s,n),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(s,i),a&&e.onMetaDataDeleted&&e.onMetaDataDeleted(s,a)}))}))));break}case _.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED})),i&&this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED})),a&&this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaCounterCreated&&e.onMetaCounterCreated(s,n),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(s,i),a&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(s,a)}))}))));break}case _.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(Se);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=n,s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new x({channels:[s],source:d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)})))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(s)}))})))));break}}break}case"USEV":{const{event:t}=e.as(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.unblock(e.userId,s.userId);break}}break}}}catch(e){if(d.isThrowingOutside(e))throw e}}))}_markAsLeave(e){var t;const s=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};s.ref++,this._leftChannels.set(e.url,s),setTimeout((()=>{s.ref--,0===s.ref&&this._leftChannels.delete(e.url)}),1e4)}addHandler(e,t){this._groupChannelHandlers.set(e,t)}removeHandler(e){this._groupChannelHandlers.delete(e)}clearHandler(){this._groupChannelHandlers.clear()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.unsubscribe(e)}_updateJoinedMemberCount(e){e.joinedMemberCount=e.members.filter((e=>e.state===exports.MemberState.JOINED)).length}getChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);try{const t=yield this.getChannelFromCache(e);if(t)return t}catch(e){}return yield this.getChannelWithoutCache(e,t)}))}getChannelWithoutCache(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);const s=new F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(k);let{unreadMessageCount:a,unreadMentionCount:r}=i;switch(i.myCountPreference){case exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:r=0;break;case exports.CountPreference.UNREAD_MENTION_COUNT_ONLY:a=0;break;case exports.CountPreference.OFF:a=0,r=0}return i._updateUnreadCount(a,r),(yield this.upsertChannelsToCache([i]))[0]}))}refreshChannel(e,t=!0,s=d.CollectionEventSource.REFRESH_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){try{const n=new F({channelUrl:e,isInternalCall:t}),i=yield this._requestQueue.send(n),{channel:a}=i.as(k);if(a.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new R({channelUrls:[a.url],source:s}));else{const e=yield this.upsertChannelsToCache([a]);this._dispatcher.dispatch(new x({channels:e,source:s}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new R({channelUrls:[e],source:s}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){const i=new V(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s})),a=yield this._requestQueue.send(i),{channels:r,token:o}=a.as(G);return this._dispatcher.dispatch(new x({channels:r,source:n})),{channels:r,token:o}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},M),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&S(n)).throw(d.SendbirdError.invalidParameters);const i=new D(d.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:n})),a=(yield this._requestQueue.send(i)).as(L),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new x({channels:r,source:s,ts:h})),o.length>0&&this._dispatcher.dispatch(new R({channelUrls:o,source:s})),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,token:a.token}}))}getGroupChannelCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},y),e);d.unless(b(t)).throw(d.SendbirdError.invalidParameters);const s=new q({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(B);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys))(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new j({userId:s.userId,filter:t}),a=yield n.send(i),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(W);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m})}))}getTotalUnreadChannelCount(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new $({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(z);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},T),e);d.unless(U(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new Q({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(K);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},I),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(u.ScheduledStatus,e.scheduledStatus,!0)&&d.isEnumOf(d.MessageTypeFilter,e.messageTypeFilter))(t)).throw(d.SendbirdError.invalidParameters);const{requestQueue:s}=d.Vault.of(this._iid),n=new Y(t),i=yield s.send(n),{count:a}=i.as(J);return a}))}getSubscribedTotalUnreadMessageCount(){const{subscribedUnreadMessageCount:e}=d.Vault.of(this._iid);return e.all>=0?e.all:0}getSubscribedCustomTypeTotalUnreadMessageCount(){let e=0;const{subscribedUnreadMessageCount:t}=d.Vault.of(this._iid);for(const s in t.customTypes)e+=t.customTypes[s];return e}getSubscribedCustomTypeUnreadMessageCount(e){var t;const{subscribedUnreadMessageCount:s}=d.Vault.of(this._iid);return null!==(t=s.customTypes[e])&&void 0!==t?t:0}createChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},v),e);d.unless(f(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new X(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(ee);return yield this.upsertChannelsToCache([i]),i}))}markAsReadAll(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Date.now();d.unless(e-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e;const t=new te({userId:this._sdkState.userId});yield this._requestQueue.send(t);const s=this._groupChannelCache.channels;for(const t of s)t._updateUnreadMemberState(this._sdkState.userId,e),t._updateUnreadCount(0,0);s.length>0&&(yield this.upsertChannelsToCache(s))}))}markAsReadWithChannelUrls(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Date.now();d.unless(d.isArrayOf("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t;const s=new te({userId:this._sdkState.userId,channelUrls:e});yield this._requestQueue.send(s);const n=this._groupChannelCache.channels,i=[];for(const s of n)e.includes(s.url)&&(s._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0),i.push(s));i.length>0&&(yield this.upsertChannelsToCache(i))}))}markAsDelivered(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getChannel(e);yield t.markAsDelivered()}))}}var Ie;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ie||(Ie={}));class Pe extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ie.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ie.IDLE}get isRunning(){return this._state===Ie.RUNNING}get isDone(){return this._state===Ie.END}get retryCount(){return this._retryCount}get retryLimit(){return this._retryLimit}_run(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this.isRunning)try{const t=yield this._worker(e);this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end()}catch(t){this.dispatch("error",t),this._retryCount`sendbird:${e}@groupchannel/${t}/message/sync`)(n.userId,t.url);this._prevSync=new Pe(l,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,i,r;const o={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(e),a.debug("message background prev sync from",null===(t=this._metadata)||void 0===t?void 0:t.range.top),null===(s=this._metadata)||void 0===s?void 0:s.previousComplete)o.hasNext=!1;else try{const t=u.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(i=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===i?void 0:i.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(r=this._metadata)||void 0===r?void 0:r.range.intersect(...e))?this.extendRange(s):this._metadata={range:new _.TimeRange({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}o.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(o.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){var t,s,n,i;const r={hasNext:!0,nextToken:0};this._nextSyncLoopCount++,yield this.loadMetadata(e),a.debug("message background next sync from",null===(t=this._metadata)||void 0===t?void 0:t.range.bottom);try{const t=u.MessageManager.of(this._iid),o=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(n=null===(s=this._metadata)||void 0===s?void 0:s.range)||void 0===n?void 0:n.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(o.length>0){const e=o.map((e=>e.createdAt));(null===(i=this._metadata)||void 0===i?void 0:i.range.intersect(...e))?this.extendRange(o):this._metadata={range:new _.TimeRange({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}r.hasNext=o.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(r.nextToken=this._metadata.range.bottom),a.debug("message background next sync progress",r),yield this.saveMetadata()}catch(e){throw a.debug("message background next sync error",e),e}return r})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new xe({_iid:e,channel:t})),Oe[e][t.url].ref++,Oe[e][t.url]}static clear(e,t){Oe[e]&&Oe[e][t]&&(Oe[e][t].close(),delete Oe[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new _.TimeRange({})}get previousComplete(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}isWrappingMessages(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes(...e.map((e=>e.createdAt)))}extendRange(e){this._metadata&&this._metadata.range.extends(...e.map((e=>e.createdAt)))}loadMetadata(e){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=d.Vault.of(this._iid),s=yield t.preference.get(this._metadataKey);s?s.range.bottom`sendbird:${e}@groupchannel/${t}/message/changelogs`)(n.userId,this._channel.url);this._sync=new Pe(o,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),s.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=u.MessageManager.of(this._iid),{updatedMessages:n,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:d.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(n.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),s.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw s.debug("message changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Re[e]||(Re[e]={}),Re[e][t.url]||(Re[e][t.url]=new we({_iid:e,channel:t})),Re[e][t.url].ref++,Re[e][t.url]}static clear(e,t){Re[e]&&Re[e][t]&&(Re[e][t].close(),delete Re[e])}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e,firstConnectedAt:t}=d.Vault.of(this._iid),s=yield e.preference.get(this._metadataKey);this._metadata={token:s?s.token:t}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);t.isConnected&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);e.debug("message changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid][this._channel.url])}}const De={};class Le{constructor({_iid:e,channel:t,hasPollMessage:s}){this.ref=0,this._iid=e,this._channel=t;const{logger:n,sdkState:i,dispatcher:a}=d.Vault.of(this._iid);var r,o;this._metadataKey=(r=i.userId,o=t.url,`sendbird:${r}@groupchannel/${o}/poll/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/poll/changelogs`)(i.userId,this._channel.url);this._sync=new Pe(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};if(yield this.loadMetadata(),n.debug("poll changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token),!(this._metadata&&this._metadata.token||(yield s()))){return{hasNext:!1,nextToken:0}}if(!this._metadata){const{firstConnectedAt:e}=d.Vault.of(this._iid);this._metadata={token:e}}try{const e=p.PollManager.of(this._iid),{hasMore:s,token:i}=yield e.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);t.hasNext=s,t.nextToken=i,this._metadata.token=i,n.debug("poll changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("poll changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t,s){return De[e]||(De[e]={}),De[e][t.url]||(De[e][t.url]=new Le({_iid:e,channel:t,hasPollMessage:s})),De[e][t.url].ref++,De[e][t.url]}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e}=d.Vault.of(this._iid),t=yield e.preference.get(this._metadataKey);this._metadata=t?{token:t.token}:void 0}}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.set(this._metadataKey,this._metadata)}}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync resume()"),this._sync.start(0)}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete De[this._iid][this._channel.url])}}class Fe extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n}}class ke extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class He extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages_gap`,this.params=d.deundefined({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(t=e.threshold)&&void 0!==t?t:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(n=e.messageType)&&void 0!==n?n:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages})}}class Ve extends d.APIResponseCommand{constructor(e,t){var s,n,i,a,r,o;super(e,t),this.isHugeGap=t.is_huge_gap,this.prevMessages=(null!==(s=t.prev_messages)&&void 0!==s?s:[]).map((t=>u.parseMessagePayload(e,t))),this.prevHasMore=null!==(n=t.prev_hasmore)&&void 0!==n&&n,this.isContinuousPrevMessages=null!==(i=t.is_continuous_prev_messages)&&void 0!==i&&i,this.nextMessages=(null!==(a=t.next_messages)&&void 0!==a?a:[]).map((t=>u.parseMessagePayload(e,t))),this.nextHasmore=null!==(r=t.next_hasmore)&&void 0!==r&&r,this.isContinuousNextMessages=null!==(o=t.is_continuous_next_messages)&&void 0!==o&&o}}const Ge=(e,t)=>t instanceof u.SendableMessage?e.findIndex((e=>e instanceof u.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),qe=(e,t)=>e.findIndex((e=>e.messageId===t)),Be=(e,t)=>{if(e.length>0){let s=0,n=e.length-1,i=Math.floor((s+n)/2);for(;s0)n=i,i=Math.floor((s+n)/2);else{if(!(a<0))return i;s=i+1,i=Math.floor((s+n)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length};class je{constructor(e){this.source=e}}class We extends je{}class $e extends je{}class ze{constructor(e){this.source=e}}class Qe extends ze{}class Ke extends ze{}const Ye=6e5,Je={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ze{_invokeResponse(e,t,s){d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){switch(e){case"local":this._onCacheResult(t,s);break;case"remote":this._onApiResult(t,s)}}))))}onCacheResult(e){return this._onCacheResult=e,this}onApiResult(e){return this._onApiResult=e,this}}class Xe{constructor(e,{filter:t,startingPoint:s,limit:n,channel:i,channelManager:a}){this._messages=[],this._unsentMessages=[],this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new u.MessageFilter,this._channel=i,this._syncRange=new _.TimeRange({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+Ye,this._limit=n||u.DEFAULT_MESSAGE_LIMIT,this._channelManager=a,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t,s)=>{const n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(t){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(const s in this._messages){if(this._messages[s].createdAt>=e.messageOffsetTimestamp){t=!0;const e=parseInt(s);if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>e.messageId)),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>e.messageId)),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),t=s;e.userId===t&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:t}=d.Vault.of(this._iid),n=s;t.userId===n&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);O(t)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(s,this.channel)}))))})))},onRemove:(e,t)=>{e.indexOf(this.channel.url)>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(s,this.channel.url)})))))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:(e,t)=>{const s=[],n=[];for(const t of e)t.channelUrl===this._channel.url&&(this.filter.match(t)?s.push(t):n.push(t.messageId));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}},onRemove:(e,t)=>{this._removeMessagesFromView(e,t)},onRemoveUnsent:(e,t)=>{this._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:(e,t)=>{this._updatePollsToView(e,t)},onPollUpdate:(e,t)=>{this._applyPollUpdateEventToView(e,t)},onPollVote:(e,t)=>{this._applyPollVoteEventToView(e,t)}});const{cacheContext:r,dispatcher:o,logger:l}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt();const h=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);h&&o.dispatch(h),this._shouldStartBackgroundSync()&&(this._backgroundSync=xe.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=we.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Le.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Pe(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t;const{messages:s,isContinuousMessages:n}=yield this._getRemoteMessages(e,{prevLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled});if(s.length>0){const e=Math.min(...s.map((e=>e.createdAt)));return this._syncRange.extends(e),n&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:s.length>=this._limit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){var t;const{messages:s,isContinuousMessages:n}=yield this._getRemoteMessages(e,{nextLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled});if(s.length>0){const e=Math.max(...s.map((e=>e.createdAt)));return this._syncRange.extends(e),n&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(s.length>=this._limit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return{hasNext:!1,nextToken:0}})))),this._connectionEventContext=o.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)})))),l.debug("check huge gap"),this._checkHugeGap();break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}));const{statLogCollector:c}=d.Vault.of(this._iid);c.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message:!0}}}))}get channel(){return this._channel}get succeededMessages(){return[...this._messages]}get failedMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.FAILED))}get pendingMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.PENDING))}get hasPrevious(){return this._hasPrevious}get hasNext(){return this._hasNext}get viewTop(){return Math.min(...this._messages.map((e=>e.createdAt)),Number.MAX_SAFE_INTEGER)}get viewBottom(){return Math.max(...this._messages.map((e=>e.createdAt)),0)}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_createChannelEventContext(e){switch(!0){case this.channel.isGroupChannel():return new We(e);case this.channel.isFeedChannel():return new $e(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createMessageEventContext(e){switch(!0){case this.channel.isGroupChannel():return new Qe(e);case this.channel.isFeedChannel():return new Ke(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createChannelUpdateEventCommand(e){switch(!0){case this.channel.isGroupChannel():return new x({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new Fe({channels:[this._channel],source:e});default:return null}}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ge(this._messages,e)<0){Ge(this._unsentMessages,e)<0&&n.push(e);const t=Be(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof u.SendableMessage){Ge(this._unsentMessages,e)<0&&Ge(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ge(this._messages,e);if(t<0){const t=Ge(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Be(this._messages,e);this._messages.splice(s,0,e)}else i.push(e),this._messages[t]=e;if(e.updatedAt>0){const t=this._updateChildMessagesInView(e);i.push(...t)}}else if(e instanceof u.SendableMessage){const t=Ge(this._unsentMessages,e);t<0?Ge(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e)):(i.push(e),this._unsentMessages[t]=e)}d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s,a,r;const o=this._createMessageEventContext(t);n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=qe(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n&&n.applyPoll(t),s.push(n)}}return s.length>0&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,n;const i=this._createMessageEventContext(t);s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=qe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=qe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ge(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ge(this._unsentMessages,t);if(e>=0){const s=this._unsentMessages.splice(e,1);if(this.hasNext&&s.length>0)i.push(s[0]);else{n.push(t);const e=Be(this._messages,t);this._messages.splice(e,0,t)}}else{const e=this._messages.map((e=>e.createdAt));(t.createdAtMath.max(...e)&&!this._hasNext)&&s.push(t)}}}else if(t instanceof u.SendableMessage){const e=Ge(this._unsentMessages,t);e>=0&&(n.push(t),this._unsentMessages[e]=t)}return d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,a,r,o;const l=this._createMessageEventContext(t);n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>e.messageId===t));if(e>=0){const t=this._messages[e];s.push(t.messageId),n.push(t),this._messages.splice(e,1)}}return d.shouldGiveEvent(t)&&n.length>0&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,i;const a=this._createMessageEventContext(t);null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,this.channel,s,n)})))),s}_removeUnsentMessageFromView(e,t){const s=this._unsentMessages.findIndex((t=>t.reqId===e));s>=0&&this._unsentMessages.splice(s,1)}_getLocalMessages(e,{prevLimit:t=0,nextLimit:s=0,inclusive:n=!0}){return d.__awaiter(this,void 0,void 0,(function*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt))}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingContinuousMessages:a=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const r=u.MessageManager.of(this._iid);return t>0||s>0?yield r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),Je),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e;return d.__awaiter(this,void 0,void 0,(function*(){if(this._messages.length>0){const e=this._syncRange.top,t=this.viewTop,s=this._syncRange.bottom,n=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,i=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,t,e),a=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,s,n);yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var r;const{dispatcher:o,requestQueue:l,cacheContext:h}=d.Vault.of(this._iid),c=new He(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:t,prevEnd:e,prevCount:i,nextStart:s,nextEnd:n,nextCount:a,checkingContinuousMessages:h.localCacheEnabled},this.filter),Je)),u=yield l.send(c),{isHugeGap:_,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:C,nextMessages:g=[],nextHasmore:E,isContinuousNextMessages:v}=u.as(Ve);if(_)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const e=this.viewTop,t=this.viewBottom,s=Math.min(Number.MAX_SAFE_INTEGER,e,...p.map((e=>e.createdAt))),n=Math.max(0,t,...g.map((e=>e.createdAt)));o.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),o.dispatch(new d.MessageUpdateEventCommand({messages:g,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(s,n),(C||v)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(s,n)),m&&this._prevFill.start(s),E&&this._nextFill.start(n)}}))),1)}else{const{cacheContext:t}=d.Vault.of(this._iid),s=Math.floor(this._limit/2),n=Date.now();try{const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(n,{prevLimit:s,nextLimit:s,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:t.localCacheEnabled});if(i.length>0){const t=i.map((e=>e.createdAt));let r=0,o=0;for(let e=0;e=n&&o++}this._hasPrevious=r>=s,this._hasNext=o>=s,this._syncRange.extends(...t),a&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(i,d.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1}catch(e){e instanceof d.SendbirdError&&e.code===d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1)}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+Ye,this.filter,1)).length>0}))}_refreshChannel(e){this._channelManager.refreshChannel(this.channel.url,!0,e)}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{e&&this.channel._runIfHandleableWithGroupChannel((e=>{var t,s;e.myMutedState=d.MutedState.UNMUTED;const n=this._createChannelEventContext(d.CollectionEventSource.EVENT_CHANNEL_UNMUTED);null===(s=null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===s||s.call(t,n,this.channel)}))}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}initialize(e){const t=new Ze;this._messages=[],this._unsentMessages=[],this._syncRange=new _.TimeRange({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(d.CollectionEventSource.REFRESH_CHANNEL),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)}))));const s=Math.floor(this._limit/2);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){const s=this._filterUnderOffsetMessage(e);this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>{const{cacheContext:e}=d.Vault.of(this._iid);this._getRemoteMessages(this._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((({messages:e,isContinuousMessages:n})=>{var i;this._messages=[];const a=this._filterUnderOffsetMessage(e);if(a.length>0){const e=a.map((e=>e.createdAt));let t=0,r=0;for(let s=0;sthis._startingPoint&&r++}this._hasPrevious=t>=s,this._hasNext=r>=s,this._syncRange.extends(...a.map((e=>e.createdAt))),n&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)}else this._hasPrevious=!1,this._hasNext=!1;t._invokeResponse("remote",null,a)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))}));const{cacheContext:n,statLogCollector:i}=d.Vault.of(this._iid);return i.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:n.localCacheEnabled,collection_interface:{message_init_policy:e}}})),t}loadPrevious(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasPrevious)return[];const e=Math.floor(this._limit/2),t=this.viewTop;let s=[];return yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){s=this._filterUnderOffsetMessage(yield this._getLocalMessages(t,{prevLimit:e,inclusive:!1}))})))),s.lengthd.__awaiter(this,void 0,void 0,(function*(){var n,i;const{cacheContext:a}=d.Vault.of(this._iid),r=yield this._getRemoteMessages(t,{prevLimit:e,reverse:!0,checkingContinuousMessages:a.localCacheEnabled});s=this._filterUnderOffsetMessage(r.messages),s=s.filter((e=>Ge(this._messages,e)<0)),this._hasPrevious=s.length>=e,s.length>0&&(this._syncRange.extends(...s.map((e=>e.createdAt))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top)))})))),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=s.length>=e,s.length>0&&this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE)),s}))}loadNext(){var e;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasNext)return[];const t=Math.floor(this._limit/2),s=this.viewBottom;let n=[];return yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){n=this._filterUnderOffsetMessage(yield this._getLocalMessages(s,{nextLimit:t,inclusive:!1}))})))),n.lengthd.__awaiter(this,void 0,void 0,(function*(){var e,i;const{cacheContext:a}=d.Vault.of(this._iid),r=yield this._getRemoteMessages(s,{nextLimit:t,reverse:!0,checkingContinuousMessages:a.localCacheEnabled});n=this._filterUnderOffsetMessage(r.messages),n=n.filter((e=>Ge(this._messages,e)<0)),this._hasNext=n.length>=t,n.length>0&&(this._syncRange.extends(...n.map((e=>e.createdAt))),(null===(e=this._backgroundSync)||void 0===e?void 0:e.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.bottom)))})))),this._addMessagesToView(n,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasNext=n.length>=t,n.length>0&&this._addMessagesToView(n,d.CollectionEventSource.REQUEST_MESSAGE)),n}))}removeFailedMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,1)}))}dispose(){var e,t,s;if(this._isDisposed)return;this._isDisposed=!0;const{cacheContext:n,dispatcher:i}=d.Vault.of(this._iid);this._messages=[],this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt();const a=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);a&&i.dispatch(a),n.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(s=this._pollChangelogSync)||void 0===s||s.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class et extends Xe{constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:Ue.of(e)}))}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}}const tt={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};class st extends d.APIRequestCommand{constructor(e){const{channelUrl:t,token:s,limit:n,order:i,mutedMemberFilter:a,memberStateFilter:r,nicknameStartsWithFilter:o,operatorFilter:l}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/members`,this.params={token:s,limit:n,order:i,muted_member_filter:a,member_state_filter:r,nickname_startswith:o,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.members=[];const{next:s,members:n}=t;this.token=s,n&&n.length>0&&(this.members=n.map((t=>new m(e,t))))}}var it,at,rt;exports.MutedMemberFilter=void 0,(it=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",it.MUTED="muted",it.UNMUTED="unmuted",exports.MemberListOrder=void 0,(at=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",at.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(rt=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",rt.JOINED="joined_only",rt.INVITED="invited_only",rt.INVITED_BY_FRIEND="invited_by_friend",rt.INVITED_BY_NON_FRIEND="invited_by_non_friend";class ot extends d.ChannelDataListQuery{constructor(e,t,s){var n,i,a,r;super(e,t,d.ChannelType.GROUP,s),this.mutedMemberFilter=exports.MutedMemberFilter.ALL,this.memberStateFilter=exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.operatorFilter=exports.OperatorFilter.ALL,this.order=exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,this.mutedMemberFilter=null!==(n=s.mutedMemberFilter)&&void 0!==n?n:exports.MutedMemberFilter.ALL,this.memberStateFilter=null!==(i=s.memberStateFilter)&&void 0!==i?i:exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null!==(a=s.nicknameStartsWithFilter)&&void 0!==a?a:null,this.order=null!==(r=s.order)&&void 0!==r?r:exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL}_validate(){return super._validate()&&d.isEnumOf(exports.MutedMemberFilter,this.mutedMemberFilter)&&d.isEnumOf(exports.MemberStateFilter,this.memberStateFilter)&&(d.isTypeOf("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&d.isEnumOf(exports.OperatorFilter,this.operatorFilter)&&d.isEnumOf(exports.MemberListOrder,this.order)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new st(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(nt);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class lt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/accept`,this.params={user_id:s,access_code:n}}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class ht extends d.APIRequestCommand{constructor(e){const{channelUrl:t,isDistinct:s,isPublic:n,isDiscoverable:i,coverUrl:a,coverImage:r,accessCode:o,name:l,data:h,customType:c,operatorUserIds:u,messageSurvivalSeconds:_}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params=d.deundefined({is_distinct:s,is_public:n,is_discoverable:i,name:l,data:h,custom_type:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class ct extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}class ut extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`}}class _t extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`}}class pt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,countPreference:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/count_preference/${encodeURIComponent(t)}`,this.params={count_preference:s}}}class mt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class Ct extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const Et=Object.assign(Object.assign({},u.BaseMessageUpdateParamsDefault),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),vt=Object.assign(Object.assign({},u.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class ft extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>u.Thumbnail.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>u.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class Mt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new u.FileMessage(e,t)}}class St extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>u.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class yt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}`}}class bt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}/send_now`}}class At extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,pushTriggerOption:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`,this.params={push_trigger_option:s}}}class Nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Tt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class Ut extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class It extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class Pt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class Ot extends d.InstancedObject{constructor(e,t){super(e),this.message=u.parseMessagePayload(e,t.message)}}class xt extends d.APIRequestCommand{constructor(e){const{channelType:t,channelUrl:s,limit:n,token:i,includeReactions:a,includeMetaArray:r,includeParentMessageInfo:o,includeThreadInfo:l,includePollDetails:h}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/pinned_messages`,this.params=d.deundefined({limit:n,token:i,include_reactions:a,with_sorted_meta_array:r,include_thread_info:l,include_parent_message_info:o,include_poll_details:h})}}class Rt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:n,next:i}=t;this.pinnedMessages=s.map((t=>new Ot(e,t))),this.hasMore=n,this.token=i}}class wt extends d.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n),this.includeMetaArray=n.includeMetaArray,this.includeReactions=n.includeReactions,this.includeParentMessageInfo=n.includeParentMessageInfo,this.includeThreadInfo=n.includeThreadInfo,this.includePollDetails=n.includePollDetails}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeMetaArray,!0)&&d.isTypeOf("boolean",this.includeReactions,!0)&&d.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&d.isTypeOf("boolean",this.includeThreadInfo,!0)&&d.isTypeOf("boolean",this.includePollDetails,!0)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new xt(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{pinnedMessages:n,hasMore:i,token:a}=s.as(Rt);return this._token=a,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}var Dt,Lt;exports.CountPreference=void 0,(Dt=exports.CountPreference||(exports.CountPreference={})).ALL="all",Dt.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Dt.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Dt.OFF="off",exports.HiddenState=void 0,(Lt=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Lt.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Lt.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class Ft extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,h,c,_,p,C,g,E,v,f,M,S,y;super(e,t),this._unreadMemberStateMap=new Map,this._undeliveredMemberStateMap=new Map,this._typingStatus=new Map,this._lastMemberCountUpdated=0,this._typingStarted=0,this._typingEnded=0,this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.members=[],this.memberCount=0,this.joinedMemberCount=0,this.hiddenState=exports.HiddenState.UNHIDDEN,this.lastMessage=null,this.messageOffsetTimestamp=0,this.messageSurvivalSeconds=-1,this.myMemberState=exports.MemberState.NONE,this.myRole=d.Role.NONE,this.myMutedState=d.MutedState.UNMUTED,this.myLastRead=0,this.myCountPreference=exports.CountPreference.ALL,this.myPushTriggerOption=d.PushTriggerOption.DEFAULT,this.inviter=null,this.invitedAt=0,this.joinedAt=0,this.pinnedMessageIds=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this._myMutedRemainingTime=-1,this.channelType=d.ChannelType.GROUP,this.isDistinct=null!==(s=t.is_distinct)&&void 0!==s&&s,this.isSuper=null!==(n=t.is_super)&&void 0!==n&&n,this.isBroadcast=null!==(i=t.is_broadcast)&&void 0!==i&&i,this.isExclusive=null!==(a=t.is_exclusive)&&void 0!==a&&a,this.isPublic=null!==(r=t.is_public)&&void 0!==r&&r,this.isDiscoverable=null!==(o=t.is_discoverable)&&void 0!==o?o:this.isPublic,this.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(h=t.is_access_code_required)&&void 0!==h&&h,this.isPushEnabled=null!==(c=t.is_push_enabled)&&void 0!==c&&c,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new m(this._iid,e)))),this.memberCount=null!==(_=t.member_count)&&void 0!==_?_:0,this.joinedMemberCount=null!==(p=t.joined_member_count)&&void 0!==p?p:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(C=t.ts_message_offset)&&void 0!==C?C:0,this.messageSurvivalSeconds=null!==(g=t.message_survival_seconds)&&void 0!==g?g:-1,this.lastMessage=t.last_message?u.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((e=>{d.isTypeOf("number",t.read_receipt[e])&&this._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((e=>{d.isTypeOf("number",t.delivery_receipt[e])&&this._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),this.myMemberState=d.isEnumOf(exports.MemberState,t.member_state)?t.member_state:exports.MemberState.NONE,this.myRole=d.isEnumOf(d.Role,t.my_role)?t.my_role:d.Role.NONE,d.isEnumOf(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.MutedState.UNMUTED,this.myCountPreference=d.isEnumOf(exports.CountPreference,t.count_preference)?t.count_preference:exports.CountPreference.ALL,this.myPushTriggerOption=d.isEnumOf(d.PushTriggerOption,t.push_trigger_option)?t.push_trigger_option:d.PushTriggerOption.ALL,this.myLastRead=null!==(E=t.user_last_read)&&void 0!==E?E:0,this.inviter=t.inviter?new d.User(this._iid,t.inviter):null,this.invitedAt=null!==(v=t.invited_at)&&void 0!==v?v:0,this.joinedAt=null!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(S=t.unread_mention_count)&&void 0!==S?S:0),this.pinnedMessageIds=null!==(y=t.pinned_message_ids)&&void 0!==y?y:[],this.lastPinnedMessage=t.latest_pinned_message?u.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null}get isHidden(){return this.hiddenState!==exports.HiddenState.UNHIDDEN}get isTyping(){return this._typingStatus.size>0}get cachedUnreadMemberState(){const e={};for(const[t,s]of this._unreadMemberStateMap)e[t]=s;return e}get cachedUndeliveredMemberState(){const e={};for(const[t,s]of this._undeliveredMemberStateMap)e[t]=s;return e}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((e=>m.payloadify(e))),last_message:e.lastMessage?u.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?u.payloadifyMessage(e.lastPinnedMessage):null})))}_shouldUpdateLastMessageWith(e){return!(e instanceof u.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){const{maxSuperGroupChannelUnreadCount:t}=d.Vault.of(this._iid);this.unreadMessageCount=t&&e>=t?t:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0}_updateUnreadMemberState(e,t){const s=this._unreadMemberStateMap.get(e);if(!s||s0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}_clearTypingStatus(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}_setLatestMemberCount(e,t,s){let n=!1;return s>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=s,n=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),n}isReadMessage(e){const{sdkState:t}=d.Vault.of(this._iid),s=this._unreadMemberStateMap.get(t.userId);return!!s&&s>=e.createdAt}serialize(){return d.serialize(this,(e=>{e.cachedUnreadMemberState=this.cachedUnreadMemberState,e.cachedUndeliveredMemberState=this.cachedUndeliveredMemberState}))}createMessageCollection(e={}){return new et(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new ot(this._iid,this.url,e)}createPinnedMessageListQuery(e={}){return new wt(this._iid,this.url,this.channelType,e)}addMember(e,t=0){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const s=this.members.findIndex((t=>t.userId===e.userId));if(s>-1){const t=this.members[s];t.state===exports.MemberState.JOINED&&(e.state=t.state),this.members.splice(s,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}}removeMember(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const t=e instanceof m?e.userId:e,s=this.members.findIndex((e=>e.userId===t));if(s>-1)return this.members.splice(s,1),this.memberCount--,!0}return!1}getUnreadMemberCount(e){if(e instanceof u.SendableMessage&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const{sdkState:t}=d.Vault.of(this._iid),s=e.createdAt;let n=0;for(const i of this.members)if(t.userId!==i.userId&&i.state===exports.MemberState.JOINED&&e.sender.userId!==i.userId){(this.cachedUnreadMemberState[i.userId]||0){if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t>=e.createdAt&&i.push(a)}})),i}getUnreadMembers(e,t=!1){const{sdkState:s}=d.Vault.of(this._iid);if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];const n=e instanceof u.SendableMessage?e.sender:null,i=[];return this.members.forEach((a=>{if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t{if(e||n.userId!==t.userId){const e=this._unreadMemberStateMap.get(n.userId);s[n.userId]=new C(this._iid,{channel_url:this.url,channel_type:this.channelType,user:m.payloadify(n),ts:null!=e?e:0})}})),s}getTypingUsers(){const e=[];return this._typingStatus.forEach((t=>{const{user:s}=t;e.push(s)})),e}invalidateTypingStatus(){const{typingIndicatorInvalidateTime:e}=d.Vault.of(this._iid),t=Date.now();let s=!1;return this._typingStatus.forEach(((n,i)=>{const{ts:a}=n;t-a>=e&&(this._typingStatus.delete(i),s=!0)})),s}refresh(){return d.__awaiter(this,void 0,void 0,(function*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(k);return this._update(a),e&&s.dispatch(new x({channels:[a],source:d.CollectionEventSource.REQUEST_CHANNEL})),this}))}freeze(){const e=Object.create(null,{freeze:{get:()=>super.freeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.freeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}))}))}unfreeze(){const e=Object.create(null,{unfreeze:{get:()=>super.unfreeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.unfreeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},tt),e);d.unless((e=>d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,requestQueue:n}=d.Vault.of(this._iid),i=new ht(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(ct);return this._update(r),s.dispatch(new x({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),this}))}invite(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(e.every((e=>e instanceof d.User))).throw(d.SendbirdError.invalidParameters),this.inviteWithUserIds(e.map((e=>e.userId)))}))}inviteWithUserIds(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isArrayOf("string",e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new oe({channelUrl:this.url,userIds:e}),i=yield s.send(n),{channel:a}=i.as(le);return this._update(a),t.dispatch(new x({channels:[a],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),this}))}join(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new se({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(ne);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new x({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),this}))}leave(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=d.Vault.of(this._iid),n=new ae({channelUrl:this.url,userId:t.userId,shouldRemoveOperatorStatus:e});yield s.send(n),this.myMemberState=exports.MemberState.NONE}))}acceptInvitation(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new lt({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(dt);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new x({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),this}))}declineInvitation(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new he({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new u.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{this.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(this.hiddenState=exports.HiddenState.UNHIDDEN),n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e);Ue.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}updateUserMessage(e,t){const s=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateUserMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ue.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new x({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ue.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new u.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ue.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendFileMessage(e){const t=new u.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ue.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new u.MultipleFilesMessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid);return super.sendMultipleFilesMessage(e).onPending((e=>{t._trigger(e)})).onFailed(((e,s)=>{t._triggerFailed(e,s)})).onSucceeded((e=>{const n=Ue.of(this._iid);this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})).onFileUploaded(((e,s,n,i)=>{t._triggerOnFileUploaded(e,s,n,i)})),t}updateFileMessage(e,t){const s=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateFileMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ue.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new x({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ue.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new u.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ue.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}deleteMessage(e){const t=Object.create(null,{deleteMessage:{get:()=>super.deleteMessage}});return d.__awaiter(this,void 0,void 0,(function*(){if(yield t.deleteMessage.call(this,e),0===e.messageId&&e instanceof u.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.EVENT_MESSAGE_DELETED}))}}))}hide(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},ue),e);d.unless((e=>d.isTypeOf("boolean",e.hidePreviousMessages,!0)&&d.isTypeOf("boolean",e.allowAutoUnhide,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,sdkState:n,requestQueue:i}=d.Vault.of(this._iid),a=new _e(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(pe);return this.hiddenState=t.allowAutoUnhide?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),o&&(this.messageOffsetTimestamp=o),s.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),this}))}unhide(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new _t({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),this}))}delete(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=d.Vault.of(this._iid),t=new ut({channelUrl:this.url});yield e.send(t)}))}markAsRead(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new ye({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(be);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);Ue.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_READ}))}))}markAsDelivered(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new Ae({channelUrl:this.url,userId:e.userId});yield t.send(s)}))}startTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingStarted>=t){this._typingStarted=s,this._typingEnded=0;const t=new Ce({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}endTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingEnded>=t){this._typingStarted=0,this._typingEnded=s;const t=new Ee({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},u.ScheduledUserMessageCreateParamsDefault),e),d.unless(u.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new u.MessageRequestHandler;return this._createScheduledUserMessage(e,t),t}updateScheduledUserMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},vt),t);d.unless((e=>u.validateUserMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0))(s)).throw(d.SendbirdError.invalidParameters);const{requestQueue:n}=d.Vault.of(this._iid),i=new St(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),a=yield n.send(i),{message:r}=a.as(h.CreateScheduledUserMessageResponseCommand);return r}))}createScheduledFileMessage(e){e=Object.assign(Object.assign({},u.ScheduledFileMessageCreateParamsDefault),e),d.unless(u.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new u.MessageRequestHandler;return d.sleep(h.PENDING_MESSAGE_DELAY).then((()=>{const i=this._createPendingScheduledFileMessage(e,s,t);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){return n._trigger(i)}))))})),d.isFile(e.file)?this._uploadFileAndUpdateParams(e).then((()=>this._createScheduledFileMessage(e,n,s,t))):this._createScheduledFileMessage(e,n,s,t),n}updateScheduledFileMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},Et),t);d.unless((e=>u.validateBaseMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0)&&(d.isFile(e.file)||d.isTypeOf("string",e.fileUrl))&&d.isTypeOf("string",e.fileName,!0)&&d.isTypeOf("string",e.mimeType,!0)&&d.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>d.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))))(s)).throw(d.SendbirdError.invalidParameters),d.isFile(s.file)&&(yield this._uploadFileAndUpdateParams(s));const n=new ft(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),{requestQueue:i}=d.Vault.of(this._iid),a=yield i.send(n),{message:r}=a.as(Mt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new yt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}sendScheduledMessageNow(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new bt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}getMyPushTriggerOption(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new Tt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(Ut);return this.myPushTriggerOption=i,i}))}setMyPushTriggerOption(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(d.PushTriggerOption,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new At({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(Nt);return this.myPushTriggerOption=r,t.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}setMyCountPreference(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(exports.CountPreference,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new pt({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(mt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new x({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new Ct({channelUrl:this.url}),n=yield t.send(s),{messageOffsetTimestamp:i}=n.as(gt);return this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new It({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}unpinMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("number",e)&&e>0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Pt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}_uploadFileAndUpdateParams(e){return d.__awaiter(this,void 0,void 0,(function*(){if(d.isFile(e.file)){const{requestQueue:t}=d.Vault.of(this._iid),s=new u.UploadFileRequestCommand({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),n=yield t.send(s),{url:i,fileSize:a=e.fileSize,thumbnailSizes:r=e.thumbnailSizes,requireAuth:o=!1}=n.as(u.UploadFileResponseCommand);e.fileUrl=i,e.fileSize=a,e.thumbnailSizes=r,e.requireAuth=o}}))}}exports.BaseMessageCollection=Xe,exports.DeclineInvitationEventCommand=ce,exports.FeedChannelEventContext=$e,exports.FeedChannelRemoveEventCommand=ke,exports.FeedChannelUpdateEventCommand=Fe,exports.GetTotalUnreadMessageCountRequestCommand=Q,exports.GetTotalUnreadMessageCountResponseCommand=K,exports.GroupChannel=Ft,exports.GroupChannelChangeLogsParamsDefault=M,exports.GroupChannelCountParamsDefault=y,exports.GroupChannelCreateParamsDefault=v,exports.GroupChannelEventContext=We,exports.GroupChannelEventSource=P,exports.GroupChannelFilter=g,exports.GroupChannelListQuery=Me,exports.GroupChannelManager=Ue,exports.InviteToGroupChannelEventCommand=de,exports.Member=m,exports.MemberListQuery=ot,exports.MessageAckCommand=fe,exports.MessageCollection=et,exports.MessageCollectionInitHandler=Ze,exports.MessageEventContext=Qe,exports.NotificationEventContext=Ke,exports.PinnedMessage=Ot,exports.PinnedMessageListQuery=wt,exports.ReadEventCommand=be,exports.ReadRequestCommand=ye,exports.ReadStatus=C,exports.Sync=Pe,exports.TotalUnreadMessageCountParamsDefault=T,exports.shouldGiveEvent=O,exports.validateGroupChannelChangeLogsParams=S,exports.validateGroupChannelCountParams=b,exports.validateGroupChannelCreateParams=f,exports.validateTotalUnreadMessageCountParams=U; diff --git a/cjs/lib/__bundle-26b86f4c.js b/cjs/lib/__bundle-26b86f4c.js new file mode 100644 index 0000000..c4de4e7 --- /dev/null +++ b/cjs/lib/__bundle-26b86f4c.js @@ -0,0 +1,2 @@ +"use strict";function e(e,t,s,n){return new(s||(s=Promise))((function(i,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t,s="4.9.8";class n{static get OS_VERSION(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}static get SDK_VERSION(){return s}static get SDK_MAJOR_VERSION(){return n.SDK_VERSION.split(".")[0]}static get DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL(){return 100}static get INTERNAL_CALL(){return"ic"}}exports.SendbirdErrorCode=void 0,(t=exports.SendbirdErrorCode||(exports.SendbirdErrorCode={}))[t.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",t[t.NON_AUTHORIZED=400108]="NON_AUTHORIZED",t[t.INVALID_TOKEN=400111]="INVALID_TOKEN",t[t.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",t[t.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",t[t.LOST_INSTANCE=700100]="LOST_INSTANCE",t[t.CONNECTION_RENEW=700102]="CONNECTION_RENEW",t[t.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",t[t.INVALID_COMMAND=700700]="INVALID_COMMAND",t[t.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",t[t.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",t[t.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",t[t.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",t[t.INVALID_PARAMETER=800110]="INVALID_PARAMETER",t[t.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",t[t.NETWORK_ERROR=800120]="NETWORK_ERROR",t[t.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",t[t.MALFORMED_DATA=800130]="MALFORMED_DATA",t[t.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",t[t.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",t[t.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",t[t.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",t[t.ACK_TIMEOUT=800180]="ACK_TIMEOUT",t[t.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",t[t.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",t[t.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",t[t.REQUEST_FAILED=800220]="REQUEST_FAILED",t[t.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",t[t.REQUEST_CANCELED=800240]="REQUEST_CANCELED",t[t.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",t[t.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",t[t.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",t[t.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",t[t.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",t[t.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",t[t.DATABASE_ERROR=800700]="DATABASE_ERROR";const i=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}static get debugModeRequired(){return new o({code:exports.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}static get lostInstance(){return new o({code:exports.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}static get invalidCommand(){return new o({code:exports.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}static get unknown(){return new o({code:exports.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}static get connectionRenew(){return new o({code:exports.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}static get invalidConnectionStateTransition(){return new o({code:exports.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}static get connectionRequired(){return new o({code:exports.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}static get connectionCanceled(){return new o({code:exports.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}static get invalidParameters(){return new o({code:exports.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}static get notSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}static get channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}static get networkError(){return new o({code:exports.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}static get markAsReadAllRateLimitExceeded(){return new o({code:exports.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}static get queryInProgress(){return new o({code:exports.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}static get noAckTimeout(){return new o({code:exports.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}static get loginTimeout(){return new o({code:exports.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}static get connectionClosed(){return new o({code:exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}static get requestFailed(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}static get fileUploadCanceled(){return new o({code:exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}static get requestCanceled(){return new o({code:exports.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}static get sessionTokenRefreshFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}static get sessionTokenRequestFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}static get databaseError(){return new o({code:exports.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}static get fileSizeLimitExceededError(){return new o({code:exports.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}throwOutside(){throw this.shouldThrowOutside=!0,this}}const r=[exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.NETWORK_ERROR,exports.SendbirdErrorCode.ACK_TIMEOUT,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,exports.SendbirdErrorCode.REQUEST_CANCELED,exports.SendbirdErrorCode.INTERNAL_SERVER_ERROR,exports.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,exports.SendbirdErrorCode.UNKNOWN_SERVER_ERROR],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED],l=(e,t,s=!1)=>!(!s||null!=t)||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||null!=t)||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||null!=t)||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&null==e)return!0;const s="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!s){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return s};class _{constructor({useMemberInfoInMessage:e=!0,typingIndicatorInvalidateTime:t=1e4,typingIndicatorThrottle:s=1e3,websocketResponseTimeout:n=1e4,websocketPayloadDecompression:i=!0,sessionTokenRefreshTimeout:o=60}={}){this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=e,this._typingIndicatorInvalidateTime=t,this._typingIndicatorThrottle=s,this._websocketResponseTimeout=n,this._sessionTokenRefreshTimeout=o,this.websocketPayloadDecompression=i}get useMemberInfoInMessage(){return this._useMemberInfoInMessage}set useMemberInfoInMessage(e){l("boolean",e)&&(this._useMemberInfoInMessage=e)}get typingIndicatorInvalidateTime(){return this._typingIndicatorInvalidateTime}set typingIndicatorInvalidateTime(e){l("number",e)&&(this._typingIndicatorInvalidateTime=e)}get typingIndicatorThrottle(){return this._typingIndicatorThrottle}set typingIndicatorThrottle(e){l("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}get websocketResponseTimeout(){return this._websocketResponseTimeout}set websocketResponseTimeout(e){l("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}get sessionTokenRefreshTimeout(){return this._sessionTokenRefreshTimeout}set sessionTokenRefreshTimeout(e){l("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}const p={encrypt:e=>e,decrypt:e=>e};class E{constructor({store:e}){this._preference=new Map,this._store=e}_savePreferenceKeys(){return e(this,void 0,void 0,(function*(){yield this._store.set({key:this._keysAddress,value:[...this._preference.keys()]})}))}init(t,s=1){var n;return e(this,void 0,void 0,(function*(){this._version=s,this._keysAddress=t;const e=`${t}.metadata.version`,i=yield this._store.get(e),o=null!==(n=yield this._store.get(t))&&void 0!==n?n:[];if(!i||i.versione.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1,this._maxSize=Math.max(e,64),s?(this._clearOrder=t,this._customClearOrderComparator=s):this._clearOrder=T.MESSAGE_COLLECTION_ACCESSED_AT}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===T.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}class N{get hasSession(){return!!this.sessionKey}clear(){this.authToken=void 0,this.sessionKey=void 0}}const y=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};class w{constructor({container:e}){this._container={},this._container=e,this.key=y()}_register(e,t,s){var n;return e in this._container||(this._container[e]=new Map),null===(n=this._container[e])||void 0===n||n.set(this.key,{occurence:t,handler:s}),this}on(e,t){return this._register(e,-1,t)}once(e,t){return this._register(e,1,t)}close(){var e;for(const t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)}}class A{constructor(){this._container={}}on(e,t){return new w({container:this._container}).on(e,t)}once(e,t){return new w({container:this._container}).once(e,t)}dispatch(e,t){const s=this._container[e];if(s){const e=[];for(const n of s.keys()){const i=s.get(n);i.handler(t),i.occurence>0&&(i.occurence--,0===i.occurence&&e.push(n))}e.forEach((e=>s.delete(e)))}}}class b{constructor(){this._dispatcher=new A}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class x{}const k=e=>{const t={};return e&&Object.keys(e).forEach((s=>{void 0===e[s]||Number.isNaN(e[s])||null===e[s]||(t[s]=e[s])})),t},I=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(const e in t)t[e]=I(t[e]);return t}for(const t in e)null===e[t]&&delete e[t];return e}return e}};var O,R,D,L,U,M,P,F,H,z;exports.ChannelType=void 0,(O=exports.ChannelType||(exports.ChannelType={})).BASE="base",O.GROUP="group",O.OPEN="open",O.FEED="feed",exports.Role=void 0,(R=exports.Role||(exports.Role={})).OPERATOR="operator",R.NONE="none",exports.MutedState=void 0,(D=exports.MutedState||(exports.MutedState={})).MUTED="muted",D.UNMUTED="unmuted",exports.MessageType=void 0,(L=exports.MessageType||(exports.MessageType={})).BASE="base",L.USER="user",L.FILE="file",L.ADMIN="admin",exports.MessageTypeFilter=void 0,(U=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",U.USER="MESG",U.FILE="FILE",U.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(M=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.MentionType=void 0,(P=exports.MentionType||(exports.MentionType={})).USERS="users",P.CHANNEL="channel",exports.ReplyType=void 0,(F=exports.ReplyType||(exports.ReplyType={})).ALL="all",F.NONE="none",F.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(H=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",H.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled";const q="v3",G=`/${q}/users`,V=`/${q}/storage/file`,K=`/${q}/group_channels`,B=`/${q}/sdk/group_channels`,j=`/${q}/open_channels`,$=`/${q}/sdk/open_channels`,Z=`/${q}/search`,W=`/${q}/report`,Q=`/${q}/emojis`,Y=`/${q}/emoji_categories`,X=`/${q}/polls`,J=`/${q}/scheduled_messages`,ee=`/${q}/sdk/ui_kit/configuration`,te=`/${q}/sdk/statistics`,se=`/${q}/notifications`,ne=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return K;case exports.ChannelType.OPEN:return j;default:return null}},ie=(e,t,s)=>{switch(e){case exports.MentionType.CHANNEL:return!0;case exports.MentionType.USERS:if(t)for(const e of t)if(e===s)return!0}return!1},oe=(e,t,s)=>{var n;let i=t||new FormData;for(const t in e){if(!Object.prototype.hasOwnProperty.call(e,t))continue;const o=e[t],r=s?`${s}[${t}]`:t;u(o)?i.append(r,o,null!==(n=o.name)&&void 0!==n?n:"filename"):"object"!=typeof o||null===o||Array.isArray(o)||o instanceof Blob?i.append(r,String(o)):i=oe(o,i,r)}return i};var re,ae;exports.APIRequestMethod=void 0,(re=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",re.POST="POST",re.PUT="PUT",re.DELETE="DELETE";class le extends x{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=y()}encodeParams(e){return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((e=>this.encodeParams(e))).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}get query(){const e=k(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=k(this.params);return Object.keys(e).some((t=>u(e[t])))?oe(e):JSON.stringify(e)}}class de extends x{constructor(e,t){super(),this._iid=e,this._payload=t}get payload(){return Object.assign({},this._payload)}as(e){return new e(this._iid,this.payload)}}class ce extends x{constructor(e){super(),this.requestId=e}}class he extends x{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}){switch(super(),this.expiresIn=null!=e?e:0,t){case exports.SendbirdErrorCode.SESSION_KEY_EXPIRED:case exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED:case exports.SendbirdErrorCode.SESSION_REVOKED:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class ue extends x{constructor(e){super(),this.statLog=e}}exports.StatType=void 0,(ae=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",ae.WEBSOCKET_CONNECT="ws:connect",ae.API_RESULT="api:result";class _e{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return k({stat_type:e.type,ts:e.createdAt,data:k(e.data)})}}const pe=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,Ee=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var ge,fe,ve;exports.SendbirdProduct=void 0,(ge=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",ge.CALLS="calls",ge.DESK="desk",ge.LIVE="live",ge.UIKIT_CHAT="uikit-chat",ge.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(fe=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",fe.IOS="ios",fe.JS="js",fe.UNREAL="unreal",fe.UNITY="unity",fe.REACT_NATIVE="react-native",fe.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(ve=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",ve.IOS="ios",ve.WEB="web",ve.MOBILE_WEB="mobile_web",ve.WINDOWS="windows";class me{}me.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${pe()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${n.SDK_VERSION}`,device_os_platform:Ee()?"mobile-web":"web",os_version:n.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:n,customData:i={}}=e;n.version&&(t.os_version=n.version),n.platform&&(t.device_os_platform=n.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete i[e])),Object.keys(i).length>0&&(t=Object.assign(Object.assign({},t),i))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},me.userAgentWithExtension=e=>{const t=pe()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",i=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:Ee()?"omobile-web":"oweb";return`${t}/c${n.SDK_VERSION}/${s}/${i}/${o}`};class Se{constructor(e,{auth:t,sdkState:s,dispatcher:n,logger:i,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=t,this._sdkState=s,this._dispatcher=n,this._dispatcher.on((e=>{e instanceof ce&&this.cancel(e.requestId)})),this._logger=i,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:i,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${n.OS_VERSION},${n.SDK_VERSION},${s}${i?`,${i}`:""}`,"SB-User-Agent":me.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":me.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(r["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(r["App-Id"]=s,r["Access-Token"]=this._auth.authToken),r}_statLogApiResult(e,t,s){this._dispatcher.dispatch(new ue(new _e({type:exports.StatType.API_RESULT,data:{endpoint:e.path,method:e.method,success:!s,latency:Date.now()-t,error_code:null==s?void 0:s.code,error_description:null==s?void 0:s.message}})))}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s}=t,n=![exports.APIRequestMethod.GET,exports.APIRequestMethod.DELETE].includes(s),{api:i}=this._sdkState,r=`${i.host}${e}${n?"":t.query}`,a=n?t.payload:null,l=this._createHeader(t,a instanceof FormData?a:void 0),d=new AbortController,{signal:c}=d;this._abortControl.set(t.requestId,d);const h=Date.now();try{if(this._shouldImportFetchCompat){this._shouldImportFetchCompat=!1;("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null}"undefined"==typeof AbortController&&(yield Promise.resolve().then((function(){return require("./__bundle-72519a03.js")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-ac62f2cb.js")})));const e=yield fetch(r,{method:s,body:a,headers:l,signal:c}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,h),new de(this._iid,n);if(n){const e=new o(n);throw(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new he({reason:e.code})),this._statLogApiResult(t,h,e),e}{const e=o.requestFailed;throw this._statLogApiResult(t,h,e),e}}catch(e){if(this._statLogApiResult(t,h,e),e instanceof o)throw this._logger.debug("fail api request",e),e;if("AbortError"===e.name)throw o.requestCanceled;{const e=o.networkError;throw this._logger.debug("fail api request",e),e}}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear()}}class Te extends x{constructor(e,t,s,n=""){var i;super(),this._iid=e,this.code=t,this.payload=s,this.requestId=null!==(i=s.req_id)&&void 0!==i?i:n}static createFromRawMessage(e,t){let s=t.substring(0,4),n={};try{n=JSON.parse(t.substring(4))}catch(e){s="NOOP"}finally{return new Te(e,s,n)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}const Ce=()=>{}; +/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function Ne(e){let t=e.length;for(;--t>=0;)e[t]=0}const ye=256,we=286,Ae=30,be=15,xe=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ke=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ie=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Oe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Re=new Array(576);Ne(Re);const De=new Array(60);Ne(De);const Le=new Array(512);Ne(Le);const Ue=new Array(256);Ne(Ue);const Me=new Array(29);Ne(Me);const Pe=new Array(Ae);function Fe(e,t,s,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let He,ze,qe;function Ge(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ne(Pe);const Ve=e=>e<256?Le[e]:Le[256+(e>>>7)],Ke=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Be=(e,t,s)=>{e.bi_valid>16-s?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<{Be(e,s[2*t],s[2*t+1])},$e=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},Ze=(e,t,s)=>{const n=new Array(16);let i,o,r=0;for(i=1;i<=be;i++)r=r+s[i-1]<<1,n[i]=r;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=$e(n[t]++,t))}},We=e=>{let t;for(t=0;t{e.bi_valid>8?Ke(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ye=(e,t,s,n)=>{const i=2*t,o=2*s;return e[i]{const n=e.heap[s];let i=s<<1;for(;i<=e.heap_len&&(i{let n,i,o,r,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===n?je(e,i,t):(o=Ue[i],je(e,o+ye+1,t),r=xe[o],0!==r&&(i-=Me[o],Be(e,i,r)),n--,o=Ve(n),je(e,o,s),r=ke[o],0!==r&&(n-=Pe[o],Be(e,n,r)))}while(a{const s=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let r,a,l,d=-1;for(e.heap_len=0,e.heap_max=573,r=0;r>1;r>=1;r--)Xe(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Xe(e,s,1),a=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=a,s[2*l]=s[2*r]+s[2*a],e.depth[l]=(e.depth[r]>=e.depth[a]?e.depth[r]:e.depth[a])+1,s[2*r+1]=s[2*a+1]=l,e.heap[1]=l++,Xe(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const s=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let d,c,h,u,_,p,E=0;for(u=0;u<=be;u++)e.bl_count[u]=0;for(s[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)c=e.heap[d],u=s[2*s[2*c+1]+1]+1,u>l&&(u=l,E++),s[2*c+1]=u,c>n||(e.bl_count[u]++,_=0,c>=a&&(_=r[c-a]),p=s[2*c],e.opt_len+=p*(u+_),o&&(e.static_len+=p*(i[2*c+1]+_)));if(0!==E){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,E-=2}while(E>0);for(u=l;0!==u;u--)for(c=e.bl_count[u];0!==c;)h=e.heap[--d],h>n||(s[2*h+1]!==u&&(e.opt_len+=(u-s[2*h+1])*s[2*h],s[2*h+1]=u),c--)}})(e,t),Ze(s,d,e.bl_count)},tt=(e,t,s)=>{let n,i,o=-1,r=t[1],a=0,l=7,d=4;for(0===r&&(l=138,d=3),t[2*(s+1)+1]=65535,n=0;n<=s;n++)i=r,r=t[2*(n+1)+1],++a{let n,i,o=-1,r=t[1],a=0,l=7,d=4;for(0===r&&(l=138,d=3),n=0;n<=s;n++)if(i=r,r=t[2*(n+1)+1],!(++a{Be(e,0+(n?1:0),3),Qe(e),Ke(e,s),Ke(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var ot=(e,t,s,n)=>{let i,o,r=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(tt(e,e.dyn_ltree,e.l_desc.max_code),tt(e,e.dyn_dtree,e.d_desc.max_code),et(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Oe[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=s+5,s+4<=i&&-1!==t?it(e,t,s,n):4===e.strategy||o===i?(Be(e,2+(n?1:0),3),Je(e,Re,De)):(Be(e,4+(n?1:0),3),((e,t,s,n)=>{let i;for(Be(e,t-257,5),Be(e,s-1,5),Be(e,n-4,4),i=0;i{nt||((()=>{let e,t,s,n,i;const o=new Array(16);for(s=0,n=0;n<28;n++)for(Me[n]=s,e=0;e<1<>=7;n(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=s,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[2*(Ue[s]+ye+1)]++,e.dyn_dtree[2*Ve(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Be(e,2,3),je(e,256,Re),(e=>{16===e.bi_valid?(Ke(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var at=(e,t,s,n)=>{let i=65535&e|0,o=e>>>16&65535|0,r=0;for(;0!==s;){r=s>2e3?2e3:s,s-=r;do{i=i+t[n++]|0,o=o+i|0}while(--r);i%=65521,o%=65521}return i|o<<16|0};const lt=new Uint32Array((()=>{let e,t=[];for(var s=0;s<256;s++){e=s;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t})());var dt=(e,t,s,n)=>{const i=lt,o=n+s;e^=-1;for(let s=n;s>>8^i[255&(e^t[s])];return-1^e},ct={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ht={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ut,_tr_stored_block:_t,_tr_flush_block:pt,_tr_tally:Et,_tr_align:gt}=rt,{Z_NO_FLUSH:ft,Z_PARTIAL_FLUSH:vt,Z_FULL_FLUSH:mt,Z_FINISH:St,Z_BLOCK:Tt,Z_OK:Ct,Z_STREAM_END:Nt,Z_STREAM_ERROR:yt,Z_DATA_ERROR:wt,Z_BUF_ERROR:At,Z_DEFAULT_COMPRESSION:bt,Z_FILTERED:xt,Z_HUFFMAN_ONLY:kt,Z_RLE:It,Z_FIXED:Ot,Z_DEFAULT_STRATEGY:Rt,Z_UNKNOWN:Dt,Z_DEFLATED:Lt}=ht,Ut=258,Mt=262,Pt=42,Ft=113,Ht=666,zt=(e,t)=>(e.msg=ct[t],t),qt=e=>2*e-(e>4?9:0),Gt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Vt=e=>{let t,s,n,i=e.w_size;t=e.hash_size,n=t;do{s=e.head[--n],e.head[n]=s>=i?s-i:0}while(--t);t=i,n=t;do{s=e.prev[--n],e.prev[n]=s>=i?s-i:0}while(--t)};let Kt=(e,t,s)=>(t<{const t=e.state;let s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+s),e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))},jt=(e,t)=>{pt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Bt(e.strm)},$t=(e,t)=>{e.pending_buf[e.pending++]=t},Zt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Wt=(e,t,s,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),s),1===e.state.wrap?e.adler=at(e.adler,t,i,s):2===e.state.wrap&&(e.adler=dt(e.adler,t,i,s)),e.next_in+=i,e.total_in+=i,i)},Qt=(e,t)=>{let s,n,i=e.max_chain_length,o=e.strstart,r=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-Mt?e.strstart-(e.w_size-Mt):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+Ut;let _=d[o+r-1],p=d[o+r];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(s=t,d[s+r]===p&&d[s+r-1]===_&&d[s]===d[o]&&d[++s]===d[o+1]){o+=2,s++;do{}while(d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&or){if(e.match_start=t,r=n,n>=a)break;_=d[o+r-1],p=d[o+r]}}}while((t=h[t&c])>l&&0!=--i);return r<=e.lookahead?r:e.lookahead},Yt=e=>{const t=e.w_size;let s,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Mt)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Vt(e),n+=t),0===e.strm.avail_in)break;if(s=Wt(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=s,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Kt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Kt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let s,n,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r=0,a=e.strm.avail_in;do{if(s=65535,i=e.bi_valid+42>>3,e.strm.avail_outn+e.strm.avail_in&&(s=n+e.strm.avail_in),s>i&&(s=i),s>8,e.pending_buf[e.pending-2]=~s,e.pending_buf[e.pending-1]=~s>>8,Bt(e.strm),n&&(n>s&&(n=s),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,s-=n),s&&(Wt(e.strm,e.strm.output,e.strm.next_out,s),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s)}while(0===r);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(Wt(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,n=e.strstart-e.block_start,(n>=o||(n||t===St)&&t!==ft&&0===e.strm.avail_in&&n<=i)&&(s=n>i?i:n,r=t===St&&0===e.strm.avail_in&&s===n?1:0,_t(e,e.block_start,s,r),e.block_start+=s,Bt(e.strm)),r?3:1)},Jt=(e,t)=>{let s,n;for(;;){if(e.lookahead=3&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-Mt&&(e.match_length=Qt(e,s)),e.match_length>=3)if(n=Et(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+1]);else n=Et(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(jt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===St?(jt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(jt(e,!1),0===e.strm.avail_out)?1:2},es=(e,t)=>{let s,n,i;for(;;){if(e.lookahead=3&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==s&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Et(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(jt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Et(e,0,e.window[e.strstart-1]),n&&jt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Et(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===St?(jt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(jt(e,!1),0===e.strm.avail_out)?1:2};function ts(e,t,s,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=n,this.func=i}const ss=[new ts(0,0,0,0,Xt),new ts(4,4,8,4,Jt),new ts(4,5,16,8,Jt),new ts(4,6,32,32,Jt),new ts(4,4,16,16,es),new ts(8,16,32,32,es),new ts(8,16,128,128,es),new ts(8,32,128,256,es),new ts(32,128,258,1024,es),new ts(32,258,258,4096,es)];function ns(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Lt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Gt(this.dyn_ltree),Gt(this.dyn_dtree),Gt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Gt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Gt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const is=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Pt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Ft&&t.status!==Ht?1:0},os=e=>{if(is(e))return zt(e,yt);e.total_in=e.total_out=0,e.data_type=Dt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Pt:Ft,e.adler=2===t.wrap?0:1,t.last_flush=-2,ut(t),Ct},rs=e=>{const t=os(e);var s;return t===Ct&&((s=e.state).window_size=2*s.w_size,Gt(s.head),s.max_lazy_match=ss[s.level].max_lazy,s.good_match=ss[s.level].good_length,s.nice_match=ss[s.level].nice_length,s.max_chain_length=ss[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=2,s.match_available=0,s.ins_h=0),t},as=(e,t,s,n,i,o)=>{if(!e)return yt;let r=1;if(t===bt&&(t=6),n<0?(r=0,n=-n):n>15&&(r=2,n-=16),i<1||i>9||s!==Lt||n<8||n>15||t<0||t>9||o<0||o>Ot||8===n&&1!==r)return zt(e,yt);8===n&&(n=9);const a=new ns;return e.state=a,a.strm=e,a.status=Pt,a.wrap=r,a.gzhead=null,a.w_bits=n,a.w_size=1<as(e,t,Lt,15,8,Rt),deflateInit2:as,deflateReset:rs,deflateResetKeep:os,deflateSetHeader:(e,t)=>is(e)||2!==e.state.wrap?yt:(e.state.gzhead=t,Ct),deflate:(e,t)=>{if(is(e)||t>Tt||t<0)return e?zt(e,yt):yt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===Ht&&t!==St)return zt(e,0===e.avail_out?At:yt);const n=s.last_flush;if(s.last_flush=t,0!==s.pending){if(Bt(e),0===e.avail_out)return s.last_flush=-1,Ct}else if(0===e.avail_in&&qt(t)<=qt(n)&&t!==St)return zt(e,At);if(s.status===Ht&&0!==e.avail_in)return zt(e,At);if(s.status===Pt&&0===s.wrap&&(s.status=Ft),s.status===Pt){let t=Lt+(s.w_bits-8<<4)<<8,n=-1;if(n=s.strategy>=kt||s.level<2?0:s.level<6?1:6===s.level?2:3,t|=n<<6,0!==s.strstart&&(t|=32),t+=31-t%31,Zt(s,t),0!==s.strstart&&(Zt(s,e.adler>>>16),Zt(s,65535&e.adler)),e.adler=1,s.status=Ft,Bt(e),0!==s.pending)return s.last_flush=-1,Ct}if(57===s.status)if(e.adler=0,$t(s,31),$t(s,139),$t(s,8),s.gzhead)$t(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),$t(s,255&s.gzhead.time),$t(s,s.gzhead.time>>8&255),$t(s,s.gzhead.time>>16&255),$t(s,s.gzhead.time>>24&255),$t(s,9===s.level?2:s.strategy>=kt||s.level<2?4:0),$t(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&($t(s,255&s.gzhead.extra.length),$t(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=dt(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if($t(s,0),$t(s,0),$t(s,0),$t(s,0),$t(s,0),$t(s,9===s.level?2:s.strategy>=kt||s.level<2?4:0),$t(s,3),s.status=Ft,Bt(e),0!==s.pending)return s.last_flush=-1,Ct;if(69===s.status){if(s.gzhead.extra){let t=s.pending,n=(65535&s.gzhead.extra.length)-s.gzindex;for(;s.pending+n>s.pending_buf_size;){let i=s.pending_buf_size-s.pending;if(s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex,s.gzindex+i),s.pending),s.pending=s.pending_buf_size,s.gzhead.hcrc&&s.pending>t&&(e.adler=dt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=i,Bt(e),0!==s.pending)return s.last_flush=-1,Ct;t=0,n-=i}let i=new Uint8Array(s.gzhead.extra);s.pending_buf.set(i.subarray(s.gzindex,s.gzindex+n),s.pending),s.pending+=n,s.gzhead.hcrc&&s.pending>t&&(e.adler=dt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex=0}s.status=73}if(73===s.status){if(s.gzhead.name){let t,n=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>n&&(e.adler=dt(e.adler,s.pending_buf,s.pending-n,n)),Bt(e),0!==s.pending)return s.last_flush=-1,Ct;n=0}t=s.gzindexn&&(e.adler=dt(e.adler,s.pending_buf,s.pending-n,n)),s.gzindex=0}s.status=91}if(91===s.status){if(s.gzhead.comment){let t,n=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>n&&(e.adler=dt(e.adler,s.pending_buf,s.pending-n,n)),Bt(e),0!==s.pending)return s.last_flush=-1,Ct;n=0}t=s.gzindexn&&(e.adler=dt(e.adler,s.pending_buf,s.pending-n,n))}s.status=103}if(103===s.status){if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size&&(Bt(e),0!==s.pending))return s.last_flush=-1,Ct;$t(s,255&e.adler),$t(s,e.adler>>8&255),e.adler=0}if(s.status=Ft,Bt(e),0!==s.pending)return s.last_flush=-1,Ct}if(0!==e.avail_in||0!==s.lookahead||t!==ft&&s.status!==Ht){let n=0===s.level?Xt(s,t):s.strategy===kt?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(Yt(e),0===e.lookahead)){if(t===ft)return 1;break}if(e.match_length=0,s=Et(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(jt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===St?(jt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(jt(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===It?((e,t)=>{let s,n,i,o;const r=e.window;for(;;){if(e.lookahead<=Ut){if(Yt(e),e.lookahead<=Ut&&t===ft)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,n=r[i],n===r[++i]&&n===r[++i]&&n===r[++i])){o=e.strstart+Ut;do{}while(n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=Et(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Et(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(jt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===St?(jt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(jt(e,!1),0===e.strm.avail_out)?1:2})(s,t):ss[s.level].func(s,t);if(3!==n&&4!==n||(s.status=Ht),1===n||3===n)return 0===e.avail_out&&(s.last_flush=-1),Ct;if(2===n&&(t===vt?gt(s):t!==Tt&&(_t(s,0,0,!1),t===mt&&(Gt(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),Bt(e),0===e.avail_out))return s.last_flush=-1,Ct}return t!==St?Ct:s.wrap<=0?Nt:(2===s.wrap?($t(s,255&e.adler),$t(s,e.adler>>8&255),$t(s,e.adler>>16&255),$t(s,e.adler>>24&255),$t(s,255&e.total_in),$t(s,e.total_in>>8&255),$t(s,e.total_in>>16&255),$t(s,e.total_in>>24&255)):(Zt(s,e.adler>>>16),Zt(s,65535&e.adler)),Bt(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Ct:Nt)},deflateEnd:e=>{if(is(e))return yt;const t=e.state.status;return e.state=null,t===Ft?zt(e,wt):Ct},deflateSetDictionary:(e,t)=>{let s=t.length;if(is(e))return yt;const n=e.state,i=n.wrap;if(2===i||1===i&&n.status!==Pt||n.lookahead)return yt;if(1===i&&(e.adler=at(e.adler,t,s,0)),n.wrap=0,s>=n.w_size){0===i&&(Gt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(s-n.w_size,s),0),t=e,s=n.w_size}const o=e.avail_in,r=e.next_in,a=e.input;for(e.avail_in=s,e.next_in=0,e.input=t,Yt(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=Kt(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,Yt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=r,e.input=a,e.avail_in=o,n.wrap=i,Ct},deflateInfo:"pako deflate (from Nodeca project)"};const ds=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var cs={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const s=t.shift();if(s){if("object"!=typeof s)throw new TypeError(s+"must be non-object");for(const t in s)ds(s,t)&&(e[t]=s[t])}}return e},flattenChunks:e=>{let t=0;for(let s=0,n=e.length;s=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;us[254]=us[254]=1;var _s={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,s,n,i,o,r=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&s):s<65536?(t[o++]=224|s>>>12,t[o++]=128|s>>>6&63,t[o++]=128|63&s):(t[o++]=240|s>>>18,t[o++]=128|s>>>12&63,t[o++]=128|s>>>6&63,t[o++]=128|63&s);return t},buf2string:(e,t)=>{const s=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const o=new Array(2*s);for(i=0,n=0;n4)o[i++]=65533,n+=r-1;else{for(t&=2===r?31:3===r?15:7;r>1&&n1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&hs)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let s="";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let s=t-1;for(;s>=0&&128==(192&e[s]);)s--;return s<0||0===s?t:s+us[e[s]]>t?s:t}};var ps=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Es=Object.prototype.toString,{Z_NO_FLUSH:gs,Z_SYNC_FLUSH:fs,Z_FULL_FLUSH:vs,Z_FINISH:ms,Z_OK:Ss,Z_STREAM_END:Ts,Z_DEFAULT_COMPRESSION:Cs,Z_DEFAULT_STRATEGY:Ns,Z_DEFLATED:ys}=ht;function ws(e){this.options=cs.assign({level:Cs,method:ys,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ns},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ps,this.strm.avail_out=0;let s=ls.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Ss)throw new Error(ct[s]);if(t.header&&ls.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?_s.string2buf(t.dictionary):"[object ArrayBuffer]"===Es.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=ls.deflateSetDictionary(this.strm,e),s!==Ss)throw new Error(ct[s]);this._dict_set=!0}}function As(e,t){const s=new ws(t);if(s.push(e,!0),s.err)throw s.msg||ct[s.err];return s.result}ws.prototype.push=function(e,t){const s=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?ms:gs,"string"==typeof e?s.input=_s.string2buf(e):"[object ArrayBuffer]"===Es.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;)if(0===s.avail_out&&(s.output=new Uint8Array(n),s.next_out=0,s.avail_out=n),(o===fs||o===vs)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(i=ls.deflate(s,o),i===Ts)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),i=ls.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Ss;if(0!==s.avail_out){if(o>0&&s.next_out>0)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else if(0===s.avail_in)break}else this.onData(s.output)}return!0},ws.prototype.onData=function(e){this.chunks.push(e)},ws.prototype.onEnd=function(e){e===Ss&&(this.result=cs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var bs={Deflate:ws,deflate:As,deflateRaw:function(e,t){return(t=t||{}).raw=!0,As(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,As(e,t)},constants:ht};const xs=16209;var ks=function(e,t){let s,n,i,o,r,a,l,d,c,h,u,_,p,E,g,f,v,m,S,T,C,N,y,w;const A=e.state;s=e.next_in,y=e.input,n=s+(e.avail_in-5),i=e.next_out,w=e.output,o=i-(t-e.avail_out),r=i+(e.avail_out-257),a=A.dmax,l=A.wsize,d=A.whave,c=A.wnext,h=A.window,u=A.hold,_=A.bits,p=A.lencode,E=A.distcode,g=(1<>>24,u>>>=m,_-=m,m=v>>>16&255,0===m)w[i++]=65535&v;else{if(!(16&m)){if(0==(64&m)){v=p[(65535&v)+(u&(1<>>=m,_-=m),_<15&&(u+=y[s++]<<_,_+=8,u+=y[s++]<<_,_+=8),v=E[u&f];s:for(;;){if(m=v>>>24,u>>>=m,_-=m,m=v>>>16&255,!(16&m)){if(0==(64&m)){v=E[(65535&v)+(u&(1<a){e.msg="invalid distance too far back",A.mode=xs;break e}if(u>>>=m,_-=m,m=i-o,T>m){if(m=T-m,m>d&&A.sane){e.msg="invalid distance too far back",A.mode=xs;break e}if(C=0,N=h,0===c){if(C+=l-m,m2;)w[i++]=N[C++],w[i++]=N[C++],w[i++]=N[C++],S-=3;S&&(w[i++]=N[C++],S>1&&(w[i++]=N[C++]))}else{C=i-T;do{w[i++]=w[C++],w[i++]=w[C++],w[i++]=w[C++],S-=3}while(S>2);S&&(w[i++]=w[C++],S>1&&(w[i++]=w[C++]))}break}}break}}while(s>3,s-=S,_-=S<<3,u&=(1<<_)-1,e.next_in=s,e.next_out=i,e.avail_in=s{const l=a.bits;let d,c,h,u,_,p,E=0,g=0,f=0,v=0,m=0,S=0,T=0,C=0,N=0,y=0,w=null;const A=new Uint16Array(16),b=new Uint16Array(16);let x,k,I,O=null;for(E=0;E<=Is;E++)A[E]=0;for(g=0;g=1&&0===A[v];v--);if(m>v&&(m=v),0===v)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(f=1;f0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&N>592)return 1;for(;;){x=E-T,r[g]+1=p?(k=O[r[g]-p],I=w[r[g]-p]):(k=96,I=0),d=1<>T)+c]=x<<24|k<<16|I|0}while(0!==c);for(d=1<>=1;if(0!==d?(y&=d-1,y+=d):y=0,g++,0==--A[E]){if(E===v)break;E=t[s+r[g]]}if(E>m&&(y&u)!==h){for(0===T&&(T=m),_+=f,S=E-T,C=1<852||2===e&&N>592)return 1;h=y&u,i[h]=m<<24|S<<16|_-o|0}}return 0!==y&&(i[_+y]=E-T<<24|64<<16|0),a.bits=m,0};const{Z_FINISH:Ms,Z_BLOCK:Ps,Z_TREES:Fs,Z_OK:Hs,Z_STREAM_END:zs,Z_NEED_DICT:qs,Z_STREAM_ERROR:Gs,Z_DATA_ERROR:Vs,Z_MEM_ERROR:Ks,Z_BUF_ERROR:Bs,Z_DEFLATED:js}=ht,$s=16180,Zs=16190,Ws=16191,Qs=16192,Ys=16194,Xs=16199,Js=16200,en=16206,tn=16209,sn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function nn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const on=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<$s||t.mode>16211?1:0},rn=e=>{if(on(e))return Gs;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=$s,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Hs},an=e=>{if(on(e))return Gs;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,rn(e)},ln=(e,t)=>{let s;if(on(e))return Gs;const n=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Gs:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,an(e))},dn=(e,t)=>{if(!e)return Gs;const s=new nn;e.state=s,s.strm=e,s.window=null,s.mode=$s;const n=ln(e,t);return n!==Hs&&(e.state=null),n};let cn,hn,un=!0;const _n=e=>{if(un){cn=new Int32Array(512),hn=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Us(1,e.lens,0,288,cn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Us(2,e.lens,0,32,hn,0,e.work,{bits:5}),un=!1}e.lencode=cn,e.lenbits=9,e.distcode=hn,e.distbits=5},pn=(e,t,s,n)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(s-o.wsize,s),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(t.subarray(s-n,s-n+i),o.wnext),(n-=i)?(o.window.set(t.subarray(s-n,s),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whavedn(e,15),inflateInit2:dn,inflate:(e,t)=>{let s,n,i,o,r,a,l,d,c,h,u,_,p,E,g,f,v,m,S,T,C,N,y=0;const w=new Uint8Array(4);let A,b;const x=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(on(e)||!e.output||!e.input&&0!==e.avail_in)return Gs;s=e.state,s.mode===Ws&&(s.mode=Qs),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,d=s.hold,c=s.bits,h=a,u=l,N=Hs;e:for(;;)switch(s.mode){case $s:if(0===s.wrap){s.mode=Qs;break}for(;c<16;){if(0===a)break e;a--,d+=n[o++]<>>8&255,s.check=dt(s.check,w,2,0),d=0,c=0,s.mode=16181;break}if(s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",s.mode=tn;break}if((15&d)!==js){e.msg="unknown compression method",s.mode=tn;break}if(d>>>=4,c-=4,C=8+(15&d),0===s.wbits&&(s.wbits=C),C>15||C>s.wbits){e.msg="invalid window size",s.mode=tn;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(w[0]=255&d,w[1]=d>>>8&255,s.check=dt(s.check,w,2,0)),d=0,c=0,s.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,d+=n[o++]<>>8&255,w[2]=d>>>16&255,w[3]=d>>>24&255,s.check=dt(s.check,w,4,0)),d=0,c=0,s.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,d+=n[o++]<>8),512&s.flags&&4&s.wrap&&(w[0]=255&d,w[1]=d>>>8&255,s.check=dt(s.check,w,2,0)),d=0,c=0,s.mode=16184;case 16184:if(1024&s.flags){for(;c<16;){if(0===a)break e;a--,d+=n[o++]<>>8&255,s.check=dt(s.check,w,2,0)),d=0,c=0}else s.head&&(s.head.extra=null);s.mode=16185;case 16185:if(1024&s.flags&&(_=s.length,_>a&&(_=a),_&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(n.subarray(o,o+_),C)),512&s.flags&&4&s.wrap&&(s.check=dt(s.check,n,_,o)),a-=_,o+=_,s.length-=_),s.length))break e;s.length=0,s.mode=16186;case 16186:if(2048&s.flags){if(0===a)break e;_=0;do{C=n[o+_++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C))}while(C&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=Ws;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=n[o++]<>>=7&c,c-=7&c,s.mode=en;break}for(;c<3;){if(0===a)break e;a--,d+=n[o++]<>>=1,c-=1,3&d){case 0:s.mode=16193;break;case 1:if(_n(s),s.mode=Xs,t===Fs){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=tn}d>>>=2,c-=2;break;case 16193:for(d>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,d+=n[o++]<>>16^65535)){e.msg="invalid stored block lengths",s.mode=tn;break}if(s.length=65535&d,d=0,c=0,s.mode=Ys,t===Fs)break e;case Ys:s.mode=16195;case 16195:if(_=s.length,_){if(_>a&&(_=a),_>l&&(_=l),0===_)break e;i.set(n.subarray(o,o+_),r),a-=_,o+=_,l-=_,r+=_,s.length-=_;break}s.mode=Ws;break;case 16196:for(;c<14;){if(0===a)break e;a--,d+=n[o++]<>>=5,c-=5,s.ndist=1+(31&d),d>>>=5,c-=5,s.ncode=4+(15&d),d>>>=4,c-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=tn;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[x[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,A={bits:s.lenbits},N=Us(0,s.lens,0,19,s.lencode,0,s.work,A),s.lenbits=A.bits,N){e.msg="invalid code lengths set",s.mode=tn;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,f=y>>>16&255,v=65535&y,!(g<=c);){if(0===a)break e;a--,d+=n[o++]<>>=g,c-=g,s.lens[s.have++]=v;else{if(16===v){for(b=g+2;c>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=tn;break}C=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=g+3;c>>=g,c-=g,C=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=g+7;c>>=g,c-=g,C=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=tn;break}for(;_--;)s.lens[s.have++]=C}}if(s.mode===tn)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=tn;break}if(s.lenbits=9,A={bits:s.lenbits},N=Us(1,s.lens,0,s.nlen,s.lencode,0,s.work,A),s.lenbits=A.bits,N){e.msg="invalid literal/lengths set",s.mode=tn;break}if(s.distbits=6,s.distcode=s.distdyn,A={bits:s.distbits},N=Us(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,A),s.distbits=A.bits,N){e.msg="invalid distances set",s.mode=tn;break}if(s.mode=Xs,t===Fs)break e;case Xs:s.mode=Js;case Js:if(a>=6&&l>=258){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=d,s.bits=c,ks(e,u),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,d=s.hold,c=s.bits,s.mode===Ws&&(s.back=-1);break}for(s.back=0;y=s.lencode[d&(1<>>24,f=y>>>16&255,v=65535&y,!(g<=c);){if(0===a)break e;a--,d+=n[o++]<>m)],g=y>>>24,f=y>>>16&255,v=65535&y,!(m+g<=c);){if(0===a)break e;a--,d+=n[o++]<>>=m,c-=m,s.back+=m}if(d>>>=g,c-=g,s.back+=g,s.length=v,0===f){s.mode=16205;break}if(32&f){s.back=-1,s.mode=Ws;break}if(64&f){e.msg="invalid literal/length code",s.mode=tn;break}s.extra=15&f,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;y=s.distcode[d&(1<>>24,f=y>>>16&255,v=65535&y,!(g<=c);){if(0===a)break e;a--,d+=n[o++]<>m)],g=y>>>24,f=y>>>16&255,v=65535&y,!(m+g<=c);){if(0===a)break e;a--,d+=n[o++]<>>=m,c-=m,s.back+=m}if(d>>>=g,c-=g,s.back+=g,64&f){e.msg="invalid distance code",s.mode=tn;break}s.offset=v,s.extra=15&f,s.mode=16203;case 16203:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=tn;break}s.mode=16204;case 16204:if(0===l)break e;if(_=u-l,s.offset>_){if(_=s.offset-_,_>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=tn;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=i,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{i[r++]=E[p++]}while(--_);0===s.length&&(s.mode=Js);break;case 16205:if(0===l)break e;i[r++]=s.length,l--,s.mode=Js;break;case en:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=n[o++]<{if(on(e))return Gs;let t=e.state;return t.window&&(t.window=null),e.state=null,Hs},inflateGetHeader:(e,t)=>{if(on(e))return Gs;const s=e.state;return 0==(2&s.wrap)?Gs:(s.head=t,t.done=!1,Hs)},inflateSetDictionary:(e,t)=>{const s=t.length;let n,i,o;return on(e)?Gs:(n=e.state,0!==n.wrap&&n.mode!==Zs?Gs:n.mode===Zs&&(i=1,i=at(i,t,s,0),i!==n.check)?Vs:(o=pn(e,t,s,s),o?(n.mode=16210,Ks):(n.havedict=1,Hs)))},inflateInfo:"pako inflate (from Nodeca project)"};var gn=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const fn=Object.prototype.toString,{Z_NO_FLUSH:vn,Z_FINISH:mn,Z_OK:Sn,Z_STREAM_END:Tn,Z_NEED_DICT:Cn,Z_STREAM_ERROR:Nn,Z_DATA_ERROR:yn,Z_MEM_ERROR:wn}=ht;function An(e){this.options=cs.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ps,this.strm.avail_out=0;let s=En.inflateInit2(this.strm,t.windowBits);if(s!==Sn)throw new Error(ct[s]);if(this.header=new gn,En.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=_s.string2buf(t.dictionary):"[object ArrayBuffer]"===fn.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=En.inflateSetDictionary(this.strm,t.dictionary),s!==Sn)))throw new Error(ct[s])}function bn(e,t){const s=new An(t);if(s.push(e),s.err)throw s.msg||ct[s.err];return s.result}An.prototype.push=function(e,t){const s=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,r,a;if(this.ended)return!1;for(r=t===~~t?t:!0===t?mn:vn,"[object ArrayBuffer]"===fn.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;){for(0===s.avail_out&&(s.output=new Uint8Array(n),s.next_out=0,s.avail_out=n),o=En.inflate(s,r),o===Cn&&i&&(o=En.inflateSetDictionary(s,i),o===Sn?o=En.inflate(s,r):o===yn&&(o=Cn));s.avail_in>0&&o===Tn&&s.state.wrap>0&&0!==e[s.next_in];)En.inflateReset(s),o=En.inflate(s,r);switch(o){case Nn:case yn:case Cn:case wn:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Tn))if("string"===this.options.to){let e=_s.utf8border(s.output,s.next_out),t=s.next_out-e,i=_s.buf2string(s.output,e);s.next_out=t,s.avail_out=n-t,t&&s.output.set(s.output.subarray(e,e+t),0),this.onData(i)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(o!==Sn||0!==a){if(o===Tn)return o=En.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},An.prototype.onData=function(e){this.chunks.push(e)},An.prototype.onEnd=function(e){e===Sn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=cs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var xn={Inflate:An,inflate:bn,inflateRaw:function(e,t){return(t=t||{}).raw=!0,bn(e,t)},ungzip:bn,constants:ht};const{Deflate:kn,deflate:In,deflateRaw:On,gzip:Rn}=bs,{Inflate:Dn,inflate:Ln,inflateRaw:Un,ungzip:Mn}=xn;var Pn={Deflate:kn,deflate:In,deflateRaw:On,gzip:Rn,Inflate:Dn,inflate:Ln,inflateRaw:Un,ungzip:Mn,constants:ht};var Fn,Hn;exports.ConnectionState=void 0,(Fn=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",Fn.OPEN="OPEN",Fn.CLOSED="CLOSED";class zn extends A{constructor(e,{sdkState:t,dispatcher:s,logger:n}){super(),this.lastActive=0,this._iid=e,this._sdkState=t,this._dispatcher=s,this._logger=n}get isOpen(){return this.connectionState===exports.ConnectionState.OPEN}get connectionState(){if(this._ws)switch(this._ws.readyState){case 0:return exports.ConnectionState.CONNECTING;case 1:return exports.ConnectionState.OPEN}return exports.ConnectionState.CLOSED}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Te.createFromRawMessage(this._iid,e);if(this._logger.debug("receive websocket event",t),"LOGI"===t.code)this.dispatch("message",t);else if("PONG"===t.code)this.dispatch("pong");else if("EXPR"===t.code){if(t.payload){const e=new he(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t){this._ws=new WebSocket(t),this._ws.onopen=()=>{this._logger.debug("websocket open"),this.dispatch("open")},this._ws.onmessage=t=>e(this,void 0,void 0,(function*(){var s;if(null===(s=this._sdkState.websocket)||void 0===s?void 0:s.compression)if(t.data instanceof Blob){const s=new FileReader;s.readAsArrayBuffer(t.data),s.onloadend=()=>e(this,void 0,void 0,(function*(){const t=yield(n=s.result,e(void 0,void 0,void 0,(function*(){const e=Pn.ungzip(n);return String.fromCharCode.apply(null,e)})));var n;this._handleMessage(t)}))}else"string"==typeof t.data&&this._handleMessage(t.data);else this._handleMessage(t.data)})),this._ws.onerror=()=>{this._logger.debug("websocket error"),this.dispatch("error",o.networkError)},this._ws.onclose=()=>{this._logger.debug("websocket close"),this.dispatch("close")},this.lastActive=Date.now()}disconnect(){return new Promise((e=>{this._logger.debug("websocket disconnect"),this._ws&&this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onopen=Ce,this._ws.onmessage=Ce,this._ws.onerror=Ce,this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()}))}send(e){if(!this._ws)throw o.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}error(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}class qn extends x{constructor({code:e,ackRequired:t,payload:s={}}){var n;super(),this.code=e,this.payload=s,this.requestId=null!==(n=this.payload.req_id)&&void 0!==n?n:y(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class Gn extends x{constructor({all:e,feed:t,custom_types:s,ts:n}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=n}}class Vn{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Kn{constructor(e,{auth:t,sdkState:s,dispatcher:n,logger:i,useFetchCompat:r=!1}){this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=n,this._logger=i,this.apiClient=new Se(e,{auth:t,sdkState:s,dispatcher:n,logger:i,useFetchCompat:r}),this.websocketClient=new zn(e,{sdkState:s,dispatcher:n,logger:i}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new Gn(e.payload.unread_cnt)),e.requestId){if(this._ackStateMap.has(e.requestId)){const t=this._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new o({code:e.payload.code,message:e.payload.message}))}}else this._dispatcher.dispatch(e)})).on("close",(()=>{this._ackStateMap.forEach((e=>{e.reject(o.connectionClosed)})),this._ackStateMap.clear()}))}_sendApiRequest(t){return e(this,void 0,void 0,(function*(){return yield this.apiClient.send(t)}))}_sendWebsocketRequest(t){return e(this,void 0,void 0,(function*(){if(!this._sdkState.websocket)throw o.connectionRequired;const e=new Vn;if(t.ackRequired){let s;const n=(n,i)=>{this._ackStateMap.has(t.requestId)&&(this._ackStateMap.delete(t.requestId),s&&(clearTimeout(s),s=null),n?(this._logger.debug("fail websocket request",n),e.reject(n)):(this._logger.debug("receive websocket ack",t.requestId),e.resolve(i)))};try{s=setTimeout((()=>n(o.noAckTimeout)),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(t.requestId,{resolve:e=>n(void 0,e),reject:e=>n(e)}),this.websocketClient.send(t)}catch(e){n(e)}}else try{this.websocketClient.send(t),e.resolve()}catch(t){e.reject(t)}return e.promise}))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof le)return yield this._sendApiRequest(t);if(t instanceof qn)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(Hn=exports.ConnectionStateType||(exports.ConnectionStateType={}))[Hn.NONE=0]="NONE",Hn[Hn.INITIALIZED=1]="INITIALIZED",Hn[Hn.CONNECTING=2]="CONNECTING",Hn[Hn.CONNECTED=3]="CONNECTED",Hn[Hn.RECONNECTING=4]="RECONNECTING",Hn[Hn.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",Hn[Hn.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",Hn[Hn.LOGOUT=7]="LOGOUT";class Bn extends x{constructor({stateType:e}){super(),this.stateType=e}}class jn{constructor(t,{auth:s,sdkState:n,dispatcher:i,logger:r,useFetchCompat:a=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Kn(t,{auth:s,sdkState:n,dispatcher:i,logger:r,useFetchCompat:a}),this._auth=s,this._logger=r,this._dispatcher=i,this._dispatcher.on((t=>{if(t instanceof Bn){const{stateType:s}=t;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:{const t=this._lazyCallQueue;this._lazyCallQueue=[],t.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:n}=t;clearTimeout(n);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))));break}case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:{const t=this._lazyCallQueue;this._lazyCallQueue=[],t.forEach((t=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:s}=t;clearTimeout(s),this._auth&&this._auth.hasSession?e.reject(o.connectionClosed):e.reject(o.connectionRequired)}))));break}}}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof qn){if(this.isReady)return this._logger.debug("send websocket request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait websocket request",t);const e=new Vn;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}throw this._logger.debug("fail websocket request"),o.connectionRequired}if(t instanceof le){if(this._auth.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Vn;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}{const e=o.connectionRequired;throw this._logger.debug("fail api request",e),e}}throw o.invalidCommand}))}forceSend(t){return e(this,void 0,void 0,(function*(){if(this._logger.debug("send forced request",t),t instanceof qn||t instanceof le)return yield this.commandRouter.send(t);throw o.invalidCommand}))}timeout(e){this._logger.debug("timeout request",e);const t=this._lazyCallQueue.findIndex((t=>t.command.requestId===e));t>-1&&(this._lazyCallQueue[t].deferred.reject(o.connectionRequired),this._lazyCallQueue.splice(t,1))}cancel(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}cancelAll(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}const $n="sendbird@devicetokens";class Zn{constructor({type:e,token:t}){this.type=e,this.token=t}static payloadify(e){return k(I({type:e.type,token:e.token}))}}class Wn extends le{constructor({userId:e,authToken:t,expiringSession:s=!0}){super(),this.path=`${G}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params={token:t,expiring_session:!!s},this.requireAuth=!1}}class Qn extends qn{constructor({authToken:e,expiringSession:t=!0,requestId:s=""}){super({code:"LOGI",payload:{token:e,expiring_session:t?1:0,req_id:s},ackRequired:!0})}}class Yn extends de{constructor(e,t){super(e,t);const{key:s}=t;this.key=s}}class Xn extends Te{constructor(e,t,s){var n;super(e,"LOGI",s),this.error=null,this.newKey=null,this.newKey=null!==(n=s.new_key)&&void 0!==n?n:null,this.error=s.error?new o(s.error):null}}class Jn extends x{}const ei=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class ti{calcTimeout(){return 0}}const si=(t,s,n=new ti)=>e(void 0,void 0,void 0,(function*(){let e=0,i=null;const o=e=>i=null!=e?e:new Error("Halted"),r=()=>{e=0};for(;-1===s||ee(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),ii=new WeakMap;class oi extends A{constructor({auth:e,cacheContext:t,sdkState:s,dispatcher:n,requestQueue:i,logger:o}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this._isRefreshingSessionKey=!1,this.currentUser=null,this.auth=e,this._cacheContext=t,this._sdkState=s,this._dispatcher=n,this._requestQueue=i,this._logger=o,this._deviceTokens=[],this._dispatcher.on((e=>{var t;if(e instanceof Bn){const{stateType:t}=e;this._currentConnectionStateType=t}else e instanceof he&&this.handler&&(e.invalidateSessionToken&&(this.auth.authToken=void 0),e.error&&(e.error.isSessionKeyExpiredError||e.error.isSessionTokenExpiredError)&&(this._logger.debug("session expired"),(null===(t=this.handler)||void 0===t?void 0:t.onSessionExpired)&&this.handler.onSessionExpired(),this.refresh()))}))}get ekey(){return ii.get(this)}get deviceTokens(){return this._deviceTokens}get deviceTokenLastDeletedAt(){return this._deviceTokenLastDeletedAt}indexOfDeviceToken(e,t){return this._deviceTokens.findIndex((s=>s.type===e&&s.token===t))}hasDeviceToken(e,t){return this.indexOfDeviceToken(e,t)>=0}createRefreshWebsocketCommand(e,t){return new Qn({authToken:e,expiringSession:!0,requestId:t})}_refreshSessionKeyByWebSocket(t){return e(this,void 0,void 0,(function*(){const e=this.createRefreshWebsocketCommand(t),s=yield this._requestQueue.forceSend(e),{newKey:n,error:i}=s.as(Xn);if(i)throw i;this.auth.sessionKey=null!=n?n:this.auth.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new Wn({userId:this._sdkState.userId,authToken:t,expiringSession:!0});yield si((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t}=e.as(Yn);this.auth.sessionKey=t}catch(e){if(!this._isSessionRelatedError(e))throw e;t(e)}}))),3)}))}_refreshSessionKey(t,s=!0){return e(this,void 0,void 0,(function*(){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED)try{return yield this._refreshSessionKeyByWebSocket(t),void this.complete()}catch(e){if(this._isSessionRelatedError(e)&&s){const e=yield this._receiveNewAuthToken();return void(e?(this.auth.authToken=e,yield this._refreshSessionKey(this.auth.authToken,!1),this.complete()):(yield this.clear(),this.close()))}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){if(!this._isSessionRelatedError(e))throw e;if(!s)throw e;{const e=yield this._receiveNewAuthToken();e?(this.auth.authToken=e,yield this._refreshSessionKeyByApi(this.auth.authToken),this.complete()):(yield this.clear(),this.close())}}}))}_receiveNewAuthToken(){const t=new Vn;return ni((()=>e(this,void 0,void 0,(function*(){if(this._isRefreshingAuthToken=!0,this.auth.clear(),this.handler.onSessionTokenRequired){let e=null;const s=()=>{e&&(clearTimeout(e),e=null)},n=e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,this.dispatch("refresh-authtoken"),t.resolve(e))},i=e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,t.reject(e))};e=setTimeout((()=>i()),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(n,i)}else t.resolve(null)})))),t.promise}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}get isSessionKeyRefreshing(){return this._isRefreshingSessionKey}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:n,userProfile:i,deviceTokenLastDeletedAt:o=0}=t;this.auth.sessionKey=e,ii.set(this,n),this._deviceTokenCacheEnabled=null===(s=null==i?void 0:i.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:r}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield r.get($n);!e||e.lastDeletedAtnew Zn(Zn.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield r.remove($n)}))}complete(){this.dispatch("refresh"),ni((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session refreshed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionRefreshed)&&this.handler.onSessionRefreshed()}))))}error(t){ni((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionError)&&this.handler.onSessionError(t)}))))}close(){this.dispatch("close"),ni((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session closed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionClosed)&&this.handler.onSessionClosed()}))))}refresh(){return e(this,void 0,void 0,(function*(){if(this.handler&&!this._isRefreshingSessionKey){if(this._isRefreshingSessionKey=!0,!this.auth.authToken)try{const e=yield this._receiveNewAuthToken();if(!e)return yield this.clear(),void(this._isRefreshingSessionKey=!1);this._logger.debug("session refreshing.."),this.auth.authToken=e}catch(e){const t=o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new Jn),this.error(t),this._isRefreshingSessionKey=!1,t}try{yield this._refreshSessionKey(this.auth.authToken),this._isRefreshingSessionKey=!1}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new Jn),this.error(t),this._isRefreshingSessionKey=!1,t}}}))}setDeviceToken(e,t){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0)return this._deviceTokens.push(new Zn({type:e,token:t})),!0}return!1}unsetDeviceToken(e,t){if(this._deviceTokenCacheEnabled){const s=this.indexOfDeviceToken(e,t);s>=0&&this._deviceTokens.splice(s,1)}}unsetDeviceTokens(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((t=>t.type!==e)):[])}setDeviceTokenDeletedAt(e){e>0&&(this._deviceTokenLastDeletedAt=e)}saveDeviceToken(){return e(this,void 0,void 0,(function*(){if(this._deviceTokenCacheEnabled){const{preference:e}=this._cacheContext;yield e.set($n,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.auth.clear(),this.close(),ii.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken()}))}}class ri{constructor(){this.type=exports.ConnectionStateType.NONE,this.name="none"}run(t){return e(this,void 0,void 0,(function*(){}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnect(t,{error:s=null,autoReconnect:n=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){}))}onLogout(t){return e(this,void 0,void 0,(function*(){}))}}class ai extends ri{constructor(){super(...arguments),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout"}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),n=t.sdkState.userId;yield t.logout(),yield t.changeState(new _i,s),ni((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(n)}))}))))}))}}class li extends ri{constructor(){super(),this.type=exports.ConnectionStateType.EXTERNAL_DISCONNECTED,this.name="externaldisconnected"}run(t){return e(this,void 0,void 0,(function*(){yield t.disconnect()}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new ui({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ci,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ai,e)}))}}class di extends ri{constructor({autoReconnect:e}){super(),this.type=exports.ConnectionStateType.INTERNAL_DISCONNECTED,this.name="internaldisconnected",this._autoReconnect=!1,this._autoReconnect=e}run(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),this._autoReconnect&&(yield t.changeState(new ci,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new ui({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ci,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new li,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ai,e)}))}}class ci extends ri{constructor(){super(...arguments),this.type=exports.ConnectionStateType.RECONNECTING,this.name="reconnecting",this._callbacks=[]}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),n=new Vn;this._callbacks.push((e=>e?n.reject(e):n.resolve())),ni((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onReconnectStarted&&e.onReconnectStarted()}))}))));try{const{reconnectMaxRetry:n,reconnectRetryStrategy:i}=t.sdkState.websocket;yield si(((s,n)=>e(this,void 0,void 0,(function*(){this._haltConnect=s,this._resetConnect=n;try{yield t.connect()}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),n,i),yield t.changeState(new hi,s),ni((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onReconnectSucceeded&&e.onReconnectSucceeded()}))}))))}catch(n){if(i(n))throw n;n instanceof o&&n.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new di({autoReconnect:!1}),s)),ni((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(n),t.connectionHandlers.forEach((e=>{e.onReconnectFailed&&e.onReconnectFailed()}))}))))}return n.promise}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=new Vn;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const n=Date.now();t.changeState(new ui({authToken:s}),n).then((()=>{e.resolve()})).catch((t=>{e.reject(t)}))})),e.promise}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){const e=new Vn;return this._resetConnect&&s&&this._resetConnect(),this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:n=!0}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new di({autoReconnect:n}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new li,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new ai,e)}))}}class hi extends ri{constructor(){super(...arguments),this.type=exports.ConnectionStateType.CONNECTED,this.name="connected"}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new ci,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new di({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new li,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ai,e)}))}}class ui extends ri{constructor({authToken:e}){super(),this.type=exports.ConnectionStateType.CONNECTING,this.name="connecting",this._authToken="",this._callbacks=[],this._authToken=e}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),n=new Vn;this._callbacks.push((e=>e?n.reject(e):n.resolve()));try{yield si((s=>e(this,void 0,void 0,(function*(){this._haltConnect=s;try{yield t.connect(this._authToken)}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),t.sdkState.websocket.connectMaxRetry),yield t.changeState(new hi,s),ni((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onConnected&&e.onConnected(t.sdkState.userId)}))}))))}catch(n){if(i(n))throw n;yield t.disconnect(),n instanceof o&&n.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new _i,s)),ni((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(n)}))))}return n.promise}))}onConnect(t){return e(this,void 0,void 0,(function*(){const e=new Vn;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:n=!1}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),t.hasSession?yield t.changeState(new di({autoReconnect:n}),e):yield t.changeState(new ai,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),t.hasSession?yield t.changeState(new li,e):yield t.changeState(new ai,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new ai,e)}))}}class _i extends ri{constructor(){super(...arguments),this.type=exports.ConnectionStateType.INITIALIZED,this.name="initialized"}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ui({authToken:s}),e)}))}}class pi extends qn{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class Ei{constructor({pingDelegate:e,sdkState:t,logger:s}){this.pingDelegate=e,this.sdkState=t,this._logger=s}get isWaiting(){return!!this._pingTimeoutTimer}ping(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;const t=new pi;try{const s=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((()=>{this._logger.debug("pinger.ping() timeout"),this.pingDelegate.error()}),s),this.pingDelegate.send(t),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return t}pong(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}refreshTimer(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;this._logger.debug("pinger.refreshTimer()");const t=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((()=>{this.ping()}),t)}start(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}stop(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}class gi{constructor(e){var t,s,n,i;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(n=e.template_list_token)&&void 0!==n?n:null,this.settingsUpdatedAt=null!==(i=e.settings_updated_at)&&void 0!==i?i:0}static payloadify(e){return k(I({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class fi{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return k(I({last_updated_at:e.lastUpdatedAt}))}}const vi=1048576;class mi{constructor(e={}){var t,s,n,i,o;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*vi:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(s=e.premium_feature_list)&&void 0!==s?s:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(n=e.multiple_file_send_max_size)&&void 0!==n?n:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new fi(null!==(o=e.uikit_config)&&void 0!==o?o:{}),this.notificationInfo=e.notifications?new gi(e.notifications):null}static payloadify(e){return k(I({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/vi,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?fi.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?gi.payloadify(e.notificationInfo):null}))}}class Si{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class Ti extends le{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${G}/${e}/metadata`,this.params={metadata:t}}}class Ci extends de{constructor(e,t){super(e,t),this.metaData=t}}class Ni extends le{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${G}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class yi extends de{constructor(e,t){super(e,t),this.metadata=t}}class wi extends le{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${G}/${e}/metadata/${t}`}}class Ai extends le{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${G}/${e}/metadata`}}const bi=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},xi=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},ki=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var Ii;exports.UserOnlineState=void 0,(Ii=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",Ii.OFFLINE="offline",Ii.NON_AVAILABLE="nonavailable";class Oi extends Si{constructor(e,t){var s,n,i,o,r,a,c,h,u,_,p,E;super(e),this.userId=null!==(n=null!==(s=t.guest_id)&&void 0!==s?s:t.user_id)&&void 0!==n?n:"",this.nickname=null!==(o=null!==(i=t.nickname)&&void 0!==i?i:t.name)&&void 0!==o?o:"",this.plainProfileUrl=null!==(a=null!==(r=t.profile_url)&&void 0!==r?r:t.image)&&void 0!==a?a:"",this.requireAuth=null!==(c=t.require_auth_for_profile_image)&&void 0!==c&&c,this.metaData=null!==(h=t.metadata)&&void 0!==h?h:{},this.connectionStatus=exports.UserOnlineState.NON_AVAILABLE,d(exports.UserOnlineState,t.is_online)?this.connectionStatus=t.is_online:l("boolean",t.is_online)&&(this.connectionStatus=t.is_online?exports.UserOnlineState.ONLINE:exports.UserOnlineState.OFFLINE),this.isActive=null===(u=t.is_active)||void 0===u||u,this.lastSeenAt=null!==(_=t.last_seen_at)&&void 0!==_?_:null,this.preferredLanguages=t.preferred_languages?[...t.preferred_languages]:null,this.friendDiscoveryKey=null!==(p=t.friend_discovery_key)&&void 0!==p?p:null,this.friendName=null!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return k(I(Object.assign(Object.assign({},super.payloadify(e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}get profileUrl(){const{sessionManager:e}=ji.of(this._iid);return this.requireAuth?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return bi(this)}_isValidMetaData(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((t=>e[t])).every((e=>l("string",e)))}_applyMetaData(e,t=!1){Object.keys(e).forEach((s=>{t?delete this.metaData[s]:this.metaData[s]=e[s]}))}createMetaData(t){return e(this,void 0,void 0,(function*(){ki(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=ji.of(this._iid),n=new Ti({userId:e.userId,metadata:t}),i=yield s.send(n),{metaData:r}=i.as(Ci);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){ki(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:n}=ji.of(this._iid),i=new Ni({userId:e.userId,metadata:t,upsert:s}),r=yield n.send(i),{metadata:a}=r.as(yi);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){ki(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=ji.of(this._iid),n=new wi({userId:e.userId,metadataKey:t});return yield s.send(n),this._applyMetaData({[t]:!0},!0),this.metaData}))}deleteAllMetaData(){return e(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=ji.of(this._iid),s=new Ai({userId:e.userId});yield t.send(s),this.metaData={}}))}}class Ri extends x{constructor({userProfile:e}){super(),this.userProfile=e}}class Di{constructor(e,t){var s,n,i,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new mi(t),this.user=new Oi(e,t),this.connectedAt=null!==(s=t.login_ts)&&void 0!==s?s:0,this.firstConnectedAt=0,this.pingInterval=null!==(n=t.ping_interval)&&void 0!==n?n:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(r=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==r?r:3e3,this.reconnectMaxInterval=null!==(l=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(c=null===(d=t.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==c?c:5,this.reconnectIntervalMultiple=null!==(u=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==u?u:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(p=t.concurrent_call_limit)&&void 0!==p?p:5,this.backOffDelay=null!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return k(I(Object.assign(Object.assign(Object.assign({},Oi.payloadify(e.user)),mi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}apply(){const e=this.reconnectInterval,t=this.reconnectMaxInterval,s=this.reconnectIntervalMultiple,n=ji.of(this._iid);n.sdkState.websocket&&(n.sdkState.websocket.pingInterval=1e3*this.pingInterval,n.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,n.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,n.sdkState.websocket.reconnectRetryStrategy={calcTimeout:n=>n>0?1e3*Math.min(e*Math.pow(s,n-1),t):10}),n.appInfo=this.appInfo,n.sessionManager.currentUser=this.user,n.connectedAt=this.connectedAt,this.firstConnectedAt||(n.firstConnectedAt=this.connectedAt),n.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,n.concurrentCallLimit=this.concurrentCallLimit,n.backOffDelay=this.backOffDelay,n.dispatcher.dispatch(new Ri({userProfile:this}))}}class Li extends Te{constructor(e,t,s){var n,i,r;super(e,t,s),this.error=null,this.userProfile=new Di(e,s),this.deviceTokenLastDeletedAt=null!==(n=s.device_token_last_deleted_at)&&void 0!==n?n:0,this.key=null!==(i=s.key)&&void 0!==i?i:"",this.ekey=null!==(r=s.ekey)&&void 0!==r?r:"",this.error=s.error?new o(s):null}static asError(e){return new Li("","LOGI",Object.assign({user_id:"",error:!0},e))}applyTo(t){return e(this,void 0,void 0,(function*(){if(this.error)throw this.error;{const e=ji.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t}=e;yield t.login(this),this.userProfile.apply()}}}))}}class Ui extends x{constructor({request:e=!0,features:t={},options:s={}}){super(),this.request=e,this.features=Object.assign({localCache:!0},t),this.options=Object.assign({ingestion:!0},s)}}class Mi extends A{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:n,sessionManager:i,websocketClient:r,dispatcher:a,logger:l,entryState:d=new _i}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectionRequestQueue=[],this._iid=e,this.sdkState=t,this.cacheContext=s,this.connectionHandlers=n,this._sessionManager=i,this._websocketClient=r,this._dispatcher=a,this._logger=l,this._currentState=d,(null===(c=this.sdkState.websocket)||void 0===c?void 0:c.pingerDisabled)||(this._pinger=new Ei({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Li))})).on("ping-refresh",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.pong()})).on("error",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.stop()})).on("close",(()=>{this._logiProcessingTimer=setTimeout((()=>{this._logiProcessingTimer=void 0,this._unresolvedLogi||this._rejectConnectionRequest(o.networkError)}),500)})),this._dispatcher.on((e=>{e instanceof Li&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.auth.hasSession}changeState(t,s){return e(this,void 0,void 0,(function*(){return s>=this._stateUpdatedAt&&(this._currentState=t,this._stateUpdatedAt=s,this._dispatcher.dispatch(new Bn({stateType:t.type})),this._logger.debug(`connection state changes to ${t.name}`),yield this._currentState.run(this),!0)}))}_tryResolveConnectionRequest(){var t;return e(this,void 0,void 0,(function*(){const e=this._unresolvedLogi;if(this._websocketClient.isOpen&&e)if(this._unresolvedLogi=void 0,e.error)this._sessionManager.auth.authToken=void 0,(e.error.isSessionKeyExpiredError||e.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new he({reason:e.error.code})),this._rejectConnectionRequest(e.error);else{yield e.applyTo(this._iid);const{userProfile:s}=e;this._enableStatLog({request:s.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:s.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:s.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(t=this._pinger)||void 0===t||t.start(),this._connectionRequestQueue.forEach((e=>e.resolve())),this._connectionRequestQueue=[],this.sdkState.appState="foreground"}}))}_rejectConnectionRequest(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){const t=this._connectionRequestQueue;this._connectionRequestQueue=[],t.forEach((t=>t.reject(e))),this._statLogConnection(e)}}_url(e=""){var t,s;const{appId:i,appVersion:o,userId:r,extensions:a,sendbirdRuntimeEnvironment:l}=this.sdkState,{localCacheEnabled:d}=this.cacheContext,{auth:c}=this._sessionManager,h=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,u=!!(null!==(s=this.sdkState.extensions)&&void 0!==s?s:{}).sb_uikit,_=me.userAgentWithExtension(a);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(n.OS_VERSION)}&sv=${encodeURIComponent(n.SDK_VERSION)}&ai=${i}${o?`&av=${o}`:""}${c.hasSession?`&key=${encodeURIComponent(c.sessionKey)}`:`&user_id=${encodeURIComponent(r)}&access_token=${encodeURIComponent(e)}`}&pmce=${h?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${_}&SB-SDK-User-Agent=${encodeURIComponent(me.sendbirdSdkUserAgentWithExtension(l))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"]))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${d?1:0}&include_poll_details=1${u?"&uikit_config=1":""}`}_enableStatLog({request:e,features:t,options:s={}}){this._dispatcher.dispatch(new Ui({request:e,features:t,options:s}))}_statLogConnection(e){var t;this._dispatcher.dispatch(new ue(new _e({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}connect(t=""){var s;return e(this,void 0,void 0,(function*(){this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(o.connectionCanceled));const e=this._url(t),n=new Vn;return this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout),t&&(this._sessionManager.auth.authToken=t),this._websocketClient.connect(e)),n.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Li.asError(o.connectionRenew))}disconnect(){return e(this,void 0,void 0,(function*(){yield this._websocketClient.disconnect()}))}logout(){return e(this,void 0,void 0,(function*(){this.sdkState.userId=void 0,this._unresolvedLogi=void 0,yield this._sessionManager.clear(),yield this.disconnect()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class Pi{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:n,sessionManager:i,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new Mi(e,{sdkState:t,cacheContext:s,connectionHandlers:n,sessionManager:i,websocketClient:o,dispatcher:r,logger:a}),this._sdkState=t,this._sessionManager=i,this._websocketClient=o}_registerEventDispatcher(){this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(()=>{this.isConnected||(this._logger.debug("try reconnect by session token refresh"),this.reconnect())})).on("refresh",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),this.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._externalCalledWebSocketClose||this._sessionManager.isRefreshingAuthToken||(this._logger.debug("try reconnect by websocket connection closed"),this.reconnect())})))}_clearEventDispatcher(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}get isConnected(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTED}get isConnecting(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTING||e.type===exports.ConnectionStateType.RECONNECTING}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnect(this._context,{autoReconnect:!1})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0})}))}disconnectWebSocket(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnectWebSocket(this._context)}))}logout(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context)}))}}class Fi extends _e{constructor({type:e,data:t,ts:s=Date.now()}){var n;super({type:e,data:t,ts:s}),this.date=new Date(s),this.key=`${n=this.date,`${n.getFullYear()}${String(n.getMonth()+1).padStart(2,"0")}${String(n.getDate()).padStart(2,"0")}`}_${e}`}}class Hi extends le{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${te}`,this.params={device_id:e,log_entries:t.map((e=>_e.payloadify(e)))}}}const zi=(e,t)=>{if(null!==e&&null!==t){const s=Object.keys(e),n=Object.keys(t),i=[...new Set([...s,...n])],o={};for(const s of i){const n=typeof e[s],i=typeof t[s];"undefined"===n?o[s]=t[s]:"undefined"===i?o[s]=e[s]:n!==i?o[s]=t[s]:"object"===n&&e[s]&&t[s]?o[s]=zi(e[s],t[s]):o[s]=t[s]}return o}return t};var qi,Gi;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(qi||(qi={}));class Vi extends A{constructor({cacheContext:e,requestQueue:t,dispatcher:s,baseLimit:n=100,maxLimit:i=1e3,minLimit:o=10}){super(),this.queue=[],this.enabledState=qi.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this.deviceId=y(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.baseLimit=n,this.limit=n,this.maxLimit=i,this.minLimit=o}get isEnabled(){return this.enabledState===qi.ENABLED}_arrangeStat(){const e=[];this._collectRequestStat&&e.push(...this.queue.filter((e=>e.type===exports.StatType.API_RESULT||e.type===exports.StatType.WEBSOCKET_CONNECT))),this._collectFeatureLocalCacheStat&&e.push(...this.queue.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE))),this.queue=e}_save(){return e(this,void 0,void 0,(function*(){this.enabledState===qi.ENABLED&&(yield this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((e=>_e.payloadify(e))),generation:this.generation++,lastFlushedAt:this.lastFlushedAt}),this.dispatch("save",[...this.queue]))}))}_flush(){return e(this,void 0,void 0,(function*(){if(this.isEnabled&&!this.isFlushing){this.isFlushing=!0;try{this._arrangeStat();const e=this.queue.filter((e=>{if(e instanceof Fi){const t=new Date,[s,n]=[e.date.getFullYear(),t.getFullYear()];if(s!(e instanceof Fi))),s=[...e,...t].slice(0,Math.min(this.limit,this.maxLimit));if(s.length>0){const n=new Hi({deviceId:this.deviceId,statLogs:s});yield this.requestQueue.send(n),this.dispatch("flush",s),this.queue=[...e,...t].slice(s.length),yield this._save()}this.limit=this.baseLimit,this.lastFlushedAt=Date.now()}catch(e){e instanceof o&&(e.code===exports.SendbirdErrorCode.STAT_LOG_NOT_ALLOWED?(yield this.clear(),this.enabledState=qi.DISABLED):e.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=qi.COLLECT_ONLY)),this.limit=this.limit+20}finally{this.isFlushing=!1}}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);if(e&&(this.deviceId=e.deviceId,this.queue=e.statLogs.map((e=>new _e({type:e.stat_type,ts:e.ts,data:e.data}))),this.generation=e.generation,this.lastFlushedAt=e.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){const e=Math.min(Math.floor(18e4*Math.random()),100);yield ei(e),yield this._flush()}this.commandEventContext||(this.commandEventContext=this.dispatcher.on((e=>{if(e instanceof ue){const{statLog:t}=e;this.put(t)}else if(e instanceof Ui){const{request:t,features:s,options:n}=e;this._collectRequestStat=t,this._collectFeatureLocalCacheStat=null==s?void 0:s.localCache,this._arrangeStat(),this._collectRequestStat||this._collectFeatureLocalCacheStat?this.enabledState=n.ingestion?qi.ENABLED:qi.COLLECT_ONLY:this.enabledState=qi.DISABLED,this.isEnabled?this.queue.length>=this.limit&&this._flush():this.clear()}})))}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState!==qi.DISABLED){if(t instanceof Fi){if(this._collectFeatureLocalCacheStat){const[e]=this.queue.filter((e=>e instanceof Fi&&e.key===t.key));e?e.data=zi(e.data,t.data):this.queue.push(t)}}else this._collectRequestStat&&this.queue.push(t);yield this._save(),this.queue.length>=this.limit&&(yield this._flush())}}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.generation=1,yield this._save()}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}exports.LogLevel=void 0,(Gi=exports.LogLevel||(exports.LogLevel={}))[Gi.NONE=0]="NONE",Gi[Gi.VERBOSE=1]="VERBOSE",Gi[Gi.DEBUG=2]="DEBUG",Gi[Gi.INFO=3]="INFO",Gi[Gi.WARN=4]="WARN",Gi[Gi.ERROR=5]="ERROR";class Ki{constructor(){this.level=exports.LogLevel.WARN}verbose(...e){this.level<=exports.LogLevel.VERBOSE&&console.log("[verbose]",...e)}debug(...e){this.level<=exports.LogLevel.DEBUG&&console.log("[debug]",...e)}info(...e){this.level<=exports.LogLevel.INFO&&console.log("[info]",...e)}warn(...e){this.level<=exports.LogLevel.WARN&&console.warn("[warn]",...e)}error(...e){this.level<=exports.LogLevel.ERROR&&console.error("[error]",...e)}}const Bi={};class ji{constructor(e,t){var s,i,o,r,a,l,d,c,h,u;if(this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,!Bi[e]){Bi[e]=this;const p=null!==(s=t.options)&&void 0!==s?s:new _,E=this.sdkState={appId:t.appId,appVersion:null!==(i=t.appVersion)&&void 0!==i?i:"",appState:"foreground",userId:void 0,extensions:{},api:{host:null!==(o=t.apiHost)&&void 0!==o?o:`https://api-${t.appId}.sendbird.com`},websocket:{host:null!==(r=t.websocketHost)&&void 0!==r?r:`wss://ws-${t.appId}.sendbird.com`,pingerDisabled:!!t.noPingpong,pingInterval:void 0,pongTimeout:void 0,connectMaxRetry:2,compression:!0,reconnectMaxRetry:-1,reconnectRetryStrategy:new ti,responseTimeout:p.websocketResponseTimeout},sessionTokenRefreshTimeout:p.sessionTokenRefreshTimeout};this.appInfo=void 0,this.subscribedUnreadMessageCount={all:0,feed:0,customTypes:{},ts:0};const f=this.logger=new Ki;this.logger.level=null!==(a=t.logLevel)&&void 0!==a?a:exports.LogLevel.WARN,this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map;const v=this.cacheContext=new g({encryption:t.encryption,store:t.store,localCacheEnabled:null!==(l=t.localCacheEnabled)&&void 0!==l&&l,localCacheConfig:null!==(d=t.localCacheConfig)&&void 0!==d?d:new C});this.debugMode=null!==(c=t.debugMode)&&void 0!==c&&c,this.maxSuperGroupChannelUnreadCount=n.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,this.useMemberInfoInMessage=p.useMemberInfoInMessage,this.typingIndicatorInvalidateTime=p.typingIndicatorInvalidateTime,this.typingIndicatorThrottle=p.typingIndicatorThrottle,this.concurrentCallLimit=void 0,this.backOffDelay=void 0;const m=this.dispatcher=new b,S=new N;this.requestQueue=new jn(e,{auth:S,sdkState:E,dispatcher:m,logger:f,useFetchCompat:t.useFetchCompat}),this.sessionManager=new oi({auth:S,cacheContext:v,sdkState:E,dispatcher:m,requestQueue:this.requestQueue,logger:f}),this.connectionManager=new Pi(e,{sdkState:E,cacheContext:this.cacheContext,connectionHandlers:this.connectionHandlers,dispatcher:m,sessionManager:this.sessionManager,websocketClient:this.requestQueue.commandRouter.websocketClient,disableWebSocketCloseEventHandling:null!==(h=t.disableWebSocketCloseEventHandling)&&void 0!==h&&h,logger:f}),this.statLogCollector=new Vi({cacheContext:this.cacheContext,requestQueue:this.requestQueue,dispatcher:m}),this.appStateToggleEnabled=null===(u=t.appStateToggleEnabled)||void 0===u||u}return Bi[e]}static of(e){if(Bi[e])return Bi[e];throw o.lostInstance}static clear(e){Bi[e]&&delete Bi[e]}hasExtension(e){return this.sdkState.extensions&&this.sdkState.extensions[e]}}var $i;exports.PollStatus=void 0,($i=exports.PollStatus||(exports.PollStatus={})).OPEN="open",$i.CLOSED="closed";const Zi=e=>{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},Wi=e=>!e||!!e.text&&l("string",e.text);class Qi extends Si{constructor(e,t){var s,n,i,o,r,a,l;super(e),this.pollId=0,this.id=0,this.text=null,this.voteCount=0,this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._lastVotedAt=0,this.pollId=null!==(s=t.poll_id)&&void 0!==s?s:0,this.id=null!==(n=t.id)&&void 0!==n?n:0,this.text=null!==(i=t.text)&&void 0!==i?i:null,this.voteCount=null!==(o=t.vote_count)&&void 0!==o?o:0,this.createdBy=null!==(r=t.created_by)&&void 0!==r?r:null,this.createdAt=null!==(a=t.created_at)&&void 0!==a?a:0,this.updatedAt=null!==(l=t.updated_at)&&void 0!==l?l:0}static payloadify(e){return k(I(Object.assign(Object.assign({},super.payloadify(e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}class Yi extends Si{constructor(e,t){var s,n,i,o,r,a,l,d,c,h,u,_,p;super(e),this.id=0,this.title=null,this.createdAt=0,this.updatedAt=0,this.closeAt=-1,this.status=exports.PollStatus.CLOSED,this.messageId=0,this.data=null,this.voterCount=-1,this.options=[],this.createdBy=null,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.votedPollOptionIds=[],this.id=null!==(s=t.id)&&void 0!==s?s:0,this.title=null!==(n=t.title)&&void 0!==n?n:null,this.createdAt=null!==(i=t.created_at)&&void 0!==i?i:0,this.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,this.closeAt=null!==(r=t.close_at)&&void 0!==r?r:-1,this.status=null!==(a=Zi(t.status))&&void 0!==a?a:exports.PollStatus.CLOSED,this.messageId=null!==(l=t.message_id)&&void 0!==l?l:0,this.data=null!==(d=t.data)&&void 0!==d?d:null,this.voterCount=null!==(c=t.voter_count)&&void 0!==c?c:-1,this.options=t.options?t.options.map((e=>new Qi(this._iid,e))):[],this.createdBy=null!==(h=t.created_by)&&void 0!==h?h:null,this.allowUserSuggestion=null!==(u=t.allow_user_suggestion)&&void 0!==u&&u,this.allowMultipleVotes=null!==(_=t.allow_multiple_votes)&&void 0!==_&&_,this.votedPollOptionIds=null!==(p=t.voted_option_ids)&&void 0!==p?p:[]}_applyPollUpdatePayload(e){var t,s,n,i,o,r,a,l;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(s=e.updated_at)&&void 0!==s?s:this.updatedAt,this.closeAt=null!==(n=e.close_at)&&void 0!==n?n:this.closeAt,this.status=null!==(i=Zi(e.status))&&void 0!==i?i:this.status,this.data=null!==(o=e.data)&&void 0!==o?o:this.data,this.voterCount=null!==(r=e.voter_count)&&void 0!==r?r:this.voterCount,e.options&&(this.options=e.options.map((e=>new Qi(this._iid,e))),this.votedPollOptionIds=e.options.filter((e=>e.vote_count>0)).map((e=>e.id))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(l=e.allow_multiple_votes)&&void 0!==l?l:this.allowMultipleVotes}static payloadify(e){return k(I(Object.assign(Object.assign({},super.payloadify(e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((e=>Qi.payloadify(e))),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}applyPollUpdateEvent(e){const t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_ate.id)),n=e._payload,i=Math.floor(n.ts/1e3);return n.updated_vote_counts.forEach((e=>{const n=s.indexOf(e.option_id);if(n>-1){const s=t[n];i>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),n.req_id&&n.voted_option_ids&&(this.votedPollOptionIds=n.voted_option_ids),"number"==typeof n.voter_count&&(this.voterCount=n.voter_count),!0}serialize(){return bi(this)}}var Xi;exports.CollectionEventSource=void 0,(Xi=exports.CollectionEventSource||(exports.CollectionEventSource={})).UNKNOWN="UNKNOWN",Xi.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Xi.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Xi.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Xi.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Xi.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Xi.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Xi.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Xi.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Xi.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Xi.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Xi.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Xi.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",Xi.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",Xi.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Xi.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Xi.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Xi.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Xi.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Xi.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Xi.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Xi.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Xi.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Xi.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",Xi.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",Xi.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",Xi.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",Xi.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",Xi.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",Xi.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Xi.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Xi.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Xi.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Xi.REQUEST_CHANNEL="REQUEST_CHANNEL",Xi.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Xi.REFRESH_CHANNEL="REFRESH_CHANNEL",Xi.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",Xi.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Xi.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",Xi.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Xi.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Xi.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Xi.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Xi.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Xi.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Xi.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Xi.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Xi.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Xi.REQUEST_MESSAGE="REQUEST_MESSAGE",Xi.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Xi.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Xi.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Xi.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Xi.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Xi.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Xi.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Xi.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Xi.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Xi.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Xi.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Xi.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Xi.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";const Ji=Object.assign({},exports.CollectionEventSource);class eo extends x{constructor({polls:e,source:t}){super(),this.polls=e,this.source=t}}class to{constructor(e,t){var s;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(s=t.limit)&&void 0!==s?s:20}get hasNext(){return this._hasNext}get isLoading(){return this._isLoading}_validate(){return l("number",this.limit)&&this.limit>0}}class so extends to{constructor(e,t,s,n){super(e,n),this.channelUrl=t,this.channelType=s}_validate(){return super._validate()&&l("string",this.channelUrl)&&d(exports.ChannelType,this.channelType)}}class no extends le{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:n,allowMultipleVotes:i,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=X,this.params={title:e,options:t,data:s,allow_user_suggestion:n,allow_multiple_votes:i,close_at:o}}}class io extends de{constructor(e,t){super(e,t),this.poll=new Yi(e,t)}}class oo extends le{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${X}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class ro extends de{constructor(e,t){super(e,t),this.poll=new Yi(e,t)}}class ao extends le{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:n}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${X}/${encodeURIComponent(s)}/options/${encodeURIComponent(n)}`,this.params={channel_url:e,channel_type:t}}}class lo extends de{constructor(e,t){super(e,t),this.pollOption=new Qi(e,t)}}class co extends le{constructor({channelType:e,channelUrl:t,timestamp:s,token:n}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=k({change_ts:s,token:n})}}class ho extends de{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new Yi(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const uo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},_o=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&Wi(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},po={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},Eo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,go={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},fo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),vo={};class mo extends le{constructor({channelUrl:e,channelType:t,token:s,limit:n}){super(),this.method=exports.APIRequestMethod.GET,this.path=X,this.params={channel_url:e,channel_type:t,token:s,limit:n}}}class So extends de{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new Yi(e,t))),this.token=t.next}}class To extends le{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:n,token:i,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${X}/${encodeURIComponent(s)}/options/${encodeURIComponent(n)}/voters`,this.params={channel_url:e,channel_type:t,token:i,limit:o}}}class Co extends de{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new Oi(e,t))),this.token=t.next}}exports.APIRequestCommand=le,exports.APIResponseCommand=de,exports.API_PATH_EMOJIS=Q,exports.API_PATH_EMOJI_CATEGORIES=Y,exports.API_PATH_GROUP_CHANNELS=K,exports.API_PATH_GROUP_CHANNELS_INTERNAL=B,exports.API_PATH_NOTIFICATIONS=se,exports.API_PATH_OPEN_CHANNELS=j,exports.API_PATH_OPEN_CHANNELS_INTERNAL=$,exports.API_PATH_POLLS=X,exports.API_PATH_REPORT=W,exports.API_PATH_SCHEDULED_MESSAGES=J,exports.API_PATH_SEARCH=Z,exports.API_PATH_UIKIT_CONFIGURATION=ee,exports.API_PATH_UPLOAD=V,exports.API_PATH_USERS=G,exports.BaseCommand=x,exports.BaseListQuery=to,exports.CachedChannelInfo=class{constructor({channel:e,cachedMessageCount:t}){this._cachedMessageCount=0,this._channel=e,this._cachedMessageCount=t}get channel(){return this._channel}get cachedMessageCount(){return this._cachedMessageCount}},exports.ChannelDataListQuery=so,exports.ConnectionStateChangeCommand=Bn,exports.DEFAULT_ENCRYPTION=p,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=Fi,exports.Deferred=Vn,exports.EventDispatcher=A,exports.InstancedObject=Si,exports.LocalCacheConfig=C,exports.MessageEventSource=Ji,exports.MessageRemoveEventCommand=class extends x{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends x{constructor({messages:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messages=e,this.source=t,this.isWebSocketEventComing=s}},exports.Module=class{init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:i,logger:o,onlineDetector:r,cacheContext:a}){this._iid=e,this._cacheContext=a,this._sdkState=t,this._dispatcher=s,this._sessionManager=n,this._requestQueue=i,this._logger=o}},exports.NotificationInfo=gi,exports.POLL_REMOVED_STATUS="removed",exports.Poll=Yi,exports.PollChangeLogEventCommand=eo,exports.PollCreateParamsDefault=uo,exports.PollListQuery=class extends so{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=ji.of(this._iid),t=new mo(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:n,token:i}=s.as(So);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:i,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=n,this._requestQueue=i,this._dispatcher=s,this._logger=o,vo[e]=this}static of(e){return vo[e]}buildPollFromSerializedData(e){const t=xi(e);return new Yi(this._iid,Yi.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){ki(fo(t)).throw(o.invalidParameters);const e=new oo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:n}=s.as(ro);return n}))}create(t){return e(this,void 0,void 0,(function*(){ki(_o(t)).throw(o.invalidParameters);const e=new no(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:n}=s.as(io);return n}))}getOption(t){return e(this,void 0,void 0,(function*(){ki(Eo(t)).throw(o.invalidParameters);const e=new ao(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:n}=s.as(lo);return n}))}getPollChangeLogs(t,s,n,i=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new co(I({channelType:s,channelUrl:t,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(ho);return r.length>0&&this._dispatcher.dispatch(new eo({polls:r,source:i})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=Qi,exports.PollOptionRetrievalParamsDefault=po,exports.PollRetrievalParamsDefault=go,exports.PollUpdateInternalEventCommand=class extends x{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoteEvent=class{constructor(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e}},exports.PollVoteInternalEventCommand=class extends x{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends so{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=ji.of(this._iid),t=new To(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:n,token:i}=s.as(Co);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw o.invalidParameters}))}},exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=_,exports.SendbirdError=o,exports.SessionExpiredCommand=he,exports.SubscribedUnreadMessageCountUpdateCommand=Gn,exports.UIKitConfigInfo=fi,exports.UnsentMessageRemoveEventCommand=class extends x{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=Oi,exports.UserProfile=Di,exports.UserProfileUpdateCommand=Ri,exports.Vault=ji,exports.WebSocketEventCommand=Te,exports.WebSocketRequestCommand=qn,exports.__awaiter=e,exports.__rest=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i{var n,i,o,r;const a=ie(null!==(n=e.mentionType)&&void 0!==n?n:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],s),l=ie(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(r=t.mentionedUserIds)&&void 0!==r?r:[],s);return!a&&l?1:a&&!l?-1:0},exports.checkIfMentioned=ie,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,exports.deepEqual=(e,t)=>{if(e!==t){const s=Object.assign({},e),n=Object.assign({},t);return(!s.hasOwnProperty("messageId")||!n.hasOwnProperty("messageId")||s.messageId===n.messageId)&&((!s.hasOwnProperty("reqId")||!n.hasOwnProperty("reqId")||s.reqId===n.reqId)&&(s.hasOwnProperty("messageId")&&delete s.messageId,s.hasOwnProperty("reqId")&&delete s.reqId,n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,JSON.stringify(s)===JSON.stringify(n)))}return!0},exports.deserialize=xi,exports.deundefined=k,exports.getChannelApiPathByType=ne,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${W}/group_channels`;case exports.ChannelType.OPEN:return`${W}/open_channels`;default:return null}},exports.hasSameMembers=(e,t)=>{if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;const s=[...e].sort(),n=[...t].sort();for(let e=0;ee>0&&a.indexOf(e)>=0,exports.isEnumOf=d,exports.isFile=u,exports.isMilliSecondOf=(e,t=!1)=>!(!t||void 0!==e)||"number"==typeof e&&13===e.toString().length,exports.isReactNative=pe,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=i,exports.isTypeOf=l,exports.noop=Ce,exports.parsePollStatusPayload=Zi,exports.runAsCallback=ni,exports.runOrNothing=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}})),exports.serialize=bi,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=ei,exports.undefineNullProps=I,exports.unless=ki,exports.uuid=y,exports.validatePollCreateParams=_o,exports.validatePollData=Wi,exports.validatePollOptionRetrievalParams=Eo,exports.validatePollRetrievalParams=fo,exports.version=s; diff --git a/cjs/lib/__bundle-4bc3a029.js b/cjs/lib/__bundle-4bc3a029.js deleted file mode 100644 index 37f45b1..0000000 --- a/cjs/lib/__bundle-4bc3a029.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,t=require("./__bundle-c176c59f.js");class s extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew t.User(this._iid,e))):[],this.lastRepliedAt=null!==(n=s.last_replied_at)&&void 0!==n?n:0,this.updatedAt=null!==(a=s.updated_at)&&void 0!==a?a:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class a{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);const r={};for(const e of this.userIds)r[e]=this.updatedAt;this._version=r}get isEmpty(){return 0===this.userIds.length}static payloadify(e){return t.deundefined(t.undefineNullProps({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}applyEvent(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){const t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}class r{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}class o{constructor(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s:0,height:null!==(i=e.height)&&void 0!==i?i:0,alt:e.alt}))}}class l{constructor(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new o(e["og:image"]))}static payloadify(e){return t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?o.payloadify(e.defaultImage):null}))}}class d{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}class u extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}var c,h;exports.ScheduledStatus=void 0,(c=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",c.SENT="sent",c.FAILED="failed",c.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(h=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",h.IN_QUEUE="in_queue",h.SENT="sent",h.FAILED="failed",h.CANCELED="canceled",h.REMOVED="removed";const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class p extends t.InstancedObject{constructor(e,s){var i,o,u,c,h,_,p,m,y,g,f,v,I,E,T,b;super(e),this.channelType=t.ChannelType.BASE,this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.messageType=t.MessageType.BASE,this.mentionType=null,this.threadInfo=null,this.reactions=[],this.metaArrays=[],this.appleCriticalAlertOptions=null,this.createdAt=0,this.updatedAt=0,this.scheduledInfo=null,this.extendedMessage={},this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(o=null!==(i=s.msg_id)&&void 0!==i?i:s.message_id)&&void 0!==o?o:0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.parentMessageId=null!==(u="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==u?u:0,this.data=null!==(c=s.data)&&void 0!==c?c:"",this.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(_=s.mentioned_user_ids)&&void 0!==_?_:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=null!==(p=s.mentioned_message_template)&&void 0!==p?p:"",this.threadInfo=s.thread_info?new n(this._iid,s.thread_info):null,this.reactions=s.reactions?s.reactions.map((e=>new a(e))):[];const O=null!==(m=s.metaarray)&&void 0!==m?m:{},N=null!==(y=s.metaarray_key_order)&&void 0!==y?y:Object.keys(O).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew r(e)))),this.ogMetaData=s.og_tag?new l(s.og_tag):null,this.silent=null!==(g=s.silent)&&void 0!==g&&g,this.isOperatorMessage=null!==(f=s.is_op_msg)&&void 0!==f&&f,this.appleCriticalAlertOptions=s.apple_critical_alert_options?new d(s.apple_critical_alert_options):null,this.createdAt=null!==(I=null!==(v=s.created_at)&&void 0!==v?v:s.ts)&&void 0!==I?I:0,this.updatedAt=null!==(E=s.updated_at)&&void 0!==E?E:0,"number"==typeof s.scheduled_message_id&&"number"==typeof s.scheduled_at&&s.scheduled_status&&(this.scheduledInfo={scheduledMessageId:s.scheduled_message_id,scheduledAt:s.scheduled_at},this._scheduledStatus=s.scheduled_status),this.extendedMessage=null!==(T=s.extended_message)&&void 0!==T?T:{},this._isContinuousMessages=null!==(b=s.is_continuous_messages)&&void 0!==b&&b}static payloadify(e){var s,i,o,u;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:_(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?n.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>a.payloadify(e))),sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>r.payloadify(e))),og_tag:e.ogMetaData?l.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?d.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(o=e.scheduledInfo)||void 0===o?void 0:o.scheduledMessageId,scheduled_at:null===(u=e.scheduledInfo)||void 0===u?void 0:u.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?u.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}isIdentical(e){return this.messageId===e.messageId}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(this.threadInfo=e.threadInfo),!1}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}}class m extends p{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new u(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:u.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}get isResendable(){return this.sendingStatus===t.SendingStatus.FAILED&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}class y{constructor(e){var t,s;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(s=e.real_height)&&void 0!==s?s:e.height}static payloadify(e){return t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get plainUrl(){return this.url.split("?auth=")[0]}}const g={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},f=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class v extends p{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},g),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&f(i)).throw(t.SendbirdError.invalidParameters);const n=bt.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class I{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class E extends m{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new I(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>I.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},g),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&f(i)).throw(t.SendbirdError.invalidParameters);const n=bt.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}applyPoll(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}get poll(){return this._poll}}class T extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.plainUrl="",this.fileName=null,this.mimeType=null,this.fileSize=0,this.thumbnails=[],this._requireAuth=!1,this.plainUrl=null!==(i=s.url)&&void 0!==i?i:"",this.fileName=null!==(n=s.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=s.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=s.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=s.require_auth)&&void 0!==o&&o;const{sessionManager:l}=t.Vault.of(this._iid);this.thumbnails=s.thumbnails?s.thumbnails.map((e=>new y(Object.assign(Object.assign({},e),{url:`${e.url.split("?auth=")[0]}${this._requireAuth?`?auth=${l.ekey}`:""}`})))):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class b extends m{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.fileInfoList=null!==(n=null===(i=s.files)||void 0===i?void 0:i.map((t=>new T(e,t))))&&void 0!==n?n:[],this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},g),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&f(i)).throw(t.SendbirdError.invalidParameters);const n=bt.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>T.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}const O=(e,s)=>{switch(s.type){case"MESG":return new E(e,s);case"FILE":return b._isMultipleFilesMessagePayload(s)?new b(e,s):new N(e,s);case"ADMM":case"BRDM":return new v(e,s)}throw t.SendbirdError.unknown};class N extends m{constructor(e,s){var i,n,a,r,o,l,d,u,c,h,_,p,m,g;super(e,s),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=s.file;this.plainUrl=(null!==(n=null!==(i=null==f?void 0:f.url)&&void 0!==i?i:s.url)&&void 0!==n?n:"").split("?auth=")[0],this.name=null!==(r=null!==(a=null==f?void 0:f.name)&&void 0!==a?a:s.name)&&void 0!==r?r:"File",this.size=null!==(l=null!==(o=null==f?void 0:f.size)&&void 0!==o?o:s.size)&&void 0!==l?l:0,this.data=null!==(u=null!==(d=null==f?void 0:f.data)&&void 0!==d?d:s.custom)&&void 0!==u?u:"",this.type=f?null!==(c=f.type)&&void 0!==c?c:"":null!==(h=s.type)&&void 0!==h?h:"";const{sessionManager:v}=t.Vault.of(this._iid);if(this.requireAuth=null!==(_=s.require_auth)&&void 0!==_&&_,this.thumbnails=s.thumbnails?s.thumbnails.map((e=>new y(Object.assign(Object.assign({},e),{url:`${e.url.split("?auth=")[0]}${this.requireAuth?`?auth=${v.ekey}`:""}`})))):[],this.messageSurvivalSeconds=null!==(p=s.message_survival_seconds)&&void 0!==p?p:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(m=i.file)||void 0===m?void 0:m.url,require_auth:null===(g=i.file)||void 0===g?void 0:g.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this.requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},g),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&f(i)).throw(t.SendbirdError.invalidParameters);const n=bt.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class S extends t.WebSocketRequestCommand{constructor(e){var s,i,n;let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?C(e.files):null,url:e.url,name:null!==(s=e.fileName)&&void 0!==s?s:"",type:null!==(i=e.mimeType)&&void 0!==i?i:"",size:null!==(n=e.fileSize)&&void 0!==n?n:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:a,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?d.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})}}class M extends t.APIRequestCommand{constructor(e){var s,i;super();let n=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?C(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:n,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(s=e.thumbnailSizes)||void 0===s?void 0:s.map((e=>y.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>r.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?d.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class w extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new b(e,i):new N(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class A extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new b(e,s):new N(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function C(e){return e.map((e=>{var s,i;return t.deundefined(t.undefineNullProps({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnailSizes)||void 0===s?void 0:s.map((e=>y.payloadify(e))),require_auth:null===(i=e._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var x;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(x||(x={}));class R{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new S(t),s=yield this._requestQueue.send(e),{message:i}=s.as(w);return i}{const e=new M(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(A);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i)if(i.isResolving)i.isResolveRequestPending=!0;else{i.isResolving=!0;const n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case x.PENDING:case x.UPLOADING:a=!1,n.push(r);break;case x.UPLOADED:if(a)try{r.state=x.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case x.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===x.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params.fileInfoList[a];t.isFile(l.file)&&!(null===(s=l._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,n,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new s({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:n.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnailSizes:h=a.thumbnailSizes,requireAuth:_=!1}=d.as(i);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.thumbnailSizes=h,a.requireAuth=_}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,n,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=n.multipleFileUploadInfo,d=a.fileInfoList[t],u=new s({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:n.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:_=d.fileSize,thumbnailSizes:p=d.thumbnailSizes,requireAuth:m=!1}=c.as(i);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=_,d.thumbnailSizes=p,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:m,isUploaded:!0})}))}request(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:x.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e={uploadIndex:0,uploadCount:i.fileInfoList.length,requestHandler:n};o.multipleFileUploadInfo=e}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case x.PENDING:s.state=x.FAILED,s.error=t.SendbirdError.requestCanceled,this._resolveMessageQueue(e);break;case x.UPLOADING:this._requestQueue.cancel(s.requestId)}}}}const L={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},k={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1};class P extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class D extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?O(e,Object.assign({},t)):null}}class U extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:_,includeReactions:p,parentMessageId:m,includeThreadInfo:y,includeParentMessageInfo:g,showSubchannelMessagesOnly:f,checkingContinuousMessages:v}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:_,include_reactions:p,parent_message_id:m,include_thread_info:y,include_parent_message_info:g,show_subchannel_message_only:f,include_poll_details:!0,checking_continuous_messages:v}))}}class F extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.messages.map((t=>O(e,t)))}}class q extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class B extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>O(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class z extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class j extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?O(e,Object.assign({},t)):null}}var K;exports.RestrictionType=void 0,(K=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",K.BANNED="banned";class G{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const V={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},H=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(r,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(d,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),$=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Q=Object.assign(Object.assign({},V),{message:"",translationTargetLanguages:void 0,pollId:void 0}),W=e=>H(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0);var Y;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Y||(Y={}));const J=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,X=e=>e===Y.BLOB||e===Y.FILE,Z=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),ee=Object.assign(Object.assign({},V),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),te={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},se=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(r,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(d,e.appleCriticalAlertOptions,!0),ie=Object.assign(Object.assign({},te),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),ne=Object.assign({},te);class ae extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,_,p;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.ReplyType.NONE,this.includeMetaArray=!1,this.includeReactions=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1,this._edge=Number.MAX_SAFE_INTEGER,this.reverse=null!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(_=n.includeThreadInfo)&&void 0!==_&&_,this.showSubchannelMessagesOnly=null!==(p=n.showSubchannelMessagesOnly)&&void 0!==p&&p}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=bt.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.undefineNullProps({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));return this._edge=Math.min(Number.MAX_SAFE_INTEGER,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}var re;exports.ReportCategory=void 0,(re=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",re.HARASSING="harassing",re.SUSPICIOUS="suspicious",re.INAPPROPRIATE="inappropriate";const oe="Message",le=Object.assign(Object.assign({},V),{fileInfoList:[]}),de=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));const ue={};class ce{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return ue[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,ue[e]=this),ue[e]}static get(e){return ue[e]}}var he,_e;!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(he||(he={}));class pe extends Error{constructor({code:e=he.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,pe.prototype)}static get storeNotDefined(){return new pe({code:he.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new pe({code:he.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new pe({code:he.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new pe({code:he.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new pe({code:he.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new pe({code:he.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new pe({code:he.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new pe({code:he.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new pe({code:he.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new pe({code:he.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new pe({code:he.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new pe({code:he.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new pe({code:he.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new pe({code:he.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new pe({code:he.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new pe({code:he.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new pe({code:he.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new pe({code:he.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new pe({code:he.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new pe({code:he.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new pe({code:he.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new pe({code:he.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new pe({code:he.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new pe({code:he.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new pe({code:he.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(_e||(_e={}));const me=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw pe.circularReferenceFound;{let s;if(t.set(e,!0),Array.isArray(e))s=e.map((e=>me(e,t)));else if(e instanceof RegExp)s=e;else if(e instanceof Date)s=e;else{s={};for(const i in e)s[i]=me(e[i],t)}return t.delete(e),s}}return e},ye=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw pe.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},ge=(e,t)=>{let s=0;for(let t=0;t>>0)%t},fe=e=>new Promise((t=>{setTimeout((()=>t()),e)})),ve=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!ve(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!ve(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(ye(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(ye(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(ye(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(ye(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},Ie=()=>{},Ee=()=>Promise.resolve(),Te=e=>e,be=(e,t)=>{t()};var Oe;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Oe||(Oe={}));class Ne{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=Te,backward:n=Ee,forward:a=Ee,complete:r=Ie}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}get prevValue(){return this._map(this._prevValue)}get nextValue(){return this._map(this._nextValue)}get error(){return this._error}get hasPrevious(){return!!this._prevValue}get hasNext(){return!!this._nextValue}prev(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.hasPrevious){try{const e=this._prevValue;this._prevValue=(yield this._backward())||null,this._nextValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.hasNext){try{const e=this._nextValue;this._nextValue=(yield this._forward())||null,this._prevValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}stop(){this._prevValue=null,this._nextValue=null,this._complete()}}class Se{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const i in this._indexer.fields){let n=this._indexer.fields[i],a=1;if("-"===n[0]&&(n=n.slice(1),a=-1),this.condition[n])if("object"==typeof this.condition[n]){const r=a>0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*ye(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*ye(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ve(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new Ne({initialNextValue:me(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ve(this.condition,e))return me(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ve(this.condition,e))return me(e)}return null})),complete:o});e(l)}))}))}}class Me{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new Se({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=Math.max(e.offset||0,0);const i="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER;if(0===i)return[];if(i<0)throw pe.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const we=e=>`nest@${e}`,Ae=(e,t)=>`${we(e)}/${t}`,Ce=(e,t)=>`${Ae(e,t)}.metadata`,xe=(e,t)=>`${Ae(e,t)}/block.`,Re=(e,t)=>`${Ae(e,t)}/blob.`;class Le{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${Re(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Re(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var ke,Pe,De;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(ke||(ke={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Pe||(Pe={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(De||(De={}));const Ue=[Pe.PENDING,Pe.VOLATILE],Fe={};class qe{constructor({dbname:e,limit:t=256}){return Fe[e]||(this.dbname=e,this._items=[],this._limit=t,Fe[e]=this),Fe[e]}static get(e){return Fe[e]}get items(){return this._items}find(e,s,i=De.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===De.PERSISTENT&&(t.state=Pe.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===De.PERSISTENT?Pe.PERSISTENT:Pe.VOLATILE},this.put(t))}return t}))}get(e,t=De.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===De.PERSISTENT&&(e.state=Pe.PERSISTENT),t!==De.NO_CACHE&&this.put(e),e}return null}put(e){if(this._limit>0){const t=this._items.map((e=>e.key)).indexOf(e.key);if(t>-1)Ue.includes(this._items[t].state)&&Ue.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);const t=this._items.filter((e=>e.state===Pe.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===Pe.VOLATILE&&s>0?s--:e.push(t);this._items=e}}}}remove(e){const t=this._items.map((e=>e.key)).indexOf(e);t>-1&&this._items.splice(t,1)}clearByCondition(e){this._items=this._items.filter((t=>!e(t)))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==Pe.VOLATILE))}}class Be{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${Ae(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${Ae(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__awaiter(this,void 0,void 0,(function*(){const t=(yield this._store.get(this.recordsetKey))||[];return t.push(...e),this._reduceRecordSet(t)}))}_reduceRecordSet(e){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=qe.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__awaiter(this,void 0,void 0,(function*(){this._metadata=(yield this._store.get(this.metadataKey))||{generation:1};const e=yield this._getReducedRecordset();for(const t of e)yield this._applyRecord(e,t)}))}on(e,t,s){switch(e){case ke.COMMIT:this._onCommit.set(t,s);break;case ke.WRITE:this._onWrite.set(t,s);break;case ke.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});qe.get(this.dbname).put(Object.assign({state:Pe.PENDING},e))}requestMultipleWrite(e,t){const s=qe.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:Pe.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){qe.get(this.dbname).clearByCondition((e=>e.state===Pe.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=qe.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=ce.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class ze{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new ze(e.value):null}get isEmpty(){return 0===this._items.length}get items(){return this._items}serialize(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}}getItemByKey(e){const t=this._items.find((t=>{const s=t[this.keyName];return e===s}));return null!=t?t:null}has(e){return this._items.map((e=>e[this.keyName])).includes(e)}add(e){const t=this._items.map((e=>e[this.keyName])).indexOf(e[this.keyName]);return t<0?this._items.length{const i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||ge)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${xe(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=qe.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=ze.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=ce.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=qe.get(this.dbname),r=yield a.find(this._store,i),o=r?ze.createFromCacheItem(r):new ze({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return!(!t||!t.remove(e))&&(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),!0)}))}clearAllBlocks(){return t.__awaiter(this,void 0,void 0,(function*(){const e=xe(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();qe.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const Ke=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},Ge={};class Ve{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${Ae(e,t)}/index.${s}`)(e,t,i.join(">"));return Ge[r]||(this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._transaction=n,this._store=a,this._transaction.on(ke.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(ke.ERROR,this.indexerKey,(()=>this.abort()))),Ge[r]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in Ge)delete Ge[e]}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!Ke(e[s]))throw pe.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=ye(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=qe.get(this.dbname),t=yield e.find(this._store,this.indexerKey,De.PERSISTENT);if(t)this._origin=t.value,this._table=me(this._origin);else{const t=xe(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,De.NO_CACHE),s=ze.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}Ge[this.indexerKey]=this}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){qe.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete Ge[this.indexerKey]}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}commit(){this._origin=this._table,this._table=me(this._origin)}abort(){this._table=me(this._origin)}}const He=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,$e=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};var Qe,We;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Qe||(Qe={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(We||(We={}));const Ye={};class Je{constructor(e,t={}){return this._state=Qe.PROCESSING,this._queue=[],this._activationQueue=[],Ye[e]&&!t.forceCreate||(this.nodeId=$e(),this.key=e,He()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.claimHost()})),window.addEventListener("message",(e=>{const t=e.data,{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case We.NEWNODE:this._sendSync();break;case We.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case We.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:We.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case We.REMOVENODE:this._queue=this._queue.filter((e=>e.nodeId!==t.nodeId)),this._currentItem&&this._currentItem.nodeId===t.nodeId&&(this._currentItem=void 0,this._acquire(this._queue[0]));break;case We.REQUEST_LOCK:this._requestLock(t);break;case We.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case We.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(We.REMOVENODE)}))),Ye[e]=this),Ye[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==Qe.DONE}_send(e,t={}){var s;const i={nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:$e(),key:this.key,op:e,data:t.data,ts:Date.now()};return He()&&window.postMessage(i,"*"),i}_acquire(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}_release(e){if(this._currentItem&&this._currentItem.requestId===e){const t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(We.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(We.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(const e in this._queue)if(this._queue[e].ts>s.ts){this._queue.splice(parseInt(e),0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(We.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((e=>({nodeId:e.nodeId,requestId:e.requestId,ts:e.ts})))}})}_waitUntilSyncCompleted(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.isHost&&!this.isInSync)return new Promise((e=>{this._activationQueue.push(e)}))}))}_waitSync(){this.isInSync||(this._activationTimeout=setTimeout((()=>{this._completeSync()}),8))}_completeSync(){this.isInSync||(this._state=Qe.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(We.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(We.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(We.REQUEST_LOCK);yield this._requestLock(e)}))}unlock(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}class Xe{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=_e.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>Ve.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new Je(((e,t)=>`${Ae(e,t)}.lock`)(e,t)),this._blobContainer=new Le({dbname:e,collectionName:t,store:a}),this._transaction=new Be({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=Ce(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===_e.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=ce.get(this.dbname),t=yield Xe.metadataOf(this.dbname,this.name,this._store);this._metadata=t||{keyName:this.keyName,blockLevel:1,blockHashBase:e.blockHashBase,blockHashMultiplier:e.blockHashMultiplier,blockHashConstant:e.blockHashConstant,indexes:this.indexes},yield this._transaction.init(),this._blockManager=new je({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>Ve.createKey(e))),a=t?t.indexes.map((e=>Ve.createKey(e))):[];for(const e of a)n.includes(e)||i.push(Ve.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new Ve({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new Ve({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=Ce(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=_e.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=_e.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=Ve.createKey(e);for(const e of this._indexers)if(t===Ve.createKey(e.fields))return e;throw pe.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Ce(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw pe.collectionInsertDuplicate;(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}))}_requestUpsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}else{(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}}))}_requestUpdate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._blockManager.getFromBlock(e);if(t){yield this._blockManager.removeFromBlock(e);for(const e of this._indexers)yield e.removeItem(t)}}))}_requestClear(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),me(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new Me({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw pe.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw pe.collectionKeyNotGiven;return yield this._requestInsert(me(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw pe.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(me(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw pe.collectionKeyNotGiven;return yield this._requestUpsert(me(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw pe.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(me(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw pe.collectionKeyNotGiven;return yield this._requestUpdate(me(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),pe.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new Se({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(ve(i,t)&&s.set){if("function"!=typeof s.set)for(const e in s.set)t[e]=s.set[e];else s.set(t);r.push(t)}e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(me(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{yield this._requestRemove(e),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}removeIf(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),pe.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new Se({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(ve(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw pe.collectionNotReady;yield this._mutex.lock();try{yield this._requestClear(),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}getBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const Ze="[NESTDB]";let et=!0;class tt{static off(){et=!1}static log(...e){et&&console.log(`${Ze}[LOG]`,...e)}static warning(...e){et&&console.warn(`${Ze}[WARNING]`,...e)}static error(...e){et&&console.error(`${Ze}[ERROR]`,...e)}}const st=[{},{a:700400,n:"error"}];class it{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:st.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e&&e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){tt.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw pe.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._setRaw([].concat(...e.map((e=>this._shardify(e))))),e.map((e=>e.value))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s;return yield this._removeRaw(this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)))),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=[];for(const s of e){const e=this._getRawKey(s,".0"),i=yield this._getRaw(e);if(i){const{metadata:e}=i;t.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(s,`.${e}`))))}}return t.length>0&&(yield this._removeRaw(t)),e}))}}const nt=1,at={};class rt extends it{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=nt}=e;this.delay=s,this.observer={}}get rawData(){return at[this.dbname]}set rawData(e){at[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(at[this.dbname])return Object.keys(at[this.dbname]);throw pe.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(at[this.dbname])return yield fe(this.delay),at[this.dbname][e]?Object.assign({key:e},at[this.dbname][e]):null;throw pe.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!at[this.dbname])throw pe.storeNotAvailable;yield fe(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;at[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!at[this.dbname])throw pe.storeNotAvailable;yield fe(this.delay);for(const t of e)at[this.dbname][t]&&delete at[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,at[this.dbname]||(at[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__awaiter(this,void 0,void 0,(function*(){for(const t of e){const e=this.observer[t.key];if(e&&"function"==typeof e.set){const t=e.set();if(t)throw t}}return s.setMany.call(this,e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield fe(this.delay),at[this.dbname]={}}))}}const ot="NestDBStore";var lt;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(lt||(lt={}));var dt,ut;exports.NestDBState=void 0,(dt=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",dt.OPENING="OPENING",dt.OPENED="OPENED",dt.CLOSED="CLOSED";class ct{constructor(){this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.ReplyType.NONE}clone(){const e=new ct,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof m))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof m&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(ut=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",ut.NEWEST_CHILD_MESSAGE="newest_child_message";const ht=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},_t=Object.assign(Object.assign({},Q),{scheduledAt:void 0}),pt=Object.assign(Object.assign({},V),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),mt="UnsentMessage",yt={};class gt extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new Je("unsendmessagecache.lock"),yt[e]=this}static of(e,t=!1){return yt[e]&&!t||(yt[e]=new gt(e)),yt[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(mt);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof E?(e.messageParams&&(s.messageParams=$(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},$(i)),{scheduledAt:i.scheduledAt})))):e instanceof N?(e.messageParams&&(s.messageParams=Z(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},Z(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof b&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return bt.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=bt.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof E){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof N){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&X(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof b){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&X(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof E){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof N){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&X(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserializeWithMessageCreateParams(t)}}))}fetch({channelUrl:e,filter:s=new ct,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=ht(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new ct){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof N||e instanceof b)&&(yield this._mutex.lock(),yield this.saveBlob(e),yield this._mutex.unlock());const t=this._serialize(e);yield this.collection.upsertOne(t)}))))))}))}upsertChildMessages(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){let t=[];e.threadInfo&&e.threadInfo.replyCount>0&&(t=yield this.getAllChildMessages(e)),t.length>0&&(t.forEach((t=>t.applyParentMessage(e))),yield this.upsert(t))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof N){if(e.messageParams){const t=e.messageParams;if(t.file&&J(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Y.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&J(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=Y.BLOB}}}else if(e instanceof b){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&J(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=Y.BLOB}}))))))}}))}}const ft={};class vt extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return gt.of(this._iid)}constructor(e){super(e),ft[e]=this}static of(e,t=!1){return ft[e]&&!t||(ft[e]=new vt(e)),ft[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(oe)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign(Object.assign({},e.serialize()),{messageId:`${e.messageId}`})}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return bt.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserialize(t)}}))}fetch({channelUrl:e,token:s,limit:i=100,filter:n=new ct,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=ht(a),h={where:{channelUrl:e,"/where":e=>{if(s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},_=yield this.collection.query(h),p=yield _.fetch({limit:null!=i?i:void 0});return Promise.all(p.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new ct){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t),yield this.upsertChildMessages(e),yield this._unsentMessageCache.upsertChildMessages(e)}}))}upsertChildMessages(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:ht(exports.MessageListOrder.CHANNEL_LATEST)});const{preference:t}=this._cacheContext;yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`)}}))}removeUnderOffset(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:ht(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=ht(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof N&&e.messageParams){const t=e.messageParams;if(t.file&&J(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const It={};class Et extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return vt.of(this._iid)}get _unsentMessageCache(){return gt.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e.messageId>0)),r=s.filter((e=>0===e.messageId));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof m?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.remove(s)})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}}))))}static of(e,t=!1){var s;return It[e]&&!t||(It[e]&&(null===(s=It[e]._dispatcherContext)||void 0===s||s.close()),It[e]=new Et(e)),It[e]}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_broadcastPollChangeLogEvent(e,t){for(const s of this._observers.values())s.onPollChangeLogUpdate&&s.onPollChangeLogUpdate(e,t)}_broadcastPollUpdateEvent(e,t){for(const s of this._observers.values())s.onPollUpdate&&s.onPollUpdate(e,t)}_broadcastPollVoteEvent(e,t){for(const s of this._observers.values())s.onPollVote&&s.onPollVote(e,t)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}_broadcastRemoveUnsentEvent(e,t){for(const s of this._observers.values())s.onRemoveUnsent&&s.onRemoveUnsent(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const Tt={};class bt{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,vt.of(e),gt.of(e),Et.of(e),this.fileMessageQueue=new R(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),Tt[e]=this}static of(e){return Tt[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);switch(s.messageType){case t.MessageType.USER:return new E(this._iid,E.payloadify(s));case t.MessageType.FILE:return b._isMultipleFilesMessageSerializedData(s)?new b(this._iid,b.payloadify(s)):new N(this._iid,N.payloadify(s));case t.MessageType.ADMIN:return new v(this._iid,v.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new u(this._iid,u.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new P(e),s=yield this._requestQueue.send(t),{message:i}=s.as(D);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new z(e),s=yield this._requestQueue.send(t),{message:i}=s.as(j);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new U(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},L),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(F);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new U(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},L),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(F);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r){return t.__awaiter(this,void 0,void 0,(function*(){const o=new U(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},L),n),{checkingContinuousMessages:r})),l=yield this._requestQueue.send(o),d=l.payload,{messages:u}=l.as(F);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:d}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new U(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},g),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(F),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new q(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},k),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(B),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class Ot extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,a=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",a)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new n(e,i),this.targetMessageId=a,this.channelUrl=r,this.channelType=o)}}const Nt={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class St extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class Mt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>O(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var wt;exports.MessageSearchOrder=void 0,(wt=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",wt.TIMESTAMP="ts";class At extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),this.keyword="",this.reverse=!1,this.exactMatch=!1,this.channelUrl="",this.channelCustomType="",this.messageTimestampFrom=null,this.messageTimestampTo=null,this.order=exports.MessageSearchOrder.SCORE,this.advancedQuery=!1,this.targetFields=null,this._nextToken="",this.totalCount=-1,this.keyword=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new St(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(Mt);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=v,exports.AppleCriticalAlertOptions=d,exports.BaseMessage=p,exports.BaseMessageUpdateParamsDefault=te,exports.BaseStore=it,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DEFAULT_POLLS_LIMIT=10,exports.DEFAULT_POLL_VOTER_LIST_LIMIT=20,exports.FileMessage=N,exports.FileMessageCreateParamsDefault=ee,exports.FileMessageEventCommand=w,exports.FileMessageUpdateParamsDefault=ne,exports.IndexedDbStore=class extends it{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=ot,this._state=lt.UNINITIALIZED,this._openJobQueue=[],this._window="undefined"!=typeof window?window:void 0,this._indexedDb=this._window?this._window.indexedDB||this._window.mozIndexedDB||this._window.webkitIndexedDB||this._window.msIndexedDB:void 0}get state(){return this._state}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=lt.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(ot,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=lt.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=lt.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=lt.UNINITIALIZED,s(e.target.error)}))}else s(pe.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case lt.UNINITIALIZED:case lt.OPEN:throw pe.storeNotInitialized;case lt.OPENING:case lt.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((s,i)=>{const n=t.put(e);n.addEventListener("success",(e=>{s(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))})))))}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((s,i)=>{const n=t.delete(e);n.addEventListener("success",(()=>s(e))),n.addEventListener("error",(e=>i(e.target.error)))})))))}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){const e="undefined"!=typeof window?window:null;if(!((null==e?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))throw pe.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!He())throw pe.storeNotAvailable;if(He()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw pe.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(pe.storeNotAvailableInPrivateBrowsing),s.onsuccess=()=>e()}catch(e){t(pe.storeNotAvailableInPrivateBrowsing)}else t(pe.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readwrite");return yield new Promise(((t,s)=>{const i=e.clear();i.addEventListener("success",(()=>t())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.MemoryStore=rt,exports.MessageBroadcast=Et,exports.MessageCache=vt,exports.MessageChangeLogsParamsDefault=k,exports.MessageFilter=ct,exports.MessageListParamsDefault=L,exports.MessageManager=bt,exports.MessageMetaArray=r,exports.MessageRequestHandler=G,exports.MessageRetrievalParamsDefault=Nt,exports.MessageSearchQuery=At,exports.MultipleFilesMessage=b,exports.MultipleFilesMessageCreateParamsDefault=le,exports.MultipleFilesMessageRequestHandler=class extends G{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,i)}onFileUploaded(e){return this._onFileUploaded=e,this}onPending(e){return super.onPending(e),this}onFailed(e){return super.onFailed(e),this}onSucceeded(e){return super.onSucceeded(e),this}},exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=oe,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=mt,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new ce({dbname:e}),this._store=s,this._event={success:Ie,error:Ie,storeReplaced:Ie,upgrade:be},this._collections=new Map,this._globalMutex=new Je(`${this.name}.lock`),this._config.disableLogger&&tt.off(),new qe({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw pe.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new Xe({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__awaiter(this,void 0,void 0,(function*(){if(yield this._globalMutex.lock(),this._state!==exports.NestDBState.OPENED){this._state=exports.NestDBState.OPENING;try{yield this._store.init(this.name);const i=(s=this.name,`${we(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)tt.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===_e.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield Xe.metadataOf(this.name,e,this._store);if(t){const s=new Xe({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{tt.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case he.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:tt.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new rt({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case he.STORE_NOT_AVAILABLE:tt.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new rt({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw tt.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){this.close();const e=qe.get(this.name);e&&e.clearByCondition((e=>e.key.startsWith(we(this.name)))),yield this._store.clear()}))}on(e,t){this._event[e]=t}off(e){if("function"==typeof this._event[e])if("upgrade"===e)this._event[e]=be;else this._event[e]=Ie}collection(e){const t=this._collections.get(e);if(t)return t;throw pe.collectionNotReady}},exports.NestDBError=pe,exports.OGImage=o,exports.OGMetaData=l,exports.Plugin=I,exports.PreviousMessageListQuery=ae,exports.Reaction=a,exports.ReactionEvent=class{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}},exports.RestrictionInfo=class{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}},exports.ScheduledFileMessageCreateParamsDefault=pt,exports.ScheduledUserMessageCreateParamsDefault=_t,exports.SendableMessage=m,exports.Sender=u,exports.ThreadInfo=n,exports.ThreadInfoUpdateEvent=Ot,exports.Thumbnail=y,exports.UnsentMessageCache=gt,exports.UploadFileRequestCommand=s,exports.UploadFileResponseCommand=i,exports.UploadedFileInfo=T,exports.UserMessage=E,exports.UserMessageCreateParamsDefault=Q,exports.UserMessageUpdateParamsDefault=ie,exports.createFileMessageCreateParamsFromFailedFileMessage=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))},exports.createUserMessageCreateParamsFromFailedUserMessage=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},exports.getMessageIndexBy=ht,exports.parseMessagePayload=O,exports.payloadifyMessage=e=>{switch(e.messageType){case t.MessageType.USER:return E.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?b.payloadify(e):N.payloadify(e);case t.MessageType.ADMIN:return v.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=se,exports.validateFileMessageCreateParams=e=>H(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateFileMessageUpdateParams=e=>se(e),exports.validateMessageChangeLogsParams=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo),exports.validateMessageListParams=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateMultipleFilesMessageCreateParams=(e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>H(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>de(e))),exports.validateScheduledFileMessageCreateParams=e=>H(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>W(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageCreateParams=W,exports.validateUserMessageUpdateParams=e=>se(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0); diff --git a/cjs/lib/__bundle-617167af.js b/cjs/lib/__bundle-617167af.js deleted file mode 100644 index 7b8dce2..0000000 --- a/cjs/lib/__bundle-617167af.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,s,t,n=require("./__bundle-c176c59f.js"),r=require("./__bundle-4bc3a029.js");exports.GroupChannelListOrder=void 0,(e=exports.GroupChannelListOrder||(exports.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.PublicGroupChannelListOrder=void 0,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:r}=s.data;return{blocker:new n.User(e,t),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new n.User(e,s))):[]}}}class c extends n.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends n.BaseCommand{constructor(){super()}}class h extends n.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,dispatcher:t,sdkState:r,logger:a}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=t,this._logger=a,this._sdkState=r,this._localCacheEnabled&&t.on((e=>{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=n.SendingStatus.FAILED,s.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(s.errorCode&&n.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new n.MessageUpdateEventCommand({messages:[s],source:n.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid);return e?yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0}):[]}))}indexOf(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId):-1}_isNotInQueue(e){return-1===this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId)}_processNextAutoResend(){return n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{if(this._autoResendQueue.length>0){this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0);const e=this._autoResendQueue[0];this._dispatcher.dispatch(new a({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)}else this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}}))}},exports.AutoResendRequestCommand=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,exports.getGroupChannelIndexBy=e=>{switch(e){case exports.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}}; diff --git a/cjs/lib/__bundle-b9602cac.js b/cjs/lib/__bundle-722ae438.js similarity index 68% rename from cjs/lib/__bundle-b9602cac.js rename to cjs/lib/__bundle-722ae438.js index 6c9f464..8f3cb25 100644 --- a/cjs/lib/__bundle-b9602cac.js +++ b/cjs/lib/__bundle-722ae438.js @@ -1 +1 @@ -"use strict";var s=require("./__bundle-c176c59f.js");class t extends s.User{constructor(s,t){var e;super(s,t),this.isMuted=!1,this.isMuted=null!==(e=t.is_muted)&&void 0!==e&&e}}exports.Participant=t; +"use strict";var s=require("./__bundle-26b86f4c.js");class t extends s.User{constructor(s,t){var e;super(s,t),this.isMuted=!1,this.isMuted=null!==(e=t.is_muted)&&void 0!==e&&e}}exports.Participant=t; diff --git a/cjs/lib/__bundle-82ee6f93.js b/cjs/lib/__bundle-82ee6f93.js new file mode 100644 index 0000000..2daf458 --- /dev/null +++ b/cjs/lib/__bundle-82ee6f93.js @@ -0,0 +1 @@ +"use strict";var e,s,t,r=require("./__bundle-26b86f4c.js"),n=require("./__bundle-aae5735d.js");exports.GroupChannelListOrder=void 0,(e=exports.GroupChannelListOrder||(exports.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.PublicGroupChannelListOrder=void 0,(s=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",s.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",s.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(t=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",t.SCHEDULED_AT="scheduled_at";class a extends r.BaseCommand{constructor({message:e}){super(),this.message=e}}const o={};var i;exports.UserEventCategory=void 0,(i=exports.UserEventCategory||(exports.UserEventCategory={}))[i.USER_BLOCK=20001]="USER_BLOCK",i[i.USER_UNBLOCK=2e4]="USER_UNBLOCK",i[i.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class d{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,s){const{blocker:t,blockee:n}=s.data;return{blocker:new r.User(e,t),blockee:new r.User(e,n)}}static getDataAsFriendDiscoveredEvent(e,s){const{friend_discoveries:t}=s.data;return{friendDiscoveries:Array.isArray(t)?t.map((s=>new r.User(e,s))):[]}}}class c extends r.BaseCommand{constructor(e,{userId:s}){super(),this._iid=e,this.userId=s}}class u extends r.BaseCommand{constructor(){super()}}class h extends r.WebSocketEventCommand{constructor(e,s,t){super(e,"USEV",t),this.event=new d(t)}}exports.AutoResendManager=class{constructor(e,{localCacheEnabled:s,dispatcher:t,sdkState:n,logger:a}){this._iid=e,o[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=t,this._logger=a,this._sdkState=n,this._localCacheEnabled&&t.on((e=>{if(e instanceof r.ConnectionStateChangeCommand)switch(e.stateType){case r.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case r.ConnectionStateType.INTERNAL_DISCONNECTED:case r.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return o[e]}processNonAutoResendRegisteredPendingMessages(){return r.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)0===s.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=r.SendingStatus.FAILED,s.errorCode=r.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new r.MessageUpdateEventCommand({messages:[s],source:r.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return r.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const s of e)if(s.errorCode&&r.isAutoResendableError(s.errorCode)){const e=(new Date).getTime(),t=s.createdAt+2592e5;e<=t?this._autoResendQueue.map((e=>e.reqId)).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(t).toLocaleString()),s.sendingStatus=r.SendingStatus.FAILED,this._dispatcher.dispatch(new r.MessageUpdateEventCommand({messages:[s],source:r.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&(e.sendingStatus===r.SendingStatus.SUCCEEDED||e.sendingStatus===r.SendingStatus.FAILED&&!r.isAutoResendableError(e.errorCode))){const s=this.indexOf(e);s>=0&&this._autoResendQueue.splice(s,1),0===s&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return r.__awaiter(this,void 0,void 0,(function*(){const e=n.UnsentMessageCache.of(this._iid),s=new n.MessageFilter;return s.replyType=r.ReplyType.ALL,yield e.fetch({sendingStatus:r.SendingStatus.PENDING,backward:!0,filter:s})}))}indexOf(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId):-1}_isNotInQueue(e){return-1===this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId)}_processNextAutoResend(){return r.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{if(this._autoResendQueue.length>0){this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0);const e=this._autoResendQueue[0];this._dispatcher.dispatch(new a({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)}else this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}}))}},exports.AutoResendRequestCommand=a,exports.DatabaseOpenCommand=c,exports.ReduceDBSizeEventCommand=u,exports.UserEvent=d,exports.UserEventCommand=h,exports.getGroupChannelIndexBy=e=>{switch(e){case exports.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}}; diff --git a/cjs/lib/__bundle-7ee4a5eb.js b/cjs/lib/__bundle-8e790a5a.js similarity index 94% rename from cjs/lib/__bundle-7ee4a5eb.js rename to cjs/lib/__bundle-8e790a5a.js index 291a90f..0f18709 100644 --- a/cjs/lib/__bundle-7ee4a5eb.js +++ b/cjs/lib/__bundle-8e790a5a.js @@ -1 +1 @@ -"use strict";var e,t=require("./__bundle-c176c59f.js"),n=require("./__bundle-4bc3a029.js"),s=require("./__bundle-f5cc59df.js");exports.ChannelEventCategory=void 0,(e=exports.ChannelEventCategory||(exports.ChannelEventCategory={}))[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED";class o{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class a extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"SYEV",n),this.event=new o(n)}}class i{constructor({top:e=Number.MAX_SAFE_INTEGER,bottom:t=0}){this.top=e,this.bottom=t}includes(...e){return e.every((e=>this.top<=e&&e<=this.bottom))}overlap(e){return this.includes(e.top)||this.includes(e.bottom)}intersect(...e){return e.some((e=>this.top<=e&&e<=this.bottom))}extends(...e){this.top=Math.min(this.top,...e),this.bottom=Math.max(this.bottom,...e)}}class r extends t.InstancedObject{get _messageCache(){return n.MessageCache.of(this._iid)}get _unsentMessageCache(){return n.UnsentMessageCache.of(this._iid)}get _messageBroadcast(){return n.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){var n;return t.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._messageCache.get(e))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(e,n,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(e,s,o,a,i=n.DEFAULT_MESSAGE_LIMIT,r=!0){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:s,limit:i,filter:a,backward:"next"===o,inclusive:r})}))}getPollMessagesFromCache(e,n,s,o){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:n,limit:o,filter:s,backward:!1,isPollOnly:!0})}))}getCachedMessageCountBetween(e,n,s,o){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,n,new i({top:s,bottom:o}))}))}getUnsentMessagesFromCache(e,n){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._unsentMessageCache.fetch({channelUrl:e,filter:n})}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([e])}))}}class h extends t.WebSocketEventCommand{constructor(e,s,o){var a,i,r,h;super(e,"ADMM",o),this.message=new n.AdminMessage(e,o);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(i=this.message.mentionedUsers)||void 0===i?void 0:i.map((e=>e.userId)))&&void 0!==r?r:[],d.userId),this.forceUpdateLastMessage=null!==(h=o.force_update_last_message)&&void 0!==h&&h}}class d extends t.WebSocketEventCommand{constructor(e,s,o){var a,i,r,h,d;super(e,"AEDI",o),this.message=new n.AdminMessage(e,o);const{sdkState:E}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(a=o.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(r=null===(i=o.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(h=this.message.mentionedUserIds)&&void 0!==h?h:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),E.userId)}}class E extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MRCT",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.event=new n.ReactionEvent(s)}}class c extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MTHD",s),this.event=new n.ThreadInfoUpdateEvent(e,s)}}class l extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MCNT",n),this.groupChannelMemberCounts=n.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=n.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class _ extends t.WebSocketEventCommand{constructor(e,n,o){super(e,"PEDI",o),this.event=new s.PollUpdateEvent(e,o),this.status=t.parsePollStatusPayload(o.poll.status)||o.poll.status,this.channelUrl=o.channel_url,this.channelType=o.channel_type}}exports.AdminMessageEventCommand=h,exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=t.noop,this.onUserUnmuted=t.noop,this.onUserBanned=t.noop,this.onUserUnbanned=t.noop,this.onChannelChanged=t.noop,this.onChannelDeleted=t.noop,this.onChannelFrozen=t.noop,this.onChannelUnfrozen=t.noop,this.onOperatorUpdated=t.noop,this.onChannelMemberCountChanged=t.noop,this.onMetaDataCreated=t.noop,this.onMetaDataUpdated=t.noop,this.onMetaDataDeleted=t.noop,this.onMetaCounterCreated=t.noop,this.onMetaCounterUpdated=t.noop,this.onMetaCounterDeleted=t.noop,this.onMessageReceived=t.noop,this.onMessageUpdated=t.noop,this.onMessageDeleted=t.noop,this.onMentionReceived=t.noop,this.onReactionUpdated=t.noop,this.onThreadInfoUpdated=t.noop}},exports.BaseChannelManager=r,exports.ChannelEventCommand=a,exports.MemberCountUpdateEventCommand=l,exports.OperatorUpdateEventCommand=class extends a{constructor(e,n,s){super(e,n,s);const{operators:o=[]}=s.data;this.operators=o.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=_,exports.ReactionEventCommand=E,exports.ThreadInfoUpdateEventCommand=c,exports.TimeRange=i,exports.UpdateAdminMessageEventCommand=d; +"use strict";var e,t=require("./__bundle-26b86f4c.js"),n=require("./__bundle-aae5735d.js"),s=require("./__bundle-f6d4722d.js");exports.ChannelEventCategory=void 0,(e=exports.ChannelEventCategory||(exports.ChannelEventCategory={}))[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED";class o{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class a extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"SYEV",n),this.event=new o(n)}}class i{constructor({top:e=Number.MAX_SAFE_INTEGER,bottom:t=0}){this.top=e,this.bottom=t}includes(...e){return e.every((e=>this.top<=e&&e<=this.bottom))}overlap(e){return this.includes(e.top)||this.includes(e.bottom)}intersect(...e){return e.some((e=>this.top<=e&&e<=this.bottom))}extends(...e){this.top=Math.min(this.top,...e),this.bottom=Math.max(this.bottom,...e)}}class r extends t.InstancedObject{get _messageCache(){return n.MessageCache.of(this._iid)}get _unsentMessageCache(){return n.UnsentMessageCache.of(this._iid)}get _messageBroadcast(){return n.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){var n;return t.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._messageCache.get(e))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(e,n,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(e,s,o,a,i=n.DEFAULT_MESSAGE_LIMIT,r=!0){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:s,limit:i,filter:a,backward:"next"===o,inclusive:r})}))}getPollMessagesFromCache(e,n,s,o){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:n,limit:o,filter:s,backward:!1,isPollOnly:!0})}))}getCachedMessageCountBetween(e,n,s,o){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,n,new i({top:s,bottom:o}))}))}getUnsentMessagesFromCache(e,n){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._unsentMessageCache.fetch({channelUrl:e,filter:n})}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([e])}))}}class h extends t.WebSocketEventCommand{constructor(e,s,o){var a,i,r,h;super(e,"ADMM",o),this.message=new n.AdminMessage(e,o);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(i=this.message.mentionedUsers)||void 0===i?void 0:i.map((e=>e.userId)))&&void 0!==r?r:[],d.userId),this.forceUpdateLastMessage=null!==(h=o.force_update_last_message)&&void 0!==h&&h}}class d extends t.WebSocketEventCommand{constructor(e,s,o){var a,i,r,h,d;super(e,"AEDI",o),this.message=new n.AdminMessage(e,o);const{sdkState:E}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(a=o.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(r=null===(i=o.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(h=this.message.mentionedUserIds)&&void 0!==h?h:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),E.userId)}}class E extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MRCT",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.event=new n.ReactionEvent(s)}}class l extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MTHD",s),this.event=new n.ThreadInfoUpdateEvent(e,s)}}class c extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MCNT",n),this.groupChannelMemberCounts=n.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=n.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class _ extends t.WebSocketEventCommand{constructor(e,n,o){super(e,"PEDI",o),this.event=new s.PollUpdateEvent(e,o),this.status=t.parsePollStatusPayload(o.poll.status)||o.poll.status,this.channelUrl=o.channel_url,this.channelType=o.channel_type}}exports.AdminMessageEventCommand=h,exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=t.noop,this.onUserUnmuted=t.noop,this.onUserBanned=t.noop,this.onUserUnbanned=t.noop,this.onChannelChanged=t.noop,this.onChannelDeleted=t.noop,this.onChannelFrozen=t.noop,this.onChannelUnfrozen=t.noop,this.onOperatorUpdated=t.noop,this.onChannelMemberCountChanged=t.noop,this.onMetaDataCreated=t.noop,this.onMetaDataUpdated=t.noop,this.onMetaDataDeleted=t.noop,this.onMetaCounterCreated=t.noop,this.onMetaCounterUpdated=t.noop,this.onMetaCounterDeleted=t.noop,this.onMessageReceived=t.noop,this.onMessageUpdated=t.noop,this.onMessageDeleted=t.noop,this.onMentionReceived=t.noop,this.onReactionUpdated=t.noop,this.onThreadInfoUpdated=t.noop}},exports.BaseChannelManager=r,exports.ChannelEventCommand=a,exports.MemberCountUpdateEventCommand=c,exports.OperatorUpdateEventCommand=class extends a{constructor(e,n,s){super(e,n,s);const{operators:o=[]}=s.data;this.operators=o.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=_,exports.ReactionEventCommand=E,exports.ThreadInfoUpdateEventCommand=l,exports.TimeRange=i,exports.UpdateAdminMessageEventCommand=d; diff --git a/cjs/lib/__bundle-a4005096.js b/cjs/lib/__bundle-a4005096.js deleted file mode 100644 index 8e853fc..0000000 --- a/cjs/lib/__bundle-a4005096.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("./__bundle-c176c59f.js"),t=require("./__bundle-4bc3a029.js"),s=require("./__bundle-f5cc59df.js");class n extends e.User{constructor(e,s){super(e,s),this.restrictionInfo=new t.RestrictionInfo(s)}static payloadify(s){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},super.payloadify(s)),t.RestrictionInfo.payloadify(s.restrictionInfo))))}}class a extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,token:n,limit:a}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/operators`,this.params={token:n,limit:a}}}class i extends e.APIResponseCommand{constructor(t,s){super(t,s),this.operators=s.operators.map((s=>new e.User(t,s))),this.token=s.next}}class r extends e.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const t=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new a(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),n=yield t.send(s),{operators:r,token:o}=n.as(i);return this._token=o,this._hasNext=!!o,this._isLoading=!1,r}return t}}throw e.SendbirdError.invalidParameters}))}}class o extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,limit:a,token:i}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/mute`,this.params={limit:a,token:i}}}class d extends e.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:a}=t;this.token=s,a&&a.length>0&&(this.mutedUsers=a.map((t=>new n(e,t))))}}class l extends e.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new o(Object.assign(Object.assign({},this),{token:this._token})),n=yield t.send(s),{mutedUsers:a,token:i}=n.as(d);return this._token=i,this._hasNext=!!i,this._isLoading=!1,a}return[]}throw e.SendbirdError.invalidParameters}))}}class u extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,limit:a,token:i}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/ban`,this.params=e.deundefined({limit:a,token:i})}}class c extends e.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:a}=t;this.token=s,a&&a.length>0&&(this.bannedUsers=a.map((t=>new n(e,t.user))))}}class h extends e.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new u(Object.assign(Object.assign({},this),{token:this._token})),n=yield t.send(s),{bannedUsers:a,token:i}=n.as(c);return this._token=i,this._hasNext=!!i,this._isLoading=!1,a}return[]}throw e.SendbirdError.invalidParameters}))}}class p extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,operatorUserIds:a}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:a}}}class m extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,operatorUserIds:a}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:a}}}class g extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,userId:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/mute/${a}`}}class _ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:n,end_at:a,remaining_duration:i,description:r}=t;this.isMuted=s,this.startAt=n,this.endAt=a,this.remainingDuration=i,this.description=r}}class y extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,keys:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metadata`,this.params={keys:a,include_ts:!0}}}class v extends e.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:n}=t;this.metadata=s,this.ts=n}}class f extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,metadata:a}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:a,include_ts:!0}}}class M extends e.APIResponseCommand{constructor(e,t){var s,n;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(n=t.ts)&&void 0!==n?n:null}}class T extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,metadata:a,upsert:i}=t;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:a,include_ts:!0,upsert:null!=i&&i}}}class I extends e.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:n}=t;this.metadata=s,this.ts=n}}class P extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class C extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,key:a}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metadata/${a}`,this.params={include_ts:!0}}}class E extends e.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class U extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class A extends e.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class S extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,keys:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:a}}}class w extends e.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class b extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,metaCounter:a}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:a}}}class R extends e.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class O extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,metaCounter:a,upsert:i=!1,mode:r="set"}=t;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:a,upsert:i,mode:r}}}class q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class D extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class x extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,key:a}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metacounter/${a}`,this.params={}}}class L extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class F extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,userId:a,seconds:i,description:r}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/mute`,this.params={user_id:a,seconds:i,description:r}}}class k extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new n(e,s.data)}}class V extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,userId:a}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(a)}`}}class $ extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new n(e,s.data)}}class N extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,userId:a,seconds:i,description:r}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/ban`,this.params=e.deundefined({user_id:a,seconds:i,description:r})}}class j extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new n(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class Q extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,userId:a}=t;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(a)}`}}class B extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new n(e,s.data)}}class G extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,freezing:a}=t;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:a}}}class z extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class W extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,category:a,userId:i,description:r}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getReportApiPathByType(n)}/${encodeURIComponent(s)}`,this.params={report_category:a,reporting_user_id:i,report_description:r}}}class H extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,category:a,userId:i,offendingUserId:r,description:o}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:n===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:i,report_description:o}}}class Y extends e.APIRequestCommand{constructor(t){const{channelUrl:s,channelType:n,category:a,userId:i,offendingUserId:r,messageId:o,description:d}=t;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getReportApiPathByType(n)}/${encodeURIComponent(s)}/messages/${o}`,this.params={report_category:a,reporting_user_id:i,report_description:d,offending_user_id:r}}}class K extends e.WebSocketRequestCommand{constructor(t){let s=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:e.deundefined(e.undefineNullProps({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage}))})}}class J extends e.WebSocketEventCommand{constructor(s,n,a){var i,r,o,d;super(s,"MESG",a),this.message=new t.UserMessage(s,a);const{sdkState:l}=e.Vault.of(s);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(o=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==o?o:[],l.userId),this.forceUpdateLastMessage=null!==(d=a.force_update_last_message)&&void 0!==d&&d}}class X extends e.WebSocketRequestCommand{constructor(s){let n=null;s.mentionType===e.MentionType.USERS&&(s.mentionedUserIds?n=s.mentionedUserIds:s.mentionedUsers&&(n=s.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:e.deundefined(e.undefineNullProps({channel_url:s.channelUrl,msg_id:s.messageId,message:s.message,data:s.data,custom_type:s.customType,metaarray:s.metaArrayParams,mention_type:s.mentionType,mentioned_user_ids:n,mentioned_message_template:s.mentionedMessageTemplate,apple_critical_alert_options:s.appleCriticalAlertOptions?t.AppleCriticalAlertOptions.payloadify(s.appleCriticalAlertOptions):null,poll_id:s.pollId}))})}}class Z extends e.WebSocketEventCommand{constructor(s,n,a){var i,r,o,d,l;super(s,"MEDI",a),this.message=new t.UserMessage(s,a);const{sdkState:u}=e.Vault.of(s);this.mentionCountChange=e.calculateMentionCountChange({mentionType:null===(i=a.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==o?o:[]},e.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(d=this.message.mentionedUserIds)&&void 0!==d?d:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),u.userId)}}class ee extends e.WebSocketRequestCommand{constructor(t){let s=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:e.deundefined(e.undefineNullProps({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions}))})}}class te extends e.WebSocketEventCommand{constructor(s,n,a){var i,r,o,d,l;super(s,"FEDI",a),this.message=new t.FileMessage(s,a);const{sdkState:u}=e.Vault.of(s);this.mentionCountChange=e.calculateMentionCountChange({mentionType:null===(i=a.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==o?o:[]},e.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(d=this.message.mentionedUserIds)&&void 0!==d?d:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),u.userId)}}class se extends e.APIRequestCommand{constructor(t){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(t.channelType)}/${t.channelUrl}/messages/${t.messageId}`}}class ne extends e.WebSocketEventCommand{constructor(e,t,s){super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id)}}class ae extends e.APIRequestCommand{constructor({channelType:t,channelUrl:s,messageId:n,reactionKey:a}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/messages/${n}/reactions`,this.params={reaction:a}}}class ie extends e.APIResponseCommand{constructor(e,s){super(e,s),this.reactionEvent=new t.ReactionEvent(s)}}class re extends e.APIRequestCommand{constructor({channelType:t,channelUrl:s,messageId:n,reactionKey:a}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/messages/${n}/reactions`,this.params={reaction:a}}}class oe extends e.APIResponseCommand{constructor(e,s){super(e,s),this.reactionEvent=new t.ReactionEvent(Object.assign({},s))}}class de extends e.APIRequestCommand{constructor({channelType:t,channelUrl:s,messageId:n,translationTargetLanguages:a}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(n)}/translation`,this.params={target_langs:a}}}class le extends e.APIResponseCommand{constructor(e,s){super(e,s),this.message=new t.UserMessage(e,s)}}class ue extends e.APIRequestCommand{constructor(s){var n;super();let a=[];s.mentionType===e.MentionType.USERS&&(s.mentionedUserIds?a=s.mentionedUserIds:s.mentionedUsers&&(a=s.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:r}=s;this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(i)}/${encodeURIComponent(r)}/scheduled_messages`,this.params=e.deundefined(e.undefineNullProps({req_id:s.reqId,scheduled_at:s.scheduledAt,message_type:e.ServerSideMessageType.USER,message:s.message,custom_type:s.customType,data:s.data,mention_type:s.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=s.metaArrays)||void 0===n?void 0:n.map((e=>t.MessageMetaArray.payloadify(e))),apple_critical_alert_options:s.appleCriticalAlertOptions?t.AppleCriticalAlertOptions.payloadify(s.appleCriticalAlertOptions):null,target_langs:s.translationTargetLanguages,push_option:s.pushNotificationDeliveryOption}))}}class ce extends e.APIResponseCommand{constructor(e,s){super(e,s),this.message=new t.UserMessage(e,s)}}class he extends e.APIRequestCommand{constructor(s){var n;super();let a=[];s.mentionType===e.MentionType.USERS&&(s.mentionedUserIds?a=s.mentionedUserIds:s.mentionedUsers&&(a=s.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:r}=s;this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(i)}/${encodeURIComponent(r)}/scheduled_messages`,this.params=e.undefineNullProps({req_id:s.reqId,scheduled_at:s.scheduledAt,message_type:e.ServerSideMessageType.FILE,url:s.fileUrl,file_name:s.fileName,file_size:s.fileSize,file_type:s.mimeType,thumbnails:s.thumbnailSizes?s.thumbnailSizes.map((e=>t.Thumbnail.payloadify(e))):[],custom_type:s.customType,data:s.data,require_auth:s.requireAuth,mention_type:s.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=s.metaArrays)||void 0===n?void 0:n.map((e=>t.MessageMetaArray.payloadify(e))),apple_critical_alert_options:s.appleCriticalAlertOptions?t.AppleCriticalAlertOptions.payloadify(s.appleCriticalAlertOptions):null,push_option:s.pushNotificationDeliveryOption})}}class pe extends e.APIResponseCommand{constructor(e,s){super(e,s),this.message=new t.FileMessage(e,s)}}class me extends e.APIRequestCommand{constructor({pollId:t,title:s,data:n,allowUserSuggestion:a,allowMultipleVotes:i,closeAt:r}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(t)}`,this.params={title:s,data:n,allow_user_suggestion:a,allow_multiple_votes:i,close_at:r}}}class ge extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class _e extends e.APIRequestCommand{constructor({pollId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(t)}`}}class ye extends e.APIRequestCommand{constructor({pollId:t}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(t)}/close`}}class ve extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class fe extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:n,optionText:a}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(n)}/options`,this.params={channel_url:t,channel_type:s,text:a}}}class Me extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class Te extends e.APIRequestCommand{constructor({pollId:t,pollOptionId:s,optionText:n}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(t)}/options/${encodeURIComponent(s)}`,this.params={text:n}}}class Ie extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class Pe extends e.APIRequestCommand{constructor({pollId:t,pollOptionId:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(t)}/options/${encodeURIComponent(s)}`}}class Ce extends e.WebSocketRequestCommand{constructor({reqId:t,channelType:s,channelUrl:n,pollId:a,pollOptionIds:i}){super({code:"VOTE",ackRequired:!0,payload:e.deundefined({req_id:t,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:n,poll_id:a,option_ids:i})})}}class Ee extends e.WebSocketEventCommand{constructor(e,t,n){super(e,"VOTE",n),this.event=new s.PollVoteEvent(n),this.channelUrl=n.channel_url,this.channelType=n.channel_type}}class Ue extends e.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(t,s){var n,a,i,r,o,d;super(t),this._name="",this._createdAt=0,this.channelType=e.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(n=s.name)&&void 0!==n?n:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(a=s.cover_url)&&void 0!==a?a:"",this.customType=null!==(i=s.custom_type)&&void 0!==i?i:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(d=s.is_ephemeral)&&void 0!==d&&d,this.creator=s.created_by?new e.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts&&(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})})))}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},super.payloadify(t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:t.creator?e.User.payloadify(t.creator):null,created_at:t.createdAt/1e3})))}isGroupChannel(){return this.channelType===e.ChannelType.GROUP}isOpenChannel(){return this.channelType===e.ChannelType.OPEN}isFeedChannel(){return this.channelType===e.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(t){const s=e.deundefined(t);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const n=this._cachedMetaData.get(s);(!n||n.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){this._cachedMetaData?this._cachedMetaData.forEach(((s,n)=>{var a;s.updatedAt<=t&&this._cachedMetaData.set(n,{value:null!==(a=e[n])&&void 0!==a?a:s.value,isRemoved:!e[n],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})))}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAtt.MessageMetaArray.payloadify(e))):null,apple_critical_alert_options:s.appleCriticalAlertOptions?t.AppleCriticalAlertOptions.payloadify(s.appleCriticalAlertOptions):null,created_at:a,user:r.currentUser?t.Sender.payloadify(r.currentUser):null,req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:s.mentionedUserIds,mentioned_users:null===(i=s.mentionedUsers)||void 0===i?void 0:i.map((t=>e.User.payloadify(t)))}))}_createPendingUserMessage(s,n,a){const i={};if(s.translationTargetLanguages)for(const e of s.translationTargetLanguages)i[e]="";const r=e.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(s,n,a)),{type:e.MessageType.USER,message:s.message,translations:i})),o=new t.UserMessage(this._iid,r);return o.messageParams=s,o}_createPendingScheduledUserMessage(e,t,s){const n=this._createPendingUserMessage(e,t,s);return n.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},n}_createPendingFileMessage(s,n,a){var i,r,o,d,l,u;const c=e.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(s,n,a)),{type:e.MessageType.FILE,url:s.fileUrl,file:{name:null!==(i=s.fileName)&&void 0!==i?i:null===(r=s.file)||void 0===r?void 0:r.name,size:null!==(o=s.fileSize)&&void 0!==o?o:null===(d=s.file)||void 0===d?void 0:d.size,type:null!==(l=s.mimeType)&&void 0!==l?l:null===(u=s.file)||void 0===u?void 0:u.type,data:s.data},thumbnails:s.thumbnailSizes?s.thumbnailSizes.map((e=>({url:"",width:e.maxWidth,height:e.maxHeight}))):[]})),h=new t.FileMessage(this._iid,c);return h.messageParams=s,h}_createPendingMultipleFilesMessage(s,n,a){const i=e.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(s,n,a)),{type:e.MessageType.FILE})),r=new t.MultipleFilesMessage(this._iid,i);return r.messageParams=s,r}_createPendingScheduledFileMessage(e,t,s){const n=this._createPendingFileMessage(e,t,s);return n.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},n}_markMessageAsFailed(t,s,n=!1){t.errorCode=s.code,s.code===e.SendbirdErrorCode.REQUEST_CANCELED||s.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.sendingStatus=e.SendingStatus.CANCELED:n||(t.sendingStatus=e.SendingStatus.FAILED)}sendUserMessage(s){const n=Object.assign(Object.assign({},t.UserMessageCreateParamsDefault),s);return e.unless(t.validateUserMessageCreateParams(n)).throw(e.SendbirdError.invalidParameters),this._sendUserMessage(n)}_sendUserMessage(s,n,a=!1){const{dispatcher:i,requestQueue:r}=e.Vault.of(this._iid);let o=null!=n?n:this._generateRequestId();const d=Date.now(),l=new t.MessageRequestHandler;return o||(o=this._generateRequestId()),e.sleep(2).then((()=>{const t=this._createPendingUserMessage(s,o,d);i.dispatch(new e.MessageUpdateEventCommand({messages:[t],source:a?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._trigger(t)}))));const n=new K(Object.assign(Object.assign({},s),{channelUrl:this.url,channelType:this.channelType,reqId:o}));r.send(n).then((t=>{const{message:s}=t.as(J);i.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((t=>{if(e.isThrowingOutside(t))throw t;e.sleep(2).then((()=>{const n=this._createPendingUserMessage(s,o,d),{cacheContext:a}=e.Vault.of(this._iid),r=a.localCacheEnabled&&e.isAutoResendableError(t.code);this._markMessageAsFailed(n,t,r),i.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:n.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(t,n)}))))}))}))})),l}_autoResendUserMessage(s){return e.unless(s instanceof t.UserMessage&&!!s.messageParams).throw(e.SendbirdError.invalidParameters),this._sendUserMessage(s.messageParams,s.reqId)}resendUserMessage(s){var n;return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.UserMessage&&!s.scheduledInfo).throw(e.SendbirdError.invalidParameters);const a=new e.Deferred,i=null!==(n=s.messageParams)&&void 0!==n?n:t.createUserMessageCreateParamsFromFailedUserMessage(s);return this._sendUserMessage(i,s.reqId,!0).onFailed((e=>a.reject(e))).onSucceeded((e=>a.resolve(e))),a.promise}))}updateUserMessage(s,n){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.UserMessageUpdateParamsDefault),n);e.unless(e.isTypeOf("number",s)&&t.validateUserMessageUpdateParams(a)).throw(e.SendbirdError.invalidParameters);const{requestQueue:i}=e.Vault.of(this._iid),r=new X(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:s},a)),o=yield i.send(r),{message:d}=o.as(Z);return d}))}copyUserMessage(s,n){var a,i,r;return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof Ue&&n instanceof t.UserMessage&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(e.SendbirdError.invalidParameters),e.unless(!n.poll).throw(e.SendbirdError.notSupportedError);const o=new e.Deferred,d=null!==(a=n.messageParams)&&void 0!==a?a:e.undefineNullProps(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(r=n.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return s._sendUserMessage(d).onSucceeded((e=>{o.resolve(e)})).onFailed((e=>o.reject(e))),o.promise}))}translateUserMessage(s,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.UserMessage&&s.messageId>0&&e.isArrayOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new de({channelType:this.channelType,channelUrl:this.url,messageId:s.messageId,translationTargetLanguages:n}),r=yield a.send(i),{message:o}=r.as(le);return o}))}_createScheduledUserMessage(t,s){const{requestQueue:n}=e.Vault.of(this._iid),a=Date.now(),i=this._generateRequestId();e.sleep(2).then((()=>{const n=this._createPendingScheduledUserMessage(t,i,a);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return s._trigger(n)}))))}));const r=new ue(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},t));n.send(r).then((t=>{const{message:n}=t.as(ce);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return s._trigger(n)}))))})).catch((n=>{if(e.isThrowingOutside(n))throw n;e.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(t,i,a);this._markMessageAsFailed(r,n),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return s._trigger(r)}))))}))}))}sendFileMessage(s){const n=Object.assign(Object.assign({},t.FileMessageCreateParamsDefault),s);return e.unless(t.validateFileMessageCreateParams(n)).throw(e.SendbirdError.invalidParameters),this._sendFileMessage(n)}sendMultipleFilesMessage(s){var n;const a=Object.assign(Object.assign({},t.MultipleFilesMessageCreateParamsDefault),s),i=e.Vault.of(this._iid);e.unless(t.validateMultipleFilesMessageCreateParams(a,null===(n=i.appInfo)||void 0===n?void 0:n.multipleFilesMessageFileCountLimit)).throw(e.SendbirdError.invalidParameters);const r=!!s.fileInfoList.find((e=>{const t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return e.unless(!r).throw(e.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(a)}_sendFileMessage(s,n,a=!1){const{dispatcher:i}=e.Vault.of(this._iid),{fileMessageQueue:r}=t.MessageManager.of(this._iid);let o=null!=n?n:this._generateRequestId();const d=Date.now(),l=new t.MessageRequestHandler;return o||(o=this._generateRequestId()),e.sleep(2).then((()=>{const t=this._createPendingFileMessage(s,o,d);i.dispatch(new e.MessageUpdateEventCommand({messages:[t],source:a?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._trigger(t)})))),r.request(this,o,s).then((t=>{i.dispatch(new e.MessageUpdateEventCommand({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._trigger(t)}))))})).catch((t=>{if(e.isThrowingOutside(t))throw t;e.sleep(2).then((()=>{const n=this._createPendingFileMessage(s,o,d),{cacheContext:a}=e.Vault.of(this._iid),r=a.localCacheEnabled&&e.isAutoResendableError(t.code);this._markMessageAsFailed(n,t,r),i.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:n.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(t,n)}))))}))}))})),l}_autoResendFileMessage(s){e.unless(s instanceof t.FileMessage&&!!s.messageParams).throw(e.SendbirdError.invalidParameters);const{logger:n}=e.Vault.of(this._iid);return n.debug("autoResendFileMessage pending",s),this._sendFileMessage(s.messageParams,s.reqId).onFailed((e=>{n.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{n.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(s,n){const{dispatcher:a}=e.Vault.of(this._iid),{fileMessageQueue:i}=t.MessageManager.of(this._iid);let r=null!=n?n:this._generateRequestId();const o=Date.now(),d=new t.MultipleFilesMessageRequestHandler;return r||(r=this._generateRequestId()),e.sleep(2).then((()=>{const t=this._createPendingMultipleFilesMessage(s,r,o);a.dispatch(new e.MessageUpdateEventCommand({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return d._trigger(t)})))),i.request(this,r,s,d).then((t=>{a.dispatch(new e.MessageUpdateEventCommand({messages:[t],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return d._trigger(t)}))))})).catch((t=>{if(e.isThrowingOutside(t))throw t;e.sleep(2).then((()=>{const n=this._createPendingMultipleFilesMessage(s,r,o);this._markMessageAsFailed(n,t),a.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return d._triggerFailed(t,n)}))))}))}))})),d}_createScheduledFileMessage(t,s,n,a){const{requestQueue:i}=e.Vault.of(this._iid),r=new he(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},t),{fileUrl:t.fileUrl,requireAuth:t.requireAuth}));i.send(r).then((t=>{const{message:n}=t.as(pe);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return s._trigger(n)}))))})).catch((i=>{if(e.isThrowingOutside(i))throw i;e.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(t,n,a);this._markMessageAsFailed(r,i),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(i,r)}))))}))}))}sendFileMessages(s){e.unless(s.every((e=>t.validateFileMessageCreateParams(Object.assign(Object.assign({},t.FileMessageCreateParamsDefault),e))))).throw(e.SendbirdError.invalidParameters);const n=new t.MessageRequestHandler;for(const e of s)this.sendFileMessage(e).onPending((e=>n._trigger(e))).onFailed(((e,t)=>n._triggerFailed(e,t))).onSucceeded((e=>n._trigger(e)));return n}resendFileMessage(s,n){var a;return e.__awaiter(this,void 0,void 0,(function*(){const i=Boolean(s.url)||e.isFile(n)||e.isFile(null===(a=s.messageParams)||void 0===a?void 0:a.file);e.unless(s instanceof t.FileMessage&&i&&!s.scheduledInfo).throw(e.SendbirdError.invalidParameters);const r=new e.Deferred,o=t.createFileMessageCreateParamsFromFailedFileMessage(s,n);return this._sendFileMessage(o,s.reqId,!0).onFailed((e=>r.reject(e))).onSucceeded((e=>r.resolve(e))),r.promise}))}updateFileMessage(s,n){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.FileMessageUpdateParamsDefault),n);e.unless(e.isTypeOf("number",s)&&t.validateFileMessageUpdateParams(a)).throw(e.SendbirdError.invalidParameters);const{requestQueue:i}=e.Vault.of(this._iid),r=new ee(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:s},a)),o=yield i.send(r),{message:d}=o.as(te);return d}))}cancelUploadingFileMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters);const{fileMessageQueue:n}=t.MessageManager.of(this._iid);return n.cancel(this,s),!0}))}copyFileMessage(s,n){var a,i,r;return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof Ue&&n instanceof t.FileMessage&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(e.SendbirdError.invalidParameters);const o=new e.Deferred,d=e.undefineNullProps(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(a=n.mentionedUserIds)&&void 0!==a?a:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((e=>e.userId)),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(r=n.thumbnails)||void 0===r?void 0:r.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:n.requireAuth,isPinnedMessage:!1}));return s._sendFileMessage(d).onSucceeded((e=>o.resolve(e))).onFailed((e=>o.reject(e))),o.promise}))}deleteMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(s instanceof t.BaseMessage).throw(e.SendbirdError.invalidParameters),s.messageId>0){const{requestQueue:t}=e.Vault.of(this._iid),n=new se({channelType:this.channelType,channelUrl:this.url,messageId:s.messageId});yield t.send(n)}}))}addReaction(s,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.BaseMessage&&s.messageId>0&&e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new ae({channelType:this.channelType,channelUrl:this.url,messageId:s.messageId,reactionKey:n}),r=yield a.send(i),{reactionEvent:o}=r.as(ie);return o}))}deleteReaction(s,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.BaseMessage&&s.messageId>0&&e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new re({channelType:this.channelType,channelUrl:this.url,messageId:s.messageId,reactionKey:n}),r=yield a.send(i),{reactionEvent:o}=r.as(oe);return o}))}_updateUserMessageMetaArray(t,s,n,a){return e.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:i,requestQueue:r}=e.Vault.of(this._iid),o=new X({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:s,mode:n,upsert:a}}),d=yield r.send(o),{message:l}=d.as(Z);return i.dispatch(new e.MessageUpdateEventCommand({messages:[l],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),l}))}_updateFileMessageMetaArray(t,s,n,a){return e.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:i,requestQueue:r}=e.Vault.of(this._iid),o=new ee({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:s,mode:n,upsert:a}}),d=yield r.send(o),{message:l}=d.as(te);return i.dispatch(new e.MessageUpdateEventCommand({messages:[l],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),l}))}createMessageMetaArrayKeys(s,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.BaseMessage&&s.messageId>0&&e.isArrayOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=n.map((e=>new t.MessageMetaArray({key:e})));return s instanceof t.FileMessage?this._updateFileMessageMetaArray(s.messageId,a,"add",!0):this._updateUserMessageMetaArray(s.messageId,a,"add",!0)}))}deleteMessageMetaArrayKeys(s,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.BaseMessage&&s.messageId>0&&e.isArrayOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=n.map((e=>new t.MessageMetaArray({key:e})));return s instanceof t.FileMessage?this._updateFileMessageMetaArray(s.messageId,a,"remove",!0):this._updateUserMessageMetaArray(s.messageId,a,"remove",!0)}))}addMessageMetaArrayValues(s,n){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(s instanceof t.BaseMessage&&s.messageId>0&&n.every((e=>e instanceof t.MessageMetaArray))).throw(e.SendbirdError.invalidParameters),s instanceof t.FileMessage?this._updateFileMessageMetaArray(s.messageId,n,"add",!0):this._updateUserMessageMetaArray(s.messageId,n,"add",!0)}))}removeMessageMetaArrayValues(s,n){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(s instanceof t.BaseMessage&&s.messageId>0&&n.every((e=>e instanceof t.MessageMetaArray))).throw(e.SendbirdError.invalidParameters),s instanceof t.FileMessage?this._updateFileMessageMetaArray(s.messageId,n,"remove",!0):this._updateUserMessageMetaArray(s.messageId,n,"remove",!0)}))}report(s,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(t.ReportCategory,s)&&e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:i}=e.Vault.of(this._iid),r=new W({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:s,description:n});yield i.send(r)}))}reportUser(s,n,a){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof e.User&&e.isEnumOf(t.ReportCategory,n)&&e.isTypeOf("string",a)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:r}=e.Vault.of(this._iid),o=new H({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:s.userId,category:n,description:a});yield r.send(o)}))}reportMessage(s,n,a){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof t.SendableMessage&&e.isEnumOf(t.ReportCategory,n)&&e.isTypeOf("string",a)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:r}=e.Vault.of(this._iid),o=new Y({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:s.sender.userId,messageId:s.messageId,category:n,description:a});yield r.send(o)}))}updatePoll(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("number",t)&&(t=>e.isTypeOf("string",t.title,!0)&&e.validatePollData(t.data)&&e.isTypeOf("boolean",t.allowUserSuggestion,!0)&&e.isTypeOf("boolean",t.allowMultipleVotes,!0)&&e.isTypeOf("number",t.closeAt,!0))(s)).throw(e.SendbirdError.invalidParameters);const{requestQueue:n}=e.Vault.of(this._iid),a=new me(Object.assign({pollId:t},s)),i=yield n.send(a),{poll:r}=i.as(ge);return r}))}deletePoll(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=e.isTypeOf("number",t);e.unless(s).throw(e.SendbirdError.invalidParameters);const{requestQueue:n}=e.Vault.of(this._iid),a=new _e({pollId:t});yield n.send(a)}))}closePoll(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=e.isTypeOf("number",t);e.unless(s).throw(e.SendbirdError.invalidParameters);const{requestQueue:n}=e.Vault.of(this._iid),a=new ye({pollId:t}),i=yield n.send(a),{poll:r}=i.as(ve);return r}))}addPollOption(t,s){return e.__awaiter(this,void 0,void 0,(function*(){const n=e.isTypeOf("number",t)&&e.isTypeOf("string",s)&&""!==s.trim();e.unless(n).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new fe({channelUrl:this.url,channelType:this.channelType,pollId:t,optionText:s}),r=yield a.send(i),{poll:o}=r.as(Me);return o}))}updatePollOption(t,s,n){return e.__awaiter(this,void 0,void 0,(function*(){const a=e.isTypeOf("number",t)&&e.isTypeOf("number",s)&&e.isTypeOf("string",n)&&""!==n.trim();e.unless(a).throw(e.SendbirdError.invalidParameters);const{requestQueue:i}=e.Vault.of(this._iid),r=new Te({pollId:t,pollOptionId:s,optionText:n}),o=yield i.send(r),{poll:d}=o.as(Ie);return d}))}deletePollOption(t,s){return e.__awaiter(this,void 0,void 0,(function*(){const n=e.isTypeOf("number",t)&&e.isTypeOf("number",s);e.unless(n).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new Pe({pollId:t,pollOptionId:s});yield a.send(i)}))}votePoll(t,s){return e.__awaiter(this,void 0,void 0,(function*(){const n=e.isTypeOf("number",t)&&e.isArrayOf("number",s);e.unless(n).throw(e.SendbirdError.invalidParameters);const{requestQueue:a,dispatcher:i}=e.Vault.of(this._iid),r=new Ce({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:s}),o=yield a.send(r),{event:d}=o.as(Ee);return i.dispatch(new e.PollVoteInternalEventCommand({event:d,source:e.CollectionEventSource.EVENT_POLL_VOTED})),d}))}getPollChangeLogsSinceTimestamp(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("number",t)).throw(e.SendbirdError.invalidParameters);const n=s.PollManager.of(this._iid);return yield n.getPollChangeLogs(this.url,this.channelType,t)}))}getPollChangeLogsSinceToken(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t,!0));const n=s.PollManager.of(this._iid);return yield n.getPollChangeLogs(this.url,this.channelType,t)}))}createPollListQuery(e=t.DEFAULT_POLLS_LIMIT){return new s.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,n,a=t.DEFAULT_POLL_VOTER_LIST_LIMIT){return new s.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:n,limit:a})}}exports.BanUserEventCommand=j,exports.BannedUserListQuery=h,exports.BaseChannel=Ue,exports.CreateScheduledUserMessageResponseCommand=ce,exports.DeleteMessageEventCommand=ne,exports.FreezeEventCommand=z,exports.MuteUserEventCommand=k,exports.MutedUserListQuery=l,exports.OperatorListQuery=r,exports.PENDING_MESSAGE_DELAY=2,exports.PollVoteEventCommand=Ee,exports.RestrictedUser=n,exports.UnbanUserEventCommand=B,exports.UnmuteUserEventCommand=$,exports.UpdateFileMessageEventCommand=te,exports.UpdateMetaCounterEventCommand=D,exports.UpdateMetaDataEventCommand=P,exports.UpdateUserMessageEventCommand=Z,exports.UserMessageEventCommand=J; diff --git a/cjs/lib/__bundle-aae5735d.js b/cjs/lib/__bundle-aae5735d.js new file mode 100644 index 0000000..6747db5 --- /dev/null +++ b/cjs/lib/__bundle-aae5735d.js @@ -0,0 +1 @@ +"use strict";var e,t=require("./__bundle-26b86f4c.js");class s extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew t.User(this._iid,e))):[],this.lastRepliedAt=null!==(n=s.last_replied_at)&&void 0!==n?n:0,this.updatedAt=null!==(a=s.updated_at)&&void 0!==a?a:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class a{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class r{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);const r={};for(const e of this.userIds)r[e]=this.updatedAt;this._version=r}get isEmpty(){return 0===this.userIds.length}static payloadify(e){return t.deundefined(t.undefineNullProps({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}applyEvent(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){const t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}class o{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}class l{constructor(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s:0,height:null!==(i=e.height)&&void 0!==i?i:0,alt:e.alt}))}}class d{constructor(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new l(e["og:image"]))}static payloadify(e){return t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}class c extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}var h,p;exports.ScheduledStatus=void 0,(h=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",h.SENT="sent",h.FAILED="failed",h.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(p=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",p.IN_QUEUE="in_queue",p.SENT="sent",p.FAILED="failed",p.CANCELED="canceled",p.REMOVED="removed";const m=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class _ extends t.InstancedObject{constructor(e,s){var i,a,l,c,h,p,m,_,g,y,f,v,I,E,T,b;super(e),this.channelType=t.ChannelType.BASE,this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.messageType=t.MessageType.BASE,this.mentionType=null,this.threadInfo=null,this.reactions=[],this.metaArrays=[],this.appleCriticalAlertOptions=null,this.createdAt=0,this.updatedAt=0,this.scheduledInfo=null,this.extendedMessage={},this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(a=null!==(i=s.msg_id)&&void 0!==i?i:s.message_id)&&void 0!==a?a:0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.parentMessageId=null!==(l="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==l?l:0,this.data=null!==(c=s.data)&&void 0!==c?c:"",this.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(p=s.mentioned_user_ids)&&void 0!==p?p:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=null!==(m=s.mentioned_message_template)&&void 0!==m?m:"",this.threadInfo=s.thread_info?new n(this._iid,s.thread_info):null,this.reactions=s.reactions?s.reactions.map((e=>new r(e))):[];const S=null!==(_=s.metaarray)&&void 0!==_?_:{},O=null!==(g=s.metaarray_key_order)&&void 0!==g?g:Object.keys(S).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew o(e)))),this.ogMetaData=s.og_tag?new d(s.og_tag):null,this.silent=null!==(y=s.silent)&&void 0!==y&&y,this.isOperatorMessage=null!==(f=s.is_op_msg)&&void 0!==f&&f,this.appleCriticalAlertOptions=s.apple_critical_alert_options?new u(s.apple_critical_alert_options):null,this.createdAt=null!==(I=null!==(v=s.created_at)&&void 0!==v?v:s.ts)&&void 0!==I?I:0,this.updatedAt=null!==(E=s.updated_at)&&void 0!==E?E:0,"number"==typeof s.scheduled_message_id&&"number"==typeof s.scheduled_at&&s.scheduled_status&&(this.scheduledInfo={scheduledMessageId:s.scheduled_message_id,scheduledAt:s.scheduled_at},this._scheduledStatus=s.scheduled_status),this.extendedMessage=null!==(T=s.extended_message)&&void 0!==T?T:{},this._isContinuousMessages=null!==(b=s.is_continuous_messages)&&void 0!==b&&b}static payloadify(e){var s,i,a,l;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:m(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?n.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>r.payloadify(e))),sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>o.payloadify(e))),og_tag:e.ogMetaData?d.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(a=e.scheduledInfo)||void 0===a?void 0:a.scheduledMessageId,scheduled_at:null===(l=e.scheduledInfo)||void 0===l?void 0:l.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:m(e.messageType),ts:e.createdAt,user:e.sender?c.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}isIdentical(e){return this.messageId===e.messageId}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(this.threadInfo=e.threadInfo),!1}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}}class g extends _{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new c(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:c.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}class y{constructor(e){var t,s;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(s=e.real_height)&&void 0!==s?s:e.height}static payloadify(e){return t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get plainUrl(){return this.url.split("?auth=")[0]}}const f={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},v=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class I extends _{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class E{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class T extends g{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new E(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>E.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}applyPoll(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}get poll(){return this._poll}}class b extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.plainUrl="",this.fileName=null,this.mimeType=null,this.fileSize=0,this.thumbnails=[],this._requireAuth=!1,this.plainUrl=null!==(i=s.url)&&void 0!==i?i:"",this.fileName=null!==(n=s.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=s.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=s.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=s.require_auth)&&void 0!==o&&o;const{sessionManager:l}=t.Vault.of(this._iid);this.thumbnails=s.thumbnails?s.thumbnails.map((e=>new y(Object.assign(Object.assign({},e),{url:`${e.url.split("?auth=")[0]}${this._requireAuth?`?auth=${l.ekey}`:""}`})))):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class S extends g{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.fileInfoList=null!==(n=null===(i=s.files)||void 0===i?void 0:i.map((t=>new b(e,t))))&&void 0!==n?n:[],this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>b.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}const O=(e,s)=>{switch(s.type){case"MESG":return new T(e,s);case"FILE":return S._isMultipleFilesMessagePayload(s)?new S(e,s):new M(e,s);case"ADMM":case"BRDM":return new I(e,s)}throw t.SendbirdError.unknown};class M extends g{constructor(e,s){var i,n,a,r,o,l,d,u,c,h,p,m,_,g;super(e,s),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=s.file;this.plainUrl=(null!==(n=null!==(i=null==f?void 0:f.url)&&void 0!==i?i:s.url)&&void 0!==n?n:"").split("?auth=")[0],this.name=null!==(r=null!==(a=null==f?void 0:f.name)&&void 0!==a?a:s.name)&&void 0!==r?r:"File",this.size=null!==(l=null!==(o=null==f?void 0:f.size)&&void 0!==o?o:s.size)&&void 0!==l?l:0,this.data=null!==(u=null!==(d=null==f?void 0:f.data)&&void 0!==d?d:s.custom)&&void 0!==u?u:"",this.type=f?null!==(c=f.type)&&void 0!==c?c:"":null!==(h=s.type)&&void 0!==h?h:"";const{sessionManager:v}=t.Vault.of(this._iid);if(this.requireAuth=null!==(p=s.require_auth)&&void 0!==p&&p,this.thumbnails=s.thumbnails?s.thumbnails.map((e=>new y(Object.assign(Object.assign({},e),{url:`${e.url.split("?auth=")[0]}${this.requireAuth?`?auth=${v.ekey}`:""}`})))):[],this.messageSurvivalSeconds=null!==(m=s.message_survival_seconds)&&void 0!==m?m:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(_=i.file)||void 0===_?void 0:_.url,require_auth:null===(g=i.file)||void 0===g?void 0:g.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this.requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class A extends t.WebSocketRequestCommand{constructor(e){var s,i,n;let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?P(e.files):null,url:e.url,name:null!==(s=e.fileName)&&void 0!==s?s:"",type:null!==(i=e.mimeType)&&void 0!==i?i:"",size:null!==(n=e.fileSize)&&void 0!==n?n:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:a,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})}}class C extends t.APIRequestCommand{constructor(e){var s,i;super();let n=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?P(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:n,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(s=e.thumbnailSizes)||void 0===s?void 0:s.map((e=>y.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>o.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class w extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new S(e,i):new M(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class N extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new S(e,s):new M(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function P(e){return e.map((e=>{var s,i;return t.deundefined(t.undefineNullProps({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnailSizes)||void 0===s?void 0:s.map((e=>y.payloadify(e))),require_auth:null===(i=e._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var U;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(U||(U={}));class R{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new A(t),s=yield this._requestQueue.send(e),{message:i}=s.as(w);return i}{const e=new C(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(N);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i)if(i.isResolving)i.isResolveRequestPending=!0;else{i.isResolving=!0;const n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case U.PENDING:case U.UPLOADING:a=!1,n.push(r);break;case U.UPLOADED:if(a)try{r.state=U.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case U.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===U.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params.fileInfoList[a];t.isFile(l.file)&&!(null===(s=l._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,n,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new s({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:n.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnailSizes:h=a.thumbnailSizes,requireAuth:p=!1}=d.as(i);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.thumbnailSizes=h,a.requireAuth=p}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,n,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=n.multipleFileUploadInfo,d=a.fileInfoList[t],u=new s({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:n.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnailSizes:m=d.thumbnailSizes,requireAuth:_=!1}=c.as(i);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d.thumbnailSizes=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0})}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:U.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case U.PENDING:if(s.state=U.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case U.UPLOADING:this._requestQueue.cancel(s.requestId)}}}}const x={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},L=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),k={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},D=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class q extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class F extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?O(e,Object.assign({},t)):null}}class B extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingContinuousMessages:v}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_continuous_messages:v}))}}class j extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.messages.map((t=>O(e,t)))}}class z extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class V extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>O(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class $ extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class Q extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?O(e,Object.assign({},t)):null}}var G;exports.RestrictionType=void 0,(G=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",G.BANNED="banned";class K{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class H extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new K(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),K.payloadify(e.restrictionInfo))))}}class W{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Y={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},J=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(o,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),X=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Z=Object.assign(Object.assign({},Y),{message:"",translationTargetLanguages:void 0,pollId:void 0});function ee(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const te=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},se=e=>J(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0);var ie;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ie||(ie={}));const ne=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,ae=e=>e===ie.BLOB||e===ie.FILE,re=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),oe=Object.assign(Object.assign({},Y),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1});function le(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1}))}const de=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))},ue=e=>J(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),ce={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},he=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(o,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),pe=Object.assign(Object.assign({},ce),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),me=e=>he(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),_e=Object.assign({},ce);class ge extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class ye extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class fe extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new ge(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(ye);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class ve extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.ReplyType.NONE,this.includeMetaArray=!1,this.includeReactions=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1,this._edge=Number.MAX_SAFE_INTEGER,this.reverse=null!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=ai.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.undefineNullProps({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));return this._edge=Math.min(Number.MAX_SAFE_INTEGER,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Ie extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ee extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new H(e,t))))}}class Te extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Ie(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ee);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class be extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class Se extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new H(e,t.user))))}}class Oe extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new be(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(Se);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Me;exports.ReportCategory=void 0,(Me=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Me.HARASSING="harassing",Me.SUSPICIOUS="suspicious",Me.INAPPROPRIATE="inappropriate";class Ae extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ce extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class we extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class Ne extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class Pe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class Ue extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class Re extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class xe extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class Le extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ke extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class De extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class Fe extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class Be extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class je extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class Ve extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class $e extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class Qe extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class Ge extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class Ke extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class He extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class We extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Ye extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Je extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class Xe extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data)}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class et extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data)}}class tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class st extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class it extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class nt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data)}}class at extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class rt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class lt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params={report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r}}}class ut extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage}))})}}class ct extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new T(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class ht extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class pt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new T(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class mt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class _t extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new M(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class gt extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`}}class yt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id)}}class ft extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new a(t)}}class It extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Et extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new a(Object.assign({},t))}}class Tt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class bt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new T(e,t)}}class St extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>o.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ot extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new T(e,t)}}class Mt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>y.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>o.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class At extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new M(e,t)}}class Ct extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class wt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Nt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class Pt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class Ut extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Rt extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Lt extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class kt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Dt extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class qt extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class Ft extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const Bt="Message";const jt=Object.assign(Object.assign({},Y),{fileInfoList:[]}),zt=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class Vt extends W{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,i)}onFileUploaded(e){return this._onFileUploaded=e,this}onPending(e){return super.onPending(e),this}onFailed(e){return super.onFailed(e),this}onSucceeded(e){return super.onSucceeded(e),this}}var $t;exports.SendMessageRequestType=void 0,($t=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",$t.RESEND="resend",$t.COPY="copy";class Qt extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l;super(e),this._name="",this._createdAt=0,this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts&&(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})})))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){this._cachedMetaData?this._cachedMetaData.forEach(((s,i)=>{var n;s.updatedAt<=t&&this._cachedMetaData.set(i,{value:null!==(n=e[i])&&void 0!==n?n:s.value,isRemoved:!e[i],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})))}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAto.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?c.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n})),r=new T(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,s,i){var n,a,r,o,l,d;const u=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(n=e.fileName)&&void 0!==n?n:null===(a=e.file)||void 0===a?void 0:a.name,size:null!==(r=e.fileSize)&&void 0!==r?r:null===(o=e.file)||void 0===o?void 0:o.size,type:null!==(l=e.mimeType)&&void 0!==l?l:null===(d=e.file)||void 0===d?void 0:d.type,data:e.data},thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>({url:"",width:e.maxWidth,height:e.maxHeight}))):[]})),c=new M(this._iid,u);return c.messageParams=e,c}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE})),a=new S(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Z),e);return t.unless(se(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new W;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new ut(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(ct);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof T&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof T&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:te(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},pe),s);t.unless(t.isTypeOf("number",e)&&me(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ht(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},i)),r=yield n.send(a),{message:o}=r.as(pt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Qt&&s instanceof T&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof T&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(bt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new St(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ot);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},oe),e);return t.unless(ue(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},jt),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>J(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>zt(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=ai.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new W;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof M&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=ai.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Vt;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Mt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(At);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ue(Object.assign(Object.assign({},oe),e))))).throw(t.SendbirdError.invalidParameters);const s=new W;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof M&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=de(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof g&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:te(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:de(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_e),s);t.unless(t.isTypeOf("number",e)&&(e=>he(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new mt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},i)),r=yield n.send(a),{message:o}=r.as(_t);return o}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=ai.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Qt&&s instanceof M&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Qt&&s instanceof g&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=ee(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=le(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof _).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new gt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new ft({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new It({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Et);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new ht({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(pt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new mt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(_t);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new o({key:e})));return e instanceof M?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new o({key:e})));return e instanceof M?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof _&&e.messageId>0&&s.every((e=>e instanceof o))).throw(t.SendbirdError.invalidParameters),e instanceof M?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof _&&e.messageId>0&&s.every((e=>e instanceof o))).throw(t.SendbirdError.invalidParameters),e instanceof M?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new ot({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new lt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof g&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new dt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Ct(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(wt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Nt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Pt({pollId:e}),a=yield i.send(n),{poll:r}=a.as(Ut);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Rt({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(xt);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new Lt({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(kt);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new qt({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(Ft);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}}const Gt={};class Kt{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Gt[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Gt[e]=this),Gt[e]}static get(e){return Gt[e]}}var Ht,Wt;!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Ht||(Ht={}));class Yt extends Error{constructor({code:e=Ht.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Yt.prototype)}static get storeNotDefined(){return new Yt({code:Ht.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Yt({code:Ht.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Yt({code:Ht.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Yt({code:Ht.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Yt({code:Ht.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Yt({code:Ht.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Yt({code:Ht.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Yt({code:Ht.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Yt({code:Ht.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Yt({code:Ht.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Yt({code:Ht.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Yt({code:Ht.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Yt({code:Ht.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Yt({code:Ht.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Yt({code:Ht.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Yt({code:Ht.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Yt({code:Ht.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Yt({code:Ht.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Yt({code:Ht.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Yt({code:Ht.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Yt({code:Ht.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Yt({code:Ht.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Yt({code:Ht.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Yt({code:Ht.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Yt({code:Ht.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Wt||(Wt={}));const Jt=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Yt.circularReferenceFound;{let s;if(t.set(e,!0),Array.isArray(e))s=e.map((e=>Jt(e,t)));else if(e instanceof RegExp)s=e;else if(e instanceof Date)s=e;else{s={};for(const i in e)s[i]=Jt(e[i],t)}return t.delete(e),s}}return e},Xt=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Yt.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},Zt=(e,t)=>{let s=0;for(let t=0;t>>0)%t},es=e=>new Promise((t=>{setTimeout((()=>t()),e)})),ts=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!ts(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!ts(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Xt(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Xt(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Xt(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Xt(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},ss=()=>{},is=()=>Promise.resolve(),ns=e=>e,as=(e,t)=>{t()};var rs;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(rs||(rs={}));class os{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=ns,backward:n=is,forward:a=is,complete:r=ss}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}get prevValue(){return this._map(this._prevValue)}get nextValue(){return this._map(this._nextValue)}get error(){return this._error}get hasPrevious(){return!!this._prevValue}get hasNext(){return!!this._nextValue}prev(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.hasPrevious){try{const e=this._prevValue;this._prevValue=(yield this._backward())||null,this._nextValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.hasNext){try{const e=this._nextValue;this._nextValue=(yield this._forward())||null,this._prevValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}stop(){this._prevValue=null,this._nextValue=null,this._complete()}}class ls{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const i in this._indexer.fields){let n=this._indexer.fields[i],a=1;if("-"===n[0]&&(n=n.slice(1),a=-1),this.condition[n])if("object"==typeof this.condition[n]){const r=a>0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Xt(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Xt(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ts(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new os({initialNextValue:Jt(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ts(this.condition,e))return Jt(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ts(this.condition,e))return Jt(e)}return null})),complete:o});e(l)}))}))}}class ds{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new ls({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=Math.max(e.offset||0,0);const i="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER;if(0===i)return[];if(i<0)throw Yt.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const us=e=>`nest@${e}`,cs=(e,t)=>`${us(e)}/${t}`,hs=(e,t)=>`${cs(e,t)}.metadata`,ps=(e,t)=>`${cs(e,t)}/block.`,ms=(e,t)=>`${cs(e,t)}/blob.`;class _s{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${ms(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=ms(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var gs,ys,fs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(gs||(gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(ys||(ys={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(fs||(fs={}));const vs=[ys.PENDING,ys.VOLATILE],Is={};class Es{constructor({dbname:e,limit:t=256}){return Is[e]||(this.dbname=e,this._items=[],this._limit=t,Is[e]=this),Is[e]}static get(e){return Is[e]}get items(){return this._items}find(e,s,i=fs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===fs.PERSISTENT&&(t.state=ys.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===fs.PERSISTENT?ys.PERSISTENT:ys.VOLATILE},this.put(t))}return t}))}get(e,t=fs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===fs.PERSISTENT&&(e.state=ys.PERSISTENT),t!==fs.NO_CACHE&&this.put(e),e}return null}put(e){if(this._limit>0){const t=this._items.map((e=>e.key)).indexOf(e.key);if(t>-1)vs.includes(this._items[t].state)&&vs.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);const t=this._items.filter((e=>e.state===ys.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===ys.VOLATILE&&s>0?s--:e.push(t);this._items=e}}}}remove(e){const t=this._items.map((e=>e.key)).indexOf(e);t>-1&&this._items.splice(t,1)}clearByCondition(e){this._items=this._items.filter((t=>!e(t)))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==ys.VOLATILE))}}class Ts{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${cs(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${cs(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__awaiter(this,void 0,void 0,(function*(){const t=(yield this._store.get(this.recordsetKey))||[];return t.push(...e),this._reduceRecordSet(t)}))}_reduceRecordSet(e){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Es.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__awaiter(this,void 0,void 0,(function*(){this._metadata=(yield this._store.get(this.metadataKey))||{generation:1};const e=yield this._getReducedRecordset();for(const t of e)yield this._applyRecord(e,t)}))}on(e,t,s){switch(e){case gs.COMMIT:this._onCommit.set(t,s);break;case gs.WRITE:this._onWrite.set(t,s);break;case gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Es.get(this.dbname).put(Object.assign({state:ys.PENDING},e))}requestMultipleWrite(e,t){const s=Es.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:ys.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Es.get(this.dbname).clearByCondition((e=>e.state===ys.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Es.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=Kt.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class bs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new bs(e.value):null}get isEmpty(){return 0===this._items.length}get items(){return this._items}serialize(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}}getItemByKey(e){const t=this._items.find((t=>{const s=t[this.keyName];return e===s}));return null!=t?t:null}has(e){return this._items.map((e=>e[this.keyName])).includes(e)}add(e){const t=this._items.map((e=>e[this.keyName])).indexOf(e[this.keyName]);return t<0?this._items.length{const i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||Zt)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${ps(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Es.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=bs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Kt.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Es.get(this.dbname),r=yield a.find(this._store,i),o=r?bs.createFromCacheItem(r):new bs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return!(!t||!t.remove(e))&&(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),!0)}))}clearAllBlocks(){return t.__awaiter(this,void 0,void 0,(function*(){const e=ps(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Es.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const Os=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},Ms={};class As{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${cs(e,t)}/index.${s}`)(e,t,i.join(">"));return Ms[r]||(this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._transaction=n,this._store=a,this._transaction.on(gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(gs.ERROR,this.indexerKey,(()=>this.abort()))),Ms[r]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in Ms)delete Ms[e]}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!Os(e[s]))throw Yt.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Xt(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Es.get(this.dbname),t=yield e.find(this._store,this.indexerKey,fs.PERSISTENT);if(t)this._origin=t.value,this._table=Jt(this._origin);else{const t=ps(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,fs.NO_CACHE),s=bs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}Ms[this.indexerKey]=this}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Es.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete Ms[this.indexerKey]}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}commit(){this._origin=this._table,this._table=Jt(this._origin)}abort(){this._table=Jt(this._origin)}}const Cs=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ws=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};var Ns,Ps;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Ns||(Ns={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Ps||(Ps={}));const Us={};class Rs{constructor(e,t={}){return this._state=Ns.PROCESSING,this._queue=[],this._activationQueue=[],Us[e]&&!t.forceCreate||(this.nodeId=ws(),this.key=e,Cs()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.claimHost()})),window.addEventListener("message",(e=>{const t=e.data,{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case Ps.NEWNODE:this._sendSync();break;case Ps.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case Ps.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:Ps.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case Ps.REMOVENODE:this._queue=this._queue.filter((e=>e.nodeId!==t.nodeId)),this._currentItem&&this._currentItem.nodeId===t.nodeId&&(this._currentItem=void 0,this._acquire(this._queue[0]));break;case Ps.REQUEST_LOCK:this._requestLock(t);break;case Ps.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case Ps.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(Ps.REMOVENODE)}))),Us[e]=this),Us[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==Ns.DONE}_send(e,t={}){var s;const i={nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ws(),key:this.key,op:e,data:t.data,ts:Date.now()};return Cs()&&window.postMessage(i,"*"),i}_acquire(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}_release(e){if(this._currentItem&&this._currentItem.requestId===e){const t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Ps.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(Ps.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(const e in this._queue)if(this._queue[e].ts>s.ts){this._queue.splice(parseInt(e),0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(Ps.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((e=>({nodeId:e.nodeId,requestId:e.requestId,ts:e.ts})))}})}_waitUntilSyncCompleted(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.isHost&&!this.isInSync)return new Promise((e=>{this._activationQueue.push(e)}))}))}_waitSync(){this.isInSync||(this._activationTimeout=setTimeout((()=>{this._completeSync()}),8))}_completeSync(){this.isInSync||(this._state=Ns.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(Ps.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(Ps.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(Ps.REQUEST_LOCK);yield this._requestLock(e)}))}unlock(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}class xs{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Wt.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>As.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new Rs(((e,t)=>`${cs(e,t)}.lock`)(e,t)),this._blobContainer=new _s({dbname:e,collectionName:t,store:a}),this._transaction=new Ts({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=hs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Wt.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=Kt.get(this.dbname),t=yield xs.metadataOf(this.dbname,this.name,this._store);this._metadata=t||{keyName:this.keyName,blockLevel:1,blockHashBase:e.blockHashBase,blockHashMultiplier:e.blockHashMultiplier,blockHashConstant:e.blockHashConstant,indexes:this.indexes},yield this._transaction.init(),this._blockManager=new Ss({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>As.createKey(e))),a=t?t.indexes.map((e=>As.createKey(e))):[];for(const e of a)n.includes(e)||i.push(As.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new As({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new As({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=hs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Wt.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Wt.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=As.createKey(e);for(const e of this._indexers)if(t===As.createKey(e.fields))return e;throw Yt.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=hs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Yt.collectionInsertDuplicate;(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}))}_requestUpsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}else{(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}}))}_requestUpdate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._blockManager.getFromBlock(e);if(t){yield this._blockManager.removeFromBlock(e);for(const e of this._indexers)yield e.removeItem(t)}}))}_requestClear(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),Jt(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new ds({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Yt.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Yt.collectionKeyNotGiven;return yield this._requestInsert(Jt(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Yt.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(Jt(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Yt.collectionKeyNotGiven;return yield this._requestUpsert(Jt(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Yt.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(Jt(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Yt.collectionKeyNotGiven;return yield this._requestUpdate(Jt(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Yt.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new ls({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(ts(i,t)&&s.set){if("function"!=typeof s.set)for(const e in s.set)t[e]=s.set[e];else s.set(t);r.push(t)}e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(Jt(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{yield this._requestRemove(e),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}removeIf(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Yt.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new ls({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(ts(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{yield this._requestClear(),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}getBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const Ls="[NESTDB]";let ks=!0;class Ds{static off(){ks=!1}static log(...e){ks&&console.log(`${Ls}[LOG]`,...e)}static warning(...e){ks&&console.warn(`${Ls}[WARNING]`,...e)}static error(...e){ks&&console.error(`${Ls}[ERROR]`,...e)}}const qs=[{},{a:700400,n:"error"}];class Fs{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:qs.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e&&e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){Ds.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Yt.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._setRaw([].concat(...e.map((e=>this._shardify(e))))),e.map((e=>e.value))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s;return yield this._removeRaw(this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)))),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=[];for(const s of e){const e=this._getRawKey(s,".0"),i=yield this._getRaw(e);if(i){const{metadata:e}=i;t.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(s,`.${e}`))))}}return t.length>0&&(yield this._removeRaw(t)),e}))}}const Bs=1,js={};class zs extends Fs{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=Bs}=e;this.delay=s,this.observer={}}get rawData(){return js[this.dbname]}set rawData(e){js[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(js[this.dbname])return Object.keys(js[this.dbname]);throw Yt.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(js[this.dbname])return yield es(this.delay),js[this.dbname][e]?Object.assign({key:e},js[this.dbname][e]):null;throw Yt.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!js[this.dbname])throw Yt.storeNotAvailable;yield es(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;js[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!js[this.dbname])throw Yt.storeNotAvailable;yield es(this.delay);for(const t of e)js[this.dbname][t]&&delete js[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,js[this.dbname]||(js[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__awaiter(this,void 0,void 0,(function*(){for(const t of e){const e=this.observer[t.key];if(e&&"function"==typeof e.set){const t=e.set();if(t)throw t}}return s.setMany.call(this,e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield es(this.delay),js[this.dbname]={}}))}}const Vs="NestDBStore";var $s;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}($s||($s={}));var Qs,Gs;exports.NestDBState=void 0,(Qs=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Qs.OPENING="OPENING",Qs.OPENED="OPENED",Qs.CLOSED="CLOSED";class Ks{constructor(){this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.ReplyType.NONE}clone(){const e=new Ks,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof g))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof g&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(Gs=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",Gs.NEWEST_CHILD_MESSAGE="newest_child_message";const Hs=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Ws=Object.assign(Object.assign({},Z),{scheduledAt:void 0}),Ys=Object.assign(Object.assign({},Y),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js="UnsentMessage",Xs={};class Zs extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new Rs("unsendmessagecache.lock"),Xs[e]=this}static of(e,t=!1){return Xs[e]&&!t||(Xs[e]=new Zs(e)),Xs[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(Js);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof T?(e.messageParams&&(s.messageParams=X(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},X(i)),{scheduledAt:i.scheduledAt})))):e instanceof M?(e.messageParams&&(s.messageParams=re(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},re(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof S&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return ai.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=ai.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof T){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof M){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&ae(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof S){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&ae(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof T){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof M){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&ae(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserializeWithMessageCreateParams(t)}}))}fetch({channelUrl:e,filter:s=new Ks,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Hs(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new Ks){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof M||e instanceof S)&&(yield this._mutex.lock(),yield this.saveBlob(e),yield this._mutex.unlock());const t=this._serialize(e);yield this.collection.upsertOne(t)}))))))}))}upsertChildMessages(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){let t=[];e.threadInfo&&e.threadInfo.replyCount>0&&(t=yield this.getAllChildMessages(e)),t.length>0&&(t.forEach((t=>t.applyParentMessage(e))),yield this.upsert(t))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof M){if(e.messageParams){const t=e.messageParams;if(t.file&&ne(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=ie.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&ne(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=ie.BLOB}}}else if(e instanceof S){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&ne(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=ie.BLOB}}))))))}}))}}const ei={};class ti extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Zs.of(this._iid)}constructor(e){super(e),ei[e]=this}static of(e,t=!1){return ei[e]&&!t||(ei[e]=new ti(e)),ei[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(Bt)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign(Object.assign({},e.serialize()),{messageId:`${e.messageId}`})}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return ai.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserialize(t)}}))}fetch({channelUrl:e,token:s,limit:i=100,filter:n=new Ks,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Hs(a),h={where:{channelUrl:e,"/where":e=>{if(s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new Ks){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t),yield this.upsertChildMessages(e),yield this._unsentMessageCache.upsertChildMessages(e)}}))}upsertChildMessages(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Hs(exports.MessageListOrder.CHANNEL_LATEST)});const{preference:t}=this._cacheContext;yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`)}}))}removeUnderOffset(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Hs(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Hs(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof M&&e.messageParams){const t=e.messageParams;if(t.file&&ne(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const si={};class ii extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return ti.of(this._iid)}get _unsentMessageCache(){return Zs.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e.messageId>0)),r=s.filter((e=>0===e.messageId));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof g?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.remove(s)})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}}))))}static of(e,t=!1){var s;return si[e]&&!t||(si[e]&&(null===(s=si[e]._dispatcherContext)||void 0===s||s.close()),si[e]=new ii(e)),si[e]}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_broadcastPollChangeLogEvent(e,t){for(const s of this._observers.values())s.onPollChangeLogUpdate&&s.onPollChangeLogUpdate(e,t)}_broadcastPollUpdateEvent(e,t){for(const s of this._observers.values())s.onPollUpdate&&s.onPollUpdate(e,t)}_broadcastPollVoteEvent(e,t){for(const s of this._observers.values())s.onPollVote&&s.onPollVote(e,t)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}_broadcastRemoveUnsentEvent(e,t){for(const s of this._observers.values())s.onRemoveUnsent&&s.onRemoveUnsent(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const ni={};class ai{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,ti.of(e),Zs.of(e),ii.of(e),this.fileMessageQueue=new R(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),ni[e]=this}static of(e){return ni[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);switch(s.messageType){case t.MessageType.USER:return new T(this._iid,T.payloadify(s));case t.MessageType.FILE:return S._isMultipleFilesMessageSerializedData(s)?new S(this._iid,S.payloadify(s)):new M(this._iid,M.payloadify(s));case t.MessageType.ADMIN:return new I(this._iid,I.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new c(this._iid,c.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new q(e),s=yield this._requestQueue.send(t),{message:i}=s.as(F);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new $(e),s=yield this._requestQueue.send(t),{message:i}=s.as(Q);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new B(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},x),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(j);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new B(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},x),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(j);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r){return t.__awaiter(this,void 0,void 0,(function*(){const o=new B(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},x),n),{checkingContinuousMessages:r})),l=yield this._requestQueue.send(o),d=l.payload,{messages:u}=l.as(j);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:d}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new B(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},f),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(j),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new z(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},k),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(V),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class ri extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,a=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",a)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new n(e,i),this.targetMessageId=a,this.channelUrl=r,this.channelType=o)}}const oi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class li extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class di extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>O(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var ui;exports.MessageSearchOrder=void 0,(ui=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",ui.TIMESTAMP="ts";class ci extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),this.keyword="",this.reverse=!1,this.exactMatch=!1,this.channelUrl="",this.channelCustomType="",this.messageTimestampFrom=null,this.messageTimestampTo=null,this.order=exports.MessageSearchOrder.SCORE,this.advancedQuery=!1,this.targetFields=null,this._nextToken="",this.totalCount=-1,this.keyword=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new li(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(di);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=I,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=st,exports.BannedUserListQuery=Oe,exports.BaseChannel=Qt,exports.BaseMessage=_,exports.BaseMessageUpdateParamsDefault=ce,exports.BaseStore=Fs,exports.CreateScheduledUserMessageResponseCommand=Ot,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DeleteMessageEventCommand=yt,exports.FileMessage=M,exports.FileMessageEventCommand=w,exports.FreezeEventCommand=rt,exports.IndexedDbStore=class extends Fs{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=Vs,this._state=$s.UNINITIALIZED,this._openJobQueue=[],this._window="undefined"!=typeof window?window:void 0,this._indexedDb=this._window?this._window.indexedDB||this._window.mozIndexedDB||this._window.webkitIndexedDB||this._window.msIndexedDB:void 0}get state(){return this._state}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=$s.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(Vs,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=$s.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=$s.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=$s.UNINITIALIZED,s(e.target.error)}))}else s(Yt.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case $s.UNINITIALIZED:case $s.OPEN:throw Yt.storeNotInitialized;case $s.OPENING:case $s.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((s,i)=>{const n=t.put(e);n.addEventListener("success",(e=>{s(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))})))))}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((s,i)=>{const n=t.delete(e);n.addEventListener("success",(()=>s(e))),n.addEventListener("error",(e=>i(e.target.error)))})))))}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){const e="undefined"!=typeof window?window:null;if(!((null==e?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))throw Yt.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Cs())throw Yt.storeNotAvailable;if(Cs()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Yt.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Yt.storeNotAvailableInPrivateBrowsing),s.onsuccess=()=>e()}catch(e){t(Yt.storeNotAvailableInPrivateBrowsing)}else t(Yt.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readwrite");return yield new Promise(((t,s)=>{const i=e.clear();i.addEventListener("success",(()=>t())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.MemoryStore=zs,exports.MessageBroadcast=ii,exports.MessageCache=ti,exports.MessageFilter=Ks,exports.MessageManager=ai,exports.MessageMetaArray=o,exports.MessageRequestHandler=W,exports.MessageRetrievalParamsDefault=oi,exports.MessageSearchQuery=ci,exports.MultipleFilesMessage=S,exports.MultipleFilesMessageRequestHandler=Vt,exports.MuteUserEventCommand=Xe,exports.MutedUserListQuery=Te,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=Bt,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=Js,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new Kt({dbname:e}),this._store=s,this._event={success:ss,error:ss,storeReplaced:ss,upgrade:as},this._collections=new Map,this._globalMutex=new Rs(`${this.name}.lock`),this._config.disableLogger&&Ds.off(),new Es({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Yt.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new xs({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__awaiter(this,void 0,void 0,(function*(){if(yield this._globalMutex.lock(),this._state!==exports.NestDBState.OPENED){this._state=exports.NestDBState.OPENING;try{yield this._store.init(this.name);const i=(s=this.name,`${us(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)Ds.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Wt.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield xs.metadataOf(this.name,e,this._store);if(t){const s=new xs({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{Ds.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ht.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:Ds.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new zs({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ht.STORE_NOT_AVAILABLE:Ds.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new zs({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw Ds.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){this.close();const e=Es.get(this.name);e&&e.clearByCondition((e=>e.key.startsWith(us(this.name)))),yield this._store.clear()}))}on(e,t){this._event[e]=t}off(e){if("function"==typeof this._event[e])if("upgrade"===e)this._event[e]=as;else this._event[e]=ss}collection(e){const t=this._collections.get(e);if(t)return t;throw Yt.collectionNotReady}},exports.NestDBError=Yt,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=fe,exports.PENDING_MESSAGE_DELAY=2,exports.Plugin=E,exports.PollVoteEventCommand=Ft,exports.PreviousMessageListQuery=ve,exports.Reaction=r,exports.ReactionEvent=a,exports.RestrictedUser=H,exports.RestrictionInfo=K,exports.ScheduledFileMessageCreateParamsDefault=Ys,exports.ScheduledUserMessageCreateParamsDefault=Ws,exports.SendableMessage=g,exports.Sender=c,exports.ThreadInfo=n,exports.ThreadInfoUpdateEvent=ri,exports.Thumbnail=y,exports.UnbanUserEventCommand=nt,exports.UnmuteUserEventCommand=et,exports.UnsentMessageCache=Zs,exports.UpdateFileMessageEventCommand=_t,exports.UpdateMetaCounterEventCommand=He,exports.UpdateMetaDataEventCommand=De,exports.UpdateUserMessageEventCommand=pt,exports.UploadFileRequestCommand=s,exports.UploadFileResponseCommand=i,exports.UploadedFileInfo=b,exports.UserMessage=T,exports.UserMessageEventCommand=ct,exports.UserMessageUpdateParamsDefault=pe,exports.createFileMessageCreateParams=le,exports.createFileMessageCreateParamsFromFailedFileMessage=de,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((e=>{var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((e=>({maxWidth:e.width,maxHeight:e.height}))),_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=ee,exports.createUserMessageCreateParamsFromFailedUserMessage=te,exports.getMessageIndexBy=Hs,exports.parseMessagePayload=O,exports.payloadifyMessage=e=>{switch(e.messageType){case t.MessageType.USER:return T.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?S.payloadify(e):M.payloadify(e);case t.MessageType.ADMIN:return I.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=he,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>J(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>se(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=me; diff --git a/cjs/lib/__bundle-c176c59f.js b/cjs/lib/__bundle-c176c59f.js deleted file mode 100644 index d2559cd..0000000 --- a/cjs/lib/__bundle-c176c59f.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";function e(e,t,s,n){return new(s||(s=Promise))((function(i,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t,s="4.9.7";class n{static get OS_VERSION(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}static get SDK_VERSION(){return s}static get SDK_MAJOR_VERSION(){return n.SDK_VERSION.split(".")[0]}static get DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL(){return 100}static get INTERNAL_CALL(){return"ic"}}exports.SendbirdErrorCode=void 0,(t=exports.SendbirdErrorCode||(exports.SendbirdErrorCode={}))[t.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",t[t.NON_AUTHORIZED=400108]="NON_AUTHORIZED",t[t.INVALID_TOKEN=400111]="INVALID_TOKEN",t[t.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",t[t.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",t[t.LOST_INSTANCE=700100]="LOST_INSTANCE",t[t.CONNECTION_RENEW=700102]="CONNECTION_RENEW",t[t.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",t[t.INVALID_COMMAND=700700]="INVALID_COMMAND",t[t.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",t[t.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",t[t.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",t[t.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",t[t.INVALID_PARAMETER=800110]="INVALID_PARAMETER",t[t.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",t[t.NETWORK_ERROR=800120]="NETWORK_ERROR",t[t.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",t[t.MALFORMED_DATA=800130]="MALFORMED_DATA",t[t.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",t[t.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",t[t.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",t[t.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",t[t.ACK_TIMEOUT=800180]="ACK_TIMEOUT",t[t.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",t[t.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",t[t.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",t[t.REQUEST_FAILED=800220]="REQUEST_FAILED",t[t.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",t[t.REQUEST_CANCELED=800240]="REQUEST_CANCELED",t[t.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",t[t.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",t[t.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",t[t.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",t[t.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",t[t.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",t[t.DATABASE_ERROR=800700]="DATABASE_ERROR";const i=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}static get debugModeRequired(){return new o({code:exports.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}static get lostInstance(){return new o({code:exports.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}static get invalidCommand(){return new o({code:exports.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}static get unknown(){return new o({code:exports.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}static get connectionRenew(){return new o({code:exports.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}static get invalidConnectionStateTransition(){return new o({code:exports.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}static get connectionRequired(){return new o({code:exports.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}static get connectionCanceled(){return new o({code:exports.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}static get invalidParameters(){return new o({code:exports.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}static get notSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}static get networkError(){return new o({code:exports.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}static get markAsReadAllRateLimitExceeded(){return new o({code:exports.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}static get queryInProgress(){return new o({code:exports.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}static get noAckTimeout(){return new o({code:exports.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}static get loginTimeout(){return new o({code:exports.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}static get connectionClosed(){return new o({code:exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}static get requestFailed(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}static get fileUploadCanceled(){return new o({code:exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}static get requestCanceled(){return new o({code:exports.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}static get sessionTokenRefreshFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}static get sessionTokenRequestFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}static get databaseError(){return new o({code:exports.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}static get fileSizeLimitExceededError(){return new o({code:exports.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}throwOutside(){throw this.shouldThrowOutside=!0,this}}const r=[exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.NETWORK_ERROR,exports.SendbirdErrorCode.ACK_TIMEOUT,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,exports.SendbirdErrorCode.REQUEST_CANCELED,exports.SendbirdErrorCode.INTERNAL_SERVER_ERROR,exports.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,exports.SendbirdErrorCode.UNKNOWN_SERVER_ERROR],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED],l=(e,t,s=!1)=>!(!s||null!=t)||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||null!=t)||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||null!=t)||Array.isArray(t)&&t.every((t=>l(e,t))),_=(e,t=!1)=>{if(t&&null==e)return!0;const s="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!s){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return s};class u{constructor({useMemberInfoInMessage:e=!0,typingIndicatorInvalidateTime:t=1e4,typingIndicatorThrottle:s=1e3,websocketResponseTimeout:n=1e4,websocketPayloadDecompression:i=!0,sessionTokenRefreshTimeout:o=60}={}){this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=e,this._typingIndicatorInvalidateTime=t,this._typingIndicatorThrottle=s,this._websocketResponseTimeout=n,this._sessionTokenRefreshTimeout=o,this.websocketPayloadDecompression=i}get useMemberInfoInMessage(){return this._useMemberInfoInMessage}set useMemberInfoInMessage(e){l("boolean",e)&&(this._useMemberInfoInMessage=e)}get typingIndicatorInvalidateTime(){return this._typingIndicatorInvalidateTime}set typingIndicatorInvalidateTime(e){l("number",e)&&(this._typingIndicatorInvalidateTime=e)}get typingIndicatorThrottle(){return this._typingIndicatorThrottle}set typingIndicatorThrottle(e){l("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}get websocketResponseTimeout(){return this._websocketResponseTimeout}set websocketResponseTimeout(e){l("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}get sessionTokenRefreshTimeout(){return this._sessionTokenRefreshTimeout}set sessionTokenRefreshTimeout(e){l("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}const p={encrypt:e=>e,decrypt:e=>e};class E{constructor({store:e}){this._preference=new Map,this._store=e}_savePreferenceKeys(){return e(this,void 0,void 0,(function*(){yield this._store.set({key:this._keysAddress,value:[...this._preference.keys()]})}))}init(t,s=1){var n;return e(this,void 0,void 0,(function*(){this._version=s,this._keysAddress=t;const e=`${t}.metadata.version`,i=yield this._store.get(e),o=null!==(n=yield this._store.get(t))&&void 0!==n?n:[];if(!i||i.versione.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1,this._maxSize=Math.max(e,64),s?(this._clearOrder=t,this._customClearOrderComparator=s):this._clearOrder=T.MESSAGE_COLLECTION_ACCESSED_AT}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===T.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}class N{get hasSession(){return!!this.sessionKey}clear(){this.authToken=void 0,this.sessionKey=void 0}}const y=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};class A{constructor({container:e}){this._container={},this._container=e,this.key=y()}_register(e,t,s){var n;return e in this._container||(this._container[e]=new Map),null===(n=this._container[e])||void 0===n||n.set(this.key,{occurence:t,handler:s}),this}on(e,t){return this._register(e,-1,t)}once(e,t){return this._register(e,1,t)}close(){var e;for(const t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)}}class w{constructor(){this._container={}}on(e,t){return new A({container:this._container}).on(e,t)}once(e,t){return new A({container:this._container}).once(e,t)}dispatch(e,t){const s=this._container[e];if(s){const e=[];for(const n of s.keys()){const i=s.get(n);i.handler(t),i.occurence>0&&(i.occurence--,0===i.occurence&&e.push(n))}e.forEach((e=>s.delete(e)))}}}class b{constructor(){this._dispatcher=new w}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class x{}const k=e=>{const t={};return e&&Object.keys(e).forEach((s=>{void 0===e[s]||Number.isNaN(e[s])||null===e[s]||(t[s]=e[s])})),t},I=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(const e in t)t[e]=I(t[e]);return t}for(const t in e)null===e[t]&&delete e[t];return e}return e}};var R,O,D,L,U,M,P,F,H,z;exports.ChannelType=void 0,(R=exports.ChannelType||(exports.ChannelType={})).BASE="base",R.GROUP="group",R.OPEN="open",R.FEED="feed",exports.Role=void 0,(O=exports.Role||(exports.Role={})).OPERATOR="operator",O.NONE="none",exports.MutedState=void 0,(D=exports.MutedState||(exports.MutedState={})).MUTED="muted",D.UNMUTED="unmuted",exports.MessageType=void 0,(L=exports.MessageType||(exports.MessageType={})).BASE="base",L.USER="user",L.FILE="file",L.ADMIN="admin",exports.MessageTypeFilter=void 0,(U=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",U.USER="MESG",U.FILE="FILE",U.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(M=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.MentionType=void 0,(P=exports.MentionType||(exports.MentionType={})).USERS="users",P.CHANNEL="channel",exports.ReplyType=void 0,(F=exports.ReplyType||(exports.ReplyType={})).ALL="all",F.NONE="none",F.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(H=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",H.SUPPRESS="suppress",exports.SendingStatus=void 0,(z=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",z.SCHEDULED="scheduled",z.SUCCEEDED="succeeded",z.FAILED="failed",z.CANCELED="canceled";const q="v3",V=`/${q}/users`,G=`/${q}/storage/file`,K=`/${q}/group_channels`,B=`/${q}/sdk/group_channels`,Z=`/${q}/open_channels`,j=`/${q}/sdk/open_channels`,W=`/${q}/search`,$=`/${q}/report`,Q=`/${q}/emojis`,Y=`/${q}/emoji_categories`,X=`/${q}/polls`,J=`/${q}/scheduled_messages`,ee=`/${q}/sdk/ui_kit/configuration`,te=`/${q}/sdk/statistics`,se=`/${q}/notifications`,ne=(e,t,s)=>{switch(e){case exports.MentionType.CHANNEL:return!0;case exports.MentionType.USERS:if(t)for(const e of t)if(e===s)return!0}return!1},ie=(e,t,s)=>{var n;let i=t||new FormData;for(const t in e){if(!Object.prototype.hasOwnProperty.call(e,t))continue;const o=e[t],r=s?`${s}[${t}]`:t;_(o)?i.append(r,o,null!==(n=o.name)&&void 0!==n?n:"filename"):"object"!=typeof o||null===o||Array.isArray(o)||o instanceof Blob?i.append(r,String(o)):i=ie(o,i,r)}return i};var oe,re;exports.APIRequestMethod=void 0,(oe=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",oe.POST="POST",oe.PUT="PUT",oe.DELETE="DELETE";class ae extends x{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=y()}encodeParams(e){return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((e=>this.encodeParams(e))).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}get query(){const e=k(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=k(this.params);return Object.keys(e).some((t=>_(e[t])))?ie(e):JSON.stringify(e)}}class le extends x{constructor(e,t){super(),this._iid=e,this._payload=t}get payload(){return Object.assign({},this._payload)}as(e){return new e(this._iid,this.payload)}}class de extends x{constructor(e){super(),this.requestId=e}}class ce extends x{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}){switch(super(),this.expiresIn=null!=e?e:0,t){case exports.SendbirdErrorCode.SESSION_KEY_EXPIRED:case exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED:case exports.SendbirdErrorCode.SESSION_REVOKED:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class he extends x{constructor(e){super(),this.statLog=e}}exports.StatType=void 0,(re=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",re.WEBSOCKET_CONNECT="ws:connect",re.API_RESULT="api:result";class _e{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return k({stat_type:e.type,ts:e.createdAt,data:k(e.data)})}}const ue=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,pe=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var Ee,fe,ge;exports.SendbirdProduct=void 0,(Ee=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",Ee.CALLS="calls",Ee.DESK="desk",Ee.LIVE="live",Ee.UIKIT_CHAT="uikit-chat",Ee.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(fe=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",fe.IOS="ios",fe.JS="js",fe.UNREAL="unreal",fe.UNITY="unity",fe.REACT_NATIVE="react-native",fe.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(ge=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",ge.IOS="ios",ge.WEB="web",ge.MOBILE_WEB="mobile_web",ge.WINDOWS="windows";class ve{}ve.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${ue()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${n.SDK_VERSION}`,device_os_platform:pe()?"mobile-web":"web",os_version:n.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:n,customData:i={}}=e;n.version&&(t.os_version=n.version),n.platform&&(t.device_os_platform=n.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete i[e])),Object.keys(i).length>0&&(t=Object.assign(Object.assign({},t),i))}return Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},ve.userAgentWithExtension=e=>{const t=ue()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",i=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:pe()?"omobile-web":"oweb";return`${t}/c${n.SDK_VERSION}/${s}/${i}/${o}`};class Se{constructor(e,{auth:t,sdkState:s,dispatcher:n,logger:i,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=t,this._sdkState=s,this._dispatcher=n,this._dispatcher.on((e=>{e instanceof de&&this.cancel(e.requestId)})),this._logger=i,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:i,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${n.OS_VERSION},${n.SDK_VERSION},${s}${i?`,${i}`:""}`,"SB-User-Agent":ve.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":ve.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(r["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(r["App-Id"]=s,r["Access-Token"]=this._auth.authToken),r}_statLogApiResult(e,t,s){this._dispatcher.dispatch(new he(new _e({type:exports.StatType.API_RESULT,data:{endpoint:e.path,method:e.method,success:!s,latency:Date.now()-t,error_code:null==s?void 0:s.code,error_description:null==s?void 0:s.message}})))}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s}=t,n=![exports.APIRequestMethod.GET,exports.APIRequestMethod.DELETE].includes(s),{api:i}=this._sdkState,r=`${i.host}${e}${n?"":t.query}`,a=n?t.payload:null,l=this._createHeader(t,a instanceof FormData?a:void 0),d=new AbortController,{signal:c}=d;this._abortControl.set(t.requestId,d);const h=Date.now();try{if(this._shouldImportFetchCompat){this._shouldImportFetchCompat=!1;("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null}"undefined"==typeof AbortController&&(yield Promise.resolve().then((function(){return require("./__bundle-72519a03.js")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-ac62f2cb.js")})));const e=yield fetch(r,{method:s,body:a,headers:l,signal:c}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,h),new le(this._iid,n);if(n){const e=new o(n);throw(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ce({reason:e.code})),this._statLogApiResult(t,h,e),e}{const e=o.requestFailed;throw this._statLogApiResult(t,h,e),e}}catch(e){if(this._statLogApiResult(t,h,e),e instanceof o)throw this._logger.debug("fail api request",e),e;if("AbortError"===e.name)throw o.requestCanceled;{const e=o.networkError;throw this._logger.debug("fail api request",e),e}}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear()}}class me extends x{constructor(e,t,s,n=""){var i;super(),this._iid=e,this.code=t,this.payload=s,this.requestId=null!==(i=s.req_id)&&void 0!==i?i:n}static createFromRawMessage(e,t){let s=t.substring(0,4),n={};try{n=JSON.parse(t.substring(4))}catch(e){s="NOOP"}finally{return new me(e,s,n)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}const Te=()=>{}; -/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function Ce(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ne=256,ye=286,Ae=30,we=15,be=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),xe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ke=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ie=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Re=new Array(576);Ce(Re);const Oe=new Array(60);Ce(Oe);const De=new Array(512);Ce(De);const Le=new Array(256);Ce(Le);const Ue=new Array(29);Ce(Ue);const Me=new Array(Ae);function Pe(e,t,s,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let Fe,He,ze;function qe(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ce(Me);const Ve=e=>e<256?De[e]:De[256+(e>>>7)],Ge=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ke=(e,t,s)=>{e.bi_valid>16-s?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<{Ke(e,s[2*t],s[2*t+1])},Ze=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},je=(e,t,s)=>{const n=new Array(16);let i,o,r=0;for(i=1;i<=we;i++)r=r+s[i-1]<<1,n[i]=r;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=Ze(n[t]++,t))}},We=e=>{let t;for(t=0;t{e.bi_valid>8?Ge(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Qe=(e,t,s,n)=>{const i=2*t,o=2*s;return e[i]{const n=e.heap[s];let i=s<<1;for(;i<=e.heap_len&&(i{let n,i,o,r,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===n?Be(e,i,t):(o=Le[i],Be(e,o+Ne+1,t),r=be[o],0!==r&&(i-=Ue[o],Ke(e,i,r)),n--,o=Ve(n),Be(e,o,s),r=xe[o],0!==r&&(n-=Me[o],Ke(e,n,r)))}while(a{const s=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let r,a,l,d=-1;for(e.heap_len=0,e.heap_max=573,r=0;r>1;r>=1;r--)Ye(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ye(e,s,1),a=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=a,s[2*l]=s[2*r]+s[2*a],e.depth[l]=(e.depth[r]>=e.depth[a]?e.depth[r]:e.depth[a])+1,s[2*r+1]=s[2*a+1]=l,e.heap[1]=l++,Ye(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const s=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let d,c,h,_,u,p,E=0;for(_=0;_<=we;_++)e.bl_count[_]=0;for(s[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)c=e.heap[d],_=s[2*s[2*c+1]+1]+1,_>l&&(_=l,E++),s[2*c+1]=_,c>n||(e.bl_count[_]++,u=0,c>=a&&(u=r[c-a]),p=s[2*c],e.opt_len+=p*(_+u),o&&(e.static_len+=p*(i[2*c+1]+u)));if(0!==E){do{for(_=l-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[l]--,E-=2}while(E>0);for(_=l;0!==_;_--)for(c=e.bl_count[_];0!==c;)h=e.heap[--d],h>n||(s[2*h+1]!==_&&(e.opt_len+=(_-s[2*h+1])*s[2*h],s[2*h+1]=_),c--)}})(e,t),je(s,d,e.bl_count)},et=(e,t,s)=>{let n,i,o=-1,r=t[1],a=0,l=7,d=4;for(0===r&&(l=138,d=3),t[2*(s+1)+1]=65535,n=0;n<=s;n++)i=r,r=t[2*(n+1)+1],++a{let n,i,o=-1,r=t[1],a=0,l=7,d=4;for(0===r&&(l=138,d=3),n=0;n<=s;n++)if(i=r,r=t[2*(n+1)+1],!(++a{Ke(e,0+(n?1:0),3),$e(e),Ge(e,s),Ge(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var it=(e,t,s,n)=>{let i,o,r=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(et(e,e.dyn_ltree,e.l_desc.max_code),et(e,e.dyn_dtree,e.d_desc.max_code),Je(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ie[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=s+5,s+4<=i&&-1!==t?nt(e,t,s,n):4===e.strategy||o===i?(Ke(e,2+(n?1:0),3),Xe(e,Re,Oe)):(Ke(e,4+(n?1:0),3),((e,t,s,n)=>{let i;for(Ke(e,t-257,5),Ke(e,s-1,5),Ke(e,n-4,4),i=0;i{st||((()=>{let e,t,s,n,i;const o=new Array(16);for(s=0,n=0;n<28;n++)for(Ue[n]=s,e=0;e<1<>=7;n(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=s,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[2*(Le[s]+Ne+1)]++,e.dyn_dtree[2*Ve(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ke(e,2,3),Be(e,256,Re),(e=>{16===e.bi_valid?(Ge(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var rt=(e,t,s,n)=>{let i=65535&e|0,o=e>>>16&65535|0,r=0;for(;0!==s;){r=s>2e3?2e3:s,s-=r;do{i=i+t[n++]|0,o=o+i|0}while(--r);i%=65521,o%=65521}return i|o<<16|0};const at=new Uint32Array((()=>{let e,t=[];for(var s=0;s<256;s++){e=s;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t})());var lt=(e,t,s,n)=>{const i=at,o=n+s;e^=-1;for(let s=n;s>>8^i[255&(e^t[s])];return-1^e},dt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ct={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ht,_tr_stored_block:_t,_tr_flush_block:ut,_tr_tally:pt,_tr_align:Et}=ot,{Z_NO_FLUSH:ft,Z_PARTIAL_FLUSH:gt,Z_FULL_FLUSH:vt,Z_FINISH:St,Z_BLOCK:mt,Z_OK:Tt,Z_STREAM_END:Ct,Z_STREAM_ERROR:Nt,Z_DATA_ERROR:yt,Z_BUF_ERROR:At,Z_DEFAULT_COMPRESSION:wt,Z_FILTERED:bt,Z_HUFFMAN_ONLY:xt,Z_RLE:kt,Z_FIXED:It,Z_DEFAULT_STRATEGY:Rt,Z_UNKNOWN:Ot,Z_DEFLATED:Dt}=ct,Lt=258,Ut=262,Mt=42,Pt=113,Ft=666,Ht=(e,t)=>(e.msg=dt[t],t),zt=e=>2*e-(e>4?9:0),qt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Vt=e=>{let t,s,n,i=e.w_size;t=e.hash_size,n=t;do{s=e.head[--n],e.head[n]=s>=i?s-i:0}while(--t);t=i,n=t;do{s=e.prev[--n],e.prev[n]=s>=i?s-i:0}while(--t)};let Gt=(e,t,s)=>(t<{const t=e.state;let s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+s),e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))},Bt=(e,t)=>{ut(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Kt(e.strm)},Zt=(e,t)=>{e.pending_buf[e.pending++]=t},jt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Wt=(e,t,s,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),s),1===e.state.wrap?e.adler=rt(e.adler,t,i,s):2===e.state.wrap&&(e.adler=lt(e.adler,t,i,s)),e.next_in+=i,e.total_in+=i,i)},$t=(e,t)=>{let s,n,i=e.max_chain_length,o=e.strstart,r=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-Ut?e.strstart-(e.w_size-Ut):0,d=e.window,c=e.w_mask,h=e.prev,_=e.strstart+Lt;let u=d[o+r-1],p=d[o+r];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(s=t,d[s+r]===p&&d[s+r-1]===u&&d[s]===d[o]&&d[++s]===d[o+1]){o+=2,s++;do{}while(d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&o<_);if(n=Lt-(_-o),o=_-Lt,n>r){if(e.match_start=t,r=n,n>=a)break;u=d[o+r-1],p=d[o+r]}}}while((t=h[t&c])>l&&0!=--i);return r<=e.lookahead?r:e.lookahead},Qt=e=>{const t=e.w_size;let s,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ut)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Vt(e),n+=t),0===e.strm.avail_in)break;if(s=Wt(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=s,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Gt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Gt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let s,n,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r=0,a=e.strm.avail_in;do{if(s=65535,i=e.bi_valid+42>>3,e.strm.avail_outn+e.strm.avail_in&&(s=n+e.strm.avail_in),s>i&&(s=i),s>8,e.pending_buf[e.pending-2]=~s,e.pending_buf[e.pending-1]=~s>>8,Kt(e.strm),n&&(n>s&&(n=s),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,s-=n),s&&(Wt(e.strm,e.strm.output,e.strm.next_out,s),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s)}while(0===r);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(Wt(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,n=e.strstart-e.block_start,(n>=o||(n||t===St)&&t!==ft&&0===e.strm.avail_in&&n<=i)&&(s=n>i?i:n,r=t===St&&0===e.strm.avail_in&&s===n?1:0,_t(e,e.block_start,s,r),e.block_start+=s,Kt(e.strm)),r?3:1)},Xt=(e,t)=>{let s,n;for(;;){if(e.lookahead=3&&(e.ins_h=Gt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-Ut&&(e.match_length=$t(e,s)),e.match_length>=3)if(n=pt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Gt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Gt(e,e.ins_h,e.window[e.strstart+1]);else n=pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Bt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===St?(Bt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Bt(e,!1),0===e.strm.avail_out)?1:2},Jt=(e,t)=>{let s,n,i;for(;;){if(e.lookahead=3&&(e.ins_h=Gt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==s&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=pt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Gt(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(Bt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=pt(e,0,e.window[e.strstart-1]),n&&Bt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=pt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===St?(Bt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Bt(e,!1),0===e.strm.avail_out)?1:2};function es(e,t,s,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=n,this.func=i}const ts=[new es(0,0,0,0,Yt),new es(4,4,8,4,Xt),new es(4,5,16,8,Xt),new es(4,6,32,32,Xt),new es(4,4,16,16,Jt),new es(8,16,32,32,Jt),new es(8,16,128,128,Jt),new es(8,32,128,256,Jt),new es(32,128,258,1024,Jt),new es(32,258,258,4096,Jt)];function ss(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Dt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),qt(this.dyn_ltree),qt(this.dyn_dtree),qt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),qt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),qt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const ns=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Mt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Pt&&t.status!==Ft?1:0},is=e=>{if(ns(e))return Ht(e,Nt);e.total_in=e.total_out=0,e.data_type=Ot;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Mt:Pt,e.adler=2===t.wrap?0:1,t.last_flush=-2,ht(t),Tt},os=e=>{const t=is(e);var s;return t===Tt&&((s=e.state).window_size=2*s.w_size,qt(s.head),s.max_lazy_match=ts[s.level].max_lazy,s.good_match=ts[s.level].good_length,s.nice_match=ts[s.level].nice_length,s.max_chain_length=ts[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=2,s.match_available=0,s.ins_h=0),t},rs=(e,t,s,n,i,o)=>{if(!e)return Nt;let r=1;if(t===wt&&(t=6),n<0?(r=0,n=-n):n>15&&(r=2,n-=16),i<1||i>9||s!==Dt||n<8||n>15||t<0||t>9||o<0||o>It||8===n&&1!==r)return Ht(e,Nt);8===n&&(n=9);const a=new ss;return e.state=a,a.strm=e,a.status=Mt,a.wrap=r,a.gzhead=null,a.w_bits=n,a.w_size=1<rs(e,t,Dt,15,8,Rt),deflateInit2:rs,deflateReset:os,deflateResetKeep:is,deflateSetHeader:(e,t)=>ns(e)||2!==e.state.wrap?Nt:(e.state.gzhead=t,Tt),deflate:(e,t)=>{if(ns(e)||t>mt||t<0)return e?Ht(e,Nt):Nt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===Ft&&t!==St)return Ht(e,0===e.avail_out?At:Nt);const n=s.last_flush;if(s.last_flush=t,0!==s.pending){if(Kt(e),0===e.avail_out)return s.last_flush=-1,Tt}else if(0===e.avail_in&&zt(t)<=zt(n)&&t!==St)return Ht(e,At);if(s.status===Ft&&0!==e.avail_in)return Ht(e,At);if(s.status===Mt&&0===s.wrap&&(s.status=Pt),s.status===Mt){let t=Dt+(s.w_bits-8<<4)<<8,n=-1;if(n=s.strategy>=xt||s.level<2?0:s.level<6?1:6===s.level?2:3,t|=n<<6,0!==s.strstart&&(t|=32),t+=31-t%31,jt(s,t),0!==s.strstart&&(jt(s,e.adler>>>16),jt(s,65535&e.adler)),e.adler=1,s.status=Pt,Kt(e),0!==s.pending)return s.last_flush=-1,Tt}if(57===s.status)if(e.adler=0,Zt(s,31),Zt(s,139),Zt(s,8),s.gzhead)Zt(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),Zt(s,255&s.gzhead.time),Zt(s,s.gzhead.time>>8&255),Zt(s,s.gzhead.time>>16&255),Zt(s,s.gzhead.time>>24&255),Zt(s,9===s.level?2:s.strategy>=xt||s.level<2?4:0),Zt(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(Zt(s,255&s.gzhead.extra.length),Zt(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=lt(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(Zt(s,0),Zt(s,0),Zt(s,0),Zt(s,0),Zt(s,0),Zt(s,9===s.level?2:s.strategy>=xt||s.level<2?4:0),Zt(s,3),s.status=Pt,Kt(e),0!==s.pending)return s.last_flush=-1,Tt;if(69===s.status){if(s.gzhead.extra){let t=s.pending,n=(65535&s.gzhead.extra.length)-s.gzindex;for(;s.pending+n>s.pending_buf_size;){let i=s.pending_buf_size-s.pending;if(s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex,s.gzindex+i),s.pending),s.pending=s.pending_buf_size,s.gzhead.hcrc&&s.pending>t&&(e.adler=lt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=i,Kt(e),0!==s.pending)return s.last_flush=-1,Tt;t=0,n-=i}let i=new Uint8Array(s.gzhead.extra);s.pending_buf.set(i.subarray(s.gzindex,s.gzindex+n),s.pending),s.pending+=n,s.gzhead.hcrc&&s.pending>t&&(e.adler=lt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex=0}s.status=73}if(73===s.status){if(s.gzhead.name){let t,n=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>n&&(e.adler=lt(e.adler,s.pending_buf,s.pending-n,n)),Kt(e),0!==s.pending)return s.last_flush=-1,Tt;n=0}t=s.gzindexn&&(e.adler=lt(e.adler,s.pending_buf,s.pending-n,n)),s.gzindex=0}s.status=91}if(91===s.status){if(s.gzhead.comment){let t,n=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>n&&(e.adler=lt(e.adler,s.pending_buf,s.pending-n,n)),Kt(e),0!==s.pending)return s.last_flush=-1,Tt;n=0}t=s.gzindexn&&(e.adler=lt(e.adler,s.pending_buf,s.pending-n,n))}s.status=103}if(103===s.status){if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size&&(Kt(e),0!==s.pending))return s.last_flush=-1,Tt;Zt(s,255&e.adler),Zt(s,e.adler>>8&255),e.adler=0}if(s.status=Pt,Kt(e),0!==s.pending)return s.last_flush=-1,Tt}if(0!==e.avail_in||0!==s.lookahead||t!==ft&&s.status!==Ft){let n=0===s.level?Yt(s,t):s.strategy===xt?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(Qt(e),0===e.lookahead)){if(t===ft)return 1;break}if(e.match_length=0,s=pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(Bt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===St?(Bt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Bt(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===kt?((e,t)=>{let s,n,i,o;const r=e.window;for(;;){if(e.lookahead<=Lt){if(Qt(e),e.lookahead<=Lt&&t===ft)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,n=r[i],n===r[++i]&&n===r[++i]&&n===r[++i])){o=e.strstart+Lt;do{}while(n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&n===r[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=pt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=pt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(Bt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===St?(Bt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Bt(e,!1),0===e.strm.avail_out)?1:2})(s,t):ts[s.level].func(s,t);if(3!==n&&4!==n||(s.status=Ft),1===n||3===n)return 0===e.avail_out&&(s.last_flush=-1),Tt;if(2===n&&(t===gt?Et(s):t!==mt&&(_t(s,0,0,!1),t===vt&&(qt(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),Kt(e),0===e.avail_out))return s.last_flush=-1,Tt}return t!==St?Tt:s.wrap<=0?Ct:(2===s.wrap?(Zt(s,255&e.adler),Zt(s,e.adler>>8&255),Zt(s,e.adler>>16&255),Zt(s,e.adler>>24&255),Zt(s,255&e.total_in),Zt(s,e.total_in>>8&255),Zt(s,e.total_in>>16&255),Zt(s,e.total_in>>24&255)):(jt(s,e.adler>>>16),jt(s,65535&e.adler)),Kt(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Tt:Ct)},deflateEnd:e=>{if(ns(e))return Nt;const t=e.state.status;return e.state=null,t===Pt?Ht(e,yt):Tt},deflateSetDictionary:(e,t)=>{let s=t.length;if(ns(e))return Nt;const n=e.state,i=n.wrap;if(2===i||1===i&&n.status!==Mt||n.lookahead)return Nt;if(1===i&&(e.adler=rt(e.adler,t,s,0)),n.wrap=0,s>=n.w_size){0===i&&(qt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(s-n.w_size,s),0),t=e,s=n.w_size}const o=e.avail_in,r=e.next_in,a=e.input;for(e.avail_in=s,e.next_in=0,e.input=t,Qt(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=Gt(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,Qt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=r,e.input=a,e.avail_in=o,n.wrap=i,Tt},deflateInfo:"pako deflate (from Nodeca project)"};const ls=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var ds={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const s=t.shift();if(s){if("object"!=typeof s)throw new TypeError(s+"must be non-object");for(const t in s)ls(s,t)&&(e[t]=s[t])}}return e},flattenChunks:e=>{let t=0;for(let s=0,n=e.length;s=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;hs[254]=hs[254]=1;var _s={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,s,n,i,o,r=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&s):s<65536?(t[o++]=224|s>>>12,t[o++]=128|s>>>6&63,t[o++]=128|63&s):(t[o++]=240|s>>>18,t[o++]=128|s>>>12&63,t[o++]=128|s>>>6&63,t[o++]=128|63&s);return t},buf2string:(e,t)=>{const s=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const o=new Array(2*s);for(i=0,n=0;n4)o[i++]=65533,n+=r-1;else{for(t&=2===r?31:3===r?15:7;r>1&&n1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&cs)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let s="";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let s=t-1;for(;s>=0&&128==(192&e[s]);)s--;return s<0||0===s?t:s+hs[e[s]]>t?s:t}};var us=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const ps=Object.prototype.toString,{Z_NO_FLUSH:Es,Z_SYNC_FLUSH:fs,Z_FULL_FLUSH:gs,Z_FINISH:vs,Z_OK:Ss,Z_STREAM_END:ms,Z_DEFAULT_COMPRESSION:Ts,Z_DEFAULT_STRATEGY:Cs,Z_DEFLATED:Ns}=ct;function ys(e){this.options=ds.assign({level:Ts,method:Ns,chunkSize:16384,windowBits:15,memLevel:8,strategy:Cs},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new us,this.strm.avail_out=0;let s=as.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==Ss)throw new Error(dt[s]);if(t.header&&as.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?_s.string2buf(t.dictionary):"[object ArrayBuffer]"===ps.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=as.deflateSetDictionary(this.strm,e),s!==Ss)throw new Error(dt[s]);this._dict_set=!0}}function As(e,t){const s=new ys(t);if(s.push(e,!0),s.err)throw s.msg||dt[s.err];return s.result}ys.prototype.push=function(e,t){const s=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?vs:Es,"string"==typeof e?s.input=_s.string2buf(e):"[object ArrayBuffer]"===ps.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;)if(0===s.avail_out&&(s.output=new Uint8Array(n),s.next_out=0,s.avail_out=n),(o===fs||o===gs)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(i=as.deflate(s,o),i===ms)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),i=as.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Ss;if(0!==s.avail_out){if(o>0&&s.next_out>0)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else if(0===s.avail_in)break}else this.onData(s.output)}return!0},ys.prototype.onData=function(e){this.chunks.push(e)},ys.prototype.onEnd=function(e){e===Ss&&(this.result=ds.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ws={Deflate:ys,deflate:As,deflateRaw:function(e,t){return(t=t||{}).raw=!0,As(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,As(e,t)},constants:ct};const bs=16209;var xs=function(e,t){let s,n,i,o,r,a,l,d,c,h,_,u,p,E,f,g,v,S,m,T,C,N,y,A;const w=e.state;s=e.next_in,y=e.input,n=s+(e.avail_in-5),i=e.next_out,A=e.output,o=i-(t-e.avail_out),r=i+(e.avail_out-257),a=w.dmax,l=w.wsize,d=w.whave,c=w.wnext,h=w.window,_=w.hold,u=w.bits,p=w.lencode,E=w.distcode,f=(1<>>24,_>>>=S,u-=S,S=v>>>16&255,0===S)A[i++]=65535&v;else{if(!(16&S)){if(0==(64&S)){v=p[(65535&v)+(_&(1<>>=S,u-=S),u<15&&(_+=y[s++]<>>24,_>>>=S,u-=S,S=v>>>16&255,!(16&S)){if(0==(64&S)){v=E[(65535&v)+(_&(1<a){e.msg="invalid distance too far back",w.mode=bs;break e}if(_>>>=S,u-=S,S=i-o,T>S){if(S=T-S,S>d&&w.sane){e.msg="invalid distance too far back",w.mode=bs;break e}if(C=0,N=h,0===c){if(C+=l-S,S2;)A[i++]=N[C++],A[i++]=N[C++],A[i++]=N[C++],m-=3;m&&(A[i++]=N[C++],m>1&&(A[i++]=N[C++]))}else{C=i-T;do{A[i++]=A[C++],A[i++]=A[C++],A[i++]=A[C++],m-=3}while(m>2);m&&(A[i++]=A[C++],m>1&&(A[i++]=A[C++]))}break}}break}}while(s>3,s-=m,u-=m<<3,_&=(1<{const l=a.bits;let d,c,h,_,u,p,E=0,f=0,g=0,v=0,S=0,m=0,T=0,C=0,N=0,y=0,A=null;const w=new Uint16Array(16),b=new Uint16Array(16);let x,k,I,R=null;for(E=0;E<=ks;E++)w[E]=0;for(f=0;f=1&&0===w[v];v--);if(S>v&&(S=v),0===v)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(b[1]=0,E=1;E852||2===e&&N>592)return 1;for(;;){x=E-T,r[f]+1=p?(k=R[r[f]-p],I=A[r[f]-p]):(k=96,I=0),d=1<>T)+c]=x<<24|k<<16|I|0}while(0!==c);for(d=1<>=1;if(0!==d?(y&=d-1,y+=d):y=0,f++,0==--w[E]){if(E===v)break;E=t[s+r[f]]}if(E>S&&(y&_)!==h){for(0===T&&(T=S),u+=g,m=E-T,C=1<852||2===e&&N>592)return 1;h=y&_,i[h]=S<<24|m<<16|u-o|0}}return 0!==y&&(i[u+y]=E-T<<24|64<<16|0),a.bits=S,0};const{Z_FINISH:Us,Z_BLOCK:Ms,Z_TREES:Ps,Z_OK:Fs,Z_STREAM_END:Hs,Z_NEED_DICT:zs,Z_STREAM_ERROR:qs,Z_DATA_ERROR:Vs,Z_MEM_ERROR:Gs,Z_BUF_ERROR:Ks,Z_DEFLATED:Bs}=ct,Zs=16180,js=16190,Ws=16191,$s=16192,Qs=16194,Ys=16199,Xs=16200,Js=16206,en=16209,tn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function sn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const nn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},on=e=>{if(nn(e))return qs;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Zs,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Fs},rn=e=>{if(nn(e))return qs;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,on(e)},an=(e,t)=>{let s;if(nn(e))return qs;const n=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?qs:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,rn(e))},ln=(e,t)=>{if(!e)return qs;const s=new sn;e.state=s,s.strm=e,s.window=null,s.mode=Zs;const n=an(e,t);return n!==Fs&&(e.state=null),n};let dn,cn,hn=!0;const _n=e=>{if(hn){dn=new Int32Array(512),cn=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Ls(1,e.lens,0,288,dn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ls(2,e.lens,0,32,cn,0,e.work,{bits:5}),hn=!1}e.lencode=dn,e.lenbits=9,e.distcode=cn,e.distbits=5},un=(e,t,s,n)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(s-o.wsize,s),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(t.subarray(s-n,s-n+i),o.wnext),(n-=i)?(o.window.set(t.subarray(s-n,s),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whaveln(e,15),inflateInit2:ln,inflate:(e,t)=>{let s,n,i,o,r,a,l,d,c,h,_,u,p,E,f,g,v,S,m,T,C,N,y=0;const A=new Uint8Array(4);let w,b;const x=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(nn(e)||!e.output||!e.input&&0!==e.avail_in)return qs;s=e.state,s.mode===Ws&&(s.mode=$s),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,d=s.hold,c=s.bits,h=a,_=l,N=Fs;e:for(;;)switch(s.mode){case Zs:if(0===s.wrap){s.mode=$s;break}for(;c<16;){if(0===a)break e;a--,d+=n[o++]<>>8&255,s.check=lt(s.check,A,2,0),d=0,c=0,s.mode=16181;break}if(s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",s.mode=en;break}if((15&d)!==Bs){e.msg="unknown compression method",s.mode=en;break}if(d>>>=4,c-=4,C=8+(15&d),0===s.wbits&&(s.wbits=C),C>15||C>s.wbits){e.msg="invalid window size",s.mode=en;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(A[0]=255&d,A[1]=d>>>8&255,s.check=lt(s.check,A,2,0)),d=0,c=0,s.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,d+=n[o++]<>>8&255,A[2]=d>>>16&255,A[3]=d>>>24&255,s.check=lt(s.check,A,4,0)),d=0,c=0,s.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,d+=n[o++]<>8),512&s.flags&&4&s.wrap&&(A[0]=255&d,A[1]=d>>>8&255,s.check=lt(s.check,A,2,0)),d=0,c=0,s.mode=16184;case 16184:if(1024&s.flags){for(;c<16;){if(0===a)break e;a--,d+=n[o++]<>>8&255,s.check=lt(s.check,A,2,0)),d=0,c=0}else s.head&&(s.head.extra=null);s.mode=16185;case 16185:if(1024&s.flags&&(u=s.length,u>a&&(u=a),u&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(n.subarray(o,o+u),C)),512&s.flags&&4&s.wrap&&(s.check=lt(s.check,n,u,o)),a-=u,o+=u,s.length-=u),s.length))break e;s.length=0,s.mode=16186;case 16186:if(2048&s.flags){if(0===a)break e;u=0;do{C=n[o+u++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C))}while(C&&u>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=Ws;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=n[o++]<>>=7&c,c-=7&c,s.mode=Js;break}for(;c<3;){if(0===a)break e;a--,d+=n[o++]<>>=1,c-=1,3&d){case 0:s.mode=16193;break;case 1:if(_n(s),s.mode=Ys,t===Ps){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=en}d>>>=2,c-=2;break;case 16193:for(d>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,d+=n[o++]<>>16^65535)){e.msg="invalid stored block lengths",s.mode=en;break}if(s.length=65535&d,d=0,c=0,s.mode=Qs,t===Ps)break e;case Qs:s.mode=16195;case 16195:if(u=s.length,u){if(u>a&&(u=a),u>l&&(u=l),0===u)break e;i.set(n.subarray(o,o+u),r),a-=u,o+=u,l-=u,r+=u,s.length-=u;break}s.mode=Ws;break;case 16196:for(;c<14;){if(0===a)break e;a--,d+=n[o++]<>>=5,c-=5,s.ndist=1+(31&d),d>>>=5,c-=5,s.ncode=4+(15&d),d>>>=4,c-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=en;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[x[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},N=Ls(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,N){e.msg="invalid code lengths set",s.mode=en;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,g=y>>>16&255,v=65535&y,!(f<=c);){if(0===a)break e;a--,d+=n[o++]<>>=f,c-=f,s.lens[s.have++]=v;else{if(16===v){for(b=f+2;c>>=f,c-=f,0===s.have){e.msg="invalid bit length repeat",s.mode=en;break}C=s.lens[s.have-1],u=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=f+3;c>>=f,c-=f,C=0,u=3+(7&d),d>>>=3,c-=3}else{for(b=f+7;c>>=f,c-=f,C=0,u=11+(127&d),d>>>=7,c-=7}if(s.have+u>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=en;break}for(;u--;)s.lens[s.have++]=C}}if(s.mode===en)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=en;break}if(s.lenbits=9,w={bits:s.lenbits},N=Ls(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,N){e.msg="invalid literal/lengths set",s.mode=en;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},N=Ls(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,N){e.msg="invalid distances set",s.mode=en;break}if(s.mode=Ys,t===Ps)break e;case Ys:s.mode=Xs;case Xs:if(a>=6&&l>=258){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=d,s.bits=c,xs(e,_),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,d=s.hold,c=s.bits,s.mode===Ws&&(s.back=-1);break}for(s.back=0;y=s.lencode[d&(1<>>24,g=y>>>16&255,v=65535&y,!(f<=c);){if(0===a)break e;a--,d+=n[o++]<>S)],f=y>>>24,g=y>>>16&255,v=65535&y,!(S+f<=c);){if(0===a)break e;a--,d+=n[o++]<>>=S,c-=S,s.back+=S}if(d>>>=f,c-=f,s.back+=f,s.length=v,0===g){s.mode=16205;break}if(32&g){s.back=-1,s.mode=Ws;break}if(64&g){e.msg="invalid literal/length code",s.mode=en;break}s.extra=15&g,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;y=s.distcode[d&(1<>>24,g=y>>>16&255,v=65535&y,!(f<=c);){if(0===a)break e;a--,d+=n[o++]<>S)],f=y>>>24,g=y>>>16&255,v=65535&y,!(S+f<=c);){if(0===a)break e;a--,d+=n[o++]<>>=S,c-=S,s.back+=S}if(d>>>=f,c-=f,s.back+=f,64&g){e.msg="invalid distance code",s.mode=en;break}s.offset=v,s.extra=15&g,s.mode=16203;case 16203:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=en;break}s.mode=16204;case 16204:if(0===l)break e;if(u=_-l,s.offset>u){if(u=s.offset-u,u>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=en;break}u>s.wnext?(u-=s.wnext,p=s.wsize-u):p=s.wnext-u,u>s.length&&(u=s.length),E=s.window}else E=i,p=r-s.offset,u=s.length;u>l&&(u=l),l-=u,s.length-=u;do{i[r++]=E[p++]}while(--u);0===s.length&&(s.mode=Xs);break;case 16205:if(0===l)break e;i[r++]=s.length,l--,s.mode=Xs;break;case Js:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=n[o++]<{if(nn(e))return qs;let t=e.state;return t.window&&(t.window=null),e.state=null,Fs},inflateGetHeader:(e,t)=>{if(nn(e))return qs;const s=e.state;return 0==(2&s.wrap)?qs:(s.head=t,t.done=!1,Fs)},inflateSetDictionary:(e,t)=>{const s=t.length;let n,i,o;return nn(e)?qs:(n=e.state,0!==n.wrap&&n.mode!==js?qs:n.mode===js&&(i=1,i=rt(i,t,s,0),i!==n.check)?Vs:(o=un(e,t,s,s),o?(n.mode=16210,Gs):(n.havedict=1,Fs)))},inflateInfo:"pako inflate (from Nodeca project)"};var En=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const fn=Object.prototype.toString,{Z_NO_FLUSH:gn,Z_FINISH:vn,Z_OK:Sn,Z_STREAM_END:mn,Z_NEED_DICT:Tn,Z_STREAM_ERROR:Cn,Z_DATA_ERROR:Nn,Z_MEM_ERROR:yn}=ct;function An(e){this.options=ds.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new us,this.strm.avail_out=0;let s=pn.inflateInit2(this.strm,t.windowBits);if(s!==Sn)throw new Error(dt[s]);if(this.header=new En,pn.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=_s.string2buf(t.dictionary):"[object ArrayBuffer]"===fn.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=pn.inflateSetDictionary(this.strm,t.dictionary),s!==Sn)))throw new Error(dt[s])}function wn(e,t){const s=new An(t);if(s.push(e),s.err)throw s.msg||dt[s.err];return s.result}An.prototype.push=function(e,t){const s=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,r,a;if(this.ended)return!1;for(r=t===~~t?t:!0===t?vn:gn,"[object ArrayBuffer]"===fn.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;){for(0===s.avail_out&&(s.output=new Uint8Array(n),s.next_out=0,s.avail_out=n),o=pn.inflate(s,r),o===Tn&&i&&(o=pn.inflateSetDictionary(s,i),o===Sn?o=pn.inflate(s,r):o===Nn&&(o=Tn));s.avail_in>0&&o===mn&&s.state.wrap>0&&0!==e[s.next_in];)pn.inflateReset(s),o=pn.inflate(s,r);switch(o){case Cn:case Nn:case Tn:case yn:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===mn))if("string"===this.options.to){let e=_s.utf8border(s.output,s.next_out),t=s.next_out-e,i=_s.buf2string(s.output,e);s.next_out=t,s.avail_out=n-t,t&&s.output.set(s.output.subarray(e,e+t),0),this.onData(i)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(o!==Sn||0!==a){if(o===mn)return o=pn.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},An.prototype.onData=function(e){this.chunks.push(e)},An.prototype.onEnd=function(e){e===Sn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=ds.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var bn={Inflate:An,inflate:wn,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wn(e,t)},ungzip:wn,constants:ct};const{Deflate:xn,deflate:kn,deflateRaw:In,gzip:Rn}=ws,{Inflate:On,inflate:Dn,inflateRaw:Ln,ungzip:Un}=bn;var Mn={Deflate:xn,deflate:kn,deflateRaw:In,gzip:Rn,Inflate:On,inflate:Dn,inflateRaw:Ln,ungzip:Un,constants:ct};var Pn,Fn;exports.ConnectionState=void 0,(Pn=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",Pn.OPEN="OPEN",Pn.CLOSED="CLOSED";class Hn extends w{constructor(e,{sdkState:t,dispatcher:s,logger:n}){super(),this.lastActive=0,this._iid=e,this._sdkState=t,this._dispatcher=s,this._logger=n}get isOpen(){return this.connectionState===exports.ConnectionState.OPEN}get connectionState(){if(this._ws)switch(this._ws.readyState){case 0:return exports.ConnectionState.CONNECTING;case 1:return exports.ConnectionState.OPEN}return exports.ConnectionState.CLOSED}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=me.createFromRawMessage(this._iid,e);if(this._logger.debug("receive websocket event",t),"LOGI"===t.code)this.dispatch("message",t);else if("PONG"===t.code)this.dispatch("pong");else if("EXPR"===t.code){if(t.payload){const e=new ce(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t){this._ws=new WebSocket(t),this._ws.onopen=()=>{this._logger.debug("websocket open"),this.dispatch("open")},this._ws.onmessage=t=>e(this,void 0,void 0,(function*(){var s;if(null===(s=this._sdkState.websocket)||void 0===s?void 0:s.compression)if(t.data instanceof Blob){const s=new FileReader;s.readAsArrayBuffer(t.data),s.onloadend=()=>e(this,void 0,void 0,(function*(){const t=yield(n=s.result,e(void 0,void 0,void 0,(function*(){const e=Mn.ungzip(n);return String.fromCharCode.apply(null,e)})));var n;this._handleMessage(t)}))}else"string"==typeof t.data&&this._handleMessage(t.data);else this._handleMessage(t.data)})),this._ws.onerror=()=>{this._logger.debug("websocket error"),this.dispatch("error",o.networkError)},this._ws.onclose=()=>{this._logger.debug("websocket close"),this.dispatch("close")},this.lastActive=Date.now()}disconnect(){return new Promise((e=>{this._logger.debug("websocket disconnect"),this._ws&&this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onopen=Te,this._ws.onmessage=Te,this._ws.onerror=Te,this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()}))}send(e){if(!this._ws)throw o.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}error(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}class zn extends x{constructor({code:e,ackRequired:t,payload:s={}}){var n;super(),this.code=e,this.payload=s,this.requestId=null!==(n=this.payload.req_id)&&void 0!==n?n:y(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class qn extends x{constructor({all:e,feed:t,custom_types:s,ts:n}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=n}}class Vn{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Gn{constructor(e,{auth:t,sdkState:s,dispatcher:n,logger:i,useFetchCompat:r=!1}){this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=n,this._logger=i,this.apiClient=new Se(e,{auth:t,sdkState:s,dispatcher:n,logger:i,useFetchCompat:r}),this.websocketClient=new Hn(e,{sdkState:s,dispatcher:n,logger:i}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new qn(e.payload.unread_cnt)),e.requestId){if(this._ackStateMap.has(e.requestId)){const t=this._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new o({code:e.payload.code,message:e.payload.message}))}}else this._dispatcher.dispatch(e)})).on("close",(()=>{this._ackStateMap.forEach((e=>{e.reject(o.connectionClosed)})),this._ackStateMap.clear()}))}_sendApiRequest(t){return e(this,void 0,void 0,(function*(){return yield this.apiClient.send(t)}))}_sendWebsocketRequest(t){return e(this,void 0,void 0,(function*(){if(!this._sdkState.websocket)throw o.connectionRequired;const e=new Vn;if(t.ackRequired){let s;const n=(n,i)=>{this._ackStateMap.has(t.requestId)&&(this._ackStateMap.delete(t.requestId),s&&(clearTimeout(s),s=null),n?(this._logger.debug("fail websocket request",n),e.reject(n)):(this._logger.debug("receive websocket ack",t.requestId),e.resolve(i)))};try{s=setTimeout((()=>n(o.noAckTimeout)),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(t.requestId,{resolve:e=>n(void 0,e),reject:e=>n(e)}),this.websocketClient.send(t)}catch(e){n(e)}}else try{this.websocketClient.send(t),e.resolve()}catch(t){e.reject(t)}return e.promise}))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof ae)return yield this._sendApiRequest(t);if(t instanceof zn)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(Fn=exports.ConnectionStateType||(exports.ConnectionStateType={}))[Fn.NONE=0]="NONE",Fn[Fn.INITIALIZED=1]="INITIALIZED",Fn[Fn.CONNECTING=2]="CONNECTING",Fn[Fn.CONNECTED=3]="CONNECTED",Fn[Fn.RECONNECTING=4]="RECONNECTING",Fn[Fn.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",Fn[Fn.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",Fn[Fn.LOGOUT=7]="LOGOUT";class Kn extends x{constructor({stateType:e}){super(),this.stateType=e}}class Bn{constructor(t,{auth:s,sdkState:n,dispatcher:i,logger:r,useFetchCompat:a=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Gn(t,{auth:s,sdkState:n,dispatcher:i,logger:r,useFetchCompat:a}),this._auth=s,this._logger=r,this._dispatcher=i,this._dispatcher.on((t=>{if(t instanceof Kn){const{stateType:s}=t;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:{const t=this._lazyCallQueue;this._lazyCallQueue=[],t.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:n}=t;clearTimeout(n);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))));break}case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:{const t=this._lazyCallQueue;this._lazyCallQueue=[],t.forEach((t=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:s}=t;clearTimeout(s),this._auth&&this._auth.hasSession?e.reject(o.connectionClosed):e.reject(o.connectionRequired)}))));break}}}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof zn){if(this.isReady)return this._logger.debug("send websocket request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait websocket request",t);const e=new Vn;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}throw this._logger.debug("fail websocket request"),o.connectionRequired}if(t instanceof ae){if(this._auth.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Vn;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}{const e=o.connectionRequired;throw this._logger.debug("fail api request",e),e}}throw o.invalidCommand}))}forceSend(t){return e(this,void 0,void 0,(function*(){if(this._logger.debug("send forced request",t),t instanceof zn||t instanceof ae)return yield this.commandRouter.send(t);throw o.invalidCommand}))}timeout(e){this._logger.debug("timeout request",e);const t=this._lazyCallQueue.findIndex((t=>t.command.requestId===e));t>-1&&(this._lazyCallQueue[t].deferred.reject(o.connectionRequired),this._lazyCallQueue.splice(t,1))}cancel(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}cancelAll(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}const Zn="sendbird@devicetokens";class jn{constructor({type:e,token:t}){this.type=e,this.token=t}static payloadify(e){return k(I({type:e.type,token:e.token}))}}class Wn extends ae{constructor({userId:e,authToken:t,expiringSession:s=!0}){super(),this.path=`${V}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params={token:t,expiring_session:!!s},this.requireAuth=!1}}class $n extends zn{constructor({authToken:e,expiringSession:t=!0,requestId:s=""}){super({code:"LOGI",payload:{token:e,expiring_session:t?1:0,req_id:s},ackRequired:!0})}}class Qn extends le{constructor(e,t){super(e,t);const{key:s}=t;this.key=s}}class Yn extends me{constructor(e,t,s){var n;super(e,"LOGI",s),this.error=null,this.newKey=null,this.newKey=null!==(n=s.new_key)&&void 0!==n?n:null,this.error=s.error?new o(s.error):null}}class Xn extends x{}const Jn=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class ei{calcTimeout(){return 0}}const ti=(t,s,n=new ei)=>e(void 0,void 0,void 0,(function*(){let e=0,i=null;const o=e=>i=null!=e?e:new Error("Halted"),r=()=>{e=0};for(;-1===s||ee(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),ni=new WeakMap;class ii extends w{constructor({auth:e,cacheContext:t,sdkState:s,dispatcher:n,requestQueue:i,logger:o}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this._isRefreshingSessionKey=!1,this.currentUser=null,this.auth=e,this._cacheContext=t,this._sdkState=s,this._dispatcher=n,this._requestQueue=i,this._logger=o,this._deviceTokens=[],this._dispatcher.on((e=>{var t;if(e instanceof Kn){const{stateType:t}=e;this._currentConnectionStateType=t}else e instanceof ce&&this.handler&&(e.invalidateSessionToken&&(this.auth.authToken=void 0),e.error&&(e.error.isSessionKeyExpiredError||e.error.isSessionTokenExpiredError)&&(this._logger.debug("session expired"),(null===(t=this.handler)||void 0===t?void 0:t.onSessionExpired)&&this.handler.onSessionExpired(),this.refresh()))}))}get ekey(){return ni.get(this)}get deviceTokens(){return this._deviceTokens}get deviceTokenLastDeletedAt(){return this._deviceTokenLastDeletedAt}indexOfDeviceToken(e,t){return this._deviceTokens.findIndex((s=>s.type===e&&s.token===t))}hasDeviceToken(e,t){return this.indexOfDeviceToken(e,t)>=0}createRefreshWebsocketCommand(e,t){return new $n({authToken:e,expiringSession:!0,requestId:t})}_refreshSessionKeyByWebSocket(t){return e(this,void 0,void 0,(function*(){const e=this.createRefreshWebsocketCommand(t),s=yield this._requestQueue.forceSend(e),{newKey:n,error:i}=s.as(Yn);if(i)throw i;this.auth.sessionKey=null!=n?n:this.auth.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new Wn({userId:this._sdkState.userId,authToken:t,expiringSession:!0});yield ti((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t}=e.as(Qn);this.auth.sessionKey=t}catch(e){if(!this._isSessionRelatedError(e))throw e;t(e)}}))),3)}))}_refreshSessionKey(t,s=!0){return e(this,void 0,void 0,(function*(){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED)try{return yield this._refreshSessionKeyByWebSocket(t),void this.complete()}catch(e){if(this._isSessionRelatedError(e)&&s){const e=yield this._receiveNewAuthToken();return void(e?(this.auth.authToken=e,yield this._refreshSessionKey(this.auth.authToken,!1),this.complete()):(yield this.clear(),this.close()))}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){if(!this._isSessionRelatedError(e))throw e;if(!s)throw e;{const e=yield this._receiveNewAuthToken();e?(this.auth.authToken=e,yield this._refreshSessionKeyByApi(this.auth.authToken),this.complete()):(yield this.clear(),this.close())}}}))}_receiveNewAuthToken(){const t=new Vn;return si((()=>e(this,void 0,void 0,(function*(){if(this._isRefreshingAuthToken=!0,this.auth.clear(),this.handler.onSessionTokenRequired){let e=null;const s=()=>{e&&(clearTimeout(e),e=null)},n=e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,this.dispatch("refresh-authtoken"),t.resolve(e))},i=e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,t.reject(e))};e=setTimeout((()=>i()),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(n,i)}else t.resolve(null)})))),t.promise}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}get isSessionKeyRefreshing(){return this._isRefreshingSessionKey}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:n,userProfile:i,deviceTokenLastDeletedAt:o=0}=t;this.auth.sessionKey=e,ni.set(this,n),this._deviceTokenCacheEnabled=null===(s=null==i?void 0:i.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:r}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield r.get(Zn);!e||e.lastDeletedAtnew jn(jn.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield r.remove(Zn)}))}complete(){this.dispatch("refresh"),si((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session refreshed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionRefreshed)&&this.handler.onSessionRefreshed()}))))}error(t){si((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionError)&&this.handler.onSessionError(t)}))))}close(){this.dispatch("close"),si((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session closed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionClosed)&&this.handler.onSessionClosed()}))))}refresh(){return e(this,void 0,void 0,(function*(){if(this.handler&&!this._isRefreshingSessionKey){if(this._isRefreshingSessionKey=!0,!this.auth.authToken)try{const e=yield this._receiveNewAuthToken();if(!e)return yield this.clear(),void(this._isRefreshingSessionKey=!1);this._logger.debug("session refreshing.."),this.auth.authToken=e}catch(e){const t=o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new Xn),this.error(t),this._isRefreshingSessionKey=!1,t}try{yield this._refreshSessionKey(this.auth.authToken),this._isRefreshingSessionKey=!1}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new Xn),this.error(t),this._isRefreshingSessionKey=!1,t}}}))}setDeviceToken(e,t){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0)return this._deviceTokens.push(new jn({type:e,token:t})),!0}return!1}unsetDeviceToken(e,t){if(this._deviceTokenCacheEnabled){const s=this.indexOfDeviceToken(e,t);s>=0&&this._deviceTokens.splice(s,1)}}unsetDeviceTokens(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((t=>t.type!==e)):[])}setDeviceTokenDeletedAt(e){e>0&&(this._deviceTokenLastDeletedAt=e)}saveDeviceToken(){return e(this,void 0,void 0,(function*(){if(this._deviceTokenCacheEnabled){const{preference:e}=this._cacheContext;yield e.set(Zn,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.auth.clear(),this.close(),ni.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken()}))}}class oi{constructor(){this.type=exports.ConnectionStateType.NONE,this.name="none"}run(t){return e(this,void 0,void 0,(function*(){}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnect(t,{error:s=null,autoReconnect:n=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){}))}onLogout(t){return e(this,void 0,void 0,(function*(){}))}}class ri extends oi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout"}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),n=t.sdkState.userId;yield t.logout(),yield t.changeState(new _i,s),si((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(n)}))}))))}))}}class ai extends oi{constructor(){super(),this.type=exports.ConnectionStateType.EXTERNAL_DISCONNECTED,this.name="externaldisconnected"}run(t){return e(this,void 0,void 0,(function*(){yield t.disconnect()}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new hi({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new di,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ri,e)}))}}class li extends oi{constructor({autoReconnect:e}){super(),this.type=exports.ConnectionStateType.INTERNAL_DISCONNECTED,this.name="internaldisconnected",this._autoReconnect=!1,this._autoReconnect=e}run(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),this._autoReconnect&&(yield t.changeState(new di,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new hi({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new di,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ai,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ri,e)}))}}class di extends oi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.RECONNECTING,this.name="reconnecting",this._callbacks=[]}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),n=new Vn;this._callbacks.push((e=>e?n.reject(e):n.resolve())),si((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onReconnectStarted&&e.onReconnectStarted()}))}))));try{const{reconnectMaxRetry:n,reconnectRetryStrategy:i}=t.sdkState.websocket;yield ti(((s,n)=>e(this,void 0,void 0,(function*(){this._haltConnect=s,this._resetConnect=n;try{yield t.connect()}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),n,i),yield t.changeState(new ci,s),si((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onReconnectSucceeded&&e.onReconnectSucceeded()}))}))))}catch(n){if(i(n))throw n;n instanceof o&&n.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new li({autoReconnect:!1}),s)),si((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(n),t.connectionHandlers.forEach((e=>{e.onReconnectFailed&&e.onReconnectFailed()}))}))))}return n.promise}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=new Vn;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const n=Date.now();t.changeState(new hi({authToken:s}),n).then((()=>{e.resolve()})).catch((t=>{e.reject(t)}))})),e.promise}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){const e=new Vn;return this._resetConnect&&s&&this._resetConnect(),this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:n=!0}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new li({autoReconnect:n}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new ai,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new ri,e)}))}}class ci extends oi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.CONNECTED,this.name="connected"}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new di,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new li({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ai,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new ri,e)}))}}class hi extends oi{constructor({authToken:e}){super(),this.type=exports.ConnectionStateType.CONNECTING,this.name="connecting",this._authToken="",this._callbacks=[],this._authToken=e}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),n=new Vn;this._callbacks.push((e=>e?n.reject(e):n.resolve()));try{yield ti((s=>e(this,void 0,void 0,(function*(){this._haltConnect=s;try{yield t.connect(this._authToken)}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),t.sdkState.websocket.connectMaxRetry),yield t.changeState(new ci,s),si((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onConnected&&e.onConnected(t.sdkState.userId)}))}))))}catch(n){if(i(n))throw n;yield t.disconnect(),n instanceof o&&n.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new _i,s)),si((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(n)}))))}return n.promise}))}onConnect(t){return e(this,void 0,void 0,(function*(){const e=new Vn;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:n=!1}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),t.hasSession?yield t.changeState(new li({autoReconnect:n}),e):yield t.changeState(new ri,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),t.hasSession?yield t.changeState(new ai,e):yield t.changeState(new ri,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new ri,e)}))}}class _i extends oi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.INITIALIZED,this.name="initialized"}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new hi({authToken:s}),e)}))}}class ui extends zn{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class pi{constructor({pingDelegate:e,sdkState:t,logger:s}){this.pingDelegate=e,this.sdkState=t,this._logger=s}get isWaiting(){return!!this._pingTimeoutTimer}ping(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;const t=new ui;try{const s=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((()=>{this._logger.debug("pinger.ping() timeout"),this.pingDelegate.error()}),s),this.pingDelegate.send(t),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return t}pong(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}refreshTimer(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;this._logger.debug("pinger.refreshTimer()");const t=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((()=>{this.ping()}),t)}start(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}stop(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}class Ei{constructor(e){var t,s,n,i;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(n=e.template_list_token)&&void 0!==n?n:null,this.settingsUpdatedAt=null!==(i=e.settings_updated_at)&&void 0!==i?i:0}static payloadify(e){return k(I({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class fi{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return k(I({last_updated_at:e.lastUpdatedAt}))}}const gi=1048576;class vi{constructor(e={}){var t,s,n,i,o;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*gi:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(s=e.premium_feature_list)&&void 0!==s?s:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(n=e.multiple_file_send_max_size)&&void 0!==n?n:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new fi(null!==(o=e.uikit_config)&&void 0!==o?o:{}),this.notificationInfo=e.notifications?new Ei(e.notifications):null}static payloadify(e){return k(I({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/gi,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?fi.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Ei.payloadify(e.notificationInfo):null}))}}class Si{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class mi extends ae{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${V}/${e}/metadata`,this.params={metadata:t}}}class Ti extends le{constructor(e,t){super(e,t),this.metaData=t}}class Ci extends ae{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${V}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class Ni extends le{constructor(e,t){super(e,t),this.metadata=t}}class yi extends ae{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${V}/${e}/metadata/${t}`}}class Ai extends ae{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${V}/${e}/metadata`}}const wi=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},bi=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var xi;exports.UserOnlineState=void 0,(xi=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",xi.OFFLINE="offline",xi.NON_AVAILABLE="nonavailable";class ki extends Si{constructor(e,t){var s,n,i,o,r,a,c,h,_,u,p,E;super(e),this.userId=null!==(n=null!==(s=t.guest_id)&&void 0!==s?s:t.user_id)&&void 0!==n?n:"",this.nickname=null!==(o=null!==(i=t.nickname)&&void 0!==i?i:t.name)&&void 0!==o?o:"",this.plainProfileUrl=null!==(a=null!==(r=t.profile_url)&&void 0!==r?r:t.image)&&void 0!==a?a:"",this.requireAuth=null!==(c=t.require_auth_for_profile_image)&&void 0!==c&&c,this.metaData=null!==(h=t.metadata)&&void 0!==h?h:{},this.connectionStatus=exports.UserOnlineState.NON_AVAILABLE,d(exports.UserOnlineState,t.is_online)?this.connectionStatus=t.is_online:l("boolean",t.is_online)&&(this.connectionStatus=t.is_online?exports.UserOnlineState.ONLINE:exports.UserOnlineState.OFFLINE),this.isActive=null===(_=t.is_active)||void 0===_||_,this.lastSeenAt=null!==(u=t.last_seen_at)&&void 0!==u?u:null,this.preferredLanguages=t.preferred_languages?[...t.preferred_languages]:null,this.friendDiscoveryKey=null!==(p=t.friend_discovery_key)&&void 0!==p?p:null,this.friendName=null!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return k(I(Object.assign(Object.assign({},super.payloadify(e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}get profileUrl(){const{sessionManager:e}=Ki.of(this._iid);return this.requireAuth?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return wi(this)}_isValidMetaData(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((t=>e[t])).every((e=>l("string",e)))}_applyMetaData(e,t=!1){Object.keys(e).forEach((s=>{t?delete this.metaData[s]:this.metaData[s]=e[s]}))}createMetaData(t){return e(this,void 0,void 0,(function*(){bi(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Ki.of(this._iid),n=new mi({userId:e.userId,metadata:t}),i=yield s.send(n),{metaData:r}=i.as(Ti);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){bi(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:n}=Ki.of(this._iid),i=new Ci({userId:e.userId,metadata:t,upsert:s}),r=yield n.send(i),{metadata:a}=r.as(Ni);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){bi(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Ki.of(this._iid),n=new yi({userId:e.userId,metadataKey:t});return yield s.send(n),this._applyMetaData({[t]:!0},!0),this.metaData}))}deleteAllMetaData(){return e(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=Ki.of(this._iid),s=new Ai({userId:e.userId});yield t.send(s),this.metaData={}}))}}class Ii extends x{constructor({userProfile:e}){super(),this.userProfile=e}}class Ri{constructor(e,t){var s,n,i,o,r,a,l,d,c,h,_,u,p,E;this._iid=e,this.appInfo=new vi(t),this.user=new ki(e,t),this.connectedAt=null!==(s=t.login_ts)&&void 0!==s?s:0,this.firstConnectedAt=0,this.pingInterval=null!==(n=t.ping_interval)&&void 0!==n?n:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(r=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==r?r:3e3,this.reconnectMaxInterval=null!==(l=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(c=null===(d=t.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==c?c:5,this.reconnectIntervalMultiple=null!==(_=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==_?_:2,this.maxUnreadCountOnSuperGroup=null!==(u=t.max_unread_cnt_on_super_group)&&void 0!==u?u:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(p=t.concurrent_call_limit)&&void 0!==p?p:5,this.backOffDelay=null!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return k(I(Object.assign(Object.assign(Object.assign({},ki.payloadify(e.user)),vi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}apply(){const e=this.reconnectInterval,t=this.reconnectMaxInterval,s=this.reconnectIntervalMultiple,n=Ki.of(this._iid);n.sdkState.websocket&&(n.sdkState.websocket.pingInterval=1e3*this.pingInterval,n.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,n.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,n.sdkState.websocket.reconnectRetryStrategy={calcTimeout:n=>n>0?1e3*Math.min(e*Math.pow(s,n-1),t):10}),n.appInfo=this.appInfo,n.sessionManager.currentUser=this.user,n.connectedAt=this.connectedAt,this.firstConnectedAt||(n.firstConnectedAt=this.connectedAt),n.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,n.concurrentCallLimit=this.concurrentCallLimit,n.backOffDelay=this.backOffDelay,n.dispatcher.dispatch(new Ii({userProfile:this}))}}class Oi extends me{constructor(e,t,s){var n,i,r;super(e,t,s),this.error=null,this.userProfile=new Ri(e,s),this.deviceTokenLastDeletedAt=null!==(n=s.device_token_last_deleted_at)&&void 0!==n?n:0,this.key=null!==(i=s.key)&&void 0!==i?i:"",this.ekey=null!==(r=s.ekey)&&void 0!==r?r:"",this.error=s.error?new o(s):null}static asError(e){return new Oi("","LOGI",Object.assign({user_id:"",error:!0},e))}applyTo(t){return e(this,void 0,void 0,(function*(){if(this.error)throw this.error;{const e=Ki.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t}=e;yield t.login(this),this.userProfile.apply()}}}))}}class Di extends x{constructor({request:e=!0,features:t={},options:s={}}){super(),this.request=e,this.features=Object.assign({localCache:!0},t),this.options=Object.assign({ingestion:!0},s)}}class Li extends w{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:n,sessionManager:i,websocketClient:r,dispatcher:a,logger:l,entryState:d=new _i}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectionRequestQueue=[],this._iid=e,this.sdkState=t,this.cacheContext=s,this.connectionHandlers=n,this._sessionManager=i,this._websocketClient=r,this._dispatcher=a,this._logger=l,this._currentState=d,(null===(c=this.sdkState.websocket)||void 0===c?void 0:c.pingerDisabled)||(this._pinger=new pi({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Oi))})).on("ping-refresh",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.pong()})).on("error",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.stop()})).on("close",(()=>{this._logiProcessingTimer=setTimeout((()=>{this._logiProcessingTimer=void 0,this._unresolvedLogi||this._rejectConnectionRequest(o.networkError)}),500)})),this._dispatcher.on((e=>{e instanceof Oi&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.auth.hasSession}changeState(t,s){return e(this,void 0,void 0,(function*(){return s>=this._stateUpdatedAt&&(this._currentState=t,this._stateUpdatedAt=s,this._dispatcher.dispatch(new Kn({stateType:t.type})),this._logger.debug(`connection state changes to ${t.name}`),yield this._currentState.run(this),!0)}))}_tryResolveConnectionRequest(){var t;return e(this,void 0,void 0,(function*(){const e=this._unresolvedLogi;if(this._websocketClient.isOpen&&e)if(this._unresolvedLogi=void 0,e.error)this._sessionManager.auth.authToken=void 0,(e.error.isSessionKeyExpiredError||e.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ce({reason:e.error.code})),this._rejectConnectionRequest(e.error);else{yield e.applyTo(this._iid);const{userProfile:s}=e;this._enableStatLog({request:s.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:s.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:s.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(t=this._pinger)||void 0===t||t.start(),this._connectionRequestQueue.forEach((e=>e.resolve())),this._connectionRequestQueue=[],this.sdkState.appState="foreground"}}))}_rejectConnectionRequest(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){const t=this._connectionRequestQueue;this._connectionRequestQueue=[],t.forEach((t=>t.reject(e))),this._statLogConnection(e)}}_url(e=""){var t,s;const{appId:i,appVersion:o,userId:r,extensions:a,sendbirdRuntimeEnvironment:l}=this.sdkState,{localCacheEnabled:d}=this.cacheContext,{auth:c}=this._sessionManager,h=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,_=!!(null!==(s=this.sdkState.extensions)&&void 0!==s?s:{}).sb_uikit,u=ve.userAgentWithExtension(a);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(n.OS_VERSION)}&sv=${encodeURIComponent(n.SDK_VERSION)}&ai=${i}${o?`&av=${o}`:""}${c.hasSession?`&key=${encodeURIComponent(c.sessionKey)}`:`&user_id=${encodeURIComponent(r)}&access_token=${encodeURIComponent(e)}`}&pmce=${h?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${u}&SB-SDK-User-Agent=${encodeURIComponent(ve.sendbirdSdkUserAgentWithExtension(l))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"]))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${d?1:0}&include_poll_details=1${_?"&uikit_config=1":""}`}_enableStatLog({request:e,features:t,options:s={}}){this._dispatcher.dispatch(new Di({request:e,features:t,options:s}))}_statLogConnection(e){var t;this._dispatcher.dispatch(new he(new _e({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}connect(t=""){var s;return e(this,void 0,void 0,(function*(){this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(o.connectionCanceled));const e=this._url(t),n=new Vn;return this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout),t&&(this._sessionManager.auth.authToken=t),this._websocketClient.connect(e)),n.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Oi.asError(o.connectionRenew))}disconnect(){return e(this,void 0,void 0,(function*(){yield this._websocketClient.disconnect()}))}logout(){return e(this,void 0,void 0,(function*(){this.sdkState.userId=void 0,this._unresolvedLogi=void 0,yield this._sessionManager.clear(),yield this.disconnect()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class Ui{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:n,sessionManager:i,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new Li(e,{sdkState:t,cacheContext:s,connectionHandlers:n,sessionManager:i,websocketClient:o,dispatcher:r,logger:a}),this._sdkState=t,this._sessionManager=i,this._websocketClient=o}_registerEventDispatcher(){this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(()=>{this.isConnected||(this._logger.debug("try reconnect by session token refresh"),this.reconnect())})).on("refresh",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),this.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._externalCalledWebSocketClose||this._sessionManager.isRefreshingAuthToken||(this._logger.debug("try reconnect by websocket connection closed"),this.reconnect())})))}_clearEventDispatcher(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}get isConnected(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTED}get isConnecting(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTING||e.type===exports.ConnectionStateType.RECONNECTING}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnect(this._context,{autoReconnect:!1})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0})}))}disconnectWebSocket(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnectWebSocket(this._context)}))}logout(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context)}))}}class Mi extends _e{constructor({type:e,data:t,ts:s=Date.now()}){var n;super({type:e,data:t,ts:s}),this.date=new Date(s),this.key=`${n=this.date,`${n.getFullYear()}${String(n.getMonth()+1).padStart(2,"0")}${String(n.getDate()).padStart(2,"0")}`}_${e}`}}class Pi extends ae{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${te}`,this.params={device_id:e,log_entries:t.map((e=>_e.payloadify(e)))}}}const Fi=(e,t)=>{if(null!==e&&null!==t){const s=Object.keys(e),n=Object.keys(t),i=[...new Set([...s,...n])],o={};for(const s of i){const n=typeof e[s],i=typeof t[s];"undefined"===n?o[s]=t[s]:"undefined"===i?o[s]=e[s]:n!==i?o[s]=t[s]:"object"===n&&e[s]&&t[s]?o[s]=Fi(e[s],t[s]):o[s]=t[s]}return o}return t};var Hi,zi;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Hi||(Hi={}));class qi extends w{constructor({cacheContext:e,requestQueue:t,dispatcher:s,baseLimit:n=100,maxLimit:i=1e3,minLimit:o=10}){super(),this.queue=[],this.enabledState=Hi.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this.deviceId=y(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.baseLimit=n,this.limit=n,this.maxLimit=i,this.minLimit=o}get isEnabled(){return this.enabledState===Hi.ENABLED}_arrangeStat(){const e=[];this._collectRequestStat&&e.push(...this.queue.filter((e=>e.type===exports.StatType.API_RESULT||e.type===exports.StatType.WEBSOCKET_CONNECT))),this._collectFeatureLocalCacheStat&&e.push(...this.queue.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE))),this.queue=e}_save(){return e(this,void 0,void 0,(function*(){this.enabledState===Hi.ENABLED&&(yield this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((e=>_e.payloadify(e))),generation:this.generation++,lastFlushedAt:this.lastFlushedAt}),this.dispatch("save",[...this.queue]))}))}_flush(){return e(this,void 0,void 0,(function*(){if(this.isEnabled&&!this.isFlushing){this.isFlushing=!0;try{this._arrangeStat();const e=this.queue.filter((e=>{if(e instanceof Mi){const t=new Date,[s,n]=[e.date.getFullYear(),t.getFullYear()];if(s!(e instanceof Mi))),s=[...e,...t].slice(0,Math.min(this.limit,this.maxLimit));if(s.length>0){const n=new Pi({deviceId:this.deviceId,statLogs:s});yield this.requestQueue.send(n),this.dispatch("flush",s),this.queue=[...e,...t].slice(s.length),yield this._save()}this.limit=this.baseLimit,this.lastFlushedAt=Date.now()}catch(e){e instanceof o&&(e.code===exports.SendbirdErrorCode.STAT_LOG_NOT_ALLOWED?(yield this.clear(),this.enabledState=Hi.DISABLED):e.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Hi.COLLECT_ONLY)),this.limit=this.limit+20}finally{this.isFlushing=!1}}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);if(e&&(this.deviceId=e.deviceId,this.queue=e.statLogs.map((e=>new _e({type:e.stat_type,ts:e.ts,data:e.data}))),this.generation=e.generation,this.lastFlushedAt=e.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){const e=Math.min(Math.floor(18e4*Math.random()),100);yield Jn(e),yield this._flush()}this.commandEventContext||(this.commandEventContext=this.dispatcher.on((e=>{if(e instanceof he){const{statLog:t}=e;this.put(t)}else if(e instanceof Di){const{request:t,features:s,options:n}=e;this._collectRequestStat=t,this._collectFeatureLocalCacheStat=null==s?void 0:s.localCache,this._arrangeStat(),this._collectRequestStat||this._collectFeatureLocalCacheStat?this.enabledState=n.ingestion?Hi.ENABLED:Hi.COLLECT_ONLY:this.enabledState=Hi.DISABLED,this.isEnabled?this.queue.length>=this.limit&&this._flush():this.clear()}})))}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState!==Hi.DISABLED){if(t instanceof Mi){if(this._collectFeatureLocalCacheStat){const[e]=this.queue.filter((e=>e instanceof Mi&&e.key===t.key));e?e.data=Fi(e.data,t.data):this.queue.push(t)}}else this._collectRequestStat&&this.queue.push(t);yield this._save(),this.queue.length>=this.limit&&(yield this._flush())}}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.generation=1,yield this._save()}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}exports.LogLevel=void 0,(zi=exports.LogLevel||(exports.LogLevel={}))[zi.NONE=0]="NONE",zi[zi.VERBOSE=1]="VERBOSE",zi[zi.DEBUG=2]="DEBUG",zi[zi.INFO=3]="INFO",zi[zi.WARN=4]="WARN",zi[zi.ERROR=5]="ERROR";class Vi{constructor(){this.level=exports.LogLevel.WARN}verbose(...e){this.level<=exports.LogLevel.VERBOSE&&console.log("[verbose]",...e)}debug(...e){this.level<=exports.LogLevel.DEBUG&&console.log("[debug]",...e)}info(...e){this.level<=exports.LogLevel.INFO&&console.log("[info]",...e)}warn(...e){this.level<=exports.LogLevel.WARN&&console.warn("[warn]",...e)}error(...e){this.level<=exports.LogLevel.ERROR&&console.error("[error]",...e)}}const Gi={};class Ki{constructor(e,t){var s,i,o,r,a,l,d,c,h,_;if(this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,!Gi[e]){Gi[e]=this;const p=null!==(s=t.options)&&void 0!==s?s:new u,E=this.sdkState={appId:t.appId,appVersion:null!==(i=t.appVersion)&&void 0!==i?i:"",appState:"foreground",userId:void 0,extensions:{},api:{host:null!==(o=t.apiHost)&&void 0!==o?o:`https://api-${t.appId}.sendbird.com`},websocket:{host:null!==(r=t.websocketHost)&&void 0!==r?r:`wss://ws-${t.appId}.sendbird.com`,pingerDisabled:!!t.noPingpong,pingInterval:void 0,pongTimeout:void 0,connectMaxRetry:2,compression:!0,reconnectMaxRetry:-1,reconnectRetryStrategy:new ei,responseTimeout:p.websocketResponseTimeout},sessionTokenRefreshTimeout:p.sessionTokenRefreshTimeout};this.appInfo=void 0,this.subscribedUnreadMessageCount={all:0,feed:0,customTypes:{},ts:0};const g=this.logger=new Vi;this.logger.level=null!==(a=t.logLevel)&&void 0!==a?a:exports.LogLevel.WARN,this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map;const v=this.cacheContext=new f({encryption:t.encryption,store:t.store,localCacheEnabled:null!==(l=t.localCacheEnabled)&&void 0!==l&&l,localCacheConfig:null!==(d=t.localCacheConfig)&&void 0!==d?d:new C});this.debugMode=null!==(c=t.debugMode)&&void 0!==c&&c,this.maxSuperGroupChannelUnreadCount=n.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,this.useMemberInfoInMessage=p.useMemberInfoInMessage,this.typingIndicatorInvalidateTime=p.typingIndicatorInvalidateTime,this.typingIndicatorThrottle=p.typingIndicatorThrottle,this.concurrentCallLimit=void 0,this.backOffDelay=void 0;const S=this.dispatcher=new b,m=new N;this.requestQueue=new Bn(e,{auth:m,sdkState:E,dispatcher:S,logger:g,useFetchCompat:t.useFetchCompat}),this.sessionManager=new ii({auth:m,cacheContext:v,sdkState:E,dispatcher:S,requestQueue:this.requestQueue,logger:g}),this.connectionManager=new Ui(e,{sdkState:E,cacheContext:this.cacheContext,connectionHandlers:this.connectionHandlers,dispatcher:S,sessionManager:this.sessionManager,websocketClient:this.requestQueue.commandRouter.websocketClient,disableWebSocketCloseEventHandling:null!==(h=t.disableWebSocketCloseEventHandling)&&void 0!==h&&h,logger:g}),this.statLogCollector=new qi({cacheContext:this.cacheContext,requestQueue:this.requestQueue,dispatcher:S}),this.appStateToggleEnabled=null===(_=t.appStateToggleEnabled)||void 0===_||_}return Gi[e]}static of(e){if(Gi[e])return Gi[e];throw o.lostInstance}static clear(e){Gi[e]&&delete Gi[e]}hasExtension(e){return this.sdkState.extensions&&this.sdkState.extensions[e]}}var Bi;exports.PollStatus=void 0,(Bi=exports.PollStatus||(exports.PollStatus={})).OPEN="open",Bi.CLOSED="closed";const Zi=e=>{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}};class ji extends Si{constructor(e,t){var s,n,i,o,r,a,l;super(e),this.pollId=0,this.id=0,this.text=null,this.voteCount=0,this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._lastVotedAt=0,this.pollId=null!==(s=t.poll_id)&&void 0!==s?s:0,this.id=null!==(n=t.id)&&void 0!==n?n:0,this.text=null!==(i=t.text)&&void 0!==i?i:null,this.voteCount=null!==(o=t.vote_count)&&void 0!==o?o:0,this.createdBy=null!==(r=t.created_by)&&void 0!==r?r:null,this.createdAt=null!==(a=t.created_at)&&void 0!==a?a:0,this.updatedAt=null!==(l=t.updated_at)&&void 0!==l?l:0}static payloadify(e){return k(I(Object.assign(Object.assign({},super.payloadify(e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}var Wi;exports.CollectionEventSource=void 0,(Wi=exports.CollectionEventSource||(exports.CollectionEventSource={})).UNKNOWN="UNKNOWN",Wi.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Wi.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Wi.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Wi.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Wi.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Wi.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Wi.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Wi.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Wi.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Wi.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Wi.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Wi.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",Wi.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",Wi.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Wi.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Wi.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Wi.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Wi.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Wi.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Wi.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Wi.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Wi.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Wi.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",Wi.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",Wi.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",Wi.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",Wi.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",Wi.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",Wi.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Wi.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Wi.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Wi.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Wi.REQUEST_CHANNEL="REQUEST_CHANNEL",Wi.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Wi.REFRESH_CHANNEL="REFRESH_CHANNEL",Wi.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",Wi.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Wi.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",Wi.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Wi.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Wi.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Wi.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Wi.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Wi.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Wi.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Wi.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Wi.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Wi.REQUEST_MESSAGE="REQUEST_MESSAGE",Wi.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Wi.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Wi.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Wi.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Wi.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Wi.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Wi.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Wi.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Wi.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Wi.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Wi.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Wi.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Wi.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";const $i=Object.assign({},exports.CollectionEventSource);class Qi{constructor(e,t){var s;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(s=t.limit)&&void 0!==s?s:20}get hasNext(){return this._hasNext}get isLoading(){return this._isLoading}_validate(){return l("number",this.limit)&&this.limit>0}}const Yi={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},Xi={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0};exports.APIRequestCommand=ae,exports.APIResponseCommand=le,exports.API_PATH_EMOJIS=Q,exports.API_PATH_EMOJI_CATEGORIES=Y,exports.API_PATH_GROUP_CHANNELS=K,exports.API_PATH_GROUP_CHANNELS_INTERNAL=B,exports.API_PATH_NOTIFICATIONS=se,exports.API_PATH_OPEN_CHANNELS=Z,exports.API_PATH_OPEN_CHANNELS_INTERNAL=j,exports.API_PATH_POLLS=X,exports.API_PATH_REPORT=$,exports.API_PATH_SCHEDULED_MESSAGES=J,exports.API_PATH_SEARCH=W,exports.API_PATH_UIKIT_CONFIGURATION=ee,exports.API_PATH_UPLOAD=G,exports.API_PATH_USERS=V,exports.BaseCommand=x,exports.BaseListQuery=Qi,exports.CachedChannelInfo=class{constructor({channel:e,cachedMessageCount:t}){this._cachedMessageCount=0,this._channel=e,this._cachedMessageCount=t}get channel(){return this._channel}get cachedMessageCount(){return this._cachedMessageCount}},exports.ChannelDataListQuery=class extends Qi{constructor(e,t,s,n){super(e,n),this.channelUrl=t,this.channelType=s}_validate(){return super._validate()&&l("string",this.channelUrl)&&d(exports.ChannelType,this.channelType)}},exports.ConnectionStateChangeCommand=Kn,exports.DEFAULT_ENCRYPTION=p,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=Mi,exports.Deferred=Vn,exports.EventDispatcher=w,exports.InstancedObject=Si,exports.LocalCacheConfig=C,exports.MessageEventSource=$i,exports.MessageRemoveEventCommand=class extends x{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends x{constructor({messages:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messages=e,this.source=t,this.isWebSocketEventComing=s}},exports.Module=class{init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:i,logger:o,onlineDetector:r,cacheContext:a}){this._iid=e,this._cacheContext=a,this._sdkState=t,this._dispatcher=s,this._sessionManager=n,this._requestQueue=i,this._logger=o}},exports.NotificationInfo=Ei,exports.POLL_REMOVED_STATUS="removed",exports.Poll=class extends Si{constructor(e,t){var s,n,i,o,r,a,l,d,c,h,_,u,p;super(e),this.id=0,this.title=null,this.createdAt=0,this.updatedAt=0,this.closeAt=-1,this.status=exports.PollStatus.CLOSED,this.messageId=0,this.data=null,this.voterCount=-1,this.options=[],this.createdBy=null,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.votedPollOptionIds=[],this.id=null!==(s=t.id)&&void 0!==s?s:0,this.title=null!==(n=t.title)&&void 0!==n?n:null,this.createdAt=null!==(i=t.created_at)&&void 0!==i?i:0,this.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,this.closeAt=null!==(r=t.close_at)&&void 0!==r?r:-1,this.status=null!==(a=Zi(t.status))&&void 0!==a?a:exports.PollStatus.CLOSED,this.messageId=null!==(l=t.message_id)&&void 0!==l?l:0,this.data=null!==(d=t.data)&&void 0!==d?d:null,this.voterCount=null!==(c=t.voter_count)&&void 0!==c?c:-1,this.options=t.options?t.options.map((e=>new ji(this._iid,e))):[],this.createdBy=null!==(h=t.created_by)&&void 0!==h?h:null,this.allowUserSuggestion=null!==(_=t.allow_user_suggestion)&&void 0!==_&&_,this.allowMultipleVotes=null!==(u=t.allow_multiple_votes)&&void 0!==u&&u,this.votedPollOptionIds=null!==(p=t.voted_option_ids)&&void 0!==p?p:[]}_applyPollUpdatePayload(e){var t,s,n,i,o,r,a,l;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(s=e.updated_at)&&void 0!==s?s:this.updatedAt,this.closeAt=null!==(n=e.close_at)&&void 0!==n?n:this.closeAt,this.status=null!==(i=Zi(e.status))&&void 0!==i?i:this.status,this.data=null!==(o=e.data)&&void 0!==o?o:this.data,this.voterCount=null!==(r=e.voter_count)&&void 0!==r?r:this.voterCount,e.options&&(this.options=e.options.map((e=>new ji(this._iid,e))),this.votedPollOptionIds=e.options.filter((e=>e.vote_count>0)).map((e=>e.id))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(l=e.allow_multiple_votes)&&void 0!==l?l:this.allowMultipleVotes}static payloadify(e){return k(I(Object.assign(Object.assign({},super.payloadify(e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((e=>ji.payloadify(e))),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}applyPollUpdateEvent(e){const t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_ate.id)),n=e._payload,i=Math.floor(n.ts/1e3);return n.updated_vote_counts.forEach((e=>{const n=s.indexOf(e.option_id);if(n>-1){const s=t[n];i>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),n.req_id&&n.voted_option_ids&&(this.votedPollOptionIds=n.voted_option_ids),"number"==typeof n.voter_count&&(this.voterCount=n.voter_count),!0}serialize(){return wi(this)}},exports.PollChangeLogEventCommand=class extends x{constructor({polls:e,source:t}){super(),this.polls=e,this.source=t}},exports.PollOption=ji,exports.PollOptionRetrievalParamsDefault=Yi,exports.PollRetrievalParamsDefault=Xi,exports.PollUpdateInternalEventCommand=class extends x{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoteInternalEventCommand=class extends x{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=u,exports.SendbirdError=o,exports.SessionExpiredCommand=ce,exports.SubscribedUnreadMessageCountUpdateCommand=qn,exports.UIKitConfigInfo=fi,exports.UnsentMessageRemoveEventCommand=class extends x{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=ki,exports.UserProfile=Ri,exports.UserProfileUpdateCommand=Ii,exports.Vault=Ki,exports.WebSocketEventCommand=me,exports.WebSocketRequestCommand=zn,exports.__awaiter=e,exports.__rest=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i{var n,i,o,r;const a=ne(null!==(n=e.mentionType)&&void 0!==n?n:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],s),l=ne(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(r=t.mentionedUserIds)&&void 0!==r?r:[],s);return!a&&l?1:a&&!l?-1:0},exports.checkIfMentioned=ne,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,exports.deepEqual=(e,t)=>{if(e!==t){const s=Object.assign({},e),n=Object.assign({},t);return(!s.hasOwnProperty("messageId")||!n.hasOwnProperty("messageId")||s.messageId===n.messageId)&&((!s.hasOwnProperty("reqId")||!n.hasOwnProperty("reqId")||s.reqId===n.reqId)&&(s.hasOwnProperty("messageId")&&delete s.messageId,s.hasOwnProperty("reqId")&&delete s.reqId,n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,JSON.stringify(s)===JSON.stringify(n)))}return!0},exports.deserialize=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},exports.deundefined=k,exports.getChannelApiPathByType=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return K;case exports.ChannelType.OPEN:return Z;default:return null}},exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${$}/group_channels`;case exports.ChannelType.OPEN:return`${$}/open_channels`;default:return null}},exports.hasSameMembers=(e,t)=>{if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;const s=[...e].sort(),n=[...t].sort();for(let e=0;ee>0&&a.indexOf(e)>=0,exports.isEnumOf=d,exports.isFile=_,exports.isReactNative=ue,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=i,exports.isTypeOf=l,exports.noop=Te,exports.parsePollStatusPayload=Zi,exports.runAsCallback=si,exports.runOrNothing=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}})),exports.serialize=wi,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=Jn,exports.undefineNullProps=I,exports.unless=bi,exports.uuid=y,exports.validateOptionTexts=e=>h("string",e)&&e.every((e=>""!==e.trim())),exports.validatePollData=e=>!e||!!e.text&&l("string",e.text),exports.validatePollOptionRetrievalParams=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,exports.validatePollRetrievalParams=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),exports.version=s; diff --git a/cjs/lib/__bundle-d5947f34.js b/cjs/lib/__bundle-d5947f34.js new file mode 100644 index 0000000..02fce99 --- /dev/null +++ b/cjs/lib/__bundle-d5947f34.js @@ -0,0 +1 @@ +"use strict";var e,t,s,n,i,a,r,o,l,d=require("./__bundle-26b86f4c.js"),h=require("./__bundle-aae5735d.js"),c=require("./__bundle-82ee6f93.js"),u=require("./__bundle-8e790a5a.js");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class _ extends h.RestrictedUser{constructor(e,t){super(e,t),this.state=null,this.role=null,this.isMuted=!1,this.isBlockedByMe=!1,this.isBlockingMe=!1,this.state=d.isEnumOf(exports.MemberState,t.state)?t.state:null,this.role=d.isEnumOf(d.Role,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(this.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(this.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(this.isBlockingMe=t.is_blocking_me)}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}class p extends d.InstancedObject{constructor(e,t){var s,n;super(e),this.channelUrl=null!==(s=t.channel_url)&&void 0!==s?s:"",this.channelType=null!==(n=t.channel_type)&&void 0!==n?n:d.ChannelType.GROUP,this.reader=new d.User(this._iid,t.user),this.readAt=t.ts}}exports.PublicChannelFilter=void 0,(t=exports.PublicChannelFilter||(exports.PublicChannelFilter={})).ALL="all",t.PUBLIC="public",t.PRIVATE="private",exports.MyMemberStateFilter=void 0,(s=exports.MyMemberStateFilter||(exports.MyMemberStateFilter={})).ALL="all",s.JOINED="joined_only",s.INVITED="invited_only",s.INVITED_BY_FRIEND="invited_by_friend",s.INVITED_BY_NON_FRIEND="invited_by_non_friend",exports.SuperChannelFilter=void 0,(n=exports.SuperChannelFilter||(exports.SuperChannelFilter={})).ALL="all",n.SUPER="super",n.NON_SUPER="nonsuper",n.BROADCAST_ONLY="broadcast_only",n.EXCLUSIVE_ONLY="exclusive_only",exports.UnreadChannelFilter=void 0,(i=exports.UnreadChannelFilter||(exports.UnreadChannelFilter={})).ALL="all",i.UNREAD_MESSAGE="unread_message",exports.HiddenChannelFilter=void 0,(a=exports.HiddenChannelFilter||(exports.HiddenChannelFilter={})).ALL="all",a.UNHIDDEN="unhidden_only",a.HIDDEN="hidden_only",a.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",a.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",exports.OperatorFilter=void 0,(r=exports.OperatorFilter||(exports.OperatorFilter={})).ALL="all",r.OPERATOR="operator",r.NONOPERATOR="nonoperator",exports.QueryType=void 0,(o=exports.QueryType||(exports.QueryType={})).AND="AND",o.OR="OR",exports.GroupChannelSearchField=void 0,(l=exports.GroupChannelSearchField||(exports.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",l.CHANNEL_NAME="channel_name";class m{constructor(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}_isFriend(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}get searchFilter(){return this._searchFilter}setSearchFilter(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}get userIdsFilter(){return this._userIdsFilter}setUserIdsFilter(e,t,s=exports.QueryType.AND){this._userIdsFilter={userIds:e,includeMode:t,queryType:s}}clone(){var e;const t=new m;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);const s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((e=>{t[e]=s[e]})),t}match(e,t){if(this._searchFilter){const{query:t,fields:s}=this._searchFilter;if(t&&s&&s.length>0&&!s.some((s=>{switch(s){case exports.GroupChannelSearchField.CHANNEL_NAME:return e.name.toLowerCase().includes(t.toLowerCase());case exports.GroupChannelSearchField.MEMBER_NICKNAME:return e.members.some((e=>e.nickname.toLowerCase().includes(t.toLowerCase())));default:return!0}})))return!1}if(this._userIdsFilter){const{userIds:s,includeMode:n,queryType:i}=this._userIdsFilter,a=e.members.map((e=>e.userId));if(n){if(s.length>0)switch(i){case exports.QueryType.AND:if(s.some((e=>!a.includes(e))))return!1;break;case exports.QueryType.OR:if(s.every((e=>!a.includes(e))))return!1}}else{if(s.includes(t)||s.push(t),e.members.length>s.length)return!1;if(!d.hasSameMembers(s,a))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp(`^${this.customTypeStartsWithFilter}`).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){const s=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().includes(s))))return!1}if(this.nicknameStartsWithFilter){const s=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().startsWith(s))))return!1}if(this.nicknameExactMatchFilter){const s=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase()!=s)))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case exports.MyMemberStateFilter.JOINED:if("joined"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED:if("invited"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case exports.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case exports.HiddenChannelFilter.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN:if(!e.isHidden)return!1;break;case exports.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===exports.UnreadChannelFilter.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case exports.PublicChannelFilter.PUBLIC:if(!e.isPublic)return!1;break;case exports.PublicChannelFilter.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case exports.SuperChannelFilter.SUPER:if(!e.isSuper)return!1;break;case exports.SuperChannelFilter.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)}}class g extends d.InstancedObject{constructor(e,{sdkState:t,cacheContext:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=s}get collection(){const{nestdb:e}=this._cacheContext;return d.unless(!!e).throw(d.SendbirdError.databaseError),e.collection(h.NESTDB_GROUPCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,t=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}_deserialize(e){return Ne.of(this._iid).buildGroupChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}filterOffsetChanged(e){return e.filter((e=>{if(this._channels.has(e.url)){return this._channels.get(e.url).messageOffsetTimestamp{if(e)switch(i){case c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;if(a&&a===t.url)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);n._pinnedMessagesUpdatedAt0&&(yield this.upsert(n))}))}block(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!0)}))}unblock(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!1)}))}markAsRead(e,t=[...this._channels.keys()]){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.get(n);(null==t?void 0:t._updateUnreadMemberState(this._sdkState.userId,e))&&(t._updateUnreadCount(0,0),s.push(t))}s.length>0&&(yield this.upsert(s))}))}}const C={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},E=e=>d.isArrayOf("string",e.invitedUserIds,!0)&&d.isTypeOf("string",e.channelUrl,!0)&&d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isSuper,!0)&&d.isTypeOf("boolean",e.isBroadcast,!0)&&d.isTypeOf("boolean",e.isExclusive,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isStrict,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("boolean",e.isEphemeral,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0),v={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},f=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty)&&d.isTypeOf("boolean",e.includeFrozen)&&d.isTypeOf("boolean",e.includeChatNotification),M={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=e=>d.isEnumOf(exports.MyMemberStateFilter,e.myMemberStateFilter);var y;exports.UnreadItemKey=void 0,(y=exports.UnreadItemKey||(exports.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",y.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",y.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",y.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",y.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",y.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",y.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",y.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",y.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";const A={keys:[]},b={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},N=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),T={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},U=Object.assign({},d.CollectionEventSource),I=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null,ts:i}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n,this.ts=i}}class O extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class R{constructor({groupChannelCache:e,messageCache:t,unsentMessageCache:s,dispatcher:n}){this._observers=new Map,n.on((n=>d.__awaiter(this,void 0,void 0,(function*(){if(n instanceof P){const{channels:s,source:i,isWebSocketEventComing:a,data:r}=n,o=s.filter((e=>e instanceof Ft)),l=e.filterOffsetChanged(o);for(const e of l)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);const d=yield e.upsert(o,n.ts);a||this._broadcastUpdateEvent(d,i,r)}else if(n instanceof O){const{channelUrls:i,source:a,isWebSocketEventComing:r}=n;yield e.remove(i),yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield t.removeMessagesOfChannel(e),yield s.removeMessagesOfChannel(e)})))),r||this._broadcastRemoveEvent(i,a)}else n instanceof c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t,s){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t,s)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class x extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},v),n);this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/my_group_channels/changelogs`,this.params=d.deundefined(d.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:t||null,token:s,custom_types:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class w extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new Ft(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class F extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${t?d.API_PATH_GROUP_CHANNELS_INTERNAL:d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class D extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}const L={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:exports.MyMemberStateFilter.ALL,unreadChannelFilter:exports.UnreadChannelFilter.ALL,superChannelFilter:exports.SuperChannelFilter.ALL,publicChannelFilter:exports.PublicChannelFilter.ALL,hiddenChannelFilter:exports.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class k extends d.APIRequestCommand{constructor(e){const{userId:t,token:s,limit:n,order:i,includeEmpty:a,myMemberStateFilter:r,superChannelFilter:o,publicChannelFilter:l,unreadChannelFilter:h,nicknameContainsFilter:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:S,includeFrozen:y,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,createdAfter:U,createdBefore:I}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=d.deundefined({token:s,limit:n,order:null!=i?i:L.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:L.includeEmpty,member_state_filter:null!=r?r:L.myMemberStateFilter,super_mode:null!=o?o:L.superChannelFilter,public_mode:null!=l?l:L.publicChannelFilter,unread_filter:null!=h?h:L.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:S,show_frozen:y,show_metadata:A,include_chat_notification:T,created_after:U,created_before:I}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class H extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:s,channels:n,ts:i}=t;this.token=s,n&&n.length>0&&(this.channels=n.map((t=>(t.ts=i,new Ft(e,t))))),this.ts=null!=i?i:0}}class V extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{myMemberStateFilter:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/group_channel_count`,this.params={state:null!=s?s:exports.MyMemberStateFilter.ALL}}}class G extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class q extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s})}}class B extends d.APIResponseCommand{constructor(e,t){super(e,t),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(this.groupChannelUnreadMentionCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(this.groupChannelUnreadMessageCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(this.groupChannelInvitationCount=t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(this.superGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(this.superGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]&&(this.superGroupChannelInvitationCount=t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(this.nonSuperGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(this.nonSuperGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(this.nonSuperGroupChannelInvitationCount=t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT])}}class j extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class z extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q extends d.APIRequestCommand{constructor({channelUrl:e,scheduledStatus:t,messageTypeFilter:s}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_SCHEDULED_MESSAGES}/count`,this.params={channel_url:e,status:Y(t)},s&&(this.params.message_type=s)}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const Y=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class J extends d.APIRequestCommand{constructor(e){const{userId:t,channelUrl:s,coverUrl:n,coverImage:i,isDistinct:a,isSuper:r,isBroadcast:o,isPublic:l,isExclusive:h,isDiscoverable:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].filter(((e,t,s)=>t===s.indexOf(e))),channel_url:s,cover_url:n,cover_file:i,is_distinct:a,is_super:r,is_broadcast:o,is_exclusive:h,is_public:l,is_discoverable:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new Ft(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class X extends d.APIRequestCommand{constructor({userId:e,channelUrls:t}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/mark_as_read_all`,this.params={channel_urls:t}}}class ee extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/join`,this.params={user_id:s,access_code:n}}}class te extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}class se extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0,users:a=null}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.members=Array.isArray(a)?a.map((t=>new _(e,t))):[new _(e,s.data)]}}class ne extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,shouldRemoveOperatorStatus:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/leave`,this.params={user_id:s,should_remove_operator_status:n}}}class ie extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.member=new _(this._iid,s.data)}}class ae extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userIds:s}=e;super(),this.method=d.APIRequestMethod.POST,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/invite`,this.params={user_ids:s}}}class re extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}class oe extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new _(e,t)))}}class le extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/decline`,this.params={user_id:s}}}class de extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n,joined_member_count:i,inviter:a,invitee:r}=s.data;this.memberCount=null!=n?n:0,this.joinedMemberCount=null!=i?i:0,this.inviter=new d.User(e,a),this.invitee=new _(e,r)}}const he={hidePreviousMessages:!1,allowAutoUnhide:!0};class ce extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,hidePreviousMessages:n,allowAutoUnhide:i}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`,this.params={user_id:s,hide_previous_messages:null!=n?n:he.hidePreviousMessages,allow_auto_unhide:null!=i?i:he.allowAutoUnhide}}}class ue extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class _e extends d.WebSocketEventCommand{constructor(e,t,s){var n,i,a;super(e,"SYEV",s),this.allowAutoUnhide=null,this.hidePreviousMessages=null,this.messageOffsetTimestamp=null,s.data&&(this.allowAutoUnhide=null!==(n=s.data.allow_auto_unhide)&&void 0!==n?n:null,this.hidePreviousMessages=null!==(i=s.data.hide_previous_messages)&&void 0!==i?i:null),this.messageOffsetTimestamp=null!==(a=s.ts_message_offset)&&void 0!==a?a:null}}class pe extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class me extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class ge extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPEN",ackRequired:!1,payload:{channel_url:e,time:t}})}}class Ce extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ee extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class ve extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,S,y,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter={fields:[],query:null},this.userIdsFilter={userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=c.GroupChannelListOrder.LATEST_LAST_MESSAGE,this.includeEmpty=null!==(s=t.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(n=t.includeFrozen)||void 0===n||n,this.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,this.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(S=t.metadataValues)&&void 0!==S?S:null,this.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeEmpty)&&d.isTypeOf("boolean",this.includeFrozen)&&d.isTypeOf("boolean",this.includeMetaData)&&d.isTypeOf("string",this.channelNameContainsFilter)&&d.isArrayOf("string",this.channelUrlsFilter,!0)&&d.isArrayOf("string",this.customTypesFilter,!0)&&d.isTypeOf("string",this.customTypeStartsWithFilter)&&d.isTypeOf("string",this.nicknameContainsFilter,!0)&&d.isTypeOf("string",this.nicknameStartsWithFilter,!0)&&d.isTypeOf("string",this.nicknameExactMatchFilter,!0)&&d.isEnumOf(exports.MyMemberStateFilter,this.myMemberStateFilter)&&d.isEnumOf(exports.SuperChannelFilter,this.superChannelFilter)&&d.isEnumOf(exports.PublicChannelFilter,this.publicChannelFilter)&&d.isEnumOf(exports.UnreadChannelFilter,this.unreadChannelFilter)&&d.isEnumOf(exports.HiddenChannelFilter,this.hiddenChannelFilter)&&d.isArrayOf(exports.GroupChannelSearchField,this.searchFilter.fields)&&d.isTypeOf("string",this.searchFilter.query,!0)&&d.isArrayOf("string",this.userIdsFilter.userIds)&&d.isTypeOf("boolean",this.userIdsFilter.includeMode)&&d.isEnumOf(exports.QueryType,this.userIdsFilter.queryType)&&d.isEnumOf(c.GroupChannelListOrder,this.order)&&d.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&d.isTypeOf("string",this.metadataKey,!0)&&d.isArrayOf("string",this.metadataValues,!0)&&d.isTypeOf("string",this.metadataValueStartsWith,!0)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!0)}serialize(){return d.serialize(this)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=Ne.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class fe extends d.WebSocketEventCommand{constructor(e,t,s){var n;super(e,"SYEV",s),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,s.data&&(this.pinnedMessageIds=null!==(n=s.data.pinned_message_ids)&&void 0!==n?n:[],this.latestPinnedMessage=s.data.latest_pinned_message?h.parseMessagePayload(e,Object.assign({},s.data.latest_pinned_message)):null),this.ts=s.ts}}class Me extends d.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class Se extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new p(e,s)}}class ye extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){super(),super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/messages/mark_as_delivered`,this.params=d.deundefined({userId:t})}}class Ae extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}const be={};class Ne extends u.BaseChannelManager{constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new g(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new R({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),this._groupChannelHandlers.forEach((t=>{t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))}),1e3),this._dispatcher.on((e=>{e instanceof d.WebSocketEventCommand?this._handleEvent(e):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand&&this.reduceDBSize()})),be[e]||(be[e]=this)}static of(e){return be[e]||(be[e]=new Ne(e,d.Vault.of(e))),be[e]}static clear(e){be[e]&&delete be[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new Ft(this._iid,Ft.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new ve(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new _(this._iid,_.payloadify(t))}getChannelFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._groupChannelCache.get(e))&&void 0!==t?t:null}))}getChannelsFromCache(e,t,s,n,i){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.fetch({token:e,filter:t,order:s,limit:n,borderlineChannelUrl:i})}))}upsertChannelsToCache(e){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.upsert(e)}))}removeChannelsFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.remove(e)}))}clearChannelsFromCache(){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.clear()}))}reduceDBSize(){return d.__awaiter(this,void 0,void 0,(function*(){const e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new Ee(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0);if(r.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(r.hiddenState=exports.HiddenState.UNHIDDEN),e instanceof h.SendableMessage){const{useMemberInfoInMessage:s}=d.Vault.of(this._iid);for(const t of r.members)if(t.userId===e.sender.userId){s||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!s&&n&&(null===(t=e.mentionedUsers)||void 0===t||t.forEach((e=>{for(const t of r.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),a){const{currentUser:t}=this._sessionManager;t&&(t.nickname=e.sender.nickname,t.plainProfileUrl=e.sender.plainProfileUrl,t.metaData=e.sender.metaData)}}e.silent&&!a||(r.isEphemeral||s)&&((!r.lastMessage||r.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(r)})))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageReceived&&t.onMessageReceived(r,e),n&&t.onMentionReceived&&t.onMentionReceived(r,e)}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===e.code?t=e.as(h.UpdateUserMessageEventCommand):"FEDI"===e.code?t=e.as(h.UpdateFileMessageEventCommand):"AEDI"===e.code&&(t=e.as(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:s}=t;if(e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),n=yield this.getChannel(e.channelUrl,!0),i=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let a=!1;if(i){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else n.isReadMessage(e)||0!==s&&!e.silent&&t&&(n._updateUnreadCount(n.unreadMessageCount,n.unreadMentionCount+s),a=!0);!n.lastMessage||n.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),r&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(n,e),0!==s&&t.onMentionReceived&&t.onMentionReceived(n,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n}=e.as(h.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.EVENT_MESSAGE_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageDeleted&&t.onMessageDeleted(e,n)}))))}break}case"READ":{const{readStatus:t}=e.as(Se);if(t.channelType===d.ChannelType.GROUP){const e=this._groupChannelCache.isCachedInMemory(t.channelUrl),s=yield this.getChannel(t.channelUrl,!0);e&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId?e?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):(this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(s)})))))}break}case"DLVR":{const{channelUrl:t,deliveredStateUpdate:s={}}=e.as(Ae),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);if(n)for(const e in s)i._updateUndeliveredMemberState(e,s[e]);Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],source:d.CollectionEventSource.EVENT_CHANNEL_DELIVERED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUndeliveredMemberStatusUpdated&&e.onUndeliveredMemberStatusUpdated(i)})))));break}case"MRCT":{const{channelUrl:t,channelType:s,event:n}=e.as(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onReactionUpdated&&t.onReactionUpdated(e,n)}))))}break}case"MTHD":{const{event:t}=e.as(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onThreadInfoUpdated&&s.onThreadInfoUpdated(e,t)}))))}break}case"MCNT":{const{groupChannelMemberCounts:t}=e.as(u.MemberCountUpdateEventCommand),s=[];for(const e of t){const{channelUrl:t,memberCount:n,joinedMemberCount:i,updatedAt:a}=e,r=yield this.getChannelFromCache(t);r&&r._setLatestMemberCount(n,i,a)&&s.push(r)}s.length>0&&(this._dispatcher.dispatch(new P({channels:s,source:d.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(s)})))));break}case"PEDI":{const{event:t,status:s,channelUrl:n,channelType:i}=e.as(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_UPDATED})),s===d.POLL_REMOVED_STATUS?d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollDeleted&&s.onPollDeleted(e,t.pollId)})))):d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollUpdated&&s.onPollUpdated(e,t)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:n}=e.as(h.PollVoteEventCommand);if(s&&n===d.ChannelType.GROUP){const e=yield this.getChannel(s,!0);this._dispatcher.dispatch(new d.PollVoteInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_VOTED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollVoted&&s.onPollVoted(e,t)}))))}break}case"SYEV":{const{event:t}=e.as(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(se);let r=!1;a.forEach((e=>{s.isExclusive||s.isSuper||s.isBroadcast?r=r||s._setLatestMemberCount(n,i,t.ts):(e.state=exports.MemberState.JOINED,s.addMember(e,t.ts),this._updateJoinedMemberCount(s)),e.userId===this._sdkState.userId&&(s.myMemberState=exports.MemberState.JOINED)})),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{for(const t of a)e.onUserJoined&&e.onUserJoined(s,t);s.isBroadcast&&r&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([s])}))}))));break}case u.ChannelEventCategory.CHANNEL_LEAVE:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0),{memberCount:i,joinedMemberCount:a,member:r}=e.as(ie);let o=!1;const{appInfo:l}=d.Vault.of(this._iid);if(n.isExclusive||n.isSuper||n.isBroadcast)o=n._setLatestMemberCount(i,a,t.ts);else{if(null==l?void 0:l.enabledChannelMemberShipHistory){const e=n.members.find((t=>t.userId===e.userId));e&&(e.state=exports.MemberState.LEFT),n.memberCount=i}else n.removeMember(r);this._updateJoinedMemberCount(n)}r.userId===this._sdkState.userId?(n.myMemberState=exports.MemberState.NONE,n.invitedAt=0,n.joinedAt=0,n._updateUnreadCount(0,0),n.isPublic?this._dispatcher.dispatch(new P({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(n),this._dispatcher.dispatch(new O({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new P({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserLeft&&e.onUserLeft(n,r),n.isBroadcast&&o&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([n])}))}))));break}case u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.OperatorUpdateEventCommand),i=n.map((e=>e.userId));for(const e of s.members)e.role=i.includes(e.userId)?d.Role.OPERATOR:d.Role.NONE;s.myRole=i.includes(this._sdkState.userId)?d.Role.OPERATOR:d.Role.NONE,this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(oe);r.forEach((e=>e.state=exports.MemberState.INVITED));for(const e of r)s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.addMember(e,t.ts),this._sdkState.userId===e.userId&&(s.hiddenState=exports.HiddenState.UNHIDDEN,s.myMemberState!==exports.MemberState.JOINED&&(s.myMemberState=exports.MemberState.INVITED),s.invitedAt=t.ts);this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(de);s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.removeMember(r),this._sdkState.userId===r.userId?(s.invitedAt=0,s.myMemberState=exports.MemberState.NONE,s.isPublic?this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new O({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?me:Ce);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onTypingStatusUpdated&&e.onTypingStatusUpdated(s)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.MutedState.UNMUTED,s._myMutedRemainingTime=i.restrictionInfo.remainingDuration);for(const e of s.members)if(e.userId===i.userId){e.isMuted=n;break}this._dispatcher.dispatch(new P({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,data:i.userId})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onUserMuted&&e.onUserMuted(s,i):e.onUserUnmuted&&e.onUserUnmuted(s,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_BAN:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0);this._markAsLeave(n);const{user:i}=e.as(h.BanUserEventCommand);i.userId===this._sdkState.userId&&this._dispatcher.dispatch(new O({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_BANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new O({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onChannelFrozen&&e.onChannelFrozen(s):e.onChannelUnfrozen&&e.onChannelUnfrozen(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(_e);null!==n&&(s.hiddenState=n?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==i&&i&&s._updateUnreadCount(0,0),null!==a&&(s.messageOffsetTimestamp=a),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new O({channelUrls:[t.channelUrl],source:d.CollectionEventSource.EVENT_CHANNEL_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelDeleted&&t.onChannelDeleted(e.url,e.channelType)}))}))));break}case u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaDataEventCommand);n&&(s._upsertCachedMetaData(n,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaDataCreated&&e.onMetaDataCreated(s,n),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(s,i),a&&e.onMetaDataDeleted&&e.onMetaDataDeleted(s,a)}))}))));break}case u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED})),i&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED})),a&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaCounterCreated&&e.onMetaCounterCreated(s,n),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(s,i),a&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(s,a)}))}))));break}case u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(fe);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=n,s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)})))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(s)}))})))));break}}break}case"USEV":{const{event:t}=e.as(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.unblock(e.userId,s.userId);break}}break}}}catch(e){if(d.isThrowingOutside(e))throw e}}))}_markAsLeave(e){var t;const s=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};s.ref++,this._leftChannels.set(e.url,s),setTimeout((()=>{s.ref--,0===s.ref&&this._leftChannels.delete(e.url)}),1e4)}addHandler(e,t){this._groupChannelHandlers.set(e,t)}removeHandler(e){this._groupChannelHandlers.delete(e)}clearHandler(){this._groupChannelHandlers.clear()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.unsubscribe(e)}_updateJoinedMemberCount(e){e.joinedMemberCount=e.members.filter((e=>e.state===exports.MemberState.JOINED)).length}getChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);try{const t=yield this.getChannelFromCache(e);if(t)return t}catch(e){}return yield this.getChannelWithoutCache(e,t)}))}getChannelWithoutCache(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);const s=new F({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(D);let{unreadMessageCount:a,unreadMentionCount:r}=i;switch(i.myCountPreference){case exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:r=0;break;case exports.CountPreference.UNREAD_MENTION_COUNT_ONLY:a=0;break;case exports.CountPreference.OFF:a=0,r=0}return i._updateUnreadCount(a,r),(yield this.upsertChannelsToCache([i]))[0]}))}refreshChannel(e,t=!0,s=d.CollectionEventSource.REFRESH_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){try{const n=new F({channelUrl:e,isInternalCall:t}),i=yield this._requestQueue.send(n),{channel:a}=i.as(D);if(a.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new O({channelUrls:[a.url],source:s}));else{const e=yield this.upsertChannelsToCache([a]);this._dispatcher.dispatch(new P({channels:e,source:s}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new O({channelUrls:[e],source:s}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));const i=new k(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s})),a=yield this._requestQueue.send(i),{channels:r,token:o}=a.as(H);return this._dispatcher.dispatch(new P({channels:r,source:n})),{channels:r,token:o}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},v),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&f(n)).throw(d.SendbirdError.invalidParameters);const i=new x(d.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:n})),a=(yield this._requestQueue.send(i)).as(w),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,source:s,ts:h})),o.length>0&&this._dispatcher.dispatch(new O({channelUrls:o,source:s})),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,token:a.token}}))}getGroupChannelCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},M),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new V({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(G);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},A),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys))(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new q({userId:s.userId,filter:t}),a=yield n.send(i),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(B);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m})}))}getTotalUnreadChannelCount(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new j({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(W);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless(N(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new $({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(z);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},T),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.ScheduledStatus,e.scheduledStatus,!0)&&d.isEnumOf(d.MessageTypeFilter,e.messageTypeFilter))(t)).throw(d.SendbirdError.invalidParameters);const{requestQueue:s}=d.Vault.of(this._iid),n=new Q(t),i=yield s.send(n),{count:a}=i.as(K);return a}))}getSubscribedTotalUnreadMessageCount(){const{subscribedUnreadMessageCount:e}=d.Vault.of(this._iid);return e.all>=0?e.all:0}getSubscribedCustomTypeTotalUnreadMessageCount(){let e=0;const{subscribedUnreadMessageCount:t}=d.Vault.of(this._iid);for(const s in t.customTypes)e+=t.customTypes[s];return e}getSubscribedCustomTypeUnreadMessageCount(e){var t;const{subscribedUnreadMessageCount:s}=d.Vault.of(this._iid);return null!==(t=s.customTypes[e])&&void 0!==t?t:0}createChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},C),e);d.unless(E(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new J(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);return yield this.upsertChannelsToCache([i]),i}))}markAsReadAll(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Date.now();d.unless(e-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e;const t=new X({userId:this._sdkState.userId});yield this._requestQueue.send(t);const s=this._groupChannelCache.channels;for(const t of s)t._updateUnreadMemberState(this._sdkState.userId,e),t._updateUnreadCount(0,0);s.length>0&&(yield this.upsertChannelsToCache(s))}))}markAsReadWithChannelUrls(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Date.now();d.unless(d.isArrayOf("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t;const s=new X({userId:this._sdkState.userId,channelUrls:e});yield this._requestQueue.send(s);const n=this._groupChannelCache.channels,i=[];for(const s of n)e.includes(s.url)&&(s._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0),i.push(s));i.length>0&&(yield this.upsertChannelsToCache(i))}))}markAsDelivered(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getChannel(e);yield t.markAsDelivered()}))}}var Te;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Te||(Te={}));class Ue extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Te.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Te.IDLE}get isRunning(){return this._state===Te.RUNNING}get isDone(){return this._state===Te.END}get retryCount(){return this._retryCount}get retryLimit(){return this._retryLimit}_run(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this.isRunning)try{const t=yield this._worker(e);this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end()}catch(t){this.dispatch("error",t),this._retryCount`sendbird:${e}@groupchannel/${t}/message/sync`)(n.userId,t.url);this._prevSync=new Ue(l,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,i,r;const o={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(e),a.debug("message background prev sync from",null===(t=this._metadata)||void 0===t?void 0:t.range.top),null===(s=this._metadata)||void 0===s?void 0:s.previousComplete)o.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(i=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===i?void 0:i.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(r=this._metadata)||void 0===r?void 0:r.range.intersect(...e))?this.extendRange(s):this._metadata={range:new u.TimeRange({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}o.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(o.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){var t,s,n,i;const r={hasNext:!0,nextToken:0};this._nextSyncLoopCount++,yield this.loadMetadata(e),a.debug("message background next sync from",null===(t=this._metadata)||void 0===t?void 0:t.range.bottom);try{const t=h.MessageManager.of(this._iid),o=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(n=null===(s=this._metadata)||void 0===s?void 0:s.range)||void 0===n?void 0:n.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(o.length>0){const e=o.map((e=>e.createdAt));(null===(i=this._metadata)||void 0===i?void 0:i.range.intersect(...e))?this.extendRange(o):this._metadata={range:new u.TimeRange({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}r.hasNext=o.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(r.nextToken=this._metadata.range.bottom),a.debug("message background next sync progress",r),yield this.saveMetadata()}catch(e){throw a.debug("message background next sync error",e),e}return r})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Ie[e]||(Ie[e]={}),Ie[e][t.url]||(Ie[e][t.url]=new Pe({_iid:e,channel:t})),Ie[e][t.url].ref++,Ie[e][t.url]}static clear(e,t){Ie[e]&&Ie[e][t]&&(Ie[e][t].close(),delete Ie[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new u.TimeRange({})}get previousComplete(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}isWrappingMessages(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes(...e.map((e=>e.createdAt)))}extendRange(e){this._metadata&&this._metadata.range.extends(...e.map((e=>e.createdAt)))}loadMetadata(e){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=d.Vault.of(this._iid),s=yield t.preference.get(this._metadataKey);s?s.range.bottom`sendbird:${e}@groupchannel/${t}/message/changelogs`)(n.userId,this._channel.url);this._sync=new Ue(o,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),s.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:n,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:d.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(n.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),s.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw s.debug("message changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new Re({_iid:e,channel:t})),Oe[e][t.url].ref++,Oe[e][t.url]}static clear(e,t){Oe[e]&&Oe[e][t]&&(Oe[e][t].close(),delete Oe[e])}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e,firstConnectedAt:t}=d.Vault.of(this._iid),s=yield e.preference.get(this._metadataKey);this._metadata={token:s?s.token:t}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);t.isConnected&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);e.debug("message changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Oe[this._iid][this._channel.url])}}const xe={};class we{constructor({_iid:e,channel:t,hasPollMessage:s}){this.ref=0,this._iid=e,this._channel=t;const{logger:n,sdkState:i,dispatcher:a}=d.Vault.of(this._iid);var r,o;this._metadataKey=(r=i.userId,o=t.url,`sendbird:${r}@groupchannel/${o}/poll/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/poll/changelogs`)(i.userId,this._channel.url);this._sync=new Ue(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};if(yield this.loadMetadata(),n.debug("poll changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token),!(this._metadata&&this._metadata.token||(yield s()))){return{hasNext:!1,nextToken:0}}if(!this._metadata){const{firstConnectedAt:e}=d.Vault.of(this._iid);this._metadata={token:e}}try{const e=d.PollManager.of(this._iid),{hasMore:s,token:i}=yield e.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);t.hasNext=s,t.nextToken=i,this._metadata.token=i,n.debug("poll changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("poll changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t,s){return xe[e]||(xe[e]={}),xe[e][t.url]||(xe[e][t.url]=new we({_iid:e,channel:t,hasPollMessage:s})),xe[e][t.url].ref++,xe[e][t.url]}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e}=d.Vault.of(this._iid),t=yield e.preference.get(this._metadataKey);this._metadata=t?{token:t.token}:void 0}}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.set(this._metadataKey,this._metadata)}}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync resume()"),this._sync.start(0)}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete xe[this._iid][this._channel.url])}}class Fe extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n}}class De extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class Le extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages_gap`,this.params=d.deundefined({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(t=e.threshold)&&void 0!==t?t:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(n=e.messageType)&&void 0!==n?n:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages})}}class ke extends d.APIResponseCommand{constructor(e,t){var s,n,i,a,r,o;super(e,t),this.isHugeGap=t.is_huge_gap,this.prevMessages=(null!==(s=t.prev_messages)&&void 0!==s?s:[]).map((t=>h.parseMessagePayload(e,t))),this.prevHasMore=null!==(n=t.prev_hasmore)&&void 0!==n&&n,this.isContinuousPrevMessages=null!==(i=t.is_continuous_prev_messages)&&void 0!==i&&i,this.nextMessages=(null!==(a=t.next_messages)&&void 0!==a?a:[]).map((t=>h.parseMessagePayload(e,t))),this.nextHasmore=null!==(r=t.next_hasmore)&&void 0!==r&&r,this.isContinuousNextMessages=null!==(o=t.is_continuous_next_messages)&&void 0!==o&&o}}const He=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Ve=(e,t)=>e.findIndex((e=>e.messageId===t)),Ge=(e,t)=>{if(e.length>0){let s=0,n=e.length-1,i=Math.floor((s+n)/2);for(;s0)n=i,i=Math.floor((s+n)/2);else{if(!(a<0))return i;s=i+1,i=Math.floor((s+n)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length};class qe{constructor(e){this.source=e}}class Be extends qe{}class je extends qe{}class We{constructor(e){this.source=e}}class $e extends We{}class ze extends We{}const Qe=6e5,Ke={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ye{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_invokeResponse(e,t,s){d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){switch(e){case"local":this._onCacheResult(t,s);break;case"remote":this._onApiResult(t,s)}}))))}onCacheResult(e){return this._onCacheResult=e,this}onApiResult(e){return this._onApiResult=e,this}}class Je{constructor(e,{filter:t,startingPoint:s,limit:n,channel:i,channelManager:a}){this._messages=[],this._unsentMessages=[],this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=i,this._syncRange=new u.TimeRange({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+Qe,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._channelManager=a,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t,s)=>{const n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(t){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(const s in this._messages){if(this._messages[s].createdAt>=e.messageOffsetTimestamp){t=!0;const e=parseInt(s);if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>e.messageId)),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>e.messageId)),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),t=s;e.userId===t&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:t}=d.Vault.of(this._iid),n=s;t.userId===n&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);I(t)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(s,this.channel)}))))})))},onRemove:(e,t)=>{e.indexOf(this.channel.url)>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(s,this.channel.url)})))))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:(e,t)=>{const s=[],n=[];for(const t of e)t.channelUrl===this._channel.url&&(this.filter.match(t)?s.push(t):n.push(t.messageId));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}},onRemove:(e,t)=>{this._removeMessagesFromView(e,t)},onRemoveUnsent:(e,t)=>{this._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:(e,t)=>{this._updatePollsToView(e,t)},onPollUpdate:(e,t)=>{this._applyPollUpdateEventToView(e,t)},onPollVote:(e,t)=>{this._applyPollVoteEventToView(e,t)}});const{cacheContext:r,dispatcher:o,logger:l}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt();const c=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);c&&o.dispatch(c),this._shouldStartBackgroundSync()&&(this._backgroundSync=Pe.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Re.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=we.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Ue(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t;const{messages:s,isContinuousMessages:n}=yield this._getRemoteMessages(e,{prevLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled});if(s.length>0){const e=Math.min(...s.map((e=>e.createdAt)));return this._syncRange.extends(e),n&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:s.length>=this._limit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){var t;const{messages:s,isContinuousMessages:n}=yield this._getRemoteMessages(e,{nextLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled});if(s.length>0){const e=Math.max(...s.map((e=>e.createdAt)));return this._syncRange.extends(e),n&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(s.length>=this._limit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return{hasNext:!1,nextToken:0}})))),this._connectionEventContext=o.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)})))),l.debug("check huge gap"),this._checkHugeGap();break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}));const{statLogCollector:_}=d.Vault.of(this._iid);_.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message:!0}}}))}get channel(){return this._channel}get succeededMessages(){return[...this._messages]}get failedMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.FAILED))}get pendingMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.PENDING))}get hasPrevious(){return this._hasPrevious}get hasNext(){return this._hasNext}get viewTop(){return Math.min(...this._messages.map((e=>e.createdAt)),Number.MAX_SAFE_INTEGER)}get viewBottom(){return Math.max(...this._messages.map((e=>e.createdAt)),0)}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_createChannelEventContext(e){switch(!0){case this.channel.isGroupChannel():return new Be(e);case this.channel.isFeedChannel():return new je(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createMessageEventContext(e){switch(!0){case this.channel.isGroupChannel():return new $e(e);case this.channel.isFeedChannel():return new ze(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createChannelUpdateEventCommand(e){switch(!0){case this.channel.isGroupChannel():return new P({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new Fe({channels:[this._channel],source:e});default:return null}}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(He(this._messages,e)<0){He(this._unsentMessages,e)<0&&n.push(e);const t=Ge(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){He(this._unsentMessages,e)<0&&He(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=He(this._messages,e);if(t<0){const t=He(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Ge(this._messages,e);this._messages.splice(s,0,e)}else i.push(e),this._messages[t]=e;if(e.updatedAt>0){const t=this._updateChildMessagesInView(e);i.push(...t)}}else if(e instanceof h.SendableMessage){const t=He(this._unsentMessages,e);t<0?He(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e)):(i.push(e),this._unsentMessages[t]=e)}d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s,a,r;const o=this._createMessageEventContext(t);n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Ve(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n&&n.applyPoll(t),s.push(n)}}return s.length>0&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,n;const i=this._createMessageEventContext(t);s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Ve(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Ve(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=He(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=He(this._unsentMessages,t);if(e>=0){const s=this._unsentMessages.splice(e,1);if(this.hasNext&&s.length>0)i.push(s[0]);else{n.push(t);const e=Ge(this._messages,t);this._messages.splice(e,0,t)}}else{const e=this._messages.map((e=>e.createdAt));(t.createdAtMath.max(...e)&&!this._hasNext)&&s.push(t)}}}else if(t instanceof h.SendableMessage){const e=He(this._unsentMessages,t);e>=0&&(n.push(t),this._unsentMessages[e]=t)}return d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,a,r,o;const l=this._createMessageEventContext(t);n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>e.messageId===t));if(e>=0){const t=this._messages[e];s.push(t.messageId),n.push(t),this._messages.splice(e,1)}}return d.shouldGiveEvent(t)&&n.length>0&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,i;const a=this._createMessageEventContext(t);null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,this.channel,s,n)})))),s}_removeUnsentMessageFromView(e,t){const s=this._unsentMessages.findIndex((t=>t.reqId===e));s>=0&&this._unsentMessages.splice(s,1)}_getLocalMessages(e,{prevLimit:t=0,nextLimit:s=0,inclusive:n=!0}){return d.__awaiter(this,void 0,void 0,(function*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt))}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingContinuousMessages:a=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const r=h.MessageManager.of(this._iid);return t>0||s>0?yield r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),Ke),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e;return d.__awaiter(this,void 0,void 0,(function*(){if(this._messages.length>0){const e=this._syncRange.top,t=this.viewTop,s=this._syncRange.bottom,n=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,i=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,t,e),a=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,s,n);yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var r;const{dispatcher:o,requestQueue:l,cacheContext:h}=d.Vault.of(this._iid),c=new Le(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:t,prevEnd:e,prevCount:i,nextStart:s,nextEnd:n,nextCount:a,checkingContinuousMessages:h.localCacheEnabled},this.filter),Ke)),u=yield l.send(c),{isHugeGap:_,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=u.as(ke);if(_)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const e=this.viewTop,t=this.viewBottom,s=Math.min(Number.MAX_SAFE_INTEGER,e,...p.map((e=>e.createdAt))),n=Math.max(0,t,...C.map((e=>e.createdAt)));o.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),o.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(s,n),(g||v)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(s,n)),m&&this._prevFill.start(s),E&&this._nextFill.start(n)}}))),1)}else{const{cacheContext:t}=d.Vault.of(this._iid),s=Math.floor(this._limit/2),n=Date.now();try{const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(n,{prevLimit:s,nextLimit:s,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:t.localCacheEnabled});if(i.length>0){const t=i.map((e=>e.createdAt));let r=0,o=0;for(let e=0;e=n&&o++}this._hasPrevious=r>=s,this._hasNext=o>=s,this._syncRange.extends(...t),a&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(i,d.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1}catch(e){e instanceof d.SendbirdError&&e.code===d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1)}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+Qe,this.filter,1)).length>0}))}_refreshChannel(e){this._channelManager.refreshChannel(this.channel.url,!0,e)}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{e&&this.channel._runIfHandleableWithGroupChannel((e=>{var t,s;e.myMutedState=d.MutedState.UNMUTED;const n=this._createChannelEventContext(d.CollectionEventSource.EVENT_CHANNEL_UNMUTED);null===(s=null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===s||s.call(t,n,this.channel)}))}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}initialize(e){const t=new Ye;this._messages=[],this._unsentMessages=[],this._syncRange=new u.TimeRange({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(d.CollectionEventSource.REFRESH_CHANNEL),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)}))));const s=Math.floor(this._limit/2);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){const s=this._filterUnderOffsetMessage(e);this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>{const{cacheContext:e}=d.Vault.of(this._iid);this._getRemoteMessages(this._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((({messages:e,isContinuousMessages:n})=>{var i;this._messages=[];const a=this._filterUnderOffsetMessage(e);if(a.length>0){const e=a.map((e=>e.createdAt));let t=0,r=0;for(let s=0;sthis._startingPoint&&r++}this._hasPrevious=t>=s,this._hasNext=r>=s,this._syncRange.extends(...a.map((e=>e.createdAt))),n&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)}else this._hasPrevious=!1,this._hasNext=!1;t._invokeResponse("remote",null,a)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))}));const{cacheContext:n,statLogCollector:i}=d.Vault.of(this._iid);return i.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:n.localCacheEnabled,collection_interface:{message_init_policy:e}}})),t}loadPrevious(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasPrevious)return[];const e=Math.floor(this._limit/2),t=this.viewTop;let s=[];return yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){s=this._filterUnderOffsetMessage(yield this._getLocalMessages(t,{prevLimit:e,inclusive:!1}))})))),s.lengthd.__awaiter(this,void 0,void 0,(function*(){var n,i;const{cacheContext:a}=d.Vault.of(this._iid),r=yield this._getRemoteMessages(t,{prevLimit:e,reverse:!0,checkingContinuousMessages:a.localCacheEnabled});s=this._filterUnderOffsetMessage(r.messages),s=s.filter((e=>He(this._messages,e)<0)),this._hasPrevious=s.length>=e,s.length>0&&(this._syncRange.extends(...s.map((e=>e.createdAt))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top)))})))),this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasPrevious=s.length>=e,s.length>0&&this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE)),s}))}loadNext(){var e;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasNext)return[];const t=Math.floor(this._limit/2),s=this.viewBottom;let n=[];return yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){n=this._filterUnderOffsetMessage(yield this._getLocalMessages(s,{nextLimit:t,inclusive:!1}))})))),n.lengthd.__awaiter(this,void 0,void 0,(function*(){var e,i;const{cacheContext:a}=d.Vault.of(this._iid),r=yield this._getRemoteMessages(s,{nextLimit:t,reverse:!0,checkingContinuousMessages:a.localCacheEnabled});n=this._filterUnderOffsetMessage(r.messages),n=n.filter((e=>He(this._messages,e)<0)),this._hasNext=n.length>=t,n.length>0&&(this._syncRange.extends(...n.map((e=>e.createdAt))),(null===(e=this._backgroundSync)||void 0===e?void 0:e.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.bottom)))})))),this._addMessagesToView(n,d.CollectionEventSource.REQUEST_MESSAGE)):(this._hasNext=n.length>=t,n.length>0&&this._addMessagesToView(n,d.CollectionEventSource.REQUEST_MESSAGE)),n}))}removeFailedMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,1)}))}dispose(){var e,t,s;if(this._isDisposed)return;this._isDisposed=!0;const{cacheContext:n,dispatcher:i}=d.Vault.of(this._iid);this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((e=>{if(e.myMemberState!==exports.MemberState.NONE){this._channel._updateMessageCollectionLastAccessedAt();const e=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);e&&i.dispatch(e)}})),n.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(s=this._pollChangelogSync)||void 0===s||s.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class Ze extends Je{constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:Ne.of(e)}))}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}}const Xe={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};class et extends d.APIRequestCommand{constructor(e){const{channelUrl:t,token:s,limit:n,order:i,mutedMemberFilter:a,memberStateFilter:r,nicknameStartsWithFilter:o,operatorFilter:l}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/members`,this.params={token:s,limit:n,order:i,muted_member_filter:a,member_state_filter:r,nickname_startswith:o,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class tt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.members=[];const{next:s,members:n}=t;this.token=s,n&&n.length>0&&(this.members=n.map((t=>new _(e,t))))}}var st,nt,it;exports.MutedMemberFilter=void 0,(st=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",st.MUTED="muted",st.UNMUTED="unmuted",exports.MemberListOrder=void 0,(nt=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",nt.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(it=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",it.JOINED="joined_only",it.INVITED="invited_only",it.INVITED_BY_FRIEND="invited_by_friend",it.INVITED_BY_NON_FRIEND="invited_by_non_friend";class at extends d.ChannelDataListQuery{constructor(e,t,s){var n,i,a,r;super(e,t,d.ChannelType.GROUP,s),this.mutedMemberFilter=exports.MutedMemberFilter.ALL,this.memberStateFilter=exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.operatorFilter=exports.OperatorFilter.ALL,this.order=exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,this.mutedMemberFilter=null!==(n=s.mutedMemberFilter)&&void 0!==n?n:exports.MutedMemberFilter.ALL,this.memberStateFilter=null!==(i=s.memberStateFilter)&&void 0!==i?i:exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null!==(a=s.nicknameStartsWithFilter)&&void 0!==a?a:null,this.order=null!==(r=s.order)&&void 0!==r?r:exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL}_validate(){return super._validate()&&d.isEnumOf(exports.MutedMemberFilter,this.mutedMemberFilter)&&d.isEnumOf(exports.MemberStateFilter,this.memberStateFilter)&&(d.isTypeOf("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&d.isEnumOf(exports.OperatorFilter,this.operatorFilter)&&d.isEnumOf(exports.MemberListOrder,this.order)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new et(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(tt);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class rt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/accept`,this.params={user_id:s,access_code:n}}}class ot extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class lt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,isDistinct:s,isPublic:n,isDiscoverable:i,coverUrl:a,coverImage:r,accessCode:o,name:l,data:h,customType:c,operatorUserIds:u,messageSurvivalSeconds:_}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params=d.deundefined({is_distinct:s,is_public:n,is_discoverable:i,name:l,data:h,custom_type:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ft(e,t)}}class ht extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`}}class ct extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`}}class ut extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,countPreference:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/count_preference/${encodeURIComponent(t)}`,this.params={count_preference:s}}}class _t extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class pt extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`}}class mt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const gt=Object.assign(Object.assign({},h.BaseMessageUpdateParamsDefault),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ct=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class Et extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>h.Thumbnail.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class vt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ft extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Mt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}`}}class St extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}/send_now`}}class yt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,pushTriggerOption:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`,this.params={push_trigger_option:s}}}class At extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class bt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class Nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Tt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class Ut extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class It extends d.InstancedObject{constructor(e,t){super(e),this.message=h.parseMessagePayload(e,t.message)}}class Pt extends d.APIRequestCommand{constructor(e){const{channelType:t,channelUrl:s,limit:n,token:i,includeReactions:a,includeMetaArray:r,includeParentMessageInfo:o,includeThreadInfo:l,includePollDetails:h}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/pinned_messages`,this.params=d.deundefined({limit:n,token:i,include_reactions:a,with_sorted_meta_array:r,include_thread_info:l,include_parent_message_info:o,include_poll_details:h})}}class Ot extends d.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:n,next:i}=t;this.pinnedMessages=s.map((t=>new It(e,t))),this.hasMore=n,this.token=i}}class Rt extends d.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n),this.includeMetaArray=n.includeMetaArray,this.includeReactions=n.includeReactions,this.includeParentMessageInfo=n.includeParentMessageInfo,this.includeThreadInfo=n.includeThreadInfo,this.includePollDetails=n.includePollDetails}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeMetaArray,!0)&&d.isTypeOf("boolean",this.includeReactions,!0)&&d.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&d.isTypeOf("boolean",this.includeThreadInfo,!0)&&d.isTypeOf("boolean",this.includePollDetails,!0)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new Pt(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{pinnedMessages:n,hasMore:i,token:a}=s.as(Ot);return this._token=a,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}var xt,wt;exports.CountPreference=void 0,(xt=exports.CountPreference||(exports.CountPreference={})).ALL="all",xt.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",xt.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",xt.OFF="off",exports.HiddenState=void 0,(wt=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",wt.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",wt.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class Ft extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,p,m,g,C,E,v,f,M,S,y;super(e,t),this._unreadMemberStateMap=new Map,this._undeliveredMemberStateMap=new Map,this._typingStatus=new Map,this._lastMemberCountUpdated=0,this._typingStarted=0,this._typingEnded=0,this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.members=[],this.memberCount=0,this.joinedMemberCount=0,this.hiddenState=exports.HiddenState.UNHIDDEN,this.lastMessage=null,this.messageOffsetTimestamp=0,this.messageSurvivalSeconds=-1,this.myMemberState=exports.MemberState.NONE,this.myRole=d.Role.NONE,this.myMutedState=d.MutedState.UNMUTED,this.myLastRead=0,this.myCountPreference=exports.CountPreference.ALL,this.myPushTriggerOption=d.PushTriggerOption.DEFAULT,this.inviter=null,this.invitedAt=0,this.joinedAt=0,this.pinnedMessageIds=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this._myMutedRemainingTime=-1,this.channelType=d.ChannelType.GROUP,this.isDistinct=null!==(s=t.is_distinct)&&void 0!==s&&s,this.isSuper=null!==(n=t.is_super)&&void 0!==n&&n,this.isBroadcast=null!==(i=t.is_broadcast)&&void 0!==i&&i,this.isExclusive=null!==(a=t.is_exclusive)&&void 0!==a&&a,this.isPublic=null!==(r=t.is_public)&&void 0!==r&&r,this.isDiscoverable=null!==(o=t.is_discoverable)&&void 0!==o?o:this.isPublic,this.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new _(this._iid,e)))),this.memberCount=null!==(p=t.member_count)&&void 0!==p?p:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((e=>{d.isTypeOf("number",t.read_receipt[e])&&this._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((e=>{d.isTypeOf("number",t.delivery_receipt[e])&&this._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),this.myMemberState=d.isEnumOf(exports.MemberState,t.member_state)?t.member_state:exports.MemberState.NONE,this.myRole=d.isEnumOf(d.Role,t.my_role)?t.my_role:d.Role.NONE,d.isEnumOf(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.MutedState.UNMUTED,this.myCountPreference=d.isEnumOf(exports.CountPreference,t.count_preference)?t.count_preference:exports.CountPreference.ALL,this.myPushTriggerOption=d.isEnumOf(d.PushTriggerOption,t.push_trigger_option)?t.push_trigger_option:d.PushTriggerOption.ALL,this.myLastRead=null!==(E=t.user_last_read)&&void 0!==E?E:0,this.inviter=t.inviter?new d.User(this._iid,t.inviter):null,this.invitedAt=null!==(v=t.invited_at)&&void 0!==v?v:0,this.joinedAt=null!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(S=t.unread_mention_count)&&void 0!==S?S:0),this.pinnedMessageIds=null!==(y=t.pinned_message_ids)&&void 0!==y?y:[],this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null}get isHidden(){return this.hiddenState!==exports.HiddenState.UNHIDDEN}get isTyping(){return this._typingStatus.size>0}get cachedUnreadMemberState(){const e={};for(const[t,s]of this._unreadMemberStateMap)e[t]=s;return e}get cachedUndeliveredMemberState(){const e={};for(const[t,s]of this._undeliveredMemberStateMap)e[t]=s;return e}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((e=>_.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null})))}_shouldUpdateLastMessageWith(e){return!(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_MESSAGE_SENT}))}_updateUnreadCount(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){const{maxSuperGroupChannelUnreadCount:t}=d.Vault.of(this._iid);this.unreadMessageCount=t&&e>=t?t:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0}_updateUnreadMemberState(e,t){const s=this._unreadMemberStateMap.get(e);if(!s||s0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}_clearTypingStatus(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}_setLatestMemberCount(e,t,s){let n=!1;return s>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=s,n=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),n}isReadMessage(e){const{sdkState:t}=d.Vault.of(this._iid),s=this._unreadMemberStateMap.get(t.userId);return!!s&&s>=e.createdAt}serialize(){return d.serialize(this,(e=>{e.cachedUnreadMemberState=this.cachedUnreadMemberState,e.cachedUndeliveredMemberState=this.cachedUndeliveredMemberState}))}createMessageCollection(e={}){return new Ze(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new at(this._iid,this.url,e)}createPinnedMessageListQuery(e={}){return new Rt(this._iid,this.url,this.channelType,e)}addMember(e,t=0){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const s=this.members.findIndex((t=>t.userId===e.userId));if(s>-1){const t=this.members[s];t.state===exports.MemberState.JOINED&&(e.state=t.state),this.members.splice(s,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}}removeMember(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const t=e instanceof _?e.userId:e,s=this.members.findIndex((e=>e.userId===t));if(s>-1)return this.members.splice(s,1),this.memberCount--,!0}return!1}getUnreadMemberCount(e){if(e instanceof h.SendableMessage&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const{sdkState:t}=d.Vault.of(this._iid),s=e.createdAt;let n=0;for(const i of this.members)if(t.userId!==i.userId&&i.state===exports.MemberState.JOINED&&e.sender.userId!==i.userId){(this.cachedUnreadMemberState[i.userId]||0){if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t>=e.createdAt&&i.push(a)}})),i}getUnreadMembers(e,t=!1){const{sdkState:s}=d.Vault.of(this._iid);if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];const n=e instanceof h.SendableMessage?e.sender:null,i=[];return this.members.forEach((a=>{if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t{if(e||n.userId!==t.userId){const e=this._unreadMemberStateMap.get(n.userId);s[n.userId]=new p(this._iid,{channel_url:this.url,channel_type:this.channelType,user:_.payloadify(n),ts:null!=e?e:0})}})),s}getTypingUsers(){const e=[];return this._typingStatus.forEach((t=>{const{user:s}=t;e.push(s)})),e}invalidateTypingStatus(){const{typingIndicatorInvalidateTime:e}=d.Vault.of(this._iid),t=Date.now();let s=!1;return this._typingStatus.forEach(((n,i)=>{const{ts:a}=n;t-a>=e&&(this._typingStatus.delete(i),s=!0)})),s}refresh(){return d.__awaiter(this,void 0,void 0,(function*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new F({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(D);return this._update(a),e&&s.dispatch(new P({channels:[a],source:d.CollectionEventSource.REQUEST_CHANNEL})),this}))}freeze(){const e=Object.create(null,{freeze:{get:()=>super.freeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.freeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}))}))}unfreeze(){const e=Object.create(null,{unfreeze:{get:()=>super.unfreeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.unfreeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Xe),e);d.unless((e=>d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,requestQueue:n}=d.Vault.of(this._iid),i=new lt(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(dt);return this._update(r),s.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),this}))}invite(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(e.every((e=>e instanceof d.User))).throw(d.SendbirdError.invalidParameters),this.inviteWithUserIds(e.map((e=>e.userId)))}))}inviteWithUserIds(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isArrayOf("string",e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new ae({channelUrl:this.url,userIds:e}),i=yield s.send(n),{channel:a}=i.as(re);return this._update(a),t.dispatch(new P({channels:[a],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),this}))}join(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new ee({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(te);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),this}))}leave(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=d.Vault.of(this._iid),n=new ne({channelUrl:this.url,userId:t.userId,shouldRemoveOperatorStatus:e});yield s.send(n),this.myMemberState=exports.MemberState.NONE}))}acceptInvitation(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new rt({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(ot);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),this}))}declineInvitation(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new le({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{this.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(this.hiddenState=exports.HiddenState.UNHIDDEN),n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e);Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}updateUserMessage(e,t){const s=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateUserMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ne.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ne.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ne.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.MultipleFilesMessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid);return super.sendMultipleFilesMessage(e).onPending((e=>{t._trigger(e)})).onFailed(((e,s)=>{t._triggerFailed(e,s)})).onSucceeded((e=>{const n=Ne.of(this._iid);this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})).onFileUploaded(((e,s,n,i)=>{t._triggerOnFileUploaded(e,s,n,i)})),t}updateFileMessage(e,t){const s=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateFileMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ne.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ne.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}deleteMessage(e){const t=Object.create(null,{deleteMessage:{get:()=>super.deleteMessage}});return d.__awaiter(this,void 0,void 0,(function*(){if(yield t.deleteMessage.call(this,e),0===e.messageId&&e instanceof h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.EVENT_MESSAGE_DELETED}))}}))}hide(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},he),e);d.unless((e=>d.isTypeOf("boolean",e.hidePreviousMessages,!0)&&d.isTypeOf("boolean",e.allowAutoUnhide,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,sdkState:n,requestQueue:i}=d.Vault.of(this._iid),a=new ce(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(ue);return this.hiddenState=t.allowAutoUnhide?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),o&&(this.messageOffsetTimestamp=o),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),this}))}unhide(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new ct({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),this}))}delete(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=d.Vault.of(this._iid),t=new ht({channelUrl:this.url});yield e.send(t)}))}markAsRead(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new Me({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(Se);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_READ}))}))}markAsDelivered(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new ye({channelUrl:this.url,userId:e.userId});yield t.send(s)}))}startTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingStarted>=t){this._typingStarted=s,this._typingEnded=0;const t=new pe({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}endTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingEnded>=t){this._typingStarted=0,this._typingEnded=s;const t=new ge({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.MessageRequestHandler;return this._createScheduledUserMessage(e,t),t}updateScheduledUserMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},Ct),t);d.unless((e=>h.validateUserMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0))(s)).throw(d.SendbirdError.invalidParameters);const{requestQueue:n}=d.Vault.of(this._iid),i=new ft(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),a=yield n.send(i),{message:r}=a.as(h.CreateScheduledUserMessageResponseCommand);return r}))}createScheduledFileMessage(e){e=Object.assign(Object.assign({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.MessageRequestHandler;return d.sleep(h.PENDING_MESSAGE_DELAY).then((()=>{const i=this._createPendingScheduledFileMessage(e,s,t);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){return n._trigger(i)}))))})),d.isFile(e.file)?this._uploadFileAndUpdateParams(e).then((()=>this._createScheduledFileMessage(e,n,s,t))):this._createScheduledFileMessage(e,n,s,t),n}updateScheduledFileMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},gt),t);d.unless((e=>h.validateBaseMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0)&&(d.isFile(e.file)||d.isTypeOf("string",e.fileUrl))&&d.isTypeOf("string",e.fileName,!0)&&d.isTypeOf("string",e.mimeType,!0)&&d.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>d.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))))(s)).throw(d.SendbirdError.invalidParameters),d.isFile(s.file)&&(yield this._uploadFileAndUpdateParams(s));const n=new Et(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),{requestQueue:i}=d.Vault.of(this._iid),a=yield i.send(n),{message:r}=a.as(vt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new Mt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}sendScheduledMessageNow(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new St({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}getMyPushTriggerOption(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new bt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(Nt);return this.myPushTriggerOption=i,i}))}setMyPushTriggerOption(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(d.PushTriggerOption,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new yt({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(At);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}setMyCountPreference(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(exports.CountPreference,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new ut({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(_t);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new pt({channelUrl:this.url}),n=yield t.send(s),{messageOffsetTimestamp:i}=n.as(mt);return this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}unpinMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("number",e)&&e>0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Ut({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}_uploadFileAndUpdateParams(e){return d.__awaiter(this,void 0,void 0,(function*(){if(d.isFile(e.file)){const{requestQueue:t}=d.Vault.of(this._iid),s=new h.UploadFileRequestCommand({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),n=yield t.send(s),{url:i,fileSize:a=e.fileSize,thumbnailSizes:r=e.thumbnailSizes,requireAuth:o=!1}=n.as(h.UploadFileResponseCommand);e.fileUrl=i,e.fileSize=a,e.thumbnailSizes=r,e.requireAuth=o}}))}resendMessage(e,t){var s;if(d.unless(e instanceof h.SendableMessage&&!e.scheduledInfo&&e.isResendable).throw(d.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(s=e.messageParams)&&void 0!==s?s:h.createUserMessageCreateParamsFromFailedUserMessage(e),n=new h.MessageRequestHandler;return this._sendUserMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Je,exports.DeclineInvitationEventCommand=de,exports.FeedChannelEventContext=je,exports.FeedChannelRemoveEventCommand=De,exports.FeedChannelUpdateEventCommand=Fe,exports.GetTotalUnreadMessageCountRequestCommand=$,exports.GetTotalUnreadMessageCountResponseCommand=z,exports.GroupChannel=Ft,exports.GroupChannelChangeLogsParamsDefault=v,exports.GroupChannelCountParamsDefault=M,exports.GroupChannelCreateParamsDefault=C,exports.GroupChannelEventContext=Be,exports.GroupChannelEventSource=U,exports.GroupChannelFilter=m,exports.GroupChannelListQuery=ve,exports.GroupChannelManager=Ne,exports.InviteToGroupChannelEventCommand=oe,exports.Member=_,exports.MemberListQuery=at,exports.MessageAckCommand=Ee,exports.MessageCollection=Ze,exports.MessageCollectionInitHandler=Ye,exports.MessageEventContext=$e,exports.NotificationEventContext=ze,exports.PinnedMessage=It,exports.PinnedMessageListQuery=Rt,exports.ReadEventCommand=Se,exports.ReadRequestCommand=Me,exports.ReadStatus=p,exports.Sync=Ue,exports.TotalUnreadMessageCountParamsDefault=b,exports.shouldGiveEvent=I,exports.validateGroupChannelChangeLogsParams=f,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=E,exports.validateTotalUnreadMessageCountParams=N; diff --git a/cjs/lib/__bundle-f5cc59df.js b/cjs/lib/__bundle-f5cc59df.js deleted file mode 100644 index 0cd0b9d..0000000 --- a/cjs/lib/__bundle-f5cc59df.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("./__bundle-c176c59f.js");class t extends e.APIRequestCommand{constructor({title:t,optionTexts:s,data:o,allowUserSuggestion:n,allowMultipleVotes:l,closeAt:i}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_POLLS,this.params={title:t,options:s,data:o,allow_user_suggestion:n,allow_multiple_votes:l,close_at:i}}}class s extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class o extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:o}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(o)}`,this.params={channel_url:t,channel_type:s}}}class n extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class l extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:o,pollOptionId:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(o)}/options/${encodeURIComponent(n)}`,this.params={channel_url:t,channel_type:s}}}class i extends e.APIResponseCommand{constructor(t,s){super(t,s),this.pollOption=new e.PollOption(t,s)}}class a extends e.APIRequestCommand{constructor({channelType:t,channelUrl:s,timestamp:o,token:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/polls/changelogs`,this.params=e.deundefined({change_ts:o,token:n})}}class r extends e.APIResponseCommand{constructor(t,s){super(t,s),this.updatedPolls=s.updated.map((s=>((t,s)=>new e.Poll(t,s))(t,s))),this.deletedPollIds=s.deleted.map((e=>e)),this.hasMore=s.has_more,this.nextToken=s.next}}const d={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},h=t=>e.isTypeOf("string",t.title)&&e.validateOptionTexts(t.optionTexts)&&e.validatePollData(t.data)&&e.isTypeOf("boolean",t.allowUserSuggestion,!0)&&e.isTypeOf("boolean",t.allowMultipleVotes,!0)&&e.isTypeOf("number",t.closeAt,!0),p={};class u extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,token:o,limit:n}){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_POLLS,this.params={channel_url:t,channel_type:s,token:o,limit:n}}}class c extends e.APIResponseCommand{constructor(t,s){var o;super(t,s),this.polls=(null!==(o=s.polls)&&void 0!==o?o:[]).map((s=>new e.Poll(t,s))),this.token=s.next}}class _ extends e.ChannelDataListQuery{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new u(Object.assign(Object.assign({},this),{token:this._token})),o=yield t.send(s),{polls:n,token:l}=o.as(c);return this._token=l,this._hasNext=!!l,this._isLoading=!1,n}return[]}throw e.SendbirdError.invalidParameters}))}}class m extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:o,pollOptionId:n,token:l,limit:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(o)}/options/${encodeURIComponent(n)}/voters`,this.params={channel_url:t,channel_type:s,token:l,limit:i}}}class P extends e.APIResponseCommand{constructor(t,s){var o;super(t,s),this.voters=(null!==(o=s.voters)&&void 0!==o?o:[]).map((s=>new e.User(t,s))),this.token=s.next}}class I extends e.ChannelDataListQuery{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&e.isTypeOf("number",this.pollId)&&e.isTypeOf("number",this.pollOptionId)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new m(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),o=yield t.send(s),{voters:n,token:l}=o.as(P);return this._token=l,this._hasNext=!!l,this._isLoading=!1,n}return[]}throw e.SendbirdError.invalidParameters}))}}exports.PollCreateParamsDefault=d,exports.PollListQuery=_,exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:o,requestQueue:n,logger:l}){this._iid=e,this._sdkState=t,this._sessionManager=o,this._requestQueue=n,this._dispatcher=s,this._logger=l,p[e]=this}static of(e){return p[e]}buildPollFromSerializedData(t){const s=e.deserialize(t);return new e.Poll(this._iid,e.Poll.payloadify(s))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.validatePollRetrievalParams(t)).throw(e.SendbirdError.invalidParameters);const s=new o(Object.assign({},t)),l=yield this._requestQueue.send(s),{poll:i}=l.as(n);return i}))}create(o){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(h(o)).throw(e.SendbirdError.invalidParameters);const n=new t(Object.assign({},o)),l=yield this._requestQueue.send(n),{poll:i}=l.as(s);return i}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.validatePollOptionRetrievalParams(t)).throw(e.SendbirdError.invalidParameters);const s=new l(Object.assign({},t)),o=yield this._requestQueue.send(s),{pollOption:n}=o.as(i);return n}))}getPollChangeLogs(t,s,o,n=e.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const l=new a(e.undefineNullProps({channelType:s,channelUrl:t,timestamp:"number"==typeof o?o:null,token:"string"==typeof o?o:null})),i=yield this._requestQueue.send(l),{updatedPolls:d,deletedPollIds:h,hasMore:p,nextToken:u}=i.as(r);return d.length>0&&this._dispatcher.dispatch(new e.PollChangeLogEventCommand({polls:d,source:n})),{updatedPolls:d,deletedPollIds:h,hasMore:p,token:u}}))}},exports.PollUpdateEvent=class{constructor(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t}},exports.PollVoteEvent=class{constructor(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e}},exports.PollVoterListQuery=I,exports.validatePollCreateParams=h; diff --git a/cjs/lib/__bundle-f6d4722d.js b/cjs/lib/__bundle-f6d4722d.js new file mode 100644 index 0000000..ceaf7fe --- /dev/null +++ b/cjs/lib/__bundle-f6d4722d.js @@ -0,0 +1 @@ +"use strict";exports.PollUpdateEvent=class{constructor(s,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=s,this._payload=t}}; diff --git a/cjs/message.js b/cjs/message.js index b449a9d..0a15f40 100644 --- a/cjs/message.js +++ b/cjs/message.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-c176c59f.js"),t=require("./lib/__bundle-4bc3a029.js");const s={channelUrl:"",scheduledMessageId:0};class r extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new t.MessageManager(e,{sdkState:s,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.MessageRetrievalParamsDefault),s);return e.unless(t.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessage(r)}))}getScheduledMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s),t);return e.unless((t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isTypeOf("number",t.scheduledMessageId)&&t.scheduledMessageId>0)(r)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(r)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageType",{enumerable:!0,get:function(){return e.MessageType}}),Object.defineProperty(exports,"MessageTypeFilter",{enumerable:!0,get:function(){return e.MessageTypeFilter}}),Object.defineProperty(exports,"PushNotificationDeliveryOption",{enumerable:!0,get:function(){return e.PushNotificationDeliveryOption}}),Object.defineProperty(exports,"ReplyType",{enumerable:!0,get:function(){return e.ReplyType}}),Object.defineProperty(exports,"SendingStatus",{enumerable:!0,get:function(){return e.SendingStatus}}),exports.AdminMessage=t.AdminMessage,exports.AppleCriticalAlertOptions=t.AppleCriticalAlertOptions,exports.BaseMessage=t.BaseMessage,exports.FileMessage=t.FileMessage,exports.MessageMetaArray=t.MessageMetaArray,exports.MessageRequestHandler=t.MessageRequestHandler,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return t.MessageSearchOrder}}),exports.MessageSearchQuery=t.MessageSearchQuery,exports.MultipleFilesMessage=t.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=t.MultipleFilesMessageRequestHandler,exports.OGImage=t.OGImage,exports.OGMetaData=t.OGMetaData,exports.PreviousMessageListQuery=t.PreviousMessageListQuery,exports.Reaction=t.Reaction,exports.ReactionEvent=t.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return t.ReactionEventOperation}}),exports.Sender=t.Sender,exports.ThreadInfo=t.ThreadInfo,exports.ThreadInfoUpdateEvent=t.ThreadInfoUpdateEvent,exports.Thumbnail=t.Thumbnail,exports.UploadedFileInfo=t.UploadedFileInfo,exports.UserMessage=t.UserMessage,exports.MessageModule=r; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-26b86f4c.js"),t=require("./lib/__bundle-aae5735d.js");const s={channelUrl:"",scheduledMessageId:0};class r extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new t.MessageManager(e,{sdkState:s,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.MessageRetrievalParamsDefault),s);return e.unless(t.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessage(r)}))}getScheduledMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s),t);return e.unless((t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isTypeOf("number",t.scheduledMessageId)&&t.scheduledMessageId>0)(r)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(r)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageType",{enumerable:!0,get:function(){return e.MessageType}}),Object.defineProperty(exports,"MessageTypeFilter",{enumerable:!0,get:function(){return e.MessageTypeFilter}}),Object.defineProperty(exports,"PushNotificationDeliveryOption",{enumerable:!0,get:function(){return e.PushNotificationDeliveryOption}}),Object.defineProperty(exports,"ReplyType",{enumerable:!0,get:function(){return e.ReplyType}}),Object.defineProperty(exports,"SendingStatus",{enumerable:!0,get:function(){return e.SendingStatus}}),exports.AdminMessage=t.AdminMessage,exports.AppleCriticalAlertOptions=t.AppleCriticalAlertOptions,exports.BaseMessage=t.BaseMessage,exports.FileMessage=t.FileMessage,exports.MessageMetaArray=t.MessageMetaArray,exports.MessageRequestHandler=t.MessageRequestHandler,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return t.MessageSearchOrder}}),exports.MessageSearchQuery=t.MessageSearchQuery,exports.MultipleFilesMessage=t.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=t.MultipleFilesMessageRequestHandler,exports.OGImage=t.OGImage,exports.OGMetaData=t.OGMetaData,exports.PreviousMessageListQuery=t.PreviousMessageListQuery,exports.Reaction=t.Reaction,exports.ReactionEvent=t.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return t.ReactionEventOperation}}),exports.Sender=t.Sender,exports.ThreadInfo=t.ThreadInfo,exports.ThreadInfoUpdateEvent=t.ThreadInfoUpdateEvent,exports.Thumbnail=t.Thumbnail,exports.UploadedFileInfo=t.UploadedFileInfo,exports.UserMessage=t.UserMessage,exports.MessageModule=r; diff --git a/cjs/openChannel.js b/cjs/openChannel.js index ff7c722..f79c91d 100644 --- a/cjs/openChannel.js +++ b/cjs/openChannel.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-c176c59f.js"),n=require("./lib/__bundle-a4005096.js"),t=require("./lib/__bundle-4bc3a029.js"),a=require("./lib/__bundle-7ee4a5eb.js"),s=require("./lib/__bundle-b9602cac.js");require("./lib/__bundle-f5cc59df.js");class r extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const i={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class o extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class h extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o,is_ephemeral:l}))}}class d extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends a.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends a.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}const p={};class _ extends a.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new r(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n);else if(n instanceof e.ConnectionStateChangeCommand&&n.stateType===e.ConnectionStateType.CONNECTED){const{enteredChannels:e}=this._openChannelCache;for(const n of e)n.enter()}})),p[n]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new T(this._iid,T.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}_handleEvent(s){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(s.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let r=null;if("MESG"===s.code?r=s.as(n.UserMessageEventCommand):"FILE"===s.code?r=s.as(t.FileMessageEventCommand):"ADMM"!==s.code&&"BRDM"!=s.code||(r=s.as(a.AdminMessageEventCommand)),r){const{message:n,isMentioned:t}=r;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageReceived&&e.onMessageReceived(a,n),t&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===s.code?t=s.as(n.UpdateUserMessageEventCommand):"FEDI"===s.code?t=s.as(n.UpdateFileMessageEventCommand):"AEDI"===s.code&&(t=s.as(a.UpdateAdminMessageEventCommand)),t){const{message:n,mentionCountChange:a}=t;if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&(e.onMessageUpdated&&e.onMessageUpdated(t,n),a>0&&e.onMentionReceived&&e.onMentionReceived(t,n))}))))}}break}case"DELM":{const{channelUrl:t,channelType:a,messageId:r}=s.as(n.DeleteMessageEventCommand);if(a===e.ChannelType.OPEN){const n=yield this.getChannel(t,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(n.url)&&e.onMessageDeleted&&e.onMessageDeleted(n,r)}))))}break}case"MRCT":{const{channelUrl:n,channelType:t,event:r}=s.as(a.ReactionEventCommand);if(t===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onReactionUpdated&&e.onReactionUpdated(t,r)}))))}break}case"MTHD":{const{event:n}=s.as(a.ThreadInfoUpdateEventCommand);if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onThreadInfoUpdated&&e.onThreadInfoUpdated(t,n)}))))}break}case"MCNT":{const{openChannelMemberCounts:n}=s.as(a.MemberCountUpdateEventCommand),t=[];for(const e of n){const{channelUrl:n,participantCount:a,updatedAt:s}=e,r=yield this.getChannelFromCache(n);r&&r._updateParticipantCount(a,s)&&t.push(r)}if(t.length>0){const n=yield this.upsertChannelsToCache(t);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(n)}))))}break}case"PEDI":{const{event:n,status:t,channelUrl:r,channelType:i}=s.as(a.PollUpdateEventCommand);if(r&&i===e.ChannelType.OPEN){const a=yield this.getChannel(r,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),t===e.POLL_REMOVED_STATUS?e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollDeleted&&e.onPollDeleted(a,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(a,n)}))))}break}case"VOTE":{const{event:t,channelUrl:a,channelType:r}=s.as(n.PollVoteEventCommand);if(a&&r===e.ChannelType.OPEN){const n=yield this.getChannel(a,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.EVENT_POLL_VOTED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollVoted&&e.onPollVoted(n,t)}))))}break}case"SYEV":{const{event:t}=s.as(a.ChannelEventCommand);if(t.isOpenChannelEvent)switch(t.category){case a.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(t.channelUrl,!0),{participantCount:a,user:r}=s.as(c),i=n._updateParticipantCount(a,t.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(t.channelUrl,!0),{participantCount:a,user:r}=s.as(C),i=n._updateParticipantCount(a,t.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(t.channelUrl,!0),{operators:r}=s.as(a.OperatorUpdateEventCommand);n.operators=r,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,r)}))}))));break}case a.ChannelEventCategory.USER_CHANNEL_MUTE:case a.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const r=yield this.getChannel(t.channelUrl,!0),i=t.category===a.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=s.as(i?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserMuted&&e.onUserMuted(r,o):e.onUserUnmuted&&e.onUserUnmuted(r,o)}))}))));break}case a.ChannelEventCategory.USER_CHANNEL_BAN:case a.ChannelEventCategory.USER_CHANNEL_UNBAN:{const r=yield this.getChannel(t.channelUrl,!0),i=t.category===a.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=s.as(i?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserBanned&&e.onUserBanned(r,o):e.onUserUnbanned&&e.onUserUnbanned(r,o)}))}))));break}case a.ChannelEventCategory.CHANNEL_FREEZE:case a.ChannelEventCategory.CHANNEL_UNFREEZE:{const a=yield this.getChannel(t.channelUrl,!0),{freeze:r}=s.as(n.FreezeEventCommand);a.isFrozen=r,this.upsertChannelsToCache([a]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onChannelFrozen&&e.onChannelFrozen(a):e.onChannelUnfrozen&&e.onChannelUnfrozen(a)}))}))));break}case a.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(t.channelUrl,!0);yield this.removeChannelsFromCache([n.url]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(t.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const a=yield this.getChannel(t.channelUrl,!0),{created:r,updated:i,deleted:o}=s.as(n.UpdateMetaDataEventCommand);r&&a._upsertCachedMetaData(r,t.ts),i&&a._upsertCachedMetaData(i,t.ts),o&&a._removeFromCachedMetaData(o,t.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaDataCreated&&e.onMetaDataCreated(a,r),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(a,i),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(a,o)}))}))));break}case a.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const a=yield this.getChannel(t.channelUrl,!0),{created:r,updated:i,deleted:o}=s.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaCounterCreated&&e.onMetaCounterCreated(a,r),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(a,i),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(a,o)}))}))));break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n)}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=new o({channelUrl:n,isInternalCall:t}),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return(yield this.upsertChannelsToCache([r]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},i),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new h(t),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return this.upsertChannelsToCache([r]),r}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class m extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class E extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:a}=n;this.token=t,this.participants=a.map((n=>new s.Participant(e,n)))}}class f extends e.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new m(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:r}=a.as(E);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class g extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o}))}}class y extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class U extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class T extends n.BaseChannel{constructor(n,t){var a;super(n,t),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(a=t.participant_count)&&void 0!==a?a:0,this.operators=Array.isArray(t.operators)?t.operators.map((t=>new e.User(n,t))):[]}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},n.BaseChannel.payloadify(t)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n)))})))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new f(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=_.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new d({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:r}=a.as(c);this._updateParticipantCount(s,r);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield n.send(a),{participantCount:r,ts:i}=s.as(C);this._updateParticipantCount(r,i);_.of(this._iid).setExitedToCache(this);t.MessageManager.of(this._iid).fileMessageQueue.cancel(this)}))}updateChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},v),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage)||e.isFile(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),s=new g(Object.assign({channelUrl:this.url},t)),r=yield a.send(s),{channel:i}=r.as(y);this._update(i);const o=_.of(this._iid);return yield o.upsertChannelsToCache([i]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},v),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:r});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new U({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}sendUserMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendUserMessage(n)}sendFileMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendFileMessage(n)}}class P extends a.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserEntered=e.noop,this.onUserExited=e.noop,this.onChannelParticipantCountChanged=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop}}class b extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:r,customTypes:i,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:r,custom_types:i,show_frozen:o,show_metadata:l})}}class O extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new T(e,n)))),this.ts="number"==typeof s?s:null}}class A extends e.BaseListQuery{constructor(e,n){var t,a,s,r,i;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(r=n.urlKeyword)&&void 0!==r?r:null,this.customTypes=null!==(i=n.customTypes)&&void 0!==i?i:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new b(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:r}=a.as(O);this._token=r,this._hasNext=!!r;const i=_.of(this._iid);return yield i.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class w extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:r,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new A(this._iid,e)}addOpenChannelHandler(e,n){this._manager.addHandler(e,n)}removeOpenChannelHandler(e){this._manager.removeHandler(e)}removeAllOpenChannelHandlers(){this._manager.clearHandler()}buildOpenChannelFromSerializedData(e){return this._manager.buildOpenChannelFromSerializedData(e)}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannel(n)}))}getChannelWithoutCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannelWithoutCache(n)}))}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.createChannel(n)}))}createChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},i);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=r,this._manager.createChannel(e)}))}}exports.OpenChannel=T,exports.OpenChannelHandler=class extends P{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=A,exports.OpenChannelModule=w,exports.ParticipantListQuery=f; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-26b86f4c.js"),n=require("./lib/__bundle-aae5735d.js"),t=require("./lib/__bundle-8e790a5a.js"),a=require("./lib/__bundle-722ae438.js");require("./lib/__bundle-f6d4722d.js");class s extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const r={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class i extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`}}class o extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new U(e,n)}}class l extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class d extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}class c extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class u extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}const C={};class p extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new s(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n);else if(n instanceof e.ConnectionStateChangeCommand&&n.stateType===e.ConnectionStateType.CONNECTED){const{enteredChannels:e}=this._openChannelCache;for(const n of e)n.enter()}})),C[n]||(C[n]=this)}static of(e){return C[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new U(this._iid,U.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageReceived&&e.onMessageReceived(a,n),t&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageUpdated&&e.onMessageUpdated(a,n),t>0&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:r}=a.as(n.DeleteMessageEventCommand);if(s===e.ChannelType.OPEN){const n=yield this.getChannel(t,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(n.url)&&e.onMessageDeleted&&e.onMessageDeleted(n,r)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:r}=a.as(t.ReactionEventCommand);if(s===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onReactionUpdated&&e.onReactionUpdated(t,r)}))))}break}case"MTHD":{const{event:n}=a.as(t.ThreadInfoUpdateEventCommand);if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onThreadInfoUpdated&&e.onThreadInfoUpdated(t,n)}))))}break}case"MCNT":{const{openChannelMemberCounts:n}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,r=yield this.getChannelFromCache(n);r&&r._updateParticipantCount(t,a)&&s.push(r)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(n)}))))}break}case"PEDI":{const{event:n,status:s,channelUrl:r,channelType:i}=a.as(t.PollUpdateEventCommand);if(r&&i===e.ChannelType.OPEN){const t=yield this.getChannel(r,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===e.POLL_REMOVED_STATUS?e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollDeleted&&e.onPollDeleted(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:r}=a.as(n.PollVoteEventCommand);if(s&&r===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.EVENT_POLL_VOTED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollVoted&&e.onPollVoted(n,t)}))))}break}case"SYEV":{const{event:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(d),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(u),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:r}=a.as(t.OperatorUpdateEventCommand);n.operators=r,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,r)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(i?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserMuted&&e.onUserMuted(r,o):e.onUserUnmuted&&e.onUserUnmuted(r,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(i?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserBanned&&e.onUserBanned(r,o):e.onUserUnbanned&&e.onUserUnbanned(r,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:r}=a.as(n.FreezeEventCommand);t.isFrozen=r,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.channelUrl,!0);yield this.removeChannelsFromCache([n.url]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaDataEventCommand);r&&t._upsertCachedMetaData(r,s.ts),i&&t._upsertCachedMetaData(i,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaDataCreated&&e.onMetaDataCreated(t,r),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,i),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,r),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,i),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n)}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=new i({channelUrl:n,isInternalCall:t}),s=yield this._requestQueue.send(a),{channel:r}=s.as(o);return(yield this.upsertChannelsToCache([r]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new l(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(o);return this.upsertChannelsToCache([i]),i}))}}const _={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class v extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E extends e.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new v(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:r}=a.as(m);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o}))}}class g extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new U(e,n)}}class y extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class U extends n.BaseChannel{constructor(n,t){var a;super(n,t),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(a=t.participant_count)&&void 0!==a?a:0,this.operators=Array.isArray(t.operators)?t.operators.map((t=>new e.User(n,t))):[]}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},n.BaseChannel.payloadify(t)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n)))})))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new E(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=p.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:r}=a.as(d);this._updateParticipantCount(s,r);p.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new c({channelUrl:this.url}),s=yield t.send(a),{participantCount:r,ts:i}=s.as(u);this._updateParticipantCount(r,i);p.of(this._iid).setExitedToCache(this);n.MessageManager.of(this._iid).fileMessageQueue.cancel(this)}))}updateChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},_),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage)||e.isFile(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),s=new f(Object.assign({channelUrl:this.url},t)),r=yield a.send(s),{channel:i}=r.as(g);this._update(i);const o=p.of(this._iid);return yield o.upsertChannelsToCache([i]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},_),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:r});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=p.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}sendUserMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendUserMessage(n)}sendFileMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendFileMessage(n)}}class T extends t.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserEntered=e.noop,this.onUserExited=e.noop,this.onChannelParticipantCountChanged=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop}}class P extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:r,customTypes:i,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:r,custom_types:i,show_frozen:o,show_metadata:l})}}class O extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new U(e,n)))),this.ts="number"==typeof s?s:null}}class b extends e.BaseListQuery{constructor(e,n){var t,a,s,r,i;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(r=n.urlKeyword)&&void 0!==r?r:null,this.customTypes=null!==(i=n.customTypes)&&void 0!==i?i:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new P(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:r}=a.as(O);this._token=r,this._hasNext=!!r;const i=p.of(this._iid);return yield i.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class A extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}),this._manager=new p(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:r,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new b(this._iid,e)}addOpenChannelHandler(e,n){this._manager.addHandler(e,n)}removeOpenChannelHandler(e){this._manager.removeHandler(e)}removeAllOpenChannelHandlers(){this._manager.clearHandler()}buildOpenChannelFromSerializedData(e){return this._manager.buildOpenChannelFromSerializedData(e)}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannel(n)}))}getChannelWithoutCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannelWithoutCache(n)}))}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.createChannel(n)}))}createChannelWithOperatorUserIds(n,t,a,s,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=U,exports.OpenChannelHandler=class extends T{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=b,exports.OpenChannelModule=A,exports.ParticipantListQuery=E; diff --git a/cjs/package.json b/cjs/package.json index c5ae5f2..ac58654 100644 --- a/cjs/package.json +++ b/cjs/package.json @@ -1,5 +1,5 @@ { - "version": "4.9.7", + "version": "4.9.8", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/cjs/poll.js b/cjs/poll.js index 1617468..03c5275 100644 --- a/cjs/poll.js +++ b/cjs/poll.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-c176c59f.js"),t=require("./lib/__bundle-f5cc59df.js");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(e,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(e,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new t.PollManager(e,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollCreateParamsDefault),r);return e.unless(t.validatePollCreateParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.create(a)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollListQuery=t.PollListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollVoteEvent=t.PollVoteEvent,exports.PollVoterListQuery=t.PollVoterListQuery,exports.PollModule=r; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-26b86f4c.js"),t=require("./lib/__bundle-f6d4722d.js");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r; diff --git a/feedChannel.js b/feedChannel.js index 2da5536..dacb181 100644 --- a/feedChannel.js +++ b/feedChannel.js @@ -1 +1 @@ -import{_ as e,s as n,q as t,g as r,o as a,p as s,b as i,c as o,a7 as c,e as u,r as l,A as h,d,f,h as p,N as _,b0 as v,ao as C,a as m,u as g,b7 as y,aG as b,K as E,V as M,x as w,T as N,X as U,W as I,ak as D,B as T,aK as k,az as A,ap as S,aE as x,aM as H}from"./lib/__bundle-1da35e70.js";import{i as L,as as P,p as O,q as R,_ as F,$ as j,a0 as V,a1 as G,a2 as B,a3 as z,t as q}from"./lib/__bundle-0099b2f2.js";import{F as W,D as Q,E as J,T as K,I as X,J as $,p as ee,K as ne,L as te,m as re,N as ae,V as se,W as ie,c as oe,X as ce}from"./lib/__bundle-4e23f900.js";export{Y as FeedChannelEventContext,Z as NotificationEventContext}from"./lib/__bundle-4e23f900.js";import{g as ue}from"./lib/__bundle-e9d4faa1.js";import{D as le}from"./lib/__bundle-f4ef8eae.js";import{a as he,C as de,b as fe,U as pe,A as _e,B as ve}from"./lib/__bundle-d3df41f8.js";import"./lib/__bundle-c336221f.js";var Ce=function(c){function h(e,n){var t=n.sdkState,r=n.cacheContext,a=n.channelManager,s=c.call(this,e)||this;return s._channels=new Map,s._sdkState=t,s._cacheContext=r,s._channelManager=a,s}return e(h,c),Object.defineProperty(h.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return n(!!e).throw(t.databaseError),e.collection(L)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),h.prototype._serialize=function(e,n){return void 0===n&&(n=0),r(r({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:n})},h.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(h.prototype,"channels",{get:function(){return a([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),h.prototype.isCachedInMemory=function(e){return this._channels.has(e)},h.prototype.get=function(e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(t){switch(t.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(n=t.sent())return this._channels.set(e,this._deserialize(n)),[2,this._channels.get(e)];t.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},h.prototype.fetch=function(e){var n=e.token,t=e.limit,r=void 0===t?P:t,a=e.backward,s=void 0!==a&&a,c=e.order,u=void 0===c?"latest_last_message":c,l=e.borderlineChannelUrl;return i(this,void 0,void 0,(function(){var e,t,a,i,c=this;return o(this,(function(o){switch(o.label){case 0:return this.localCacheEnabled?(e=ue(u),t={where:function(e){if(n&&"latest_last_message"===u){if(!s&&e.lastMessageUpdatedAt>n||s&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new Q({channels:h,source:s})),d.length>0&&this._dispatcher.dispatch(new W({channelUrls:d,source:s})),[2,{updatedChannels:h,deletedChannelUrls:d,hasMore:f,token:p}]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return i(this,void 0,void 0,(function(){var a,s,i,c,u,l,h;return o(this,(function(o){switch(o.label){case 0:return a=r(r({},K),e),n(X(a)).throw(t.invalidParameters),s=M.of(this._iid),i=s.sdkState,c=s.requestQueue,u=new $({userId:i.userId,filter:a,includeFeedChannel:!0}),[4,c.send(u)];case 1:return l=o.sent(),h=l.as(J).unreadFeedCount,[2,void 0===h?0:h]}}))}))},u.prototype.getGlobalNotificationChannelSetting=function(){return i(this,void 0,void 0,(function(){var e,n;return o(this,(function(t){switch(t.label){case 0:return e=new De,[4,this._requestQueue.send(e)];case 1:return n=t.sent(),[2,{jsonString:n.as(Te).jsonString}]}}))}))},u.prototype.getNotificationTemplateListByToken=function(e,a){return void 0===a&&(a={}),i(this,void 0,void 0,(function(){var s,i,c,u,l,h,d;return o(this,(function(o){switch(o.label){case 0:return s=r(r({},Se),a),n(m("string",e)&&function(e){return m("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&m("number",e.limit,!0)}(s)).throw(t.invalidParameters),i=new ke({token:e,keys:s.keys,reverse:s.reverse,limit:s.limit}),[4,this._requestQueue.send(i)];case 1:return c=o.sent(),u=c.as(Ae),l=u.hasMore,h=u.nextToken,d=u.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},u.prototype.getNotificationTemplate=function(e){return i(this,void 0,void 0,(function(){var r,a;return o(this,(function(s){switch(s.label){case 0:return n(m("string",e)).throw(t.invalidParameters),r=new xe({key:e}),[4,this._requestQueue.send(r)];case 1:return a=s.sent(),[2,{jsonString:a.as(He).jsonString}]}}))}))},u.prototype.upsertChannelsToCache=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.removeChannelsFromCache=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return n.sent(),[2]}}))}))},u.prototype.refreshChannel=function(e,n,t){return void 0===n&&(n=!0),void 0===t&&(t=N.REFRESH_CHANNEL),i(this,void 0,void 0,(function(){var r,a,s,i,c;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:n}),[4,this._requestQueue.send(r)];case 1:return a=o.sent(),(s=a.as(Me).channel).myMemberState!==ee.NONE?[3,2]:(this._dispatcher.dispatch(new W({channelUrls:[s.url],source:t})),[3,4]);case 2:return[4,this.upsertChannelsToCache([s])];case 3:i=o.sent(),this._dispatcher.dispatch(new Q({channels:i,source:t})),o.label=4;case 4:return[3,6];case 5:return(c=o.sent()).code!==D.NON_AUTHORIZED&&c.code!==D.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new W({channelUrls:[e],source:t})),[3,6];case 6:return[2]}}))}))},u.prototype.subscribeChannelEvent=function(e,n){this._feedChannelBroadcast.subscribe(e,n)},u.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},u.prototype._handleEvent=function(e){return i(this,void 0,void 0,(function(){var n,t,r,a,s,c,u,h,d,f,p,v,C,m,g,y,b,E,w,U,I=this;return o(this,(function(D){switch(D.label){case 0:switch(e.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"SYEV":return[3,13]}return[3,23];case 1:return(g="MESG"===e.code?e.as(B):"FILE"===e.code?e.as(z):"ADMM"===e.code||"BRDM"===e.code?e.as(_e):null)&&g.message.channelType===this._channelType?(n=g.message,t=g.isMentioned,r=g.forceUpdateLastMessage,this._disableMack||_((function(){return i(I,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new se(n),this._requestQueue.send(e),[2]}))}))})),[4,this.getChannel(n.channelUrl,!0)]):[3,3];case 2:(a=D.sent())._runIfHandleableWithGroupChannel((function(e){var s,c,u,h=I._feedChannelCache.isCachedInMemory(n.channelUrl),d=n instanceof j&&n.sender.userId===I._sdkState.userId;if(e.hiddenState===re.HIDDEN_ALLOW_AUTO_UNHIDE&&(e.hiddenState=re.UNHIDDEN),n instanceof j){var f=M.of(I._iid).useMemberInfoInMessage;try{for(var p=l(e.members),_=p.next();!_.done;_=p.next()){var v=_.value;if(v.userId===n.sender.userId){f||(n.sender.nickname=v.nickname,n.sender.plainProfileUrl=v.plainProfileUrl,n.sender.metaData=v.metaData,n.sender.isBlockedByMe=v.isBlockedByMe);break}}}catch(e){s={error:e}}finally{try{_&&!_.done&&(c=p.return)&&c.call(p)}finally{if(s)throw s.error}}if(!f&&t&&(null===(u=n.mentionedUsers)||void 0===u||u.forEach((function(n){var t,r;try{for(var a=l(e.members),s=a.next();!s.done;s=a.next()){var i=s.value;if(n.userId===i.userId){n.nickname=i.nickname,n.plainProfileUrl=i.plainProfileUrl,n.metaData=i.metaData;break}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}))),d){var C=I._sessionManager.currentUser;C&&(C.nickname=n.sender.nickname,C.plainProfileUrl=n.sender.plainProfileUrl,C.metaData=n.sender.metaData)}}n.silent&&!d||(e.isEphemeral||h)&&((!e.lastMessage||e.lastMessage.createdAt0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),I._dispatcher.dispatch(new Q({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return i(I,void 0,void 0,(function(){var e,n,t,r,a;return o(this,(function(s){try{for(e=l(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(I._dispatcher.dispatch(new Q({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return i(I,void 0,void 0,(function(){var e,n,t,r,a;return o(this,(function(s){try{for(e=l(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(I._dispatcher.dispatch(new Q({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return i(I,void 0,void 0,(function(){var e,n,t,r,a;return o(this,(function(s){try{for(e=l(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onUnreadMemberStatusUpdated&&t.onUnreadMemberStatusUpdated(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})))})),D.label=12;case 12:return[3,23];case 13:if(!(g="SYEV"===e.code?e.as(de):null)||g.event.channelType!==this._channelType)return[3,22];switch(y=g.event,y.category){case fe.CHANNEL_INVITE:return[3,14];case fe.CHANNEL_DECLINE_INVITE:return[3,16];case fe.CHANNEL_DELETED:return[3,18];case fe.CHANNEL_PROP_CHANGED:return[3,20]}return[3,22];case 14:return[4,this.getChannel(y.channelUrl,!0)];case 15:return(b=D.sent())._runIfHandleableWithGroupChannel((function(n){var t,r,a=e.as(te),s=a.memberCount,i=a.joinedMemberCount,o=a.invitees;o.forEach((function(e){return e.state=ee.INVITED}));try{for(var c=l(o),u=c.next();!u.done;u=c.next()){var h=u.value;n.isExclusive||n.isSuper||n.isBroadcast?n._setLatestMemberCount(s,i,y.ts):n.addMember(h,y.ts),I._sdkState.userId===h.userId&&(n.hiddenState=re.UNHIDDEN,n.myMemberState!==ee.JOINED&&(n.myMemberState=ee.INVITED),n.invitedAt=y.ts)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}I._dispatcher.dispatch(new Q({channels:[b],source:N.EVENT_CHANNEL_INVITED}))})),[3,22];case 16:return[4,this.getChannel(y.channelUrl,!0)];case 17:return(E=D.sent())._runIfHandleableWithGroupChannel((function(n){var t=e.as(ne),r=t.memberCount,a=t.joinedMemberCount,s=t.invitee;n.isExclusive||n.isSuper||n.isBroadcast?n._setLatestMemberCount(r,a,y.ts):n.removeMember(s),I._sdkState.userId===s.userId?(n.invitedAt=0,n.myMemberState=ee.NONE,n.isPublic?I._dispatcher.dispatch(new Q({channels:[E],source:N.EVENT_CHANNEL_DECLINED_INVITE})):I._dispatcher.dispatch(new W({channelUrls:[E.url],source:N.EVENT_CHANNEL_DECLINED_INVITE}))):I._dispatcher.dispatch(new Q({channels:[E],source:N.EVENT_CHANNEL_DECLINED_INVITE}))})),[3,22];case 18:return[4,this.getChannel(y.channelUrl,!0)];case 19:return w=D.sent(),this._dispatcher.dispatch(new W({channelUrls:[y.channelUrl],source:N.EVENT_CHANNEL_DELETED})),T((function(){return i(I,void 0,void 0,(function(){return o(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(w.url,w.channelType)})),[2]}))}))})),[3,22];case 20:return[4,this.getChannelWithoutCache(y.channelUrl,!0)];case 21:return U=D.sent(),this._dispatcher.dispatch(new Q({channels:[U],source:N.EVENT_CHANNEL_UPDATED})),T((function(){return i(I,void 0,void 0,(function(){return o(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(U)})),[2]}))}))})),[3,22];case 22:return[3,23];case 23:return[2]}}))}))},u}(he),Oe=function(n){function t(e,t){return n.call(this,e,r(r({},t),{channelManager:Pe.of(e)}))||this}return e(t,n),t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t}(ie),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channelType=U.FEED,r._groupChannel=new oe(e,t),r}return e(t,n),t.payloadify=function(e){var n;return r({},oe.payloadify(null!==(n=e._groupChannel)&&void 0!==n?n:e))},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastMessage",{get:function(){return this._groupChannel.lastMessage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){return r({},this._groupChannel.serialize())},t.prototype.refresh=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(){return i(this,void 0,void 0,(function(){var e,n,t,r,a,s,i,c=this;return o(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),n=e.sdkState,t=e.dispatcher,r=e.requestQueue,a=new ce({channelUrl:this.url}),[4,r.send(a)];case 1:return s=o.sent(),i=s.as(ae).readStatus,this._groupChannel._updateUnreadMemberState(n.userId,i.readAt),(this._groupChannel.unreadMessageCount>0||this._groupChannel.unreadMentionCount>0)&&(this._groupChannel._updateUnreadCount(0,0),Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(c)}))),t.dispatch(new Q({channels:[this],source:N.EVENT_CHANNEL_READ})),[2]}}))}))},t.prototype.createNotificationCollection=function(e){return void 0===e&&(e={}),new Oe(this._iid,r({channel:this},e))},t}(q),Fe=["onUserMuted","onUserUnmuted","onUserBanned","onUserUnbanned","onChannelFrozen","onChannelUnfrozen","onOperatorUpdated","onMetaDataCreated","onMetaDataUpdated","onMetaDataDeleted","onMetaCounterCreated","onMetaCounterUpdated","onMetaCounterDeleted","onReactionUpdated","onThreadInfoUpdated"],je=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){Object.prototype.hasOwnProperty.call(t,n)&&-1===Fe.indexOf(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUnreadMemberStatusUpdated=S,e.onUserMuted=S,e.onUserUnmuted=S,e.onUserBanned=S,e.onUserUnbanned=S,e.onChannelFrozen=S,e.onChannelUnfrozen=S,e.onOperatorUpdated=S,e.onMetaDataCreated=S,e.onMetaDataUpdated=S,e.onMetaDataDeleted=S,e.onMetaCounterCreated=S,e.onMetaCounterUpdated=S,e.onMetaCounterDeleted=S,e.onReactionUpdated=S,e.onThreadInfoUpdated=S,e}return e(t,n),t}(ve)),Ve=function(n){function a(e,t){var r,a=this;return(a=n.call(this,e,t)||this).includeEmpty=me,a.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r?r:me,a}return e(a,n),a.prototype._validate=function(){return n.prototype._validate.call(this)&&m("boolean",this.includeEmpty)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,n,a,s,i;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Pe.of(this._iid),n=g(r({},this)),[4,e.getMyFeedChannels(this._token,n,this.limit)]):[3,2]:[3,5];case 1:return a=o.sent(),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw t.queryInProgress;case 4:return[3,6];case 5:throw t.invalidParameters;case 6:return[2]}}))}))},a}(x),Ge=function(a){function s(){var e=null!==a&&a.apply(this,arguments)||this;return e.name="feedChannel",e}return e(s,a),s.prototype.init=function(e,n){a.prototype.init.call(this,e,n),this._manager=new Pe(e,n)},s.prototype.createMyFeedChannelListQuery=function(e){return void 0===e&&(e={}),new Ve(this._iid,e)},s.prototype.addFeedChannelHandler=function(e,r){n(m("string",e)&&r instanceof je).throw(t.invalidParameters),this._manager.addHandler(e,r)},s.prototype.removeFeedChannelHandler=function(e){n(m("string",e)).throw(t.invalidParameters),this._manager.removeHandler(e)},s.prototype.removeAllFeedChannelHandlers=function(){this._manager.clearHandler()},s.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(r){return n(m("string",e)).throw(t.invalidParameters),[2,this._manager.getChannel(e)]}))}))},s.prototype.getMyFeedChannelChangeLogsByTimestamp=function(e,a){return void 0===a&&(a={}),i(this,void 0,void 0,(function(){var s;return o(this,(function(i){switch(i.label){case 0:return s=r(r({},we),a),n(m("number",e)&&Ne(s)).throw(t.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,s)];case 1:return[2,i.sent()]}}))}))},s.prototype.getMyFeedChannelChangeLogsByToken=function(e,a){return void 0===a&&(a={}),i(this,void 0,void 0,(function(){var s;return o(this,(function(i){switch(i.label){case 0:return s=r(r({},we),a),n(m("string",e)&&Ne(s)).throw(t.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,s)];case 1:return[2,i.sent()]}}))}))},s.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,n.sent()]}}))}))},s.prototype.getGlobalNotificationChannelSetting=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._manager.getGlobalNotificationChannelSetting()];case 1:return[2,e.sent()]}}))}))},s.prototype.getNotificationTemplateListByToken=function(e,n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._manager.getNotificationTemplateListByToken(e,n)];case 1:return[2,t.sent()]}}))}))},s.prototype.getNotificationTemplate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._manager.getNotificationTemplate(e)];case 1:return[2,n.sent()]}}))}))},s}(H);export{Re as FeedChannel,je as FeedChannelHandler,Ve as FeedChannelListQuery,Ge as FeedChannelModule,Oe as NotificationCollection}; +import{_ as e,s as n,q as t,g as r,o as a,p as s,b as i,c as o,a7 as c,e as u,r as l,A as h,d,f,h as p,N as _,b0 as v,ao as C,a as m,u as g,b8 as y,aG as b,K as E,V as M,x as w,T as N,X as U,W as I,ak as D,B as T,aK as k,az as A,ap as S,aE as x,aM as H}from"./lib/__bundle-fdefc164.js";import{i as L,ay as P,p as O,q as R,_ as F,$ as j,a0 as V,a1 as G,a2 as B,a3 as z,t as q}from"./lib/__bundle-bd25634c.js";import{F as W,D as Q,E as J,T as K,I as X,J as $,p as ee,K as ne,L as te,m as re,N as ae,V as se,W as ie,c as oe,X as ce}from"./lib/__bundle-2e839992.js";export{Y as FeedChannelEventContext,Z as NotificationEventContext}from"./lib/__bundle-2e839992.js";import{g as ue}from"./lib/__bundle-e9d4faa1.js";import{D as le}from"./lib/__bundle-8934878d.js";import{a as he,C as de,b as fe,U as pe,A as _e,B as ve}from"./lib/__bundle-6f8fc428.js";import"./lib/__bundle-c336221f.js";var Ce=function(c){function h(e,n){var t=n.sdkState,r=n.cacheContext,a=n.channelManager,s=c.call(this,e)||this;return s._channels=new Map,s._sdkState=t,s._cacheContext=r,s._channelManager=a,s}return e(h,c),Object.defineProperty(h.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return n(!!e).throw(t.databaseError),e.collection(L)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),h.prototype._serialize=function(e,n){return void 0===n&&(n=0),r(r({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:n})},h.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(h.prototype,"channels",{get:function(){return a([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),h.prototype.isCachedInMemory=function(e){return this._channels.has(e)},h.prototype.get=function(e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(t){switch(t.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(n=t.sent())return this._channels.set(e,this._deserialize(n)),[2,this._channels.get(e)];t.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},h.prototype.fetch=function(e){var n=e.token,t=e.limit,r=void 0===t?P:t,a=e.backward,s=void 0!==a&&a,c=e.order,u=void 0===c?"latest_last_message":c,l=e.borderlineChannelUrl;return i(this,void 0,void 0,(function(){var e,t,a,i,c=this;return o(this,(function(o){switch(o.label){case 0:return this.localCacheEnabled?(e=ue(u),t={where:function(e){if(n&&"latest_last_message"===u){if(!s&&e.lastMessageUpdatedAt>n||s&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new Q({channels:h,source:s})),d.length>0&&this._dispatcher.dispatch(new W({channelUrls:d,source:s})),[2,{updatedChannels:h,deletedChannelUrls:d,hasMore:f,token:p}]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return i(this,void 0,void 0,(function(){var a,s,i,c,u,l,h;return o(this,(function(o){switch(o.label){case 0:return a=r(r({},K),e),n(X(a)).throw(t.invalidParameters),s=M.of(this._iid),i=s.sdkState,c=s.requestQueue,u=new $({userId:i.userId,filter:a,includeFeedChannel:!0}),[4,c.send(u)];case 1:return l=o.sent(),h=l.as(J).unreadFeedCount,[2,void 0===h?0:h]}}))}))},u.prototype.getGlobalNotificationChannelSetting=function(){return i(this,void 0,void 0,(function(){var e,n;return o(this,(function(t){switch(t.label){case 0:return e=new De,[4,this._requestQueue.send(e)];case 1:return n=t.sent(),[2,{jsonString:n.as(Te).jsonString}]}}))}))},u.prototype.getNotificationTemplateListByToken=function(e,a){return void 0===a&&(a={}),i(this,void 0,void 0,(function(){var s,i,c,u,l,h,d;return o(this,(function(o){switch(o.label){case 0:return s=r(r({},Se),a),n(m("string",e)&&function(e){return m("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&m("number",e.limit,!0)}(s)).throw(t.invalidParameters),i=new ke({token:e,keys:s.keys,reverse:s.reverse,limit:s.limit}),[4,this._requestQueue.send(i)];case 1:return c=o.sent(),u=c.as(Ae),l=u.hasMore,h=u.nextToken,d=u.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},u.prototype.getNotificationTemplate=function(e){return i(this,void 0,void 0,(function(){var r,a;return o(this,(function(s){switch(s.label){case 0:return n(m("string",e)).throw(t.invalidParameters),r=new xe({key:e}),[4,this._requestQueue.send(r)];case 1:return a=s.sent(),[2,{jsonString:a.as(He).jsonString}]}}))}))},u.prototype.upsertChannelsToCache=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.removeChannelsFromCache=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return n.sent(),[2]}}))}))},u.prototype.refreshChannel=function(e,n,t){return void 0===n&&(n=!0),void 0===t&&(t=N.REFRESH_CHANNEL),i(this,void 0,void 0,(function(){var r,a,s,i,c;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:n}),[4,this._requestQueue.send(r)];case 1:return a=o.sent(),(s=a.as(Me).channel).myMemberState!==ee.NONE?[3,2]:(this._dispatcher.dispatch(new W({channelUrls:[s.url],source:t})),[3,4]);case 2:return[4,this.upsertChannelsToCache([s])];case 3:i=o.sent(),this._dispatcher.dispatch(new Q({channels:i,source:t})),o.label=4;case 4:return[3,6];case 5:return(c=o.sent()).code!==D.NON_AUTHORIZED&&c.code!==D.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new W({channelUrls:[e],source:t})),[3,6];case 6:return[2]}}))}))},u.prototype.subscribeChannelEvent=function(e,n){this._feedChannelBroadcast.subscribe(e,n)},u.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},u.prototype._handleEvent=function(e){return i(this,void 0,void 0,(function(){var n,t,r,a,s,c,u,h,d,f,p,v,C,m,g,y,b,E,w,U,I=this;return o(this,(function(D){switch(D.label){case 0:switch(e.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"SYEV":return[3,13]}return[3,23];case 1:return(g="MESG"===e.code?e.as(B):"FILE"===e.code?e.as(z):"ADMM"===e.code||"BRDM"===e.code?e.as(_e):null)&&g.message.channelType===this._channelType?(n=g.message,t=g.isMentioned,r=g.forceUpdateLastMessage,this._disableMack||_((function(){return i(I,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new se(n),this._requestQueue.send(e),[2]}))}))})),[4,this.getChannel(n.channelUrl,!0)]):[3,3];case 2:(a=D.sent())._runIfHandleableWithGroupChannel((function(e){var s,c,u,h=I._feedChannelCache.isCachedInMemory(n.channelUrl),d=n instanceof j&&n.sender.userId===I._sdkState.userId;if(e.hiddenState===re.HIDDEN_ALLOW_AUTO_UNHIDE&&(e.hiddenState=re.UNHIDDEN),n instanceof j){var f=M.of(I._iid).useMemberInfoInMessage;try{for(var p=l(e.members),_=p.next();!_.done;_=p.next()){var v=_.value;if(v.userId===n.sender.userId){f||(n.sender.nickname=v.nickname,n.sender.plainProfileUrl=v.plainProfileUrl,n.sender.metaData=v.metaData,n.sender.isBlockedByMe=v.isBlockedByMe);break}}}catch(e){s={error:e}}finally{try{_&&!_.done&&(c=p.return)&&c.call(p)}finally{if(s)throw s.error}}if(!f&&t&&(null===(u=n.mentionedUsers)||void 0===u||u.forEach((function(n){var t,r;try{for(var a=l(e.members),s=a.next();!s.done;s=a.next()){var i=s.value;if(n.userId===i.userId){n.nickname=i.nickname,n.plainProfileUrl=i.plainProfileUrl,n.metaData=i.metaData;break}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}))),d){var C=I._sessionManager.currentUser;C&&(C.nickname=n.sender.nickname,C.plainProfileUrl=n.sender.plainProfileUrl,C.metaData=n.sender.metaData)}}n.silent&&!d||(e.isEphemeral||h)&&((!e.lastMessage||e.lastMessage.createdAt0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),I._dispatcher.dispatch(new Q({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return i(I,void 0,void 0,(function(){var e,n,t,r,a;return o(this,(function(s){try{for(e=l(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(I._dispatcher.dispatch(new Q({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return i(I,void 0,void 0,(function(){var e,n,t,r,a;return o(this,(function(s){try{for(e=l(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(I._dispatcher.dispatch(new Q({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return i(I,void 0,void 0,(function(){var e,n,t,r,a;return o(this,(function(s){try{for(e=l(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onUnreadMemberStatusUpdated&&t.onUnreadMemberStatusUpdated(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})))})),D.label=12;case 12:return[3,23];case 13:if(!(g="SYEV"===e.code?e.as(de):null)||g.event.channelType!==this._channelType)return[3,22];switch(y=g.event,y.category){case fe.CHANNEL_INVITE:return[3,14];case fe.CHANNEL_DECLINE_INVITE:return[3,16];case fe.CHANNEL_DELETED:return[3,18];case fe.CHANNEL_PROP_CHANGED:return[3,20]}return[3,22];case 14:return[4,this.getChannel(y.channelUrl,!0)];case 15:return(b=D.sent())._runIfHandleableWithGroupChannel((function(n){var t,r,a=e.as(te),s=a.memberCount,i=a.joinedMemberCount,o=a.invitees;o.forEach((function(e){return e.state=ee.INVITED}));try{for(var c=l(o),u=c.next();!u.done;u=c.next()){var h=u.value;n.isExclusive||n.isSuper||n.isBroadcast?n._setLatestMemberCount(s,i,y.ts):n.addMember(h,y.ts),I._sdkState.userId===h.userId&&(n.hiddenState=re.UNHIDDEN,n.myMemberState!==ee.JOINED&&(n.myMemberState=ee.INVITED),n.invitedAt=y.ts)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}I._dispatcher.dispatch(new Q({channels:[b],source:N.EVENT_CHANNEL_INVITED}))})),[3,22];case 16:return[4,this.getChannel(y.channelUrl,!0)];case 17:return(E=D.sent())._runIfHandleableWithGroupChannel((function(n){var t=e.as(ne),r=t.memberCount,a=t.joinedMemberCount,s=t.invitee;n.isExclusive||n.isSuper||n.isBroadcast?n._setLatestMemberCount(r,a,y.ts):n.removeMember(s),I._sdkState.userId===s.userId?(n.invitedAt=0,n.myMemberState=ee.NONE,n.isPublic?I._dispatcher.dispatch(new Q({channels:[E],source:N.EVENT_CHANNEL_DECLINED_INVITE})):I._dispatcher.dispatch(new W({channelUrls:[E.url],source:N.EVENT_CHANNEL_DECLINED_INVITE}))):I._dispatcher.dispatch(new Q({channels:[E],source:N.EVENT_CHANNEL_DECLINED_INVITE}))})),[3,22];case 18:return[4,this.getChannel(y.channelUrl,!0)];case 19:return w=D.sent(),this._dispatcher.dispatch(new W({channelUrls:[y.channelUrl],source:N.EVENT_CHANNEL_DELETED})),T((function(){return i(I,void 0,void 0,(function(){return o(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(w.url,w.channelType)})),[2]}))}))})),[3,22];case 20:return[4,this.getChannelWithoutCache(y.channelUrl,!0)];case 21:return U=D.sent(),this._dispatcher.dispatch(new Q({channels:[U],source:N.EVENT_CHANNEL_UPDATED})),T((function(){return i(I,void 0,void 0,(function(){return o(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(U)})),[2]}))}))})),[3,22];case 22:return[3,23];case 23:return[2]}}))}))},u}(he),Oe=function(n){function t(e,t){return n.call(this,e,r(r({},t),{channelManager:Pe.of(e)}))||this}return e(t,n),t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t}(ie),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channelType=U.FEED,r._groupChannel=new oe(e,t),r}return e(t,n),t.payloadify=function(e){var n;return r({},oe.payloadify(null!==(n=e._groupChannel)&&void 0!==n?n:e))},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastMessage",{get:function(){return this._groupChannel.lastMessage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){return r({},this._groupChannel.serialize())},t.prototype.refresh=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(){return i(this,void 0,void 0,(function(){var e,n,t,r,a,s,i,c=this;return o(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),n=e.sdkState,t=e.dispatcher,r=e.requestQueue,a=new ce({channelUrl:this.url}),[4,r.send(a)];case 1:return s=o.sent(),i=s.as(ae).readStatus,this._groupChannel._updateUnreadMemberState(n.userId,i.readAt),(this._groupChannel.unreadMessageCount>0||this._groupChannel.unreadMentionCount>0)&&(this._groupChannel._updateUnreadCount(0,0),Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(c)}))),t.dispatch(new Q({channels:[this],source:N.EVENT_CHANNEL_READ})),[2]}}))}))},t.prototype.createNotificationCollection=function(e){return void 0===e&&(e={}),new Oe(this._iid,r({channel:this},e))},t}(q),Fe=["onUserMuted","onUserUnmuted","onUserBanned","onUserUnbanned","onChannelFrozen","onChannelUnfrozen","onOperatorUpdated","onMetaDataCreated","onMetaDataUpdated","onMetaDataDeleted","onMetaCounterCreated","onMetaCounterUpdated","onMetaCounterDeleted","onReactionUpdated","onThreadInfoUpdated"],je=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){Object.prototype.hasOwnProperty.call(t,n)&&-1===Fe.indexOf(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUnreadMemberStatusUpdated=S,e.onUserMuted=S,e.onUserUnmuted=S,e.onUserBanned=S,e.onUserUnbanned=S,e.onChannelFrozen=S,e.onChannelUnfrozen=S,e.onOperatorUpdated=S,e.onMetaDataCreated=S,e.onMetaDataUpdated=S,e.onMetaDataDeleted=S,e.onMetaCounterCreated=S,e.onMetaCounterUpdated=S,e.onMetaCounterDeleted=S,e.onReactionUpdated=S,e.onThreadInfoUpdated=S,e}return e(t,n),t}(ve)),Ve=function(n){function a(e,t){var r,a=this;return(a=n.call(this,e,t)||this).includeEmpty=me,a.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r?r:me,a}return e(a,n),a.prototype._validate=function(){return n.prototype._validate.call(this)&&m("boolean",this.includeEmpty)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,n,a,s,i;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Pe.of(this._iid),n=g(r({},this)),[4,e.getMyFeedChannels(this._token,n,this.limit)]):[3,2]:[3,5];case 1:return a=o.sent(),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw t.queryInProgress;case 4:return[3,6];case 5:throw t.invalidParameters;case 6:return[2]}}))}))},a}(x),Ge=function(a){function s(){var e=null!==a&&a.apply(this,arguments)||this;return e.name="feedChannel",e}return e(s,a),s.prototype.init=function(e,n){a.prototype.init.call(this,e,n),this._manager=new Pe(e,n)},s.prototype.createMyFeedChannelListQuery=function(e){return void 0===e&&(e={}),new Ve(this._iid,e)},s.prototype.addFeedChannelHandler=function(e,r){n(m("string",e)&&r instanceof je).throw(t.invalidParameters),this._manager.addHandler(e,r)},s.prototype.removeFeedChannelHandler=function(e){n(m("string",e)).throw(t.invalidParameters),this._manager.removeHandler(e)},s.prototype.removeAllFeedChannelHandlers=function(){this._manager.clearHandler()},s.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(r){return n(m("string",e)).throw(t.invalidParameters),[2,this._manager.getChannel(e)]}))}))},s.prototype.getMyFeedChannelChangeLogsByTimestamp=function(e,a){return void 0===a&&(a={}),i(this,void 0,void 0,(function(){var s;return o(this,(function(i){switch(i.label){case 0:return s=r(r({},we),a),n(m("number",e)&&Ne(s)).throw(t.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,s)];case 1:return[2,i.sent()]}}))}))},s.prototype.getMyFeedChannelChangeLogsByToken=function(e,a){return void 0===a&&(a={}),i(this,void 0,void 0,(function(){var s;return o(this,(function(i){switch(i.label){case 0:return s=r(r({},we),a),n(m("string",e)&&Ne(s)).throw(t.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,s)];case 1:return[2,i.sent()]}}))}))},s.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,n.sent()]}}))}))},s.prototype.getGlobalNotificationChannelSetting=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._manager.getGlobalNotificationChannelSetting()];case 1:return[2,e.sent()]}}))}))},s.prototype.getNotificationTemplateListByToken=function(e,n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._manager.getNotificationTemplateListByToken(e,n)];case 1:return[2,t.sent()]}}))}))},s.prototype.getNotificationTemplate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._manager.getNotificationTemplate(e)];case 1:return[2,n.sent()]}}))}))},s}(H);export{Re as FeedChannel,je as FeedChannelHandler,Ve as FeedChannelListQuery,Ge as FeedChannelModule,Oe as NotificationCollection}; diff --git a/groupChannel.js b/groupChannel.js index 2247dcd..6ab5f09 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{b as i,V as s,c as h,y as f,z as v,q as _,o as g,p as L,T,H as F,r as N,B as D,m as I,aW as V,aX as K,u as j,g as W,ak as Y,N as J,_ as X,A as Z,ao as $,e as ee,f as te,h as ne,a as ae,K as re,O as ie,aE as se,ap as oe,aY as le,ae as ue,s as ce,aM as he}from"./lib/__bundle-1da35e70.js";export{aZ as MessageEventSource,a_ as MutedState}from"./lib/__bundle-1da35e70.js";import{S as de,G as pe,s as fe,a as me,b as ve,P as _e,c as ge,d as ye,e as Ce,f as be,v as Me,g as Se,h as Ee,i as we,j as Le}from"./lib/__bundle-4e23f900.js";export{C as CountPreference,c as GroupChannel,b as GroupChannelEventContext,k as GroupChannelEventSource,a as GroupChannelFilter,e as GroupChannelListQuery,l as GroupChannelSearchField,H as HiddenChannelFilter,m as HiddenState,M as Member,n as MemberListOrder,o as MemberListQuery,p as MemberState,q as MemberStateFilter,t as MessageCollection,u as MessageCollectionInitHandler,w as MessageCollectionInitPolicy,x as MessageEventContext,y as MutedMemberFilter,r as MyMemberStateFilter,O as OperatorFilter,z as PinnedMessage,A as PinnedMessageListQuery,P as PublicChannelFilter,Q as QueryType,R as ReadStatus,d as SuperChannelFilter,U as UnreadChannelFilter,B as UnreadItemKey}from"./lib/__bundle-4e23f900.js";import{G as Te,P as Ae,S as ke}from"./lib/__bundle-f4ef8eae.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-f4ef8eae.js";import{T as Fe,B as Ne}from"./lib/__bundle-d3df41f8.js";import{D as Ge,z as xe,E as Ue}from"./lib/__bundle-0099b2f2.js";export{G as MessageFilter,E as ScheduledStatus}from"./lib/__bundle-0099b2f2.js";import"./lib/__bundle-c336221f.js";var Oe,De={},Pe=function(){function e(e){var t=e._iid,n=e.limit,a=void 0===n?100:n,r=this;this.ref=0,this._iid=t,this._limit=a;var o,l=s.of(this._iid),u=l.sdkState,c=l.dispatcher,d=l.logger,p=l.cacheContext;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/sync.meta"));var m=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(u.userId);this._sync=new de(m,(function(){return i(r,void 0,void 0,(function(){var e,t,n,a,r,i,s,o,l,c,f,m;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),d.debug("channel background sync from",null===(l=this._metadata)||void 0===l?void 0:l.token),null===(c=this._metadata)||void 0===c?void 0:c.completed)return[3,13];h.label=2;case 2:if(h.trys.push([2,9,,12]),(t={includeEmpty:!0,order:Te.CHRONOLOGICAL}).order!==Te.LATEST_LAST_MESSAGE)return[3,6];h.label=3;case 3:return h.trys.push([3,5,,6]),[4,p.preference.get(F(u.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,pe.of(this._iid).getMyGroupChannels(null!==(m=null===(f=this._metadata)||void 0===f?void 0:f.token)&&void 0!==m?m:"",t,this._limit,T.SYNC_CHANNEL_BACKGROUND)];case 7:return a=h.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(o=this._metadata.range).extends.apply(o,g([],L(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),d.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[3,14];case 13:e.hasNext=!1,e.nextToken="",h.label=14;case 14:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t){return De[t]||(De[t]=new e({_iid:t})),De[t].ref++,De[t]},e.clear=function(e){De[e]&&(De[e].close(),delete De[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Fe({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,s.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Fe(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e,t,n=s.of(this._iid),a=n.logger;n.connectionManager.isConnected&&(a.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){s.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete De[this._iid])},e}(),Ie={},He=function(){function e(e){var t=e._iid,n=this;this.ref=0,this._iid=t;var a,r=s.of(this._iid),o=r.logger,l=r.sdkState,u=r.dispatcher,c=r.cacheContext;this._metadataKey=(a=l.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new de(d,(function(){return i(n,void 0,void 0,(function(){var e,t,n,a,r,i,s,u,d,p;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:h.sent(),o.debug("channel changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),h.label=2;case 2:h.trys.push([2,9,,12]),t={includeEmpty:!0},h.label=3;case 3:return h.trys.push([3,5,,6]),[4,c.preference.get(F(l.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,pe.of(this._iid).getMyGroupChannelChangeLogs(null!==(p=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==p?p:"",t,T.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=h.sent(),r=a.hasMore,i=a.token,e.hasNext=r,e.nextToken=i,this._metadata&&(this._metadata.token=i),o.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),o.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Ie[t]||(Ie[t]=new e({_iid:t})),Ie[t].ref++,Ie[t]},e.clear=function(e){Ie[e]&&(Ie[e].close(),delete Ie[e])},e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,a;return h(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=s.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){s.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ie[this._iid])},e}(),Re=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Ve=function(e,t,n){if(e.length>0){for(var a=Re(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Ke(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Ke=function(e,t,n){switch(n){case Te.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Te.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Te.CHANNEL_NAME_ALPHABETICAL:var a=e.name.localeCompare(t.name);return 0===a?e.createdAt-t.createdAt:a;default:return 0}},Qe=function(){function e(e,t){var n=t.filter,a=t.order,r=t.limit,o=this;this.channels=[],this._iid=e,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new me,this.order=null!=a?a:Te.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=r?r:Ge;var l=s.of(this._iid),u=l.sdkState,c=l.cacheContext,d=l.dispatcher;c.localCacheEnabled&&(this._backgroundSync=Pe.of(e),this._backgroundSync.resume()),this._changelogSync=He.of(e),this._changelogSync.resume(),pe.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){if(fe(t)){var n=e.filter((function(e){return o.filter.match(e,u.userId)})),a=e.filter((function(e){return!o.filter.match(e,u.userId)})).map((function(e){return e.url}));n.length>0&&o._addChannelsToView(n,t),a.length>0&&o._removeChannelsFromView(a,t)}},onRemove:function(e,t){o._removeChannelsFromView(e,t)}}),s.of(this._iid).statLogCollector.put(new V({type:K.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{group_channel:!0}}})),d.on((function(e){e instanceof f&&(e.stateType===v.CONNECTED?o._isGetRemoteChannelsSucceeded||i(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===v.LOGOUT&&o.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var a,r,s,o,l=this;void 0===n&&(n=!1);var u=[],c=[],d=[];try{for(var p=N(e),f=p.next();!f.done;f=p.next()){var m=f.value,v=Re(this.channels,m);v>=0&&this.channels.splice(v,1);var _=Ve(this.channels,m,this.order).place;if(v<0)_===this.channels.length?!n&&this._hasMore||(u.push(m),this.channels.push(m)):(u.push(m),this.channels.splice(_,0,m));else switch(t){case T.EVENT_CHANNEL_UPDATED:case T.EVENT_MESSAGE_RECEIVED:case T.SYNC_CHANNEL_CHANGELOGS:case T.EVENT_MESSAGE_SENT:_!==v&&this._hasMore&&_===this.channels.length?d.push(m):(this.channels.splice(_,0,m),c.push(m));break;default:this.channels.splice(_,0,m),c.push(m)}}}catch(e){a={error:e}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(a)throw a.error}}if(d.length>0)try{for(var g=N(d),y=g.next();!y.done;y=g.next()){m=y.value;var C=Re(this.channels,m);-1!==C&&this.channels.splice(C,1)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}fe(t)&&D((function(){return i(l,void 0,void 0,(function(){var e,n,a,r;return h(this,(function(i){return e=new ve(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),d.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,d.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,a,r=this,s=[],o=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var u=N(e),c=u.next();!c.done;c=u.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}return fe(t)&&s.length>0&&D((function(){return i(r,void 0,void 0,(function(){var e,n;return h(this,(function(a){return e=new ve(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,s),[2]}))}))})),s},e.prototype._getLocalChannels=function(){return i(this,void 0,void 0,(function(){var e,t;return h(this,(function(n){switch(n.label){case 0:return e=pe.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Te.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Te.CHRONOLOGICAL:return e.createdAt;case Te.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return i(this,void 0,void 0,(function(){var e,t,n;return h(this,(function(a){switch(a.label){case 0:return[4,pe.of(this._iid).getMyGroupChannels(this._token,j(W(W({},this.filter),{order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,T.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r=this;return h(this,(function(o){switch(o.label){case 0:if(this._isDisposed)throw new _({code:Y.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=s.of(this._iid),t=e.cacheContext,n=e.connectionManager,a=[],!t.localCacheEnabled||n.isConnected&&!this._backgroundSync.completed?[3,2]:[4,J((function(){return i(r,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return a=e.sent(),[2]}}))}))}))]):[3,6];case 1:return o.sent(),this._hasMore=a.length>=this._limit,[3,5];case 2:return o.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return a=o.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return o.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(a,T.REQUEST_CHANNEL,!0),[2,a];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),pe.of(this._iid).unsubscribeChannelEvent(this._key))},e}(),je=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,m=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=Z.GET,n.path=$,n.params=ee(j({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:_e.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:_,show_metadata:g})),n}return X(t,e),t}(te),We=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new ge(t,e)}))),a.ts="number"==typeof s?s:0,a}return X(t,e),t}(ne);!function(e){e.ALL="all",e.JOINED="joined"}(Oe||(Oe={}));var ze=function(e){function t(t,n){var a,r,i,s,o,l,u,c,h,d,p,f,m,v,_=this;return(_=e.call(this,t,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=Oe.ALL,_.superChannelFilter=ye.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=Ae.CHRONOLOGICAL,_.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,_.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,_.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,_.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,_.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,_.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,_.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,_.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:Oe.ALL,_.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:ye.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,_.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,_.order=null!==(v=n.order)&&void 0!==v?v:Ae.CHRONOLOGICAL,_}return X(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ae("boolean",this.includeEmpty)&&ae("boolean",this.includeFrozen)&&ae("boolean",this.includeMetaData)&&ae("string",this.channelNameContainsFilter,!0)&&re("string",this.channelUrlsFilter,!0)&&re("string",this.customTypesFilter,!0)&&ae("string",this.customTypeStartsWithFilter,!0)&&ie(Oe,this.membershipFilter)&&ie(ye,this.superChannelFilter)&&ie(Ae,this.order)&&ae("string",this.metadataOrderKeyFilter,!0)&&ae("string",this.metadataKey,!0)&&re("string",this.metadataValues,!0)&&ae("string",this.metadataValueStartsWith,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i,o,l;return h(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=s.of(this._iid),n=t.requestQueue,t.dispatcher,a=new je(j(W(W({},this),{token:this._token}))),[4,n.send(a)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(We),o=i.channels,l=i.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(se),Be=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return X(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=oe,t.onUserLeft=oe,t.onUserReceivedInvitation=oe,t.onUserDeclinedInvitation=oe,t.onChannelHidden=oe,t.onUnreadMemberStatusUpdated=oe,t.onUndeliveredMemberStatusUpdated=oe,t.onTypingStatusUpdated=oe,t.onPollUpdated=oe,t.onPollVoted=oe,t.onPollDeleted=oe,t.onPinnedMessageUpdated=oe,t}return X(t,e),t}(Ne)),qe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=Z.GET,n.path="".concat(le),n.params=ee(j({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return X(t,e),t}(te),Ye=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return xe(t,e)})),a}return X(t,e),t}(ne),Je=function(e){function t(t,n){var a,r,i,s,o,l=this;return(l=e.call(this,t,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=ue.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:ue.ALL,l}return X(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ae("string",this.channelUrl,!0)&&(ie(ke,this.order)||null===this.order)&&ae("boolean",this.reverse)&&(re(Ue,this.scheduledStatus)||null===this.scheduledStatus)&&ie(ue,this.messageTypeFilter)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i;return h(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.of(this._iid).requestQueue,t=new qe(j(W(W({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(Ye),r=a.scheduledMessages,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(se),Xe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return X(t,e),t.prototype.init=function(t,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new pe(t,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Qe(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Ce(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ze(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){ce(ae("string",e)&&t instanceof Be).throw(_.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){ce(ae("string",e)).throw(_.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ce(ae("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ce(ae("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=W(W({},be),t),ce(ae("string",e)&&Me(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=W(W({},be),t),ce(ae("number",e)&&Me(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=W(W({},Se),e),ce(Ee(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=W(W({},we),e),ce(Le(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=W(W({},we),e),ce(Le(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,r,s){return void 0===t&&(t=!1),void 0===r&&(r=""),void 0===s&&(s=""),i(this,void 0,void 0,(function(){var i;return h(this,(function(o){return i=W(W({},we),{invitedUserIds:e,isDistinct:t,name:n,data:r,customType:s}),"string"==typeof a?i.coverUrl=a:i.coverImage=a,[2,this.createChannel(i)]}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ce(re("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return ce(ae("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(he);export{Qe as GroupChannelCollection,Be as GroupChannelHandler,Xe as GroupChannelModule,Oe as MembershipFilter,ze as PublicGroupChannelListQuery,Je as ScheduledMessageListQuery}; +import{b as i,V as s,c as h,y as f,z as v,q as _,o as g,p as E,T as L,H as T,r as F,B as N,m as D,aW as I,aX as V,u as K,g as j,ak as W,N as Y,_ as J,A as X,ao as Z,e as $,f as ee,h as te,a as ne,K as ae,O as re,aE as ie,ap as se,aY as oe,ae as le,s as ue,aM as ce}from"./lib/__bundle-fdefc164.js";export{aZ as MessageEventSource,a_ as MutedState}from"./lib/__bundle-fdefc164.js";import{S as he,G as de,s as pe,a as fe,b as me,P as ve,c as _e,d as ge,e as ye,f as Ce,v as be,g as Me,h as Se,i as Ee,j as we}from"./lib/__bundle-2e839992.js";export{C as CountPreference,c as GroupChannel,b as GroupChannelEventContext,k as GroupChannelEventSource,a as GroupChannelFilter,e as GroupChannelListQuery,l as GroupChannelSearchField,H as HiddenChannelFilter,m as HiddenState,M as Member,n as MemberListOrder,o as MemberListQuery,p as MemberState,q as MemberStateFilter,t as MessageCollection,u as MessageCollectionInitHandler,w as MessageCollectionInitPolicy,x as MessageEventContext,y as MutedMemberFilter,r as MyMemberStateFilter,O as OperatorFilter,z as PinnedMessage,A as PinnedMessageListQuery,P as PublicChannelFilter,Q as QueryType,R as ReadStatus,d as SuperChannelFilter,U as UnreadChannelFilter,B as UnreadItemKey}from"./lib/__bundle-2e839992.js";import{G as Le,P as Te,S as Ae}from"./lib/__bundle-8934878d.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-8934878d.js";import{T as ke,B as Fe}from"./lib/__bundle-6f8fc428.js";import{D as Ne,E as Ge,G as xe}from"./lib/__bundle-bd25634c.js";export{z as MessageFilter,G as ScheduledStatus}from"./lib/__bundle-bd25634c.js";import"./lib/__bundle-c336221f.js";var Ue,Oe={},De=function(){function e(e){var t=e._iid,n=e.limit,a=void 0===n?100:n,r=this;this.ref=0,this._iid=t,this._limit=a;var o,l=s.of(this._iid),u=l.sdkState,c=l.dispatcher,d=l.logger,p=l.cacheContext;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/sync.meta"));var m=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(u.userId);this._sync=new he(m,(function(){return i(r,void 0,void 0,(function(){var e,t,n,a,r,i,s,o,l,c,f,m;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),d.debug("channel background sync from",null===(l=this._metadata)||void 0===l?void 0:l.token),null===(c=this._metadata)||void 0===c?void 0:c.completed)return[3,13];h.label=2;case 2:if(h.trys.push([2,9,,12]),(t={includeEmpty:!0,order:Le.CHRONOLOGICAL}).order!==Le.LATEST_LAST_MESSAGE)return[3,6];h.label=3;case 3:return h.trys.push([3,5,,6]),[4,p.preference.get(T(u.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,de.of(this._iid).getMyGroupChannels(null!==(m=null===(f=this._metadata)||void 0===f?void 0:f.token)&&void 0!==m?m:"",t,this._limit,L.SYNC_CHANNEL_BACKGROUND)];case 7:return a=h.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(o=this._metadata.range).extends.apply(o,g([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),d.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[3,14];case 13:e.hasNext=!1,e.nextToken="",h.label=14;case 14:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t){return Oe[t]||(Oe[t]=new e({_iid:t})),Oe[t].ref++,Oe[t]},e.clear=function(e){Oe[e]&&(Oe[e].close(),delete Oe[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new ke({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,s.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new ke(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e,t,n=s.of(this._iid),a=n.logger;n.connectionManager.isConnected&&(a.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){s.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Oe[this._iid])},e}(),Pe={},Ie=function(){function e(e){var t=e._iid,n=this;this.ref=0,this._iid=t;var a,r=s.of(this._iid),o=r.logger,l=r.sdkState,u=r.dispatcher,c=r.cacheContext;this._metadataKey=(a=l.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new he(d,(function(){return i(n,void 0,void 0,(function(){var e,t,n,a,r,i,s,u,d,p;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:h.sent(),o.debug("channel changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),h.label=2;case 2:h.trys.push([2,9,,12]),t={includeEmpty:!0},h.label=3;case 3:return h.trys.push([3,5,,6]),[4,c.preference.get(T(l.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,de.of(this._iid).getMyGroupChannelChangeLogs(null!==(p=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==p?p:"",t,L.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=h.sent(),r=a.hasMore,i=a.token,e.hasNext=r,e.nextToken=i,this._metadata&&(this._metadata.token=i),o.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),o.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Pe[t]||(Pe[t]=new e({_iid:t})),Pe[t].ref++,Pe[t]},e.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,a;return h(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=s.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){s.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},e}(),He=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Re=function(e,t,n){if(e.length>0){for(var a=He(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Ve(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Ve=function(e,t,n){switch(n){case Le.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Le.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Le.CHANNEL_NAME_ALPHABETICAL:var a=e.name.localeCompare(t.name);return 0===a?e.createdAt-t.createdAt:a;default:return 0}},Ke=function(){function e(e,t){var n=t.filter,a=t.order,r=t.limit,o=this;this.channels=[],this._iid=e,this._key="gcc-".concat(D()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new fe,this.order=null!=a?a:Le.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=r?r:Ne;var l=s.of(this._iid),u=l.sdkState,c=l.cacheContext,d=l.dispatcher;c.localCacheEnabled&&(this._backgroundSync=De.of(e),this._backgroundSync.resume()),this._changelogSync=Ie.of(e),this._changelogSync.resume(),de.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){if(pe(t)){var n=e.filter((function(e){return o.filter.match(e,u.userId)})),a=e.filter((function(e){return!o.filter.match(e,u.userId)})).map((function(e){return e.url}));n.length>0&&o._addChannelsToView(n,t),a.length>0&&o._removeChannelsFromView(a,t)}},onRemove:function(e,t){o._removeChannelsFromView(e,t)}}),s.of(this._iid).statLogCollector.put(new I({type:V.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{group_channel:!0}}})),d.on((function(e){e instanceof f&&(e.stateType===v.CONNECTED?o._isGetRemoteChannelsSucceeded||i(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===v.LOGOUT&&o.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var a,r,s,o,l=this;void 0===n&&(n=!1);var u=[],c=[],d=[];try{for(var p=F(e),f=p.next();!f.done;f=p.next()){var m=f.value,v=He(this.channels,m);v>=0&&this.channels.splice(v,1);var _=Re(this.channels,m,this.order).place;if(v<0)_===this.channels.length?!n&&this._hasMore||(u.push(m),this.channels.push(m)):(u.push(m),this.channels.splice(_,0,m));else switch(t){case L.EVENT_CHANNEL_UPDATED:case L.EVENT_MESSAGE_RECEIVED:case L.SYNC_CHANNEL_CHANGELOGS:case L.EVENT_MESSAGE_SENT:_!==v&&this._hasMore&&_===this.channels.length?d.push(m):(this.channels.splice(_,0,m),c.push(m));break;default:this.channels.splice(_,0,m),c.push(m)}}}catch(e){a={error:e}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(a)throw a.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){m=y.value;var C=He(this.channels,m);-1!==C&&this.channels.splice(C,1)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}pe(t)&&N((function(){return i(l,void 0,void 0,(function(){var e,n,a,r;return h(this,(function(i){return e=new me(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),d.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,d.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,a,r=this,s=[],o=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var u=F(e),c=u.next();!c.done;c=u.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}return pe(t)&&s.length>0&&N((function(){return i(r,void 0,void 0,(function(){var e,n;return h(this,(function(a){return e=new me(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,s),[2]}))}))})),s},e.prototype._getLocalChannels=function(){return i(this,void 0,void 0,(function(){var e,t;return h(this,(function(n){switch(n.label){case 0:return e=de.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Le.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Le.CHRONOLOGICAL:return e.createdAt;case Le.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return i(this,void 0,void 0,(function(){var e,t,n;return h(this,(function(a){switch(a.label){case 0:return[4,de.of(this._iid).getMyGroupChannels(this._token,K(j(j({},this.filter),{order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,L.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r=this;return h(this,(function(o){switch(o.label){case 0:if(this._isDisposed)throw new _({code:W.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=s.of(this._iid),t=e.cacheContext,n=e.connectionManager,a=[],!t.localCacheEnabled||n.isConnected&&!this._backgroundSync.completed?[3,2]:[4,Y((function(){return i(r,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return a=e.sent(),[2]}}))}))}))]):[3,6];case 1:return o.sent(),this._hasMore=a.length>=this._limit,[3,5];case 2:return o.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return a=o.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return o.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(a,L.REQUEST_CHANNEL,!0),[2,a];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),de.of(this._iid).unsubscribeChannelEvent(this._key))},e}(),Qe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,m=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=X.GET,n.path=Z,n.params=$(K({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ve.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:_,show_metadata:g})),n}return J(t,e),t}(ee),je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new _e(t,e)}))),a.ts="number"==typeof s?s:0,a}return J(t,e),t}(te);!function(e){e.ALL="all",e.JOINED="joined"}(Ue||(Ue={}));var We=function(e){function t(t,n){var a,r,i,s,o,l,u,c,h,d,p,f,m,v,_=this;return(_=e.call(this,t,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=Ue.ALL,_.superChannelFilter=ge.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=Te.CHRONOLOGICAL,_.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,_.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,_.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,_.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,_.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,_.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,_.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,_.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:Ue.ALL,_.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:ge.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,_.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,_.order=null!==(v=n.order)&&void 0!==v?v:Te.CHRONOLOGICAL,_}return J(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ne("boolean",this.includeEmpty)&&ne("boolean",this.includeFrozen)&&ne("boolean",this.includeMetaData)&&ne("string",this.channelNameContainsFilter,!0)&&ae("string",this.channelUrlsFilter,!0)&&ae("string",this.customTypesFilter,!0)&&ne("string",this.customTypeStartsWithFilter,!0)&&re(Ue,this.membershipFilter)&&re(ge,this.superChannelFilter)&&re(Te,this.order)&&ne("string",this.metadataOrderKeyFilter,!0)&&ne("string",this.metadataKey,!0)&&ae("string",this.metadataValues,!0)&&ne("string",this.metadataValueStartsWith,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i,o,l;return h(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=s.of(this._iid),n=t.requestQueue,t.dispatcher,a=new Qe(K(j(j({},this),{token:this._token}))),[4,n.send(a)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(je),o=i.channels,l=i.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(ie),ze=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return J(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=se,t.onUserLeft=se,t.onUserReceivedInvitation=se,t.onUserDeclinedInvitation=se,t.onChannelHidden=se,t.onUnreadMemberStatusUpdated=se,t.onUndeliveredMemberStatusUpdated=se,t.onTypingStatusUpdated=se,t.onPollUpdated=se,t.onPollVoted=se,t.onPollDeleted=se,t.onPinnedMessageUpdated=se,t}return J(t,e),t}(Fe)),Be=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=X.GET,n.path="".concat(oe),n.params=$(K({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return J(t,e),t}(ee),qe=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ge(t,e)})),a}return J(t,e),t}(te),Ye=function(e){function t(t,n){var a,r,i,s,o,l=this;return(l=e.call(this,t,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=le.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:le.ALL,l}return J(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ne("string",this.channelUrl,!0)&&(re(Ae,this.order)||null===this.order)&&ne("boolean",this.reverse)&&(ae(xe,this.scheduledStatus)||null===this.scheduledStatus)&&re(le,this.messageTypeFilter)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i;return h(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.of(this._iid).requestQueue,t=new Be(K(j(j({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(qe),r=a.scheduledMessages,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(ie),Je=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return J(t,e),t.prototype.init=function(t,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new de(t,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Ke(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ye(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new We(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){ue(ne("string",e)&&t instanceof ze).throw(_.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){ue(ne("string",e)).throw(_.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ue(ne("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ue(ne("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=j(j({},Ce),t),ue(ne("string",e)&&be(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=j(j({},Ce),t),ue(ne("number",e)&&be(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=j(j({},Me),e),ue(Se(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=j(j({},Ee),e),ue(we(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=j(j({},Ee),e),ue(we(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,r,s){return void 0===t&&(t=!1),void 0===r&&(r=""),void 0===s&&(s=""),i(this,void 0,void 0,(function(){var i;return h(this,(function(o){return i=j(j({},Ee),{invitedUserIds:e,isDistinct:t,name:n,data:r,customType:s}),"string"==typeof a?i.coverUrl=a:i.coverImage=a,[2,this.createChannel(i)]}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ue(ae("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return ue(ne("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(ce);export{Ke as GroupChannelCollection,ze as GroupChannelHandler,Je as GroupChannelModule,Ue as MembershipFilter,We as PublicGroupChannelListQuery,Ye as ScheduledMessageListQuery}; diff --git a/index.js b/index.js index 8954e70..5ff84a7 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import{i as e,a as n,_ as r,E as i,b as o,c as a,A as c,d,e as l,u as h,f,U as p,g,h as _,P as b,j as I,k as E,l as D,S as A,L as N,m as z,n as j,V as H,o as G,p as W,v as K,C as V,q as J,r as ee,s as te,t as ne,w as re,x as ie,y as oe,z as se,W as ae,B as ue,D as ce,F as de,G as le,H as he,I as fe,J as pe,K as ve,M as ge,N as _e,O as me,Q as be,R as ye}from"./lib/__bundle-1da35e70.js";export{Y as CachedChannelInfo,X as ChannelType,T as CollectionEventSource,C as ConnectionState,a5 as DeviceOsPlatform,L as LocalCacheConfig,Z as LogLevel,$ as NotificationInfo,R as PushTemplate,M as PushTokenRegistrationState,P as PushTokenType,Q as PushTriggerOption,a0 as Role,S as SendbirdChatOptions,q as SendbirdError,a4 as SendbirdPlatform,a3 as SendbirdProduct,a1 as UIKitConfigInfo,U as User,a2 as UserOnlineState}from"./lib/__bundle-1da35e70.js";import{N as we,a as Ie,b as ke,c as Ce,g as Se,M as Te,d as Ee,e as Pe,f as Ue,h as De,i as Oe,j as Ae,k as Le,A as Ne,I as Me,l as Re,U as ze,C as Qe,m as je,B as qe,F as Fe,n as He,S as xe,o as Ge,p as We,q as Be,r as Ke}from"./lib/__bundle-0099b2f2.js";export{m as ApplicationUserListQuery,s as BannedUserListQuery,t as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,k as MemoryStore,u as MutedUserListQuery,O as OperatorListQuery,P as Participant,v as Plugin,R as ReportCategory,w as RestrictedUser,x as RestrictionInfo,y as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-0099b2f2.js";import{PollModule as Ve}from"./poll.js";import{g as Je,G as Xe,A as Ye,U as Ze,a as $e,b as et,D as tt,R as nt}from"./lib/__bundle-f4ef8eae.js";import{g as rt}from"./lib/__bundle-e9d4faa1.js";import"./lib/__bundle-c336221f.js";var it=function(e){this.key=e.key,this.url=e.url},ot=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new it(e)})):[]},st=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new ot(e)})):[]},at={profileImage:void 0,profileUrl:void 0,nickname:void 0},ut=function(e){return{v2:e.commitSchema([{collectionName:we,keyName:Ie,index:[Je(Xe.LATEST_LAST_MESSAGE),Je(Xe.CHRONOLOGICAL),Je(Xe.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ke,keyName:Ce,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:Pe,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:De}]),v3:e.commitSchema([{collectionName:Oe,keyName:Ae,index:[rt("latest_last_message")]}])}},ct=function(e,t){return function(n,r){switch(n){case 1:e.clear().then((function(){t.clear().then((function(){ut(e).v2.then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));break;case 2:ut(e).v3.then((function(){return r()})).catch((function(e){return r(e)}));break;default:r()}}},dt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},lt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?dt:n,i=t.initialState,o=void 0===i?"visible":i,s=t.isEnabled,a=void 0===s||s,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=o,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return r(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(i),ht=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return o(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:c.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),ft=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,o=t.profileImage,s=t.preferredLanguages,a=e.call(this)||this;return a.method=c.PUT,a.path="".concat(d,"/").concat(encodeURIComponent(n)),a.params=l(h({nickname:r,profile_url:i,profile_file:o,preferred_languages:s})),a}return r(t,e),t}(f),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new p(t,g({},n)),r}return r(t,e),t}(_),vt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r}r(t,e)}(_);var gt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r}r(t,e)}(_);var _t=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var mt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var bt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),r}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var yt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var wt=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,o=t.ts,s=e.call(this)||this;return s.method=c.GET,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),s.params={created_ts:o,token:i},s}return r(t,e),t}(f),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?b[n.type.toLowerCase()]:b.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return r(t,e),t}(_),kt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return r(t,e),t}(f),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(_),St=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return r(t,e),t}(f),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(_),Et=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(_),Ut=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,o=t.startMin,s=t.endHour,a=t.endMin,u=t.timezone,l=e.call(this)||this;return l.method=c.PUT,l.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),l.params={do_not_disturb:r,start_hour:i,start_min:o,end_hour:s,end_min:a,timezone:u},l}return r(t,e),t}(f),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(_),Ot=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(_),Lt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,o=t.endTs,s=e.call(this)||this;return s.method=c.PUT,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),s.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:o},s}return r(t,e),t}(f),Nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(_),Mt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new p(t,n),r}r(t,e)}(_);var Rt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(_),jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return r(t,e),t}(f),qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(_),Ft=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),r}return r(t,e),t}(f),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(_),xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return r(t,e),t}(f),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(_),Wt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.GET,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return r(t,e),t}(f),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new p(t,e)})),updatedUsers:n.updated.map((function(e){return new p(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return r(t,e),t}(_),Kt=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return r(t,e),t}(f),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return r(t,e),t}(_),Jt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var Xt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(f),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new p(t,e)})),r}return r(t,e),t}(_),Zt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var $t=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return r(t,e),t}(f),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return r(t,e),t}(_),tn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var nn,rn=function(e){function t(){var t=e.call(this)||this;return t.method=c.GET,t.path=I,t}return r(t,e),t}(f),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new st(n),r}return r(t,e),t}(_),sn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(I,"/").concat(n),r}return r(t,e),t}(f),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new ot(n),r}return r(t,e),t}(_),un=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(E,"/").concat(n),r}return r(t,e),t}(f),cn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new it(n),r}return r(t,e),t}(_),dn=function(e){function t(){var t=e.call(this)||this;return t.method=c.GET,t.path="".concat(D),t}return r(t,e),t}(f),ln=function(e){function t(t,n){var r,i=this,o=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return r(t,e),t}(_),hn=function(){function t(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=H.of(e),s=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new ht({logger:h,connectionDelegate:{reconnect:function(){var t=H.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){H.of(e).connectionManager.disconnect()}}});var v=new Ye(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:s,logger:h});n.forEach((function(t){t.init(e,{sdkState:s,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new lt({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){var n;if(t instanceof oe){if(t.stateType===se.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var i=t.as(Ze).event;if(i.category===$e.FRIEND_DISCOVERED){var c=et.getDataAsFriendDiscoveredEvent(e,i).friendDiscoveries;ue((function(){return o(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=H.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;if("number"==typeof p&&p>d.ts){if(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes)for(var g in t.customTypes)d.customTypes[g]!==t.customTypes[g]&&(l=!0),d.customTypes[g]=t.customTypes[g];l=l&&d.ts>0,d.ts=p}l&&ue((function(){return o(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(s.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&(t.error.isSessionRevokedError||t.error.isUserAuthDeactivedError||t.error.isUserAuthDeletedOrNotFoundError)&&(h.debug("session revoked."),r.disconnect())}))}return t.init=function(e){var n=e.appId,r=e.appVersion,i=e.modules,o=void 0===i?[]:i,s=e.options,a=void 0===s?new A:s,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,g=void 0!==v&&v,_=e.localCacheConfig,m=void 0===_?new N:_,b=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,I=e.appStateToggleEnabled,k=void 0===I||I;if(!nn||f){var C="su-".concat(z()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new Le({encryption:S});c||(T=j()?w?new Ne({AsyncStorage:w,encryption:S}):new Le({encryption:S}):new Me({encryption:S})),new H(C,{appId:n,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(n,".sendbird.com"),store:T,encryption:S,logLevel:p,localCacheEnabled:g,localCacheConfig:m,debugMode:c,appStateToggleEnabled:k});var E=[new Re,new Ve],P=new t(C,a,G(G([],W(o),!1),W(E),!1));return nn||(nn=P),P}return nn},Object.defineProperty(t,"instance",{get:function(){return nn},enumerable:!1,configurable:!0}),Object.defineProperty(t,"version",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appId",{get:function(){return H.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appInfo",{get:function(){var e=H.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appVersion",{get:function(){var e;return null!==(e=H.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugMode",{get:function(){return!!H.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return H.of(this._iid).logger.level},set:function(e){H.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCacheEnabled",{get:function(){return H.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheConfig",{get:function(){var e=H.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ekey",{get:function(){return H.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentUser",{get:function(){var e;return null!==(e=H.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectionState",{get:function(){var e=H.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastConnectedAt",{get:function(){var e=H.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),t.prototype._getNestDBVersion=function(){return 3},t.prototype._getCurrentPreferenceVersion=function(){return 1},t.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},t.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},t.prototype.getMemoryStoreForDebugging=function(){var e=H.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Le?n.store:null;throw J.debugModeRequired},t.prototype.addExtension=function(e,t){var n=H.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},t.prototype.addSendbirdExtensions=function(e,t,n){var r,i,o=H.of(this._iid),s=o.logger,a=o.sdkState,u=new RegExp(pe);if(0===e.length)return s.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return s.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=ee(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=W(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return s.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},t.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},t.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},t.prototype._safeInitializeStore=function(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=H.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new Le),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},t.prototype.initializeCache=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:return t=H.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,o=t.dispatcher,s=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(a.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];a.label=2;case 2:return a.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==Ke.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Ge({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:this._getNestDBVersion(),store:r.store})).on("upgrade",ct(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",ct(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,o.dispatch(new tt(this._iid,{userId:e})),a.label=4;case 4:return n.userId=e,[3,7];case 5:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw a.sent(),n.userId=e,J.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:a.sent(),n.userId=e,a.label=10;case 10:return[2]}}))}))},t.prototype.getCacheDataSize=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=H.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},t.prototype.clearCachedData=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=H.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},t.prototype.clearCachedMessages=function(e){return o(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=We.of(this._iid),n=Be.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return o(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.connect=function(e,t){return o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:te(n("string",e)&&n("string",t,!0)).throw(J.invalidParameters),r=H.of(this._iid),i=r.sdkState,o=r.cacheContext,s=r.connectionManager,u=r.statLogCollector,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return a.sent(),H.of(this._iid).dispatcher.dispatch(new nt),[3,4];case 3:return a.sent(),c=H.of(this._iid).logger,o.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return a.sent(),[4,o.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=a.sent())&&new le(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:a.sent(),a.label=8;case 8:return a.trys.push([8,,10,11]),[4,s.connect(t)];case 9:return a.sent(),[3,11];case 10:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 11:return[2,this.currentUser]}}))}))},t.prototype.reconnect=function(){var e=H.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},t.prototype.disconnect=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=H.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},t.prototype.disconnectWebSocket=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=H.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},t.prototype.setBackgroundState=function(){var e=H.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},t.prototype.setForegroundState=function(){var e=H.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},t.prototype.setSessionHandler=function(e){te(e instanceof xe).throw(J.invalidParameters),H.of(this._iid).sessionManager.handler=e},t.prototype.addUserEventHandler=function(e,t){te(n("string",e)&&t instanceof ze).throw(J.invalidParameters),H.of(this._iid).userEventHandlers.set(e,t)},t.prototype.removeUserEventHandler=function(e){H.of(this._iid).userEventHandlers.delete(e)},t.prototype.removeAllUserEventHandler=function(){H.of(this._iid).userEventHandlers.clear()},t.prototype.addConnectionHandler=function(e,t){te(n("string",e)&&t instanceof Qe).throw(J.invalidParameters),H.of(this._iid).connectionHandlers.set(e,t)},t.prototype.removeConnectionHandler=function(e){H.of(this._iid).connectionHandlers.delete(e)},t.prototype.removeAllConnectionHandler=function(){H.of(this._iid).connectionHandlers.clear()},t.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new je(this._iid,e)},t.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},t.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Fe(this._iid,e)},t.prototype.createMessageSearchQuery=function(e){return new He(this._iid,e)},t.prototype.createPollListQuery=function(e){return new ne(this._iid,g({},e))},t.prototype.createPollVoterListQuery=function(e){return new re(this._iid,g({},e))},t.prototype.buildUserFromSerializedData=function(e){var t=ie(e);return new p(this._iid,p.payloadify(t))},t.prototype.updateCurrentUserInfo=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=g(g({},at),t),te(function(t){return e(t.profileImage,!0)&&n("string",t.profileUrl,!0)&&n("string",t.nickname,!0)}(r)).throw(J.invalidParameters),this.currentUser?(i=H.of(this._iid),o=i.sdkState,s=i.requestQueue,u=new ft(g({userId:o.userId},r)),[4,s.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(pt).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw J.connectionRequired}}))}))},t.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),this.currentUser?(t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ft({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return o=a.sent(),s=o.as(pt).user,this.currentUser&&(this.currentUser.preferredLanguages=s.preferredLanguages),[2,s];case 2:throw J.connectionRequired}}))}))},t.prototype.registerFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,r.hasDeviceToken(b.FCM,e)?[2,ge.SUCCESS]:(u=new gt({userId:i.userId,token:e}),[4,s.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,u=new mt({userId:i.userId,token:e}),[4,s.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,s,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=H.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new yt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.FCM),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},t.prototype.registerAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,r.hasDeviceToken(b.APNS,e)?[2,ge.SUCCESS]:(u=new vt({userId:i.userId,token:e}),[4,s.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,u=new _t({userId:i.userId,token:e}),[4,s.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,s,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=H.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new bt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.APNS),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},t.prototype.getChannelInvitationPreference=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new kt({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,{autoAccept:i.as(Ct).autoAccept}]}}))}))},t.prototype.setChannelInvitationPreference=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return te(n("boolean",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new St({userId:r.userId,willAutoAccept:e}),[4,i.send(o)];case 1:return s=a.sent(),[2,{autoAccept:s.as(Tt).autoAccept}]}}))}))},t.prototype.getDoNotDisturb=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Et({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(Pt).preference]}}))}))},t.prototype.setDoNotDisturb=function(e,t,r,i,s,u){return void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===u&&(u=""),o(this,void 0,void 0,(function(){var o,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return te(n("boolean",e)&&n("number",t)&&n("number",r)&&n("number",i)&&n("number",s)&&n("string",u)).throw(J.invalidParameters),o=H.of(this._iid),c=o.sdkState,d=o.requestQueue,l=new Ut({userId:c.userId,doNotDisturbOn:e,startHour:t,startMin:r,endHour:i,endMin:s,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Dt).preference]}}))}))},t.prototype.getSnoozePeriod=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ot({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(At).snoozePeriod]}}))}))},t.prototype.setSnoozePeriod=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=0),o(this,void 0,void 0,(function(){var i,o,s,u,c;return a(this,(function(a){switch(a.label){case 0:return te(n("boolean",e)&&n("number",t)&&n("number",r)).throw(J.invalidParameters),i=H.of(this._iid),o=i.sdkState,s=i.requestQueue,u=new Lt({userId:o.userId,snoozeOn:e,startTs:t,endTs:r}),[4,s.send(u)];case 1:return c=a.sent(),[2,c.as(Nt).snoozePeriod]}}))}))},t.prototype.getMyPushTokensByToken=function(e,t){return o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return te(n("string",e)&&me(b,t)).throw(J.invalidParameters),r=H.of(this._iid),i=r.sdkState,o=r.requestQueue,s=r.sessionManager,u=new wt({userId:i.userId,type:t,token:e}),[4,o.send(u)];case 1:c=a.sent(),d=c.as(It).pushTokens;try{for(l=ee(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,s.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,s.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},t.prototype.getPushTriggerOption=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Qt).pushTriggerOption]}}))}))},t.prototype.setPushTriggerOption=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(me(be,e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,o.sent().as(qt).pushTriggerOption]}}))}))},t.prototype.getPushTemplate=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ft({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Ht).name]}}))}))},t.prototype.setPushTemplate=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(me(ye,e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,o.sent().as(Gt).name]}}))}))},t.prototype.blockUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(e instanceof p||n("string",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Mt({userId:r.userId,blockedUserId:e instanceof p?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},t.prototype.blockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},t.prototype.unblockUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(e instanceof p||n("string",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Rt({userId:r.userId,unblockedUserId:e instanceof p?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},t.prototype.unblockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},t.prototype.getFriendChangeLogsByToken=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return te(n("string",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Wt({userId:r.userId,token:e}),[4,i.send(o)];case 1:return s=a.sent(),[2,s.as(Bt).changelogs]}}))}))},t.prototype.getAllowFriendDiscovery=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new $t({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(en).allowFriendDiscovery]}}))}))},t.prototype.setAllowFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(n("boolean",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new tn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(o)];case 1:return s.sent(),[2,e]}}))}))},t.prototype.uploadFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return a(this,(function(s){switch(s.label){case 0:return t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Kt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Vt).friendDiscoveryRequestId]}}))}))},t.prototype.deleteFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},t.prototype.deleteFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},t.prototype.addFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Yt).users]}}))}))},t.prototype.deleteFriend=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},t.prototype.deleteFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Zt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},t.prototype.getAllEmoji=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=H.of(this._iid).requestQueue,t=new rn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(on).emojiContainer]}}))}))},t.prototype.getEmojiCategory=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=H.of(this._iid).requestQueue,n=new sn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(an).emojiCategory]}}))}))},t.prototype.getEmoji=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=H.of(this._iid).requestQueue,n=new un({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(cn).emoji]}}))}))},t.prototype.getUIKitConfiguration=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=H.of(this._iid),te(e.hasExtension("sb_uikit")).throw(J.notSupportedError),t=e.requestQueue,n=new dn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(ln).uikitConfiguration]}}))}))},t}();export{it as Emoji,ot as EmojiCategory,st as EmojiContainer,hn as default}; +import{i as e,a as n,_ as r,E as i,b as o,c as a,A as c,d,e as l,u as h,f,U as p,g,h as _,P as b,j as I,k as E,l as D,S as A,L as N,m as z,n as j,V as H,o as G,p as W,v as K,C as V,q as J,r as ee,s as te,t as ne,w as re,x as ie,y as oe,z as se,W as ae,B as ue,D as ce,F as de,G as le,H as he,I as fe,J as pe,K as ve,M as ge,N as _e,O as me,Q as be,R as ye}from"./lib/__bundle-fdefc164.js";export{Y as CachedChannelInfo,X as ChannelType,T as CollectionEventSource,C as ConnectionState,a5 as DeviceOsPlatform,L as LocalCacheConfig,Z as LogLevel,$ as NotificationInfo,R as PushTemplate,M as PushTokenRegistrationState,P as PushTokenType,Q as PushTriggerOption,a0 as Role,S as SendbirdChatOptions,q as SendbirdError,a4 as SendbirdPlatform,a3 as SendbirdProduct,a1 as UIKitConfigInfo,U as User,a2 as UserOnlineState}from"./lib/__bundle-fdefc164.js";import{N as we,a as Ie,b as ke,c as Ce,g as Se,M as Te,d as Ee,e as Pe,f as Ue,h as De,i as Oe,j as Ae,k as Le,A as Ne,I as Me,l as Re,U as ze,C as Qe,m as je,B as qe,F as Fe,n as He,S as xe,o as Ge,p as We,q as Be,r as Ke}from"./lib/__bundle-bd25634c.js";export{m as ApplicationUserListQuery,s as BannedUserListQuery,t as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,k as MemoryStore,u as MutedUserListQuery,O as OperatorListQuery,P as Participant,v as Plugin,R as ReportCategory,w as RestrictedUser,x as RestrictionInfo,y as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-bd25634c.js";import{PollModule as Ve}from"./poll.js";import{g as Je,G as Xe,A as Ye,U as Ze,a as $e,b as et,D as tt,R as nt}from"./lib/__bundle-8934878d.js";import{g as rt}from"./lib/__bundle-e9d4faa1.js";import"./lib/__bundle-c336221f.js";var it=function(e){this.key=e.key,this.url=e.url},ot=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new it(e)})):[]},st=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new ot(e)})):[]},at={profileImage:void 0,profileUrl:void 0,nickname:void 0},ut=function(e){return{v2:e.commitSchema([{collectionName:we,keyName:Ie,index:[Je(Xe.LATEST_LAST_MESSAGE),Je(Xe.CHRONOLOGICAL),Je(Xe.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ke,keyName:Ce,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:Pe,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:De}]),v3:e.commitSchema([{collectionName:Oe,keyName:Ae,index:[rt("latest_last_message")]}])}},ct=function(e,t){return function(n,r){switch(n){case 1:e.clear().then((function(){t.clear().then((function(){ut(e).v2.then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));break;case 2:ut(e).v3.then((function(){return r()})).catch((function(e){return r(e)}));break;default:r()}}},dt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},lt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?dt:n,i=t.initialState,o=void 0===i?"visible":i,s=t.isEnabled,a=void 0===s||s,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=o,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return r(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(i),ht=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return o(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:c.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),ft=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,o=t.profileImage,s=t.preferredLanguages,a=e.call(this)||this;return a.method=c.PUT,a.path="".concat(d,"/").concat(encodeURIComponent(n)),a.params=l(h({nickname:r,profile_url:i,profile_file:o,preferred_languages:s})),a}return r(t,e),t}(f),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new p(t,g({},n)),r}return r(t,e),t}(_),vt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r}r(t,e)}(_);var gt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r}r(t,e)}(_);var _t=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var mt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var bt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),r}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var yt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var wt=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,o=t.ts,s=e.call(this)||this;return s.method=c.GET,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),s.params={created_ts:o,token:i},s}return r(t,e),t}(f),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?b[n.type.toLowerCase()]:b.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return r(t,e),t}(_),kt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return r(t,e),t}(f),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(_),St=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return r(t,e),t}(f),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(_),Et=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(_),Ut=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,o=t.startMin,s=t.endHour,a=t.endMin,u=t.timezone,l=e.call(this)||this;return l.method=c.PUT,l.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),l.params={do_not_disturb:r,start_hour:i,start_min:o,end_hour:s,end_min:a,timezone:u},l}return r(t,e),t}(f),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(_),Ot=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(_),Lt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,o=t.endTs,s=e.call(this)||this;return s.method=c.PUT,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),s.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:o},s}return r(t,e),t}(f),Nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(_),Mt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new p(t,n),r}r(t,e)}(_);var Rt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(_),jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return r(t,e),t}(f),qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(_),Ft=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),r}return r(t,e),t}(f),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(_),xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return r(t,e),t}(f),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(_),Wt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.GET,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return r(t,e),t}(f),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new p(t,e)})),updatedUsers:n.updated.map((function(e){return new p(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return r(t,e),t}(_),Kt=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return r(t,e),t}(f),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return r(t,e),t}(_),Jt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var Xt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(f),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new p(t,e)})),r}return r(t,e),t}(_),Zt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var $t=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return r(t,e),t}(f),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return r(t,e),t}(_),tn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var nn,rn=function(e){function t(){var t=e.call(this)||this;return t.method=c.GET,t.path=I,t}return r(t,e),t}(f),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new st(n),r}return r(t,e),t}(_),sn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(I,"/").concat(n),r}return r(t,e),t}(f),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new ot(n),r}return r(t,e),t}(_),un=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(E,"/").concat(n),r}return r(t,e),t}(f),cn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new it(n),r}return r(t,e),t}(_),dn=function(e){function t(){var t=e.call(this)||this;return t.method=c.GET,t.path="".concat(D),t}return r(t,e),t}(f),ln=function(e){function t(t,n){var r,i=this,o=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return r(t,e),t}(_),hn=function(){function t(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=H.of(e),s=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new ht({logger:h,connectionDelegate:{reconnect:function(){var t=H.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){H.of(e).connectionManager.disconnect()}}});var v=new Ye(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:s,logger:h});n.forEach((function(t){t.init(e,{sdkState:s,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new lt({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){var n;if(t instanceof oe){if(t.stateType===se.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var i=t.as(Ze).event;if(i.category===$e.FRIEND_DISCOVERED){var c=et.getDataAsFriendDiscoveredEvent(e,i).friendDiscoveries;ue((function(){return o(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=H.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;if("number"==typeof p&&p>d.ts){if(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes)for(var g in t.customTypes)d.customTypes[g]!==t.customTypes[g]&&(l=!0),d.customTypes[g]=t.customTypes[g];l=l&&d.ts>0,d.ts=p}l&&ue((function(){return o(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(s.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&(t.error.isSessionRevokedError||t.error.isUserAuthDeactivedError||t.error.isUserAuthDeletedOrNotFoundError)&&(h.debug("session revoked."),r.disconnect())}))}return t.init=function(e){var n=e.appId,r=e.appVersion,i=e.modules,o=void 0===i?[]:i,s=e.options,a=void 0===s?new A:s,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,g=void 0!==v&&v,_=e.localCacheConfig,m=void 0===_?new N:_,b=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,I=e.appStateToggleEnabled,k=void 0===I||I;if(!nn||f){var C="su-".concat(z()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new Le({encryption:S});c||(T=j()?w?new Ne({AsyncStorage:w,encryption:S}):new Le({encryption:S}):new Me({encryption:S})),new H(C,{appId:n,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(n,".sendbird.com"),store:T,encryption:S,logLevel:p,localCacheEnabled:g,localCacheConfig:m,debugMode:c,appStateToggleEnabled:k});var E=[new Re,new Ve],P=new t(C,a,G(G([],W(o),!1),W(E),!1));return nn||(nn=P),P}return nn},Object.defineProperty(t,"instance",{get:function(){return nn},enumerable:!1,configurable:!0}),Object.defineProperty(t,"version",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appId",{get:function(){return H.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appInfo",{get:function(){var e=H.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appVersion",{get:function(){var e;return null!==(e=H.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugMode",{get:function(){return!!H.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return H.of(this._iid).logger.level},set:function(e){H.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCacheEnabled",{get:function(){return H.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheConfig",{get:function(){var e=H.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ekey",{get:function(){return H.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentUser",{get:function(){var e;return null!==(e=H.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectionState",{get:function(){var e=H.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastConnectedAt",{get:function(){var e=H.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),t.prototype._getNestDBVersion=function(){return 3},t.prototype._getCurrentPreferenceVersion=function(){return 1},t.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},t.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},t.prototype.getMemoryStoreForDebugging=function(){var e=H.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Le?n.store:null;throw J.debugModeRequired},t.prototype.addExtension=function(e,t){var n=H.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},t.prototype.addSendbirdExtensions=function(e,t,n){var r,i,o=H.of(this._iid),s=o.logger,a=o.sdkState,u=new RegExp(pe);if(0===e.length)return s.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return s.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=ee(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=W(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return s.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},t.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},t.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},t.prototype._safeInitializeStore=function(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=H.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new Le),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},t.prototype.initializeCache=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:return t=H.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,o=t.dispatcher,s=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(a.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];a.label=2;case 2:return a.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==Ke.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Ge({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:this._getNestDBVersion(),store:r.store})).on("upgrade",ct(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",ct(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,o.dispatch(new tt(this._iid,{userId:e})),a.label=4;case 4:return n.userId=e,[3,7];case 5:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw a.sent(),n.userId=e,J.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:a.sent(),n.userId=e,a.label=10;case 10:return[2]}}))}))},t.prototype.getCacheDataSize=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=H.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},t.prototype.clearCachedData=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=H.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},t.prototype.clearCachedMessages=function(e){return o(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=We.of(this._iid),n=Be.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return o(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.connect=function(e,t){return o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:te(n("string",e)&&n("string",t,!0)).throw(J.invalidParameters),r=H.of(this._iid),i=r.sdkState,o=r.cacheContext,s=r.connectionManager,u=r.statLogCollector,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return a.sent(),H.of(this._iid).dispatcher.dispatch(new nt),[3,4];case 3:return a.sent(),c=H.of(this._iid).logger,o.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return a.sent(),[4,o.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=a.sent())&&new le(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:a.sent(),a.label=8;case 8:return a.trys.push([8,,10,11]),[4,s.connect(t)];case 9:return a.sent(),[3,11];case 10:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 11:return[2,this.currentUser]}}))}))},t.prototype.reconnect=function(){var e=H.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},t.prototype.disconnect=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=H.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},t.prototype.disconnectWebSocket=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=H.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},t.prototype.setBackgroundState=function(){var e=H.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},t.prototype.setForegroundState=function(){var e=H.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},t.prototype.setSessionHandler=function(e){te(e instanceof xe).throw(J.invalidParameters),H.of(this._iid).sessionManager.handler=e},t.prototype.addUserEventHandler=function(e,t){te(n("string",e)&&t instanceof ze).throw(J.invalidParameters),H.of(this._iid).userEventHandlers.set(e,t)},t.prototype.removeUserEventHandler=function(e){H.of(this._iid).userEventHandlers.delete(e)},t.prototype.removeAllUserEventHandler=function(){H.of(this._iid).userEventHandlers.clear()},t.prototype.addConnectionHandler=function(e,t){te(n("string",e)&&t instanceof Qe).throw(J.invalidParameters),H.of(this._iid).connectionHandlers.set(e,t)},t.prototype.removeConnectionHandler=function(e){H.of(this._iid).connectionHandlers.delete(e)},t.prototype.removeAllConnectionHandler=function(){H.of(this._iid).connectionHandlers.clear()},t.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new je(this._iid,e)},t.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},t.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Fe(this._iid,e)},t.prototype.createMessageSearchQuery=function(e){return new He(this._iid,e)},t.prototype.createPollListQuery=function(e){return new ne(this._iid,g({},e))},t.prototype.createPollVoterListQuery=function(e){return new re(this._iid,g({},e))},t.prototype.buildUserFromSerializedData=function(e){var t=ie(e);return new p(this._iid,p.payloadify(t))},t.prototype.updateCurrentUserInfo=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=g(g({},at),t),te(function(t){return e(t.profileImage,!0)&&n("string",t.profileUrl,!0)&&n("string",t.nickname,!0)}(r)).throw(J.invalidParameters),this.currentUser?(i=H.of(this._iid),o=i.sdkState,s=i.requestQueue,u=new ft(g({userId:o.userId},r)),[4,s.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(pt).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw J.connectionRequired}}))}))},t.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),this.currentUser?(t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ft({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return o=a.sent(),s=o.as(pt).user,this.currentUser&&(this.currentUser.preferredLanguages=s.preferredLanguages),[2,s];case 2:throw J.connectionRequired}}))}))},t.prototype.registerFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,r.hasDeviceToken(b.FCM,e)?[2,ge.SUCCESS]:(u=new gt({userId:i.userId,token:e}),[4,s.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,u=new mt({userId:i.userId,token:e}),[4,s.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,s,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=H.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new yt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.FCM),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},t.prototype.registerAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,r.hasDeviceToken(b.APNS,e)?[2,ge.SUCCESS]:(u=new vt({userId:i.userId,token:e}),[4,s.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(te(n("string",e)).throw(J.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),t=H.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,u=new _t({userId:i.userId,token:e}),[4,s.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,s,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=H.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new bt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.APNS),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},t.prototype.getChannelInvitationPreference=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new kt({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,{autoAccept:i.as(Ct).autoAccept}]}}))}))},t.prototype.setChannelInvitationPreference=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return te(n("boolean",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new St({userId:r.userId,willAutoAccept:e}),[4,i.send(o)];case 1:return s=a.sent(),[2,{autoAccept:s.as(Tt).autoAccept}]}}))}))},t.prototype.getDoNotDisturb=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Et({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(Pt).preference]}}))}))},t.prototype.setDoNotDisturb=function(e,t,r,i,s,u){return void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===u&&(u=""),o(this,void 0,void 0,(function(){var o,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return te(n("boolean",e)&&n("number",t)&&n("number",r)&&n("number",i)&&n("number",s)&&n("string",u)).throw(J.invalidParameters),o=H.of(this._iid),c=o.sdkState,d=o.requestQueue,l=new Ut({userId:c.userId,doNotDisturbOn:e,startHour:t,startMin:r,endHour:i,endMin:s,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Dt).preference]}}))}))},t.prototype.getSnoozePeriod=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ot({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(At).snoozePeriod]}}))}))},t.prototype.setSnoozePeriod=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=0),o(this,void 0,void 0,(function(){var i,o,s,u,c;return a(this,(function(a){switch(a.label){case 0:return te(n("boolean",e)&&n("number",t)&&n("number",r)).throw(J.invalidParameters),i=H.of(this._iid),o=i.sdkState,s=i.requestQueue,u=new Lt({userId:o.userId,snoozeOn:e,startTs:t,endTs:r}),[4,s.send(u)];case 1:return c=a.sent(),[2,c.as(Nt).snoozePeriod]}}))}))},t.prototype.getMyPushTokensByToken=function(e,t){return o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return te(n("string",e)&&me(b,t)).throw(J.invalidParameters),r=H.of(this._iid),i=r.sdkState,o=r.requestQueue,s=r.sessionManager,u=new wt({userId:i.userId,type:t,token:e}),[4,o.send(u)];case 1:c=a.sent(),d=c.as(It).pushTokens;try{for(l=ee(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,s.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,s.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},t.prototype.getPushTriggerOption=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Qt).pushTriggerOption]}}))}))},t.prototype.setPushTriggerOption=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(me(be,e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,o.sent().as(qt).pushTriggerOption]}}))}))},t.prototype.getPushTemplate=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ft({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Ht).name]}}))}))},t.prototype.setPushTemplate=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(me(ye,e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,o.sent().as(Gt).name]}}))}))},t.prototype.blockUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(e instanceof p||n("string",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Mt({userId:r.userId,blockedUserId:e instanceof p?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},t.prototype.blockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},t.prototype.unblockUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(e instanceof p||n("string",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Rt({userId:r.userId,unblockedUserId:e instanceof p?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},t.prototype.unblockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},t.prototype.getFriendChangeLogsByToken=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return te(n("string",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Wt({userId:r.userId,token:e}),[4,i.send(o)];case 1:return s=a.sent(),[2,s.as(Bt).changelogs]}}))}))},t.prototype.getAllowFriendDiscovery=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=H.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new $t({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(en).allowFriendDiscovery]}}))}))},t.prototype.setAllowFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(n("boolean",e)).throw(J.invalidParameters),t=H.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new tn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(o)];case 1:return s.sent(),[2,e]}}))}))},t.prototype.uploadFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return a(this,(function(s){switch(s.label){case 0:return t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Kt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Vt).friendDiscoveryRequestId]}}))}))},t.prototype.deleteFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},t.prototype.deleteFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},t.prototype.addFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return a(this,(function(s){switch(s.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Yt).users]}}))}))},t.prototype.deleteFriend=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},t.prototype.deleteFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return te(ve("string",e)).throw(J.invalidParameters),t=H.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Zt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},t.prototype.getAllEmoji=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=H.of(this._iid).requestQueue,t=new rn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(on).emojiContainer]}}))}))},t.prototype.getEmojiCategory=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=H.of(this._iid).requestQueue,n=new sn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(an).emojiCategory]}}))}))},t.prototype.getEmoji=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=H.of(this._iid).requestQueue,n=new un({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(cn).emoji]}}))}))},t.prototype.getUIKitConfiguration=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=H.of(this._iid),te(e.hasExtension("sb_uikit")).throw(J.notSupportedError),t=e.requestQueue,n=new dn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(ln).uikitConfiguration]}}))}))},t}();export{it as Emoji,ot as EmojiCategory,st as EmojiContainer,hn as default}; diff --git a/lib/__bundle-0099b2f2.js b/lib/__bundle-0099b2f2.js deleted file mode 100644 index 4bd0ccf..0000000 --- a/lib/__bundle-0099b2f2.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,A as t,a6 as n,e as r,f as i,h as s,u as a,g as o,U as u,a7 as c,K as l,a as d,O as h,o as f,p,r as m,a0 as v,a8 as y,a9 as _,aa as g,X as b,ab as I,ac as E,ad as T,ae as w,b as M,c as S,s as A,q as N,af as U,V as O,ag as C,ah as P,ai as k,aj as R,W as x,y as L,z as D,ak as q,al as F,i as z,am as B,an as K,ao as j,ap as Q,aq as G,ar as V,as as W,at as H,au as Y,av as J,aw as X,ax as Z,ay as $,m as ee,az as te,T as ne,B as re,aA as ie,aB as se,t as ae,w as oe,aC as ue,aD as ce,d as le,aE as de,aF as he,aG as fe,N as pe,aH as me,aI as ve,aJ as ye,aK as _e,x as ge,aL as be,aM as Ie}from"./__bundle-1da35e70.js";var Ee,Te=function(i){function s(e){var s=i.call(this)||this;if(s.method=t.POST,s.path="".concat(n),s.params=r({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var a=0;a0&&d("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return r(a({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case Ee.ADD:t<0&&this.userIds.push(e.userId);break;case Ee.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),Oe=function(){function e(e){this.key=e.key,this.value=l("string",e.value)?f([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return r(a({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),Ce=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return r(a({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))},e}(),Pe=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new Ce(e["og:image"]))}return e.payloadify=function(e){return r(a({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Ce.payloadify(e.defaultImage):null}))},e}(),ke=function(){function e(e){var t,n;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return r(a({name:e.name,volume:e.volume}))},e}(),Re=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).isBlockedByMe=!1,i.role=h(v,n.role)?n.role:v.NONE,i.isBlockedByMe=null!==(r=n.is_blocked_by_me)&&void 0!==r&&r,i}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))},n}(u);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(Se||(Se={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Ae||(Ae={}));var xe=function(e){switch(e){case _.BASE:return"";case _.USER:return"MESG";case _.FILE:return"FILE";case _.ADMIN:return"ADMM"}},Le=function(t){function n(e,n){var r,i,s,a,o,c,l,d,f,p,m,v,y,g,E,T,w=this;(w=t.call(this,e)||this).channelType=b.BASE,w.parentMessage=null,w.silent=!1,w.isOperatorMessage=!1,w.messageType=_.BASE,w.mentionType=null,w.threadInfo=null,w.reactions=[],w.metaArrays=[],w.appleCriticalAlertOptions=null,w.createdAt=0,w.updatedAt=0,w.scheduledInfo=null,w.extendedMessage={},w._isContinuousMessages=!1,w._scheduledStatus=null,w.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,w.channelUrl=n.channel_url,w.channelType=h(b,n.channel_type)?n.channel_type:b.GROUP,n.channel&&(n.channel.channel_url&&(w.channelUrl=n.channel.channel_url),n.channel.channel_type&&(w.channelType=n.channel.channel_type)),w.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,w.data=null!==(a=n.data)&&void 0!==a?a:"",w.customType=null!==(o=n.custom_type)&&void 0!==o?o:"",w.mentionType=h(I,n.mention_type)?n.mention_type:null,w.mentionedUsers=n.mentioned_users?n.mentioned_users.map((function(e){return new u(w._iid,e)})):null,w.mentionedUserIds=null!==(c=n.mentioned_user_ids)&&void 0!==c?c:null,w.mentionedUsers&&!w.mentionedUserIds&&(w.mentionedUserIds=w.mentionedUsers.map((function(e){return e.userId}))),w.mentionedMessageTemplate=null!==(l=n.mentioned_message_template)&&void 0!==l?l:"",w.threadInfo=n.thread_info?new Me(w._iid,n.thread_info):null,w.reactions=n.reactions?n.reactions.map((function(e){return new Ue(e)})):[];var M=null!==(d=n.metaarray)&&void 0!==d?d:{},S=null!==(f=n.metaarray_key_order)&&void 0!==f?f:Object.keys(M).sort((function(e,t){return e.localeCompare(t)}));w.metaArrays=[];for(var A=0;A=t)return this.parentMessage=e,!0}return!1},n}(c),De=function(t){function n(e,n){var r,i,s,a,o=this;if((o=t.call(this,e,n)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=n.user?new Re(o._iid,n.user):n.sender_id,o.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=n.is_reply_to_channel)&&void 0!==s&&s,n.request_state&&h(E,n.request_state)&&(o.sendingStatus=n.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=E.SUCCEEDED;else if(o.scheduledInfo)switch(n.scheduled_status&&(o._scheduledStatus=n.scheduled_status),n.scheduled_status){case Ae.SENT:case Ae.IN_QUEUE:o.sendingStatus=E.SUCCEEDED;break;case Ae.PENDING:o.sendingStatus=E.SCHEDULED;break;case Ae.FAILED:case Ae.REMOVED:o.sendingStatus=E.FAILED;break;case Ae.CANCELED:o.sendingStatus=E.CANCELED}else o.sendingStatus=E.PENDING;return o.errorCode=null!==(a=n.error_code)&&void 0!==a?a:0,o}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{user:Re.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===E.FAILED&&T(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(Le),qe=function(){function e(e){var t,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return r(a({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),Fe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:w.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ze=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&h(w,e.messageTypeFilter)&&l("string",e.customTypesFilter,!0)&&l("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},Be=function(t){function n(e,n){var i,s,u,c,l=this;if((l=t.call(this,e,n)||this).translations={},l.message=null!==(i=n.message)&&void 0!==i?i:"",l.messageType=_.ADMIN,l.translations=null!==(s=n.translations)&&void 0!==s?s:{},n.parent_message_info){var d=n.parent_message_info;l.parentMessage=We(e,r(a(o(o({},d),{message_id:l.parentMessageId,channel_url:l.channelUrl,channel_type:l.channelType,file:d.file,url:null===(u=d.file)||void 0===u?void 0:u.url,require_auth:null===(c=d.file)||void 0===c?void 0:c.require_auth}))))}return l}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return M(this,void 0,void 0,(function(){var n;return S(this,(function(r){switch(r.label){case 0:return n=o(o({},Fe),t),A(this.messageId>0&&d("number",e)&&ze(n)).throw(N.invalidParameters),[4,Zi.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n}(Le),Ke=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return r(a({type:e.type,vendor:e.vendor,detail:e.detail}))},e}(),je=function(t){function n(e,n){var i,s,u,c,l,d,h,f=this;if((f=t.call(this,e,n)||this).message="",f.messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.message=n.message,f.messageType=_.USER,f.translations=null!==(u=n.translations)&&void 0!==u?u:{},f.translationTargetLanguages=null!==(c=n.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=m(f.translationTargetLanguages),v=p.next();!v.done;v=p.next()){var y=v.value;f.translations[y]=""}}catch(e){i={error:e}}finally{try{v&&!v.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}if(f.messageSurvivalSeconds=null!==(l=n.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=n.plugins?n.plugins.map((function(e){return new Ke(e)})):[],f._poll=n.poll?new U(f._iid,n.poll):null,n.parent_message_info){var g=n.parent_message_info;f.parentMessage=We(e,r(a(o(o({},g),{created_at:g.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:g.file,url:null===(d=g.file)||void 0===d?void 0:d.url,require_auth:null===(h=g.file)||void 0===h?void 0:h.require_auth}))))}return f}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Ke.payloadify(e)})),poll:e._poll?U.payloadify(e._poll):null,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return M(this,void 0,void 0,(function(){var n;return S(this,(function(r){switch(r.label){case 0:return n=o(o({},Fe),t),A(this.messageId>0&&d("number",e)&&ze(n)).throw(N.invalidParameters),[4,Zi.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(De),Qe=function(t){function n(e,n){var r,i,s,a,u,c=this;(c=t.call(this,e)||this).plainUrl="",c.fileName=null,c.mimeType=null,c.fileSize=0,c.thumbnails=[],c._requireAuth=!1,c.plainUrl=null!==(r=n.url)&&void 0!==r?r:"",c.fileName=null!==(i=n.file_name)&&void 0!==i?i:null,c.mimeType=null!==(s=n.file_type)&&void 0!==s?s:null,c.fileSize=null!==(a=n.file_size)&&void 0!==a?a:0,c._requireAuth=null!==(u=n.require_auth)&&void 0!==u&&u;var l=O.of(c._iid).sessionManager;return c.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new qe(o(o({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(c._requireAuth?"?auth=".concat(l.ekey):"")}))})):[],c}return e(n,t),n.payloadify=function(e){var t;return r(a({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))},Object.defineProperty(n.prototype,"url",{get:function(){var e=O.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(c),Ge=function(t){function n(e,n){var i,s,u,c,l,d=this;if((d=t.call(this,e,n)||this).messageParams=null,d.fileInfoList=[],d.messageSurvivalSeconds=-1,d.messageType=_.FILE,d.fileInfoList=null!==(s=null===(i=n.files)||void 0===i?void 0:i.map((function(t){return new Qe(e,t)})))&&void 0!==s?s:[],d.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,n.parent_message_info){var h=n.parent_message_info;d.parentMessage=We(e,r(a(o(o({},h),{created_at:h.ts,message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth}))))}return d}return e(n,t),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return M(this,void 0,void 0,(function(){var n;return S(this,(function(r){switch(r.label){case 0:return n=o(o({},Fe),t),A(this.messageId>0&&d("number",e)&&ze(n)).throw(N.invalidParameters),[4,Zi.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qe.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(De),Ve=function(e){switch(e.messageType){case _.USER:return je.payloadify(e);case _.FILE:return e.fileInfoList?Ge.payloadify(e):He.payloadify(e);case _.ADMIN:return Be.payloadify(e);default:throw N.unknown}},We=function(e,t){switch(t.type){case"MESG":return new je(e,t);case"FILE":return Ge._isMultipleFilesMessagePayload(t)?new Ge(e,t):new He(e,t);case"ADMM":case"BRDM":return new Be(e,t)}throw N.unknown},He=function(t){function n(e,n){var i,s,u,c,l,d,h,f,p,m,v,y,g,b,I=this;(I=t.call(this,e,n)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=_.FILE;var E=n.file;I.plainUrl=(null!==(s=null!==(i=null==E?void 0:E.url)&&void 0!==i?i:n.url)&&void 0!==s?s:"").split("?auth=")[0],I.name=null!==(c=null!==(u=null==E?void 0:E.name)&&void 0!==u?u:n.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:n.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:n.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=n.type)&&void 0!==m?m:"";var T=O.of(I._iid).sessionManager;if(I.requireAuth=null!==(v=n.require_auth)&&void 0!==v&&v,I.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new qe(o(o({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(I.requireAuth?"?auth=".concat(T.ekey):"")}))})):[],I.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var w=n.parent_message_info;I.parentMessage=We(e,r(a(o(o({},w),{created_at:w.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:w.file,url:null===(g=w.file)||void 0===g?void 0:g.url,require_auth:null===(b=w.file)||void 0===b?void 0:b.require_auth}))))}return I}return e(n,t),n.payloadify=function(e){var n;return r(a(o(o({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},Object.defineProperty(n.prototype,"url",{get:function(){var e=O.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return M(this,void 0,void 0,(function(){var n;return S(this,(function(r){switch(r.label){case 0:return n=o(o({},Fe),t),A(this.messageId>0&&d("number",e)&&ze(n)).throw(N.invalidParameters),[4,Zi.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n}(De),Ye=function(t){function n(e){var n,i,s,o=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,files:e.files?$e(e.files):null,url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(i=e.mimeType)&&void 0!==i?i:"",size:null!==(s=e.fileSize)&&void 0!==s?s:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==C.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(P),Je=function(n){function i(e){var i,s,o=this;o=n.call(this)||this;var u=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?u=e.mentionedUserIds:e.mentionedUsers&&(u=e.mentionedUsers.map((function(e){return e.userId})))),o.method=t.POST,o.path="".concat(k(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),o.params=r(a({message_type:_.FILE,user_id:e.userId,files:e.files?$e(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:u,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(i=e.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return qe.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((function(e){return Oe.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage})),o}return e(i,n),i}(i),Xe=function(t){function n(e,n,r){var i,s,a,o,u=this;(u=t.call(this,e,"FILE",r)||this).message=r.files&&r.files.length>=2?new Ge(e,r):new He(e,r);var c=O.of(e).sdkState;return u.isMentioned=R(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return e(n,t),n}(x),Ze=function(t){function n(e,n){var r,i,s,a,o=this;(o=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Ge(e,n):new He(e,n);var u=O.of(e).sdkState;return o.isMentioned=R(o.message.mentionType,null!==(s=null!==(r=o.message.mentionedUserIds)&&void 0!==r?r:null===(i=o.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==s?s:[],u.userId),o.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,o}return e(n,t),n}(s);function $e(e){return e.map((function(e){var t,n;return r(a({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return qe.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var et;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(et||(et={}));var tt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof L&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===D.CONNECTED||this._connectionState===D.CONNECTING||this._connectionState===D.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return S(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ye(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Xe).message];case 2:return r=new Je(o(o({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ze).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=o(o({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return M(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return S(this,(function(v){switch(v.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,v.label=1;case 1:v.trys.push([1,15,16,17]),s=m(n.messageQueue),a=s.next(),v.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case et.PENDING:case et.UPLOADING:return[3,3];case et.UPLOADED:return[3,4];case et.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];v.label=5;case 5:return v.trys.push([5,8,,9]),o.state=et.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=v.sent(),o.deferred.resolve(u),[4,F(100)];case 7:return v.sent(),[3,9];case 8:return c=v.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),v.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:N.unknown,o.deferred.reject(l.code===q.REQUEST_CANCELED?N.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=v.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:v.sent(),v.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,v.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return M(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l;return S(this,(function(d){switch(d.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===et.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,l=r.params,u=l.fileInfoList[s],!z(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return d.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return M(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return S(this,(function(v){switch(v.label){case 0:return a=new Te({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(we),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnailSizes,f=void 0===h?n.thumbnailSizes:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.thumbnailSizes=f,n.requireAuth=m,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return M(this,void 0,void 0,(function(){var a,u,c,l,d,h,f,p,m,v,y,_;return S(this,(function(g){switch(g.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[a],c=new Te({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=g.sent(),d=l.as(we),h=d.url,f=d.fileSize,p=void 0===f?u.fileSize:f,m=d.thumbnailSizes,v=void 0===m?u.thumbnailSizes:m,y=d.requireAuth,_=void 0!==y&&y,u.fileName=null!==(r=u.fileName)&&void 0!==r?r:u.file.name,u.mimeType=null!==(i=u.mimeType)&&void 0!==i?i:u.file.type,u.fileSize=null!==(s=u.fileSize)&&void 0!==s?s:u.file.size,u.file=void 0,u.fileUrl=h,u.fileSize=p,u.thumbnailSizes=v,u._uploadedMetaData=o(o({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i,s,a,o,u;return S(this,(function(c){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new B,o={requestId:t,params:n,state:et.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(u={uploadIndex:0,uploadCount:n.fileInfoList.length,requestHandler:r},o.multipleFileUploadInfo=u),s.messageQueue.push(o),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:f([],p(i.messageQueue),!1);try{for(var a=m(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case et.PENDING:u.state=et.FAILED,u.error=N.requestCanceled,this._resolveMessageQueue(e);break;case et.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e}();var nt,rt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:w.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:K.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},it=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&h(w,e.messageTypeFilter)&&l("string",e.customTypesFilter,!0)&&l("string",e.senderUserIdsFilter,!0)&&h(K,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},st={replyType:K.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},at=function(e){return h(K,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},ot=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.includeMetaArray,o=e.includeReactions,u=e.includeThreadInfo,c=e.includeParentMessageInfo,l=n.call(this)||this;return l.method=t.GET,l.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return e(r,n),r}(i),ut=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=n?We(e,o({},n)):null,r}return e(n,t),n}(s),ct=function(n){function i(e){var i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,m=e.senderUserIdsFilter,v=e.replyType,y=e.includeMetaArray,_=e.includeReactions,g=e.parentMessageId,b=e.includeThreadInfo,I=e.includeParentMessageInfo,E=e.showSubchannelMessagesOnly,T=e.checkingContinuousMessages,w=n.call(this)||this;return w.method=t.GET,w.path="".concat(k(i),"/").concat(encodeURIComponent(s),"/messages"),w.params=r(a({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_continuous_messages:T})),w}return e(i,n),i}(i),lt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.messages=n.messages.map((function(t){return We(e,t)})),r}return e(n,t),n}(s),dt=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,a=e.token,o=e.replyType,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return e(r,n),r}(i),ht=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedMessages=n.updated.map((function(t){return We(e,t)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return e(n,t),n}(s),ft=function(n){function r(e){var r=e.channelUrl,i=e.scheduledMessageId,s=n.call(this)||this;return s.method=t.GET,s.path="".concat(j,"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(i)),s.params={},s}return e(r,n),r}(i),pt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=n?We(e,o({},n)):null,r}return e(n,t),n}(s);!function(e){e.MUTED="muted",e.BANNED="banned"}(nt||(nt={}));var mt,vt=function(){function e(e){var t,n,r,i;this.restrictionType=null,h(nt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return e.payloadify=function(e){return r(a({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),yt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.restrictionInfo=new vt(n),r}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),vt.payloadify(e.restrictionInfo))))},n}(u),_t=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return e(n,t),n}(u),gt=function(){function e(){this._onPending=Q,this._onFailed=Q,this._onSucceeded=Q}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case E.PENDING:0===e.errorCode&&this._onPending(e);break;case E.SCHEDULED:case E.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case E.FAILED:case E.CANCELED:this._onFailed(e,t.scheduledInfo?null:t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),bt={data:void 0,customType:void 0,mentionType:I.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},It=function(e){return d("string",e.data,!0)&&d("string",e.customType,!0)&&h(I,e.mentionType)&&l("string",e.mentionedUserIds,!0)&&l(u,e.mentionedUsers,!0)&&d("string",e.mentionedMessageTemplate,!0)&&l(Oe,e.metaArrays,!0)&&d("number",e.parentMessageId,!0)&&d("boolean",e.isReplyToChannel)&&h(C,e.pushNotificationDeliveryOption,!0)&&d(ke,e.appleCriticalAlertOptions,!0)&&d("boolean",e.isPinnedMessage,!0)},Et=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Tt=o(o({},bt),{message:"",translationTargetLanguages:void 0,pollId:void 0}),wt=function(e){return It(e)&&d("string",e.message)&&l("string",e.translationTargetLanguages,!0)&&d("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(mt||(mt={}));var Mt,St=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},At=function(e){return e===mt.BLOB||e===mt.FILE},Nt=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Ut=o(o({},bt),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ot=function(e){return It(e)&&(z(e.file)||d("string",e.fileUrl))&&d("string",e.fileName,!0)&&d("string",e.mimeType,!0)&&d("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return d("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Ct={data:void 0,customType:void 0,mentionType:I.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},Pt=function(e){return d("string",e.data,!0)&&d("string",e.customType,!0)&&h(I,e.mentionType)&&l("string",e.mentionedUserIds,!0)&&l(u,e.mentionedUsers,!0)&&d("string",e.mentionedMessageTemplate,!0)&&l(Oe,e.metaArrays,!0)&&h(C,e.pushNotificationDeliveryOption,!0)&&d(ke,e.appleCriticalAlertOptions,!0)},kt=o(o({},Ct),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Rt=function(e){return Pt(e)&&d("string",e.message,!0)&&l("string",e.translationTargetLanguages,!0)&&d("number",e.pollId,!0)},xt=o({},Ct),Lt=function(n){function r(e){var r=e.channelUrl,i=e.channelType,s=e.token,a=e.limit,o=n.call(this)||this;return o.method=t.GET,o.path="".concat(k(i),"/").concat(encodeURIComponent(r),"/operators"),o.params={token:s,limit:a},o}return e(r,n),r}(i),Dt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.operators=n.operators.map((function(t){return new u(e,t)})),r.token=n.next,r}return e(n,t),n}(s),qt=function(t){function n(e,n,r,i){return t.call(this,e,n,r,i)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s,a;return S(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=O.of(this._iid).requestQueue,n=new Lt(o(o({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Dt),s=i.operators,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,e];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(G),Ft=function(t){function n(e,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=t.call(this,e,n,r,i)||this).reverse=!1,m.messageTypeFilter=w.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=K.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:w.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:K.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&h(w,this.messageTypeFilter)&&h(K,this.replyType)&&l("string",this.customTypesFilter,!0)&&l("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Zi.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,a({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}))]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,f([Number.MAX_SAFE_INTEGER],p(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(G),zt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.limit,o=e.token;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute"),r.params={limit:a,token:o},r}return e(r,n),r}(i),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(t){return new yt(e,t)}))),r}return e(n,t),n}(s),Kt=function(t){function n(e,n,r,i){return t.call(this,e,n,r,i)||this}return e(n,t),n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=O.of(this._iid).requestQueue,t=new zt(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(Bt),i=r.mutedUsers,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(G),jt=function(n){function i(e){var i=this,s=e.channelUrl,a=e.channelType,o=e.limit,u=e.token;return(i=n.call(this)||this).method=t.GET,i.path="".concat(k(a),"/").concat(encodeURIComponent(s),"/ban"),i.params=r({limit:o,token:u}),i}return e(i,n),i}(i),Qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(t){return new yt(e,t.user)}))),r}return e(n,t),n}(s),Gt=function(t){function n(e,n,r,i){return t.call(this,e,n,r,i)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=O.of(this._iid).requestQueue,t=new jt(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(Qt),i=r.bannedUsers,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(G);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Mt||(Mt={}));var Vt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.operatorUserIds;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/operators"),r.params={operator_ids:a},r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Wt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.operatorUserIds;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/operators"),r.params={operator_ids:a},r}return e(r,n),r}(i);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(s);var Ht=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute/").concat(a),r}return e(r,n),r}(i),Yt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return e(n,t),n}(s),Jt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.keys;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={keys:a,include_ts:!0},r}return e(r,n),r}(i),Xt=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return e(n,t),n}(s),Zt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metadata;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={metadata:a,include_ts:!0},r}return e(r,n),r}(i),$t=function(t){function n(e,n){var r,i,s=this;return(s=t.call(this,e,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return e(n,t),n}(s),en=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metadata,o=e.upsert;return(r=n.call(this)||this).method=t.PUT,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={metadata:a,include_ts:!0,upsert:null!=o&&o},r}return e(r,n),r}(i),tn=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return e(n,t),n}(s),nn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return e(n,t),n}(x),rn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.key;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(a),r.params={include_ts:!0},r}return e(r,n),r}(i),sn=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.ts;return r.ts=i,r}return e(n,t),n}(s),an=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={include_ts:!0},r}return e(r,n),r}(i),on=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.ts;return r.ts=i,r}return e(n,t),n}(s),un=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.keys;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={keys:a},r}return e(r,n),r}(i),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.metaCounter=n,r}return e(n,t),n}(s),ln=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metaCounter;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={metacounter:a},r}return e(r,n),r}(i),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.metaCounter=n,r}return e(n,t),n}(s),hn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metaCounter,o=e.upsert,u=void 0!==o&&o,c=e.mode,l=void 0===c?"set":c;return(r=n.call(this)||this).method=t.PUT,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={metacounter:a,upsert:u,mode:l},r}return e(r,n),r}(i),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.metaCounter=n,r}return e(n,t),n}(s),pn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return e(n,t),n}(x),mn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.key;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(a),r.params={},r}return e(r,n),r}(i);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(s);var vn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={},r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var yn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId,o=e.seconds,u=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute"),r.params={user_id:a,seconds:o,description:u},r}return e(r,n),r}(i);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(s);var _n=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new yt(e,r.data),i}return e(n,t),n}(x),gn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(a)),r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var bn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new yt(e,r.data),i}return e(n,t),n}(x),In=function(n){function i(e){var i=this,s=e.channelUrl,a=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(i=n.call(this)||this).method=t.POST,i.path="".concat(k(a),"/").concat(encodeURIComponent(s),"/ban"),i.params=r({user_id:o,seconds:u,description:c}),i}return e(i,n),i}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var En=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new yt(e,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return e(n,t),n}(x),Tn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(a)),r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var wn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new yt(e,r.data),i}return e(n,t),n}(x),Mn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.freezing;return(r=n.call(this)||this).method=t.PUT,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/freeze"),r.params={freeze:a},r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Sn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return e(n,t),n}(x),An=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(V(s),"/").concat(encodeURIComponent(i)),r.params={report_category:a,reporting_user_id:o,report_description:u},r}return e(r,n),r}(i),Nn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.offendingUserId,c=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(W,"/users/").concat(u),r.params={channel_url:i,channel_type:s===b.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},r}return e(r,n),r}(i),Un=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.offendingUserId,c=e.messageId,l=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(V(s),"/").concat(encodeURIComponent(i),"/messages/").concat(c),r.params={report_category:a,reporting_user_id:o,report_description:l,offending_user_id:u},r}return e(r,n),r}(i),On=function(t){function n(e){var n=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:n,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==C.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(P),Cn=function(t){function n(e,n,r){var i,s,a,o,u=this;(u=t.call(this,e,"MESG",r)||this).message=new je(e,r);var c=O.of(e).sdkState;return u.isMentioned=R(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return e(n,t),n}(x),Pn=function(t){function n(e){var n=null;return e.mentionType===I.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:n,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})||this}return e(n,t),n}(P),kn=function(t){function n(e,n,r){var i,s,o,u,c,l=this;(l=t.call(this,e,"MEDI",r)||this).message=new je(e,r);var d=O.of(e).sdkState;return l.mentionCountChange=H({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},a({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return e(n,t),n}(x),Rn=function(t){function n(e){var n=null;return e.mentionType===I.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:n,apple_critical_alert_options:e.appleCriticalAlertOptions}))})||this}return e(n,t),n}(P),xn=function(t){function n(e,n,r){var i,s,o,u,c,l=this;(l=t.call(this,e,"FEDI",r)||this).message=new He(e,r);var d=O.of(e).sdkState;return l.mentionCountChange=H({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},a({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return e(n,t),n}(x),Ln=function(n){function r(e){var r=n.call(this)||this;return r.method=t.DELETE,r.path="".concat(k(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Dn=function(t){function n(e,n,r){var i=t.call(this,e,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return e(n,t),n}(x),qn=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.reactionKey,o=n.call(this)||this;return o.method=t.POST,o.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return e(r,n),r}(i),Fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.reactionEvent=new Ne(n),r}return e(n,t),n}(s),zn=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.reactionKey,o=n.call(this)||this;return o.method=t.DELETE,o.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return e(r,n),r}(i),Bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.reactionEvent=new Ne(o({},n)),r}return e(n,t),n}(s),Kn=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.translationTargetLanguages,o=n.call(this)||this;return o.method=t.POST,o.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return e(r,n),r}(i),jn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new je(e,n),r}return e(n,t),n}(s),Qn=function(n){function i(e){var i,s=this;s=n.call(this)||this;var o=[];e.mentionType===I.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl;return s.method=t.POST,s.path="".concat(k(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=r(a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:Y.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return Oe.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),s}return e(i,n),i}(i),Gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new je(e,n),r}return e(n,t),n}(s),Vn=function(n){function r(e){var r,i=this;i=n.call(this)||this;var s=[];e.mentionType===I.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl;return i.method=t.POST,i.path="".concat(k(o),"/").concat(encodeURIComponent(u),"/scheduled_messages"),i.params=a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:Y.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return qe.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return Oe.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}),i}return e(r,n),r}(i),Wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new He(e,n),r}return e(n,t),n}(s),Hn=function(n){function r(e){var r=e.pollId,i=e.title,s=e.data,a=e.allowUserSuggestion,o=e.allowMultipleVotes,u=e.closeAt,c=n.call(this)||this;return c.method=t.PUT,c.path="".concat(X,"/").concat(encodeURIComponent(r)),c.params={title:i,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return e(r,n),r}(i),Yn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),Jn=function(n){function r(e){var r=e.pollId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(X,"/").concat(encodeURIComponent(r)),i}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Xn=function(n){function r(e){var r=e.pollId,i=n.call(this)||this;return i.method=t.PUT,i.path="".concat(X,"/").concat(encodeURIComponent(r),"/close"),i}return e(r,n),r}(i),Zn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),$n=function(n){function r(e){var r=e.channelUrl,i=e.channelType,s=e.pollId,a=e.optionText,o=n.call(this)||this;return o.method=t.POST,o.path="".concat(X,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:r,channel_type:i,text:a},o}return e(r,n),r}(i),er=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),tr=function(n){function r(e){var r=e.pollId,i=e.pollOptionId,s=e.optionText,a=n.call(this)||this;return a.method=t.PUT,a.path="".concat(X,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(i)),a.params={text:s},a}return e(r,n),r}(i),nr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),rr=function(n){function r(e){var r=e.pollId,i=e.pollOptionId,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(X,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(i)),s}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var ir,sr=function(t){function n(e){var n=e.reqId,i=e.channelType,s=e.channelUrl,a=e.pollId,o=e.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:r({req_id:n,channel_type:i===b.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return e(n,t),n}(P),ar=function(t){function n(e,n,r){var i=t.call(this,e,"VOTE",r)||this;return i.event=new Z(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return e(n,t),n}(x),or=100,ur="GroupChannel",cr="url",lr=100,dr="Message",hr="messageId",fr="Poll",pr="pollId",mr=100,vr="FeedChannel",yr="url",_r=o(o({},bt),{fileInfoList:[]}),gr=function(e){return(z(e.file)||d("string",e.fileUrl))&&d("string",e.fileName,!0)&&d("string",e.mimeType,!0)&&d("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},br=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=Q,e}return e(n,t),n.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},n.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},n.prototype.onPending=function(e){return t.prototype.onPending.call(this,e),this},n.prototype.onFailed=function(e){return t.prototype.onFailed.call(this,e),this},n.prototype.onSucceeded=function(e){return t.prototype.onSucceeded.call(this,e),this},n}(gt),Ir=2,Er=function(t){function n(e,n){var r,i,s,a,o,c,l=this;return(l=t.call(this,e)||this)._name="",l._createdAt=0,l.channelType=b.BASE,l.coverUrl="",l.customType="",l.data="",l.isFrozen=!1,l.isEphemeral=!1,l.creator=null,l._messageCollectionLastAccessedAt=0,l._url=n.channel_url,l._name=null!==(r=n.name)&&void 0!==r?r:"",l._createdAt=1e3*n.created_at,l.coverUrl=null!==(i=n.cover_url)&&void 0!==i?i:"",l.customType=null!==(s=n.custom_type)&&void 0!==s?s:"",l.data=null!==(a=n.data)&&void 0!==a?a:"",l.isFrozen=null!==(o=n.freeze)&&void 0!==o&&o,l.isEphemeral=null!==(c=n.is_ephemeral)&&void 0!==c&&c,l.creator=n.created_by?new u(l._iid,n.created_by):null,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(l._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){l._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),l}return e(n,t),Object.defineProperty(n.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),n.prototype.toJSON=function(){return o(o({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?u.payloadify(e.creator):null,created_at:e.createdAt/1e3})))},n.prototype.isGroupChannel=function(){return this.channelType===b.GROUP},n.prototype.isOpenChannel=function(){return this.channelType===b.OPEN},n.prototype.isFeedChannel=function(){return this.channelType===b.FEED},Object.defineProperty(n.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),n.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},n.prototype._update=function(e){var t=r(e);Object.assign(this,t)},n.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},n.prototype._updateCachedMetaData=function(e,t){var n=this;this._cachedMetaData?this._cachedMetaData.forEach((function(r,i){var s;r.updatedAt<=t&&n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:r.value,isRemoved:!e[i],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})))},n.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&l("string",t)).throw(N.invalidParameters),n=O.of(this._iid).requestQueue,r=new Kn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(jn).message]}}))}))},n.prototype._createScheduledUserMessage=function(e,t){var n=this,r=O.of(this._iid).requestQueue,i=Date.now(),s=this._generateRequestId();F(2).then((function(){var r=n._createPendingScheduledUserMessage(e,s,i);re((function(){return M(n,void 0,void 0,(function(){return S(this,(function(e){return[2,t._trigger(r)]}))}))}))}));var a=new Qn(o({reqId:s,channelType:this.channelType,channelUrl:this.url},e));r.send(a).then((function(e){var r=e.as(Gn).message;re((function(){return M(n,void 0,void 0,(function(){return S(this,(function(e){return[2,t._trigger(r)]}))}))}))})).catch((function(r){if(ie(r))throw r;F(2).then((function(){var a=n._createPendingScheduledUserMessage(e,s,i);n._markMessageAsFailed(a,r),re((function(){return M(n,void 0,void 0,(function(){return S(this,(function(e){return[2,t._trigger(a)]}))}))}))}))}))},n.prototype.sendFileMessage=function(e){var t=o(o({},Ut),e);return A(Ot(t)).throw(N.invalidParameters),this._sendFileMessage(t)},n.prototype.sendMultipleFilesMessage=function(e){var t,n=o(o({},_r),e),r=O.of(this._iid);A(function(e,t){return void 0===t&&(t=$),It(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return gr(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(N.invalidParameters);var i=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return A(!i).throw(N.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)},n.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===n&&(n=!1);var i=O.of(this._iid).dispatcher,s=Zi.of(this._iid).fileMessageQueue,a=null!=t?t:this._generateRequestId(),o=Date.now(),u=new gt;return a||(a=this._generateRequestId()),F(2).then((function(){var t=r._createPendingFileMessage(e,a,o);i.dispatch(new te({messages:[t],source:n?ne.LOCAL_MESSAGE_RESEND_STARTED:ne.EVENT_MESSAGE_SENT_PENDING})),re((function(){return M(r,void 0,void 0,(function(){return S(this,(function(e){return[2,u._trigger(t)]}))}))})),s.request(r,a,e).then((function(e){i.dispatch(new te({messages:[e],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),re((function(){return M(r,void 0,void 0,(function(){return S(this,(function(t){return[2,u._trigger(e)]}))}))}))})).catch((function(t){if(ie(t))throw t;F(2).then((function(){var n=r._createPendingFileMessage(e,a,o),s=O.of(r._iid).cacheContext.localCacheEnabled&&se(t.code);r._markMessageAsFailed(n,t,s),i.dispatch(new te({messages:[n],source:n.sendingStatus===E.PENDING?ne.REQUEST_RESEND_MESSAGE:t.code===q.FILE_UPLOAD_CANCEL_FAILED?ne.LOCAL_MESSAGE_CANCELED:ne.EVENT_MESSAGE_SENT_FAILED})),re((function(){return M(r,void 0,void 0,(function(){return S(this,(function(e){return[2,u._triggerFailed(t,n)]}))}))}))}))}))})),u},n.prototype._autoResendFileMessage=function(e){A(e instanceof He&&!!e.messageParams).throw(N.invalidParameters);var t=O.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},n.prototype._sendMultipleFilesMessage=function(e,t){var n=this,r=O.of(this._iid).dispatcher,i=Zi.of(this._iid).fileMessageQueue,s=null!=t?t:this._generateRequestId(),a=Date.now(),o=new br;return s||(s=this._generateRequestId()),F(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,s,a);r.dispatch(new te({messages:[t],source:ne.EVENT_MESSAGE_SENT_PENDING})),re((function(){return M(n,void 0,void 0,(function(){return S(this,(function(e){return[2,o._trigger(t)]}))}))})),i.request(n,s,e,o).then((function(e){r.dispatch(new te({messages:[e],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),re((function(){return M(n,void 0,void 0,(function(){return S(this,(function(t){return[2,o._trigger(e)]}))}))}))})).catch((function(t){if(ie(t))throw t;F(2).then((function(){var i=n._createPendingMultipleFilesMessage(e,s,a);n._markMessageAsFailed(i,t),r.dispatch(new te({messages:[i],source:ne.EVENT_MESSAGE_SENT_FAILED})),re((function(){return M(n,void 0,void 0,(function(){return S(this,(function(e){return[2,o._triggerFailed(t,i)]}))}))}))}))}))})),o},n.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,s=O.of(this._iid).requestQueue,a=new Vn(o(o({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));s.send(a).then((function(e){var n=e.as(Wn).message;re((function(){return M(i,void 0,void 0,(function(){return S(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(s){if(ie(s))throw s;F(2).then((function(){var a=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(a,s),re((function(){return M(i,void 0,void 0,(function(){return S(this,(function(e){return[2,t._triggerFailed(s,a)]}))}))}))}))}))},n.prototype.sendFileMessages=function(e){var t,n;A(e.every((function(e){return Ot(o(o({},Ut),e))}))).throw(N.invalidParameters);var r=new gt;try{for(var i=m(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).onPending((function(e){return r._trigger(e)})).onFailed((function(e,t){return r._triggerFailed(e,t)})).onSucceeded((function(e){return r._trigger(e)}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},n.prototype.resendFileMessage=function(e,t){var n;return M(this,void 0,void 0,(function(){var i,s,o;return S(this,(function(u){return i=Boolean(e.url)||z(t)||z(null===(n=e.messageParams)||void 0===n?void 0:n.file),A(e instanceof He&&i&&!e.scheduledInfo).throw(N.invalidParameters),s=new B,o=function(e,t){var n;return e.messageParams?(!e.url&&z(t)&&(e.messageParams.file=t),e.messageParams):r(a({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))}(e,t),this._sendFileMessage(o,e.reqId,!0).onFailed((function(e){return s.reject(e)})).onSucceeded((function(e){return s.resolve(e)})),[2,s.promise]}))}))},n.prototype.updateFileMessage=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return n=o(o({},xt),t),A(d("number",e)&&function(e){return Pt(e)}(n)).throw(N.invalidParameters),r=O.of(this._iid).requestQueue,i=new Rn(o({channelType:this.channelType,channelUrl:this.url,messageId:e},n)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(xn).message]}}))}))},n.prototype.cancelUploadingFileMessage=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){return A(d("string",e)).throw(N.invalidParameters),Zi.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},n.prototype.copyFileMessage=function(e,t){var r,i,s;return M(this,void 0,void 0,(function(){var u,c;return S(this,(function(l){return A(e instanceof n&&t instanceof He&&t.sendingStatus===E.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(N.invalidParameters),u=new B,c=a(o(o({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(i=t.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:C.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=t.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),[2,u.promise]}))}))},n.prototype.deleteMessage=function(e){return M(this,void 0,void 0,(function(){var t,n;return S(this,(function(r){switch(r.label){case 0:return A(e instanceof Le).throw(N.invalidParameters),e.messageId>0?(t=O.of(this._iid).requestQueue,n=new Ln({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},n.prototype.addReaction=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return S(this,(function(s){switch(s.label){case 0:return A(e instanceof Le&&e.messageId>0&&d("string",t)).throw(N.invalidParameters),n=O.of(this._iid).requestQueue,r=new qn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Fn).reactionEvent]}}))}))},n.prototype.deleteReaction=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return S(this,(function(s){switch(s.label){case 0:return A(e instanceof Le&&e.messageId>0&&d("string",t)).throw(N.invalidParameters),n=O.of(this._iid).requestQueue,r=new zn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Bn).reactionEvent]}}))}))},n.prototype._updateUserMessageMetaArray=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i,s,a,o,u,c;return S(this,(function(l){switch(l.label){case 0:return i=O.of(this._iid),s=i.dispatcher,a=i.requestQueue,o=new Pn({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(kn).message,s.dispatch(new te({messages:[c],source:ne.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},n.prototype._updateFileMessageMetaArray=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i,s,a,o,u,c;return S(this,(function(l){switch(l.label){case 0:return i=O.of(this._iid),s=i.dispatcher,a=i.requestQueue,o=new Rn({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(xn).message,s.dispatch(new te({messages:[c],source:ne.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},n.prototype.createMessageMetaArrayKeys=function(e,t){return M(this,void 0,void 0,(function(){var n;return S(this,(function(r){return A(e instanceof Le&&e.messageId>0&&l("string",t)).throw(N.invalidParameters),n=t.map((function(e){return new Oe({key:e})})),e instanceof He?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},n.prototype.deleteMessageMetaArrayKeys=function(e,t){return M(this,void 0,void 0,(function(){var n;return S(this,(function(r){return A(e instanceof Le&&e.messageId>0&&l("string",t)).throw(N.invalidParameters),n=t.map((function(e){return new Oe({key:e})})),e instanceof He?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},n.prototype.addMessageMetaArrayValues=function(e,t){return M(this,void 0,void 0,(function(){return S(this,(function(n){return A(e instanceof Le&&e.messageId>0&&t.every((function(e){return e instanceof Oe}))).throw(N.invalidParameters),e instanceof He?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},n.prototype.removeMessageMetaArrayValues=function(e,t){return M(this,void 0,void 0,(function(){return S(this,(function(n){return A(e instanceof Le&&e.messageId>0&&t.every((function(e){return e instanceof Oe}))).throw(N.invalidParameters),e instanceof He?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},n.prototype.report=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return A(h(Mt,e)&&d("string",t)).throw(N.invalidParameters),n=O.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new An({channelUrl:this.url,channelType:this.channelType,userId:r.userId,category:e,description:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},n.prototype.reportUser=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return A(e instanceof u&&h(Mt,t)&&d("string",n)).throw(N.invalidParameters),r=O.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new Nn({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.userId,category:t,description:n}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},n.prototype.reportMessage=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return A(e instanceof De&&h(Mt,t)&&d("string",n)).throw(N.invalidParameters),r=O.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new Un({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:n}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},n.prototype.updatePoll=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return S(this,(function(s){switch(s.label){case 0:return A(d("number",e)&&function(e){return d("string",e.title,!0)&&J(e.data)&&d("boolean",e.allowUserSuggestion,!0)&&d("boolean",e.allowMultipleVotes,!0)&&d("number",e.closeAt,!0)}(t)).throw(N.invalidParameters),n=O.of(this._iid).requestQueue,r=new Hn(o({pollId:e},t)),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Yn).poll]}}))}))},n.prototype.deletePoll=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return S(this,(function(i){switch(i.label){case 0:return t=d("number",e),A(t).throw(N.invalidParameters),n=O.of(this._iid).requestQueue,r=new Jn({pollId:e}),[4,n.send(r)];case 1:return i.sent(),[2]}}))}))},n.prototype.closePoll=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return S(this,(function(s){switch(s.label){case 0:return t=d("number",e),A(t).throw(N.invalidParameters),n=O.of(this._iid).requestQueue,r=new Xn({pollId:e}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Zn).poll]}}))}))},n.prototype.addPollOption=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return n=d("number",e)&&d("string",t)&&""!==t.trim(),A(n).throw(N.invalidParameters),r=O.of(this._iid).requestQueue,i=new $n({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(er).poll]}}))}))},n.prototype.updatePollOption=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return r=d("number",e)&&d("number",t)&&d("string",n)&&""!==n.trim(),A(r).throw(N.invalidParameters),i=O.of(this._iid).requestQueue,s=new tr({pollId:e,pollOptionId:t,optionText:n}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(nr).poll]}}))}))},n.prototype.deletePollOption=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return S(this,(function(s){switch(s.label){case 0:return n=d("number",e)&&d("number",t),A(n).throw(N.invalidParameters),r=O.of(this._iid).requestQueue,i=new rr({pollId:e,pollOptionId:t}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.votePoll=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return S(this,(function(c){switch(c.label){case 0:return n=d("number",e)&&l("number",t),A(n).throw(N.invalidParameters),r=O.of(this._iid),i=r.requestQueue,s=r.dispatcher,a=new sr({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(ar).event,s.dispatch(new ue({event:u,source:ne.EVENT_POLL_VOTED})),[2,u]}}))}))},n.prototype.getPollChangeLogsSinceTimestamp=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return A(d("number",e)).throw(N.invalidParameters),[4,ce.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getPollChangeLogsSinceToken=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return A(d("string",e,!0)),[4,ce.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},n.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ae(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},n.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new oe(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},n}(c),Tr=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onConnected=Q,this.onReconnectStarted=Q,this.onReconnectSucceeded=Q,this.onReconnectFailed=Q,this.onDisconnected=Q})),wr=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onSessionExpired=Q,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Q,this.onSessionRefreshed=Q,this.onSessionClosed=Q})),Mr=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onFriendsDiscovered=Q,this.onTotalUnreadMessageCountChanged=Q,this.onTotalUnreadMessageCountUpdated=Q})),Sr=function(n){function i(e){var i=e.limit,s=e.token,a=e.userIdsFilter,o=e.metaDataKeyFilter,u=e.metaDataValuesFilter,c=e.nicknameStartsWithFilter,l=n.call(this)||this;return l.method=t.GET,l.path=le,l.params=r({limit:i,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return e(i,n),i}(i),Ar=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new u(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Nr=function(t){function n(e,n){var r,i,s,a=this;return(a=t.call(this,e,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&l("string",this.userIdsFilter,!0)&&d("string",this.metaDataKeyFilter,!0)&&l("string",this.metaDataValuesFilter,!0)&&d("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s;return S(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=O.of(this._iid).requestQueue,t=new Sr(a(o(o({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(Ar),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(de),Ur=function(n){function i(e){var i=e.userId,s=e.limit,a=e.token,o=e.userIdsFilter,u=n.call(this)||this;return u.method=t.GET,u.path="".concat(le,"/").concat(i,"/block"),u.params=r({limit:s,token:a,user_ids:o}),u}return e(i,n),i}(i),Or=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new u(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Cr=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&l("string",this.userIdsFilter,!0)},n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s,u,c;return S(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=O.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ur(a(o(o({},this),{userId:t.userId,token:this._token}))),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=l.sent(),s=i.as(Or),u=s.users,c=s.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(de),Pr=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(le,"/").concat(encodeURIComponent(r),"/friends"),a.params={limit:i,token:s},a}return e(r,n),r}(i),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(t){return new u(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Rr=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,u,c;return S(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=O.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pr(o(o({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=l.sent(),s=i.as(kr),a=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(de),xr={},Lr=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return xr[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,xr[t]=this),xr[t]}return e.get=function(e){return xr[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(ir||(ir={}));var Dr,qr=function(t){function n(e){var r=e.code,i=void 0===r?ir.UNKNOWN_ERROR:r,s=e.message,a=void 0===s?"Unknown error occurred.":s,o=t.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,n.prototype),o}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:ir.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailable",{get:function(){return new n({code:ir.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailableInPrivateBrowsing",{get:function(){return new n({code:ir.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeIsFull",{get:function(){return new n({code:ir.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotInitialized",{get:function(){return new n({code:ir.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:ir.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenIntegrity",{get:function(){return new n({code:ir.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenBlob",{get:function(){return new n({code:ir.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeEncryptionInvalid",{get:function(){return new n({code:ir.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeItemSizeExceeded",{get:function(){return new n({code:ir.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeReadFailed",{get:function(){return new n({code:ir.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:ir.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:ir.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionNotReady",{get:function(){return new n({code:ir.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotMatch",{get:function(){return new n({code:ir.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionQueryNotValid",{get:function(){return new n({code:ir.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionInsertDuplicate",{get:function(){return new n({code:ir.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:ir.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:ir.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionWriteFailed",{get:function(){return new n({code:ir.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:ir.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTableIsRequired",{get:function(){return new n({code:ir.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:ir.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"compareTypesNotMatch",{get:function(){return new n({code:ir.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"circularReferenceFound",{get:function(){return new n({code:ir.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),n}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Dr||(Dr={}));var Fr,zr=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw qr.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return zr(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=zr(e[r],t);return t.delete(e),n}return e},Br=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw qr.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Kr=function(e,t){for(var n=0,r=0;r>>0)%t},jr=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Qr=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!Qr(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Qr(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(Br(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Br(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Br(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Br(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Gr=function(){},Vr=function(){return Promise.resolve()},Wr=function(e){return e},Hr=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Fr||(Fr={}));var Yr,Jr,Xr,Zr=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?Wr:a,u=e.backward,c=void 0===u?Vr:u,l=e.forward,d=void 0===l?Vr:l,h=e.complete,f=void 0===h?Gr:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return M(this,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),$r=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*Br(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*Br(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},h=this,i=0;i-1){var r=this._items[n];return t===Xr.PERSISTENT&&(r.state=Jr.PERSISTENT),t!==Xr.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)ci.includes(this._items[r].state)&&ci.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===Jr.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=m(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===Jr.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==Jr.VOLATILE}))},e}(),hi=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(ni(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ni(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,f([],p(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s,a,u,c,l,d;return S(this,(function(h){switch(h.label){case 0:n=di.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return o(o({},e.data),{generation:r})})))];case 2:for(a=h.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=di.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=fi.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return n=Lr.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,di.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?fi.createFromCacheItem(s):new fi({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return M(this,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:return e=ii(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),di.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),mi={},vi=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var u=function(e,t,n){return"".concat(ni(e,t),"/index.").concat(n)}(t,n,i.join(">"));return mi[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=a,this._transaction.on(Yr.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Yr.ERROR,this.indexerKey,(function(){return o.abort()}))),mi[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in mi)delete mi[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=p(this.indexOf(n),2),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=p(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=m(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw qr.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=Br(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,v,y;return S(this,(function(_){switch(_.label){case 0:return[4,(e=di.get(this.dbname)).find(this._store,this.indexerKey,Xr.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=ii(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=m(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,Xr.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=fi.createFromCacheItem(o))try{for(v=void 0,c=m(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){v={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(v)throw v.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=zr(this._origin),_.label=12;case 12:return mi[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return di.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete mi[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=zr(this._origin)},e.prototype.abort=function(){this._table=zr(this._origin)},e}(),yi=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},_i=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(oi||(oi={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(ui||(ui={}));var gi,bi={},Ii=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=oi.PROCESSING,this._queue=[],this._activationQueue=[],bi[e]&&!t.forceCreate||(this.nodeId=_i(),this.key=e,yi()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case ui.NEWNODE:n._sendSync();break;case ui.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case ui.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:ui.REQUEST_LOCK,ts:e.ts})};try{for(var p=m(h),v=p.next();!v.done;v=p.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case ui.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case ui.REQUEST_LOCK:n._requestLock(i);break;case ui.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case ui.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(ui.REMOVENODE)}))),bi[e]=this),bi[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==oi.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:_i(),key:this.key,op:e,data:t.data,ts:Date.now()};return yi()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(ui.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(ui.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),i=!0;break}i||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))},e.prototype._sendSync=function(){var e;this.isHost&&this._send(ui.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},e.prototype._waitUntilSyncCompleted=function(){return M(this,void 0,void 0,(function(){var e=this;return S(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=oi.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(ui.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(ui.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(ui.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),Ei=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Dr.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=f([[r]],p(s.filter((function(e){return vi.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new Ii(function(e,t){return"".concat(ni(e,t),".lock")}(t,n)),this._blobContainer=new ai({dbname:t,collectionName:n,store:a}),this._transaction=new hi({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return S(this,(function(i){switch(i.label){case 0:return r=ri(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Dr.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,v,y,_=this;return S(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Lr.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.sent(),this._metadata=n||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:g.sent(),this._blockManager=new pi({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=f([],p(this.indexes),!1),i=[],s=r.map((function(e){return vi.createKey(e)})),a=n?n.indexes.map((function(e){return vi.createKey(e)})):[];try{for(o=m(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(vi.parseKey(c))}catch(e){v={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(v)throw v.error}}return(l=[]).push.apply(l,f([],p(r.map((function(e){var t=new vi({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,f([],p(i.map((function(e){return new vi({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=ri(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=Dr.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Dr.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=vi.createKey(e);try{for(var i=m(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===vi.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw qr.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return e=ri(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=m(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw qr.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return S(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=m(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=m(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return S(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=m(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=m(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return S(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=m(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return M(this,void 0,void 0,(function(){var t,n;return S(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,zr(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw qr.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new ei({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw qr.collectionNotReady},e.prototype.insertOne=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw qr.collectionKeyNotGiven;return[4,this._requestInsert(zr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return S(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw qr.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=m(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(zr(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw qr.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw qr.collectionKeyNotGiven;return[4,this._requestUpsert(zr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return S(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw qr.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=m(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(zr(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw qr.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw qr.collectionKeyNotGiven;return[4,this._requestUpdate(zr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,v,y=this;return S(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new $r({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return M(y,void 0,void 0,(function(){var n,i;return S(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Qr(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=m(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(zr(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(v=c.return)&&v.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),qr.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,v=this;return S(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new $r({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return M(v,void 0,void 0,(function(){var t,r;return S(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Qr(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=m(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),qr.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return M(this,void 0,void 0,(function(){return S(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Ti="[NESTDB]",wi=!0,Mi=function(){function e(){}return e.off=function(){wi=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return M(o,void 0,void 0,(function(){var n,i;return S(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw qr.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,o({},e.value)]}}))}))},e.prototype.setMany=function(e){return M(this,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,f([],p(e.map((function(e){return n._shardify(e)}))),!1)))];case 1:return r.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i=this;return S(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l=this;return S(this,(function(d){switch(d.label){case 0:t=[],n=function(e){var n,i,s;return S(this,(function(a){switch(a.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=a.sent())&&(s=i.metadata,t.push.apply(t,f([],p(r._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return l._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,d.label=1;case 1:d.trys.push([1,6,7,8]),i=m(e),s=i.next(),d.label=2;case 2:return s.done?[3,5]:(a=s.value,[5,n(a)]);case 3:d.sent(),d.label=4;case 4:return s=i.next(),[3,2];case 5:return[3,8];case 6:return o=d.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:d.sent(),d.label=10;case 10:return[2,e]}}))}))},e}(),Ni={},Ui=function(t){function n(e){void 0===e&&(e={});var n,r=this;r=t.call(this,o(o({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=e.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return e(n,t),Object.defineProperty(n.prototype,"rawData",{get:function(){return Ni[this.dbname]},set:function(e){Ni[this.dbname]=e},enumerable:!1,configurable:!0}),n.prototype._getAllRawKeys=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){if(Ni[this.dbname])return[2,Object.keys(Ni[this.dbname])];throw qr.storeNotAvailable}))}))},n.prototype._getRaw=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return Ni[this.dbname]?[4,jr(this.delay)]:[3,2];case 1:return t.sent(),[2,Ni[this.dbname][e]?o({key:e},Ni[this.dbname][e]):null];case 2:throw qr.storeNotAvailable}}))}))},n.prototype._setRaw=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return S(this,(function(c){switch(c.label){case 0:return Ni[this.dbname]?[4,jr(this.delay)]:[3,2];case 1:c.sent();try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,Ni[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw qr.storeNotAvailable;case 3:return[2]}}))}))},n.prototype._removeRaw=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return Ni[this.dbname]?[4,jr(this.delay)]:[3,2];case 1:a.sent();try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,Ni[this.dbname][r]&&delete Ni[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw qr.storeNotAvailable;case 3:return[2]}}))}))},n.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},n.prototype.checkAvailability=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){return[2]}))}))},n.prototype.init=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.dbname=e,Ni[this.dbname]||(Ni[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},n.prototype.set=function(e){return M(this,void 0,void 0,(function(){var n,r;return S(this,(function(i){if((n=this.observer[e.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,t.prototype.set.call(this,e)]}))}))},n.prototype.setMany=function(e){return M(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return S(this,(function(c){try{for(n=m(e),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,t.prototype.setMany.call(this,e)]}))}))},n.prototype.clear=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,jr(this.delay)];case 1:return e.sent(),Ni[this.dbname]={},[2]}}))}))},n}(Ai),Oi="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(gi||(gi={}));var Ci=function(t){function n(e){void 0===e&&(e={});var n,r=this;return(r=t.call(this,o(o({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Oi,r._state=gi.UNINITIALIZED,r._openJobQueue=[],r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return e(n,t),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=gi.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Oi,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=gi.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=gi.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=gi.UNINITIALIZED,r(e.target.error)}))}else r(qr.storeNotAvailable)}))},n.prototype._getObjectStore=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return this._database?[2,this._database.transaction(this._storeName,e).objectStore(this._storeName)]:[3,1];case 1:switch(this._state){case gi.UNINITIALIZED:case gi.OPEN:return[3,2];case gi.OPENING:case gi.CLOSED:return[3,3]}return[3,4];case 2:throw qr.storeNotInitialized;case 3:return[2,new Promise((function(n){t._openJobQueue.push((function(){return n(t._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,n.sent()]}}))}))},n.prototype._getAllRawKeys=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},n.prototype._getRaw=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return t=n.sent(),[4,new Promise((function(n,r){var i=t.get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return[2,n.sent()]}}))}))},n.prototype._setRaw=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 2:return n.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 2:return n.sent(),[2]}}))}))},n.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},n.prototype.checkAvailability=function(){return M(this,void 0,void 0,(function(){var e,t=this;return S(this,(function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!yi())return[3,4];if(!(yi()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw qr.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(qr.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(qr.storeNotAvailableInPrivateBrowsing)}else n(qr.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw qr.storeNotAvailable;case 5:return[3,7];case 6:throw qr.storeNotAvailable;case 7:return[2]}}))}))},n.prototype.init=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},n.prototype.clear=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},n}(Ai),Pi=function(t){function n(e){var n=this,r=e.AsyncStorage,i=e.itemSizeLimit,s=void 0===i?6291456:i,a=fe(e,["AsyncStorage","itemSizeLimit"]);return(n=t.call(this,o(o({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return M(this,void 0,void 0,(function(){var e,t=this;return S(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return S(this,(function(u){switch(u.label){case 0:t=[];try{for(n=m(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},n.prototype.checkAvailability=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){if(!this._asyncStorage)throw qr.storeNotAvailable;return[2]}))}))},n.prototype.init=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},n.prototype.clear=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},n}(Ai);!function(t){function n(e){var n,r=this;return(r=t.call(this,o(o({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=e.MMKV,r}e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return M(this,void 0,void 0,(function(){var e,t=this;return S(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a;return S(this,(function(o){try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},n.prototype._removeRaw=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s;return S(this,(function(a){try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},n.prototype.checkAvailability=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){if(!this._mmkv)throw qr.storeNotAvailable;return[2]}))}))},n.prototype.init=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},n.prototype.clear=function(){return M(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(Ai);var ki;!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(ki||(ki={}));var Ri,xi=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=ki.INIT,this._config=i||new Lr({dbname:t}),this._store=r,this._event={success:Gr,error:Gr,storeReplaced:Gr,upgrade:Hr},this._collections=new Map,this._globalMutex=new Ii("".concat(this.name,".lock")),this._config.disableLogger&&Mi.off(),new di({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,M(void 0,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return this._state!==ki.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t,n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new Ei({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw qr.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return M(this,void 0,void 0,(function(){var t,n,r,i,s=this;return S(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===ki.OPENED)return[3,12];this._state=ki.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(ti(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof De))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case K.NONE:if(e.parentMessageId>0)return!1;break;case K.ONLY_REPLY_TO_CHANNEL:if(e instanceof De&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Ri||(Ri={}));var Di,qi=function(e){switch(e){case Ri.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Ri.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Fi=o(o({},Tt),{scheduledAt:void 0}),zi=function(e){return wt(e)&&d("number",e.scheduledAt,!0)},Bi=o(o({},bt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ki=function(e){return It(e)&&d("number",e.scheduledAt)&&(z(e.file)||d("string",e.fileUrl))&&d("string",e.fileName,!0)&&d("string",e.mimeType,!0)&&d("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return d("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ji="UnsentMessage",Qi="reqId",Gi={},Vi=function(t){function n(e){var n=t.call(this,e)||this;return n._mutex=new Ii("unsendmessagecache.lock"),Gi[e]=n,n}return e(n,t),Object.defineProperty(n.prototype,"_cacheContext",{get:function(){return O.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),n.of=function(e,t){return void 0===t&&(t=!1),Gi[e]&&!t||(Gi[e]=new n(e)),Gi[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(ji);if(!t)throw N.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){if(e.messageId>0)throw N.invalidParameters;var t,n=o({},e.serialize());return e instanceof je?(e.messageParams&&(n.messageParams=Et(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,o(o({},Et(t)),{scheduledAt:t.scheduledAt})))):e instanceof He?(e.messageParams&&(n.messageParams=Nt(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return o(o({},Nt(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof Ge&&e.messageParams&&(n.messageParams=function(e){return r({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n},n.prototype._deserialize=function(e){return e=o(o({},e),{messageId:parseInt(e.messageId)}),Zi.of(this._iid).buildMessageFromSerializedData(e)},n.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return M(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return S(this,(function(d){switch(d.label){case 0:return i=Zi.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof je?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof He?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&At(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Ge&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return M(l,void 0,void 0,(function(){var t,n,r,i,s;return S(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&At(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof je?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof He?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&At(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},n.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},n.prototype.get=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,void 0]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Li:n,i=e.order,s=void 0===i?Ri.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return M(this,void 0,void 0,(function(){var e,n,i,o,l=this;return S(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=qi(s),n={"/where":function(e){return!!(s!==Ri.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return M(l,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Li),M(this,void 0,void 0,(function(){return S(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Ri.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return e instanceof He||e instanceof Ge?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a;return S(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=m(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return M(this,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.saveBlob=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i=this;return S(this,(function(s){switch(s.label){case 0:return e instanceof He?e.messageParams&&(r=e.messageParams).file&&St(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=mt.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&St(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=mt.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Ge&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return M(i,void 0,void 0,(function(){var r;return S(this,(function(i){switch(i.label){case 0:return t.file&&St(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=mt.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},n}(c),Wi={},Hi=function(t){function n(e){var n=t.call(this,e)||this;return Wi[e]=n,n}return e(n,t),Object.defineProperty(n.prototype,"_sdkState",{get:function(){return O.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_cacheContext",{get:function(){return O.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_unsentMessageCache",{get:function(){return Vi.of(this._iid)},enumerable:!1,configurable:!0}),n.of=function(e,t){return void 0===t&&(t=!1),Wi[e]&&!t||(Wi[e]=new n(e)),Wi[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return A(!!e).throw(N.databaseError),e.collection(dr)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){return o(o({},e.serialize()),{messageId:"".concat(e.messageId)})},n.prototype._deserialize=function(e){return e=o(o({},e),{messageId:parseInt(e.messageId)}),Zi.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Li:s,o=e.order,u=void 0===o?Ri.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return M(this,void 0,void 0,(function(){var e,r,s,o=this;return S(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=qi(u),r={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case Ri.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case Ri.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return M(o,void 0,void 0,(function(){return S(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Li),M(this,void 0,void 0,(function(){return S(this,(function(n){switch(n.label){case 0:return[4,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Ri.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return M(this,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,5];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:return r.sent(),[4,this.upsertChildMessages(e)];case 3:return r.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 4:r.sent(),r.label=5;case 5:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t,n;return S(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a;return S(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=m(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:qi(Ri.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},n.prototype.removeUnderOffset=function(e,t){return M(this,void 0,void 0,(function(){return S(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:qi(Ri.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return M(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.countBetween=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i=this;return S(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=qi(Ri.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},n.prototype.saveBlobs=function(e){return M(this,void 0,void 0,(function(){var t=this;return S(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t,n;return S(this,(function(r){switch(r.label){case 0:return e instanceof He&&e.messageParams&&((t=e.messageParams).file&&St(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n.prototype._getGroupChannelPreferenceSize=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,a;return S(this,(function(o){switch(o.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},n}(c),Yi={},Ji=function(t){function n(e){var n=t.call(this,e)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return M(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return S(this,(function(v){switch(v.label){case 0:return e instanceof te?(t=e.messages,f=e.source,s=e.isWebSocketEventComing,n=t.filter((function(e){return e.messageId>0})),r=t.filter((function(e){return 0===e.messageId})),n.length>0?[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof De?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:v.sent(),s||this._broadcastUpdateEvent(n,f),v.label=2;case 2:return r.length>0?[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:v.sent(),s||this._broadcastUpdateEvent(r,f),v.label=4;case 4:return[3,21];case 5:return e instanceof _e?(i=e.messageIds,f=e.source,s=e.isWebSocketEventComing,[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.remove(i)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return v.sent(),s||this._broadcastRemoveEvent(i,f),[3,21];case 7:return e instanceof ye?(a=e.reqId,f=e.source,[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([a])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return v.sent(),this._broadcastRemoveUnsentEvent(a,f),[3,21];case 9:return e instanceof ve?(o=e.polls,f=e.source,this._cacheContext.localCacheEnabled?(u=o.map((function(e){return e.messageId})),[4,Promise.all(u.map((function(e){return m._messageCache.get(e)})))]):[3,12]):[3,13];case 10:return(c=v.sent().filter((function(e){return e}))).length>0&&o.forEach((function(e){var t=c.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(c)];case 1:return[2,e.sent()]}}))}))}))];case 11:v.sent(),v.label=12;case 12:return this._broadcastPollChangeLogEvent(o,f),[3,21];case 13:return e instanceof me?(l=e.event,f=e.source,[4,this._messageCache.get(l.messageId)]):[3,17];case 14:return(d=v.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(l)?[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:v.sent(),v.label=16;case 16:return this._broadcastPollUpdateEvent(l,f),[3,21];case 17:return e instanceof ue?(h=e.event,f=e.source,[4,this._messageCache.get(h.messageId)]):[3,21];case 18:return(p=v.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollVoteEvent(h)?[4,pe((function(){return M(m,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:v.sent(),v.label=20;case 20:this._broadcastPollVoteEvent(h,f),v.label=21;case 21:return[2]}}))}))})),n}return e(n,t),Object.defineProperty(n.prototype,"_cacheContext",{get:function(){return O.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_dispatcher",{get:function(){return O.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_messageCache",{get:function(){return Hi.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_unsentMessageCache",{get:function(){return Vi.of(this._iid)},enumerable:!1,configurable:!0}),n.of=function(e,t){var r;return void 0===t&&(t=!1),Yi[e]&&!t||(Yi[e]&&(null===(r=Yi[e]._dispatcherContext)||void 0===r||r.close()),Yi[e]=new n(e)),Yi[e]},n.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype.subscribe=function(e,t){this._observers.set(e,t)},n.prototype.unsubscribe=function(e){this._observers.delete(e)},n.prototype.unsubscribeAll=function(){this._observers.clear()},n}(c),Xi={},Zi=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,Hi.of(e),Vi.of(e),Ji.of(e),this.fileMessageQueue=new tt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Xi[e]=this}return e.of=function(e){return Xi[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=ge(e);switch(t.messageType){case _.USER:return new je(this._iid,je.payloadify(t));case _.FILE:return Ge._isMultipleFilesMessageSerializedData(t)?new Ge(this._iid,Ge.payloadify(t)):new He(this._iid,He.payloadify(t));case _.ADMIN:return new Be(this._iid,Be.payloadify(t))}throw N.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return r(a({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return r(a({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){return r({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return o(o({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return o(o({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=ge(e);return new Re(this._iid,Re.payloadify(t))},e.prototype.getMessage=function(e){return M(this,void 0,void 0,(function(){var t,n;return S(this,(function(r){switch(r.label){case 0:return t=new ot(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(ut).message]}}))}))},e.prototype.getScheduledMessage=function(e){return M(this,void 0,void 0,(function(){var t,n;return S(this,(function(r){switch(r.label){case 0:return t=new ft(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(pt).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=ne.REQUEST_MESSAGE),M(this,void 0,void 0,(function(){var s,a,u;return S(this,(function(c){switch(c.label){case 0:return s=new ct(o(o({channelType:t,channelUrl:e,token:String(n)},rt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),u=a.as(lt).messages,this._dispatcher.dispatch(new te({messages:u,source:i})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=ne.REQUEST_MESSAGE),M(this,void 0,void 0,(function(){var s,a,u;return S(this,(function(c){switch(c.label){case 0:return s=new ct(o(o({channelType:t,channelUrl:e,timestamp:n},rt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),u=a.as(lt).messages,this._dispatcher.dispatch(new te({messages:u,source:i})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s){return void 0===i&&(i=ne.REQUEST_MESSAGE),M(this,void 0,void 0,(function(){var a,u,c,l;return S(this,(function(d){switch(d.label){case 0:return a=new ct(o(o(o({channelType:t,channelUrl:e,timestamp:n},rt),r),{checkingContinuousMessages:s})),[4,this._requestQueue.send(a)];case 1:return u=d.sent(),c=u.payload,l=u.as(lt).messages,this._dispatcher.dispatch(new te({messages:l,source:i})),[2,{messages:l,isContinuousMessages:c}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=ne.REQUEST_THREADED_MESSAGE),M(this,void 0,void 0,(function(){var i,s,a,u;return S(this,(function(c){switch(c.label){case 0:return i=new ct(o(o(o({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},Fe),n),{replyType:K.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(lt).messages,(u=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new te({messages:u,source:r})),[2,{parentMessage:a[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,i,s){return void 0===s&&(s=ne.REQUEST_MESSAGE_CHANGELOGS),M(this,void 0,void 0,(function(){var u,c,l,d,h,f,p,m;return S(this,(function(v){switch(v.label){case 0:return u=new dt(r(a(o(o({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},st),i)))),[4,this._requestQueue.send(u)];case 1:return c=v.sent(),l=c.as(ht),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new te({messages:d,source:s})),m.length>0&&this._dispatcher.dispatch(new _e({messageIds:m,source:s})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},e}(),$i=function(t){function n(e,n){var r=t.call(this,e)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&d("object",i)&&d("number",s)&&d("string",a)&&d("string",o)&&(r.threadInfo=new Me(e,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return e(n,t),n}(c),es={channelUrl:"",channelType:b.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},ts=function(n){function r(e){var r=e.channelCustomType,i=e.keyword,s=e.limit,a=e.reverse,o=e.exactMatch,u=e.channelUrl,c=e.order,l=e.messageTimestampFrom,d=e.messageTimestampTo,h=e.advancedQuery,f=e.targetFields,p=e.nextToken,m=n.call(this)||this;return m.method=t.GET,m.path="".concat(be,"/messages"),m.params={custom_type:r,query:i,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return e(r,n),r}(i),ns=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.messages=n.results.map((function(t){return We(e,t)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return e(n,t),n}(s);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Di||(Di={}));var rs=function(t){function n(e,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Di.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:Di.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&h(Di,this.order)&&d("boolean",this.advancedQuery)&&l("string",this.targetFields,!0)},n.prototype.next=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i,s,u,c;return S(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=O.of(this._iid).requestQueue,t=new ts(a(o(o({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=l.sent(),r=n.as(ns),i=r.messages,s=r.hasNext,u=r.nextToken,c=r.totalCount,this._nextToken=u,this._hasNext=s,this._isLoading=!1,this.totalCount=c,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},n}(de),is={channelUrl:"",scheduledMessageId:0},ss=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new Zi(e,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},n.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},n.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},n.prototype.getMessage=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){return t=o(o({},es),e),A(function(e){return d("string",e.channelUrl)&&h(b,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeReactions,!0)&&d("boolean",e.includeMetaArray,!0)&&d("boolean",e.includeParentMessageInfo,!0)&&d("boolean",e.includeThreadInfo,!0)}(t)).throw(N.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return M(this,void 0,void 0,(function(){var t;return S(this,(function(n){return t=o(o({},is),e),A(function(e){return d("string",e.channelUrl)&&""!==e.channelUrl&&d("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(N.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Ie);export{De as $,Pi as A,Cr as B,Tr as C,or as D,Se as E,Rr as F,Li as G,Ae as H,Ci as I,je as J,He as K,pn as L,Ri as M,ur as N,qt as O,_t as P,nn as Q,Mt as R,wr as S,Sn as T,Mr as U,wn as V,En as W,_n as X,bn as Y,ar as Z,Dn as _,cr as a,kn as a0,xn as a1,Cn as a2,Xe as a3,Zi as a4,lr as a5,Ct as a6,Pt as a7,kt as a8,Rt as a9,Ee as aA,Re as aB,Me as aC,Qe as aD,qe as aa,Oe as ab,ke as ac,Ve as ad,br as ae,Fi as af,zi as ag,Bi as ah,Ki as ai,gt as aj,Gn as ak,Ir as al,we as am,Te as an,Ji as ao,Be as ap,Ne as aq,$i as ar,mr as as,Le as at,Di as au,Ge as av,Ce as aw,Pe as ax,Ft as ay,Ue as az,dr as b,hr as c,ji as d,Qi as e,fr as f,qi as g,pr as h,vr as i,yr as j,Ui as k,ss as l,Nr as m,rs as n,xi as o,Hi as p,Vi as q,ki as r,Gt as s,Er as t,Kt as u,Ke as v,yt as w,vt as x,nt as y,We as z}; diff --git a/lib/__bundle-1da35e70.js b/lib/__bundle-1da35e70.js deleted file mode 100644 index 9dbaf29..0000000 --- a/lib/__bundle-1da35e70.js +++ /dev/null @@ -1 +0,0 @@ -var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},C=function(e){return e>0&&m.indexOf(e)>=0},k=function(e,t){if(void 0===t&&(t=!1),t&&null==e)return!0;var n="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},O=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),R={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),s?(this._clearOrder=o,this._customClearOrderComparator=s):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),B=function(){function e(){}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0},e}(),Z=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},W=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=Z()}return e.prototype._register=function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)},e}(),Q=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new W({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new W({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var o=[];try{for(var a=s(i.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),Y=function(){function e(){this._dispatcher=new Q}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),X=function(){},J=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},$=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){var t=c([],a(e),!1);for(var n in t)t[n]=$(t[n]);return t}for(var r in e)null===e[r]&&delete e[r];return e}return e}};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open",e.FEED="feed"}(x||(x={})),function(e){e.OPERATOR="operator",e.NONE="none"}(U||(U={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(M||(M={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(P||(P={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(z||(z={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(F||(F={})),function(e){e.USERS="users",e.CHANNEL="channel"}(H||(H={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(V||(V={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(G||(G={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(q||(q={}));var ee,te="v3",ne="/".concat(te,"/users"),re="/".concat(te,"/storage/file"),ie="/".concat(te,"/group_channels"),oe="/".concat(te,"/sdk/group_channels"),se="/".concat(te,"/open_channels"),ae="/".concat(te,"/sdk/open_channels"),ce="/".concat(te,"/search"),ue="/".concat(te,"/report"),le="/".concat(te,"/emojis"),he="/".concat(te,"/emoji_categories"),de="/".concat(te,"/polls"),_e="/".concat(te,"/scheduled_messages"),fe="/".concat(te,"/sdk/ui_kit/configuration"),pe="/".concat(te,"/sdk/statistics"),Ee="/".concat(te,"/notifications"),ge=function(e){switch(e){case x.FEED:case x.GROUP:return ie;case x.OPEN:return se;default:return null}},ve=function(e){switch(e){case x.GROUP:return"".concat(ue,"/group_channels");case x.OPEN:return"".concat(ue,"/open_channels");default:return null}},be=function(e,t,n){var r,i;switch(e){case H.CHANNEL:return!0;case H.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},me=function(e,t,n){var r,i,o,s,a=be(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],n),c=be(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!a&&c?1:a&&!c?-1:0},ye=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;k(s)?i.append(a,s,null!==(r=s.name)&&void 0!==r?r:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?i.append(a,String(s)):i=ye(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(ee||(ee={}));var we,Ne=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=Z(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=J(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=J(this.params);return Object.keys(e).some((function(t){return k(e[t])}))?ye(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(X),Te=function(e){function r(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return t(r,e),Object.defineProperty(r.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),r.prototype.as=function(e){return new e(this._iid,this.payload)},r}(X),Se=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(X),Ae=function(e){function n(t){var n=t.expires_in,r=t.reason,i=void 0===r?u.SESSION_KEY_EXPIRED:r,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,i){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:case u.USER_AUTH_DEACTIVATED:case u.USER_AUTH_DELETED_OR_NOT_FOUND:o.error=new v({code:i})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)},enumerable:!1,configurable:!0}),n}(X),Ce=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(X);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(we||(we={}));var ke,Oe,Ie,Re=function(){function e(e){var t=e.type,n=e.data,r=e.ts,i=void 0===r?Date.now():r;this.type=t,this.createdAt=i,this.data=n}return e.payloadify=function(e){return J({stat_type:e.type,ts:e.createdAt,data:J(e.data)})},e}(),De=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Le=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};!function(e){e.CHAT="chat",e.CALLS="calls",e.DESK="desk",e.LIVE="live",e.UIKIT_CHAT="uikit-chat",e.UIKIT_LIVE="uikit-live"}(ke||(ke={})),function(e){e.ANDROID="android",e.IOS="ios",e.JS="js",e.UNREAL="unreal",e.UNITY="unity",e.REACT_NATIVE="react-native",e.FLUTTER="flutter"}(Oe||(Oe={})),function(e){e.ANDROID="android",e.IOS="ios",e.WEB="web",e.MOBILE_WEB="mobile_web",e.WINDOWS="windows"}(Ie||(Ie={}));var xe="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",Ue=function(){function e(){}return e.sendbirdSdkUserAgentWithExtension=function(e){var t=De()?Oe.REACT_NATIVE:Oe.JS,r={main_sdk_info:"chat/".concat(t,"/").concat(h.SDK_VERSION),device_os_platform:Le()?"mobile-web":"web",os_version:h.OS_VERSION};if(e){var i=e.sendbirdExtensions,o=e.deviceOS,s=e.customData,c=void 0===s?{}:s;o.version&&(r.os_version=o.version),o.platform&&(r.device_os_platform=o.platform),i.length>0&&(r.extension_sdk_info=i.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(r=n(n({},r),c))}return Object.entries(r).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},e.userAgentWithExtension=function(e){var t=De()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Le()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},e}(),Me=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof Se&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var r=this._sdkState,i=r.appId,o=r.appVersion,s=r.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":Ue.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Ue.sendbirdSdkUserAgentWithExtension(s)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(a["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(a["App-Id"]=i,a["Access-Token"]=this._auth.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Ce(new Re({type:we.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,E;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![ee.GET,ee.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:void 0),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-40c7abbd.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h),[2,new Te(this._iid,_)];throw _?(((f=new v(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Ae({reason:f.code})),this._statLogApiResult(e,h,f),f):(f=v.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof v?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?v.requestCanceled:(E=v.networkError,this._logger.debug("fail api request",E),E);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),Pe=function(e){function n(t,n,r,i){void 0===i&&(i="");var o,s=this;return(s=e.call(this)||this)._iid=t,s.code=n,s.payload=r,s.requestId=null!==(o=r.req_id)&&void 0!==o?o:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i={};try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(X),ze=function(){};function Fe(e){let t=e.length;for(;--t>=0;)e[t]=0}const He=256,Ve=286,Ge=30,qe=15,je=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ke=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Be=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),We=new Array(576);Fe(We);const Qe=new Array(60);Fe(Qe);const Ye=new Array(512);Fe(Ye);const Xe=new Array(256);Fe(Xe);const Je=new Array(29);Fe(Je);const $e=new Array(Ge);function et(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let tt,nt,rt;function it(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Fe($e);const ot=e=>e<256?Ye[e]:Ye[256+(e>>>7)],st=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},at=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{at(e,n[2*t],n[2*t+1])},ut=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},lt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=qe;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=ut(r[t]++,t))}},ht=e=>{let t;for(t=0;t{e.bi_valid>8?st(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_t=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?ct(e,i,t):(o=Xe[i],ct(e,o+He+1,t),s=je[o],0!==s&&(i-=Je[o],at(e,i,s)),r--,o=ot(r),ct(e,o,n),s=Ke[o],0!==s&&(r-=$e[o],at(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)ft(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ft(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,ft(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=qe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),lt(n,u,e.bl_count)},gt=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{at(e,0+(r?1:0),3),dt(e),st(e,n),st(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var yt=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(gt(e,e.dyn_ltree,e.l_desc.max_code),gt(e,e.dyn_dtree,e.d_desc.max_code),Et(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ze[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?mt(e,t,n,r):4===e.strategy||o===i?(at(e,2+(r?1:0),3),pt(e,We,Qe)):(at(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(at(e,t-257,5),at(e,n-1,5),at(e,r-4,4),i=0;i{bt||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Je[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Xe[n]+He+1)]++,e.dyn_dtree[2*ot(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{at(e,2,3),ct(e,256,We),(e=>{16===e.bi_valid?(st(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Nt=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const Tt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var St=(e,t,n,r)=>{const i=Tt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},At={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ct={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:kt,_tr_stored_block:Ot,_tr_flush_block:It,_tr_tally:Rt,_tr_align:Dt}=wt,{Z_NO_FLUSH:Lt,Z_PARTIAL_FLUSH:xt,Z_FULL_FLUSH:Ut,Z_FINISH:Mt,Z_BLOCK:Pt,Z_OK:zt,Z_STREAM_END:Ft,Z_STREAM_ERROR:Ht,Z_DATA_ERROR:Vt,Z_BUF_ERROR:Gt,Z_DEFAULT_COMPRESSION:qt,Z_FILTERED:jt,Z_HUFFMAN_ONLY:Kt,Z_RLE:Bt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Wt,Z_UNKNOWN:Qt,Z_DEFLATED:Yt}=Ct,Xt=258,Jt=262,$t=42,en=113,tn=666,nn=(e,t)=>(e.msg=At[t],t),rn=e=>2*e-(e>4?9:0),on=e=>{let t=e.length;for(;--t>=0;)e[t]=0},sn=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let an=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},un=(e,t)=>{It(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,cn(e.strm)},ln=(e,t)=>{e.pending_buf[e.pending++]=t},hn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},dn=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=Nt(e.adler,t,i,n):2===e.state.wrap&&(e.adler=St(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},_n=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Jt?e.strstart-(e.w_size-Jt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Xt;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},fn=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Jt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),sn(e),r+=t),0===e.strm.avail_in)break;if(n=dn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=an(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=an(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,cn(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(dn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(dn(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Mt)&&t!==Lt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Mt&&0===e.strm.avail_in&&n===r?1:0,Ot(e,e.block_start,n,s),e.block_start+=n,cn(e.strm)),s?3:1)},En=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=an(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Jt&&(e.match_length=_n(e,n)),e.match_length>=3)if(r=Rt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=an(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=an(e,e.ins_h,e.window[e.strstart+1]);else r=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(un(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Mt?(un(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(un(e,!1),0===e.strm.avail_out)?1:2},gn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=an(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=Rt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=an(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(un(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Rt(e,0,e.window[e.strstart-1]),r&&un(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Rt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Mt?(un(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(un(e,!1),0===e.strm.avail_out)?1:2};function vn(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const bn=[new vn(0,0,0,0,pn),new vn(4,4,8,4,En),new vn(4,5,16,8,En),new vn(4,6,32,32,En),new vn(4,4,16,16,gn),new vn(8,16,32,32,gn),new vn(8,16,128,128,gn),new vn(8,32,128,256,gn),new vn(32,128,258,1024,gn),new vn(32,258,258,4096,gn)];function mn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Yt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),on(this.dyn_ltree),on(this.dyn_dtree),on(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),on(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),on(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const yn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==$t&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==en&&t.status!==tn?1:0},wn=e=>{if(yn(e))return nn(e,Ht);e.total_in=e.total_out=0,e.data_type=Qt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?$t:en,e.adler=2===t.wrap?0:1,t.last_flush=-2,kt(t),zt},Nn=e=>{const t=wn(e);var n;return t===zt&&((n=e.state).window_size=2*n.w_size,on(n.head),n.max_lazy_match=bn[n.level].max_lazy,n.good_match=bn[n.level].good_length,n.nice_match=bn[n.level].nice_length,n.max_chain_length=bn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Tn=(e,t,n,r,i,o)=>{if(!e)return Ht;let s=1;if(t===qt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==Yt||r<8||r>15||t<0||t>9||o<0||o>Zt||8===r&&1!==s)return nn(e,Ht);8===r&&(r=9);const a=new mn;return e.state=a,a.strm=e,a.status=$t,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<Tn(e,t,Yt,15,8,Wt),deflateInit2:Tn,deflateReset:Nn,deflateResetKeep:wn,deflateSetHeader:(e,t)=>yn(e)||2!==e.state.wrap?Ht:(e.state.gzhead=t,zt),deflate:(e,t)=>{if(yn(e)||t>Pt||t<0)return e?nn(e,Ht):Ht;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===tn&&t!==Mt)return nn(e,0===e.avail_out?Gt:Ht);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(cn(e),0===e.avail_out)return n.last_flush=-1,zt}else if(0===e.avail_in&&rn(t)<=rn(r)&&t!==Mt)return nn(e,Gt);if(n.status===tn&&0!==e.avail_in)return nn(e,Gt);if(n.status===$t&&0===n.wrap&&(n.status=en),n.status===$t){let t=Yt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Kt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,hn(n,t),0!==n.strstart&&(hn(n,e.adler>>>16),hn(n,65535&e.adler)),e.adler=1,n.status=en,cn(e),0!==n.pending)return n.last_flush=-1,zt}if(57===n.status)if(e.adler=0,ln(n,31),ln(n,139),ln(n,8),n.gzhead)ln(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),ln(n,255&n.gzhead.time),ln(n,n.gzhead.time>>8&255),ln(n,n.gzhead.time>>16&255),ln(n,n.gzhead.time>>24&255),ln(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),ln(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(ln(n,255&n.gzhead.extra.length),ln(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=St(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(ln(n,0),ln(n,0),ln(n,0),ln(n,0),ln(n,0),ln(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),ln(n,3),n.status=en,cn(e),0!==n.pending)return n.last_flush=-1,zt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,cn(e),0!==n.pending)return n.last_flush=-1,zt;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),cn(e),0!==n.pending)return n.last_flush=-1,zt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),cn(e),0!==n.pending)return n.last_flush=-1,zt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(cn(e),0!==n.pending))return n.last_flush=-1,zt;ln(n,255&e.adler),ln(n,e.adler>>8&255),e.adler=0}if(n.status=en,cn(e),0!==n.pending)return n.last_flush=-1,zt}if(0!==e.avail_in||0!==n.lookahead||t!==Lt&&n.status!==tn){let r=0===n.level?pn(n,t):n.strategy===Kt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(fn(e),0===e.lookahead)){if(t===Lt)return 1;break}if(e.match_length=0,n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(un(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Mt?(un(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(un(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Bt?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=Xt){if(fn(e),e.lookahead<=Xt&&t===Lt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+Xt;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Rt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(un(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Mt?(un(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(un(e,!1),0===e.strm.avail_out)?1:2})(n,t):bn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=tn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),zt;if(2===r&&(t===xt?Dt(n):t!==Pt&&(Ot(n,0,0,!1),t===Ut&&(on(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),cn(e),0===e.avail_out))return n.last_flush=-1,zt}return t!==Mt?zt:n.wrap<=0?Ft:(2===n.wrap?(ln(n,255&e.adler),ln(n,e.adler>>8&255),ln(n,e.adler>>16&255),ln(n,e.adler>>24&255),ln(n,255&e.total_in),ln(n,e.total_in>>8&255),ln(n,e.total_in>>16&255),ln(n,e.total_in>>24&255)):(hn(n,e.adler>>>16),hn(n,65535&e.adler)),cn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?zt:Ft)},deflateEnd:e=>{if(yn(e))return Ht;const t=e.state.status;return e.state=null,t===en?nn(e,Vt):zt},deflateSetDictionary:(e,t)=>{let n=t.length;if(yn(e))return Ht;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==$t||r.lookahead)return Ht;if(1===i&&(e.adler=Nt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(on(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,fn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=an(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,fn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,zt},deflateInfo:"pako deflate (from Nodeca project)"};const An=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Cn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)An(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;On[254]=On[254]=1;var In={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&kn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+On[e[n]]>t?n:t}};var Rn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Dn=Object.prototype.toString,{Z_NO_FLUSH:Ln,Z_SYNC_FLUSH:xn,Z_FULL_FLUSH:Un,Z_FINISH:Mn,Z_OK:Pn,Z_STREAM_END:zn,Z_DEFAULT_COMPRESSION:Fn,Z_DEFAULT_STRATEGY:Hn,Z_DEFLATED:Vn}=Ct;function Gn(e){this.options=Cn.assign({level:Fn,method:Vn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Hn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Rn,this.strm.avail_out=0;let n=Sn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Pn)throw new Error(At[n]);if(t.header&&Sn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?In.string2buf(t.dictionary):"[object ArrayBuffer]"===Dn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Sn.deflateSetDictionary(this.strm,e),n!==Pn)throw new Error(At[n]);this._dict_set=!0}}function qn(e,t){const n=new Gn(t);if(n.push(e,!0),n.err)throw n.msg||At[n.err];return n.result}Gn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Mn:Ln,"string"==typeof e?n.input=In.string2buf(e):"[object ArrayBuffer]"===Dn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===xn||o===Un)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=Sn.deflate(n,o),i===zn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Sn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Pn;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Gn.prototype.onData=function(e){this.chunks.push(e)},Gn.prototype.onEnd=function(e){e===Pn&&(this.result=Cn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var jn={Deflate:Gn,deflate:qn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,qn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,qn(e,t)},constants:Ct};const Kn=16209;var Bn=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,N,T,S;const A=e.state;n=e.next_in,T=e.input,r=n+(e.avail_in-5),i=e.next_out,S=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=A.dmax,c=A.wsize,u=A.whave,l=A.wnext,h=A.window,d=A.hold,_=A.bits,f=A.lencode,p=A.distcode,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)S[i++]=65535&v;else{if(!(16&b)){if(0==(64&b)){v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];n:for(;;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,!(16&b)){if(0==(64&b)){v=p[(65535&v)+(d&(1<a){e.msg="invalid distance too far back",A.mode=Kn;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&A.sane){e.msg="invalid distance too far back",A.mode=Kn;break e}if(w=0,N=h,0===l){if(w+=c-b,b2;)S[i++]=N[w++],S[i++]=N[w++],S[i++]=N[w++],m-=3;m&&(S[i++]=N[w++],m>1&&(S[i++]=N[w++]))}else{w=i-y;do{S[i++]=S[w++],S[i++]=S[w++],S[i++]=S[w++],m-=3}while(m>2);m&&(S[i++]=S[w++],m>1&&(S[i++]=S[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,N=0,T=0,S=null;const A=new Uint16Array(16),C=new Uint16Array(16);let k,O,I,R=null;for(p=0;p<=Zn;p++)A[p]=0;for(E=0;E=1&&0===A[v];v--);if(b>v&&(b=v),0===v)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(C[1]=0,p=1;p852||2===e&&N>592)return 1;for(;;){k=p-y,s[E]+1=f?(O=R[s[E]-f],I=S[s[E]-f]):(O=96,I=0),u=1<>y)+l]=k<<24|O<<16|I|0}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--A[p]){if(p===v)break;p=t[n+s[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&N>592)return 1;h=T&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==T&&(i[_+T]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:$n,Z_BLOCK:er,Z_TREES:tr,Z_OK:nr,Z_STREAM_END:rr,Z_NEED_DICT:ir,Z_STREAM_ERROR:or,Z_DATA_ERROR:sr,Z_MEM_ERROR:ar,Z_BUF_ERROR:cr,Z_DEFLATED:ur}=Ct,lr=16180,hr=16190,dr=16191,_r=16192,fr=16194,pr=16199,Er=16200,gr=16206,vr=16209,br=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function mr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const yr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},wr=e=>{if(yr(e))return or;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=lr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,nr},Nr=e=>{if(yr(e))return or;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,wr(e)},Tr=(e,t)=>{let n;if(yr(e))return or;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?or:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Nr(e))},Sr=(e,t)=>{if(!e)return or;const n=new mr;e.state=n,n.strm=e,n.window=null,n.mode=lr;const r=Tr(e,t);return r!==nr&&(e.state=null),r};let Ar,Cr,kr=!0;const Or=e=>{if(kr){Ar=new Int32Array(512),Cr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Jn(1,e.lens,0,288,Ar,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Jn(2,e.lens,0,32,Cr,0,e.work,{bits:5}),kr=!1}e.lencode=Ar,e.lenbits=9,e.distcode=Cr,e.distbits=5},Ir=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whaveSr(e,15),inflateInit2:Sr,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,N,T=0;const S=new Uint8Array(4);let A,C;const k=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(yr(e)||!e.output||!e.input&&0!==e.avail_in)return or;n=e.state,n.mode===dr&&(n.mode=_r),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,N=nr;e:for(;;)switch(n.mode){case lr:if(0===n.wrap){n.mode=_r;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=St(n.check,S,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=vr;break}if((15&u)!==ur){e.msg="unknown compression method",n.mode=vr;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=vr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(S[0]=255&u,S[1]=u>>>8&255,n.check=St(n.check,S,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,S[2]=u>>>16&255,S[3]=u>>>24&255,n.check=St(n.check,S,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(S[0]=255&u,S[1]=u>>>8&255,n.check=St(n.check,S,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=St(n.check,S,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=St(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=dr;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=gr;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Or(n),n.mode=pr,t===tr){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=vr}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=vr;break}if(n.length=65535&u,u=0,l=0,n.mode=fr,t===tr)break e;case fr:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=dr;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=vr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[k[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,A={bits:n.lenbits},N=Jn(0,n.lens,0,19,n.lencode,0,n.work,A),n.lenbits=A.bits,N){e.msg="invalid code lengths set",n.mode=vr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=r[o++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(C=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=vr;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(C=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(C=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=vr;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===vr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=vr;break}if(n.lenbits=9,A={bits:n.lenbits},N=Jn(1,n.lens,0,n.nlen,n.lencode,0,n.work,A),n.lenbits=A.bits,N){e.msg="invalid literal/lengths set",n.mode=vr;break}if(n.distbits=6,n.distcode=n.distdyn,A={bits:n.distbits},N=Jn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,A),n.distbits=A.bits,N){e.msg="invalid distances set",n.mode=vr;break}if(n.mode=pr,t===tr)break e;case pr:n.mode=Er;case Er:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,Bn(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===dr&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=dr;break}if(64&g){e.msg="invalid literal/length code",n.mode=vr;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(C=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=vr;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(C=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=vr;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=vr;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=Er);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=Er;break;case gr:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(yr(e))return or;let t=e.state;return t.window&&(t.window=null),e.state=null,nr},inflateGetHeader:(e,t)=>{if(yr(e))return or;const n=e.state;return 0==(2&n.wrap)?or:(n.head=t,t.done=!1,nr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return yr(e)?or:(r=e.state,0!==r.wrap&&r.mode!==hr?or:r.mode===hr&&(i=1,i=Nt(i,t,n,0),i!==r.check)?sr:(o=Ir(e,t,n,n),o?(r.mode=16210,ar):(r.havedict=1,nr)))},inflateInfo:"pako inflate (from Nodeca project)"};var Dr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Lr=Object.prototype.toString,{Z_NO_FLUSH:xr,Z_FINISH:Ur,Z_OK:Mr,Z_STREAM_END:Pr,Z_NEED_DICT:zr,Z_STREAM_ERROR:Fr,Z_DATA_ERROR:Hr,Z_MEM_ERROR:Vr}=Ct;function Gr(e){this.options=Cn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Rn,this.strm.avail_out=0;let n=Rr.inflateInit2(this.strm,t.windowBits);if(n!==Mr)throw new Error(At[n]);if(this.header=new Dr,Rr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=In.string2buf(t.dictionary):"[object ArrayBuffer]"===Lr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Rr.inflateSetDictionary(this.strm,t.dictionary),n!==Mr)))throw new Error(At[n])}function qr(e,t){const n=new Gr(t);if(n.push(e),n.err)throw n.msg||At[n.err];return n.result}Gr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Ur:xr,"[object ArrayBuffer]"===Lr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=Rr.inflate(n,s),o===zr&&i&&(o=Rr.inflateSetDictionary(n,i),o===Mr?o=Rr.inflate(n,s):o===Hr&&(o=zr));n.avail_in>0&&o===Pr&&n.state.wrap>0&&0!==e[n.next_in];)Rr.inflateReset(n),o=Rr.inflate(n,s);switch(o){case Fr:case Hr:case zr:case Vr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Pr))if("string"===this.options.to){let e=In.utf8border(n.output,n.next_out),t=n.next_out-e,i=In.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Mr||0!==a){if(o===Pr)return o=Rr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Gr.prototype.onData=function(e){this.chunks.push(e)},Gr.prototype.onEnd=function(e){e===Mr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Cn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var jr={Inflate:Gr,inflate:qr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,qr(e,t)},ungzip:qr,constants:Ct};const{Deflate:Kr,deflate:Br,deflateRaw:Zr,gzip:Wr}=jn,{Inflate:Qr,inflate:Yr,inflateRaw:Xr,ungzip:Jr}=jr;var $r,ei={Deflate:Kr,deflate:Br,deflateRaw:Zr,gzip:Wr,Inflate:Qr,inflate:Yr,inflateRaw:Xr,ungzip:Jr,constants:Ct};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}($r||($r={}));var ti,ni=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===$r.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return $r.CONNECTING;case 1:return $r.OPEN}return $r.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Pe.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Ae(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=ei.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",v.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==$r.CLOSED?(e._ws.onopen=ze,e._ws.onmessage=ze,e._ws.onerror=ze,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(Q),ri=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?{}:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:Z(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(X),ii=function(e){function n(t){var n=t.all,r=t.feed,i=t.custom_types,o=t.ts,s=e.call(this)||this;return s.all=n,s.feed=r,s.customTypes=i,s.ts=o,s}return t(n,e),n}(X),oi=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},si=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new Me(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new ni(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new ii(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new oi,e.ackRequired){r=function(r,o){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(void 0,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof Ne?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof ri?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(ti||(ti={}));var ai=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(X),ci=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=ti.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new si(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof ai){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case ti.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case ti.INITIALIZED:case ti.INTERNAL_DISCONNECTED:case ti.EXTERNAL_DISCONNECTED:case ti.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(v.connectionClosed):t.reject(v.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===ti.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===ti.CONNECTING||this._currentConnectionStateType===ti.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof ri?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:return[2,i.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new oi,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 7:return[3,9];case 4:return e instanceof Ne?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,8];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new oi,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 8:throw v.invalidCommand;case 9:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof ri||e instanceof Ne?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(v.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),ui="sendbird@devicetokens",li=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return J($({type:e.type,token:e.token}))},e}(),hi=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(ne,"/").concat(n,"/session_key"),s.method=ee.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(Ne),di=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?"":o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(ri),_i=function(e){function n(t,n){var r=e.call(this,t,n)||this,i=n.key;return r.key=i,r}return t(n,e),n}(Te),fi=function(e){function n(t,n,r){var i,o=this;return(o=e.call(this,t,"LOGI",r)||this).error=null,o.newKey=null,o.newKey=null!==(i=r.new_key)&&void 0!==i?i:null,o.error=r.error?new v(r.error):null,o}return t(n,e),n}(Pe),pi=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(X),Ei=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},gi=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),vi=function(e,t,n){return void 0===n&&(n=new gi),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new di({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(fi),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new hi({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,vi((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(_i).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==ti.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)&&t?[4,this._receiveNewAuthToken()]:[3,9];case 4:return(i=o.sent())?(this.auth.authToken=i,[4,this._refreshSessionKey(this.auth.authToken,!1)]):[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return r=o.sent(),this._isSessionRelatedError(r)?t?[4,this._receiveNewAuthToken()]:[3,18]:[3,20];case 13:return(i=o.sent())?(this.auth.authToken=i,[4,this._refreshSessionKeyByApi(this.auth.authToken)]):[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw r;case 19:return[3,21];case 20:throw r;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new oi;return bi((function(){return i(e,void 0,void 0,(function(){var e,n,r,i,s=this;return o(this,(function(o){return this._isRefreshingAuthToken=!0,this.auth.clear(),this.handler.onSessionTokenRequired?(e=null,n=function(){e&&(clearTimeout(e),e=null)},r=function(e){n(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),t.resolve(e))},i=function(e){n(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,t.reject(e))},e=setTimeout((function(){return i()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(r,i)):t.resolve(null),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,yi.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(ui)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(ui,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),this.close(),yi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(Q),Ni=function(){function e(){this.type=ti.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),Ti=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ti.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new Ii,t)];case 2:return s.sent(),bi((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(Ni),Si=function(e){function n(){var t=e.call(this)||this;return t.type=ti.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new Oi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ci,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ti,t)];case 1:return n.sent(),[2]}}))}))},n}(Ni),Ai=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=ti.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new Ci,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new Oi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ci,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ti,t)];case 1:return n.sent(),[2]}}))}))},n}(Ni),Ci=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ti.RECONNECTING,t.name="reconnecting",t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new oi,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),bi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,vi((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof v&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new ki,t)];case 3:return h.sent(),bi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),g(c)?[3,7]:c instanceof v?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new Ai({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return bi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new oi,this._halt(v.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new Oi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new oi,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Ai({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Ti,t)];case 1:return n.sent(),[2]}}))}))},n}(Ni),ki=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ti.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new Ci,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new Ai({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ti,t)];case 1:return n.sent(),[2]}}))}))},n}(Ni),Oi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=ti.CONNECTING,r.name="connecting",r._authToken="",r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new oi,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,vi((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof v&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new ki,t)];case 3:return a.sent(),bi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),g(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof v?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new Ii,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return bi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new oi,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect,a=void 0!==s&&s;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:v.connectionCanceled),e.hasSession?[4,e.changeState(new Ai({autoReconnect:a}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new Ti,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),e.hasSession?[4,e.changeState(new Si,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new Ti,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Ti,t)];case 1:return n.sent(),[2]}}))}))},n}(Ni),Ii=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ti.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new Oi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(Ni),Ri=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(ri),Di=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;this.pingDelegate=t,this.sdkState=n,this._logger=r}return Object.defineProperty(e.prototype,"isWaiting",{get:function(){return!!this._pingTimeoutTimer},enumerable:!1,configurable:!0}),e.prototype.ping=function(){var e,t=this;if(!this.sdkState.websocket)throw v.connectionRequired;var n=new Ri;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e.prototype.refreshTimer=function(){var e,t=this;if(!this.sdkState.websocket)throw v.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)},e.prototype.start=function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()},e.prototype.stop=function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e}(),Li=function(){function e(e){var t,n,r,i;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(r=e.template_list_token)&&void 0!==r?r:null,this.settingsUpdatedAt=null!==(i=e.settings_updated_at)&&void 0!==i?i:0}return e.payloadify=function(e){return J($({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),xi=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Ui=function(){function e(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}return e.payloadify=function(e){return J($({last_updated_at:e.lastUpdatedAt}))},e}(),Mi=1048576,Pi=5,zi=function(){function e(e){var t,n,r,i,o;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Mi:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(r=e.multiple_file_send_max_size)&&void 0!==r?r:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new Ui(null!==(o=e.uikit_config)&&void 0!==o?o:{}),this.notificationInfo=e.notifications?new Li(e.notifications):null}return e.payloadify=function(e){return J($({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Mi,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Ui.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Li.payloadify(e.notificationInfo):null}))},e}(),Fi=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Hi=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=ee.POST,i.path="".concat(ne,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(Ne),Vi=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(Te),Gi=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=ee.PUT,o.path="".concat(ne,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(Ne),qi=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(Te),ji=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=ee.DELETE,i.path="".concat(ne,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(Ne);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Te);var Ki=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=ee.DELETE,r.path="".concat(ne,"/").concat(n,"/metadata"),r}return t(n,e),n}(Ne);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Te);var Bi,Zi=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Wi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Qi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Bi||(Bi={}));var Yi,Xi=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",g.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=Bi.NON_AVAILABLE,N(Bi,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?Bi.ONLINE:Bi.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(r,e),r.payloadify=function(t){return J($(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})))},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=_o.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return Zi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return Qi(this._isValidMetaData(e)).throw(v.invalidParameters),t=_o.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Hi({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Vi).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return Qi(this._isValidMetaData(e)).throw(v.invalidParameters),n=_o.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gi({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(qi).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return Qi(w("string",e)).throw(v.invalidParameters),t=_o.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ji({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=_o.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ki({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Fi),Ji=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(X),$i=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new zi(t),this.user=new Xi(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return J($(n(n(n({},Xi.payloadify(e.user)),zi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=_o.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Ji({userProfile:this}))},e}(),eo=function(e){function r(t,n,r){var i,o,s,a=this;return(a=e.call(this,t,n,r)||this).error=null,a.userProfile=new $i(t,r),a.deviceTokenLastDeletedAt=null!==(i=r.device_token_last_deleted_at)&&void 0!==i?i:0,a.key=null!==(o=r.key)&&void 0!==o?o:"",a.ekey=null!==(s=r.ekey)&&void 0!==s?s:"",a.error=r.error?new v(r):null,a}return t(r,e),r.asError=function(e){return new r("","LOGI",n({user_id:"",error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=_o.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(Pe),to=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(X),no=function(e){function n(t,n){var r,i=n.sdkState,o=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,c=n.websocketClient,u=n.dispatcher,l=n.logger,h=n.entryState,d=void 0===h?new Ii:h,_=this;return(_=e.call(this)||this)._stateUpdatedAt=0,_._connectingAt=0,_._connectionRequestQueue=[],_._iid=t,_.sdkState=i,_.cacheContext=o,_.connectionHandlers=s,_._sessionManager=a,_._websocketClient=c,_._dispatcher=u,_._logger=l,_._currentState=d,(null===(r=_.sdkState.websocket)||void 0===r?void 0:r.pingerDisabled)||(_._pinger=new Di({pingDelegate:{send:function(e){return _._websocketClient.send(e)},error:function(e){return _._websocketClient.error(e)}},sdkState:_.sdkState,logger:l})),_._websocketClient.on("open",(function(){_._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)_.clearLoginTimer(),_._dispatcher.dispatch(e.as(eo))})).on("ping-refresh",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){_._logiProcessingTimer=setTimeout((function(){_._logiProcessingTimer=void 0,_._unresolvedLogi||_._rejectConnectionRequest(v.networkError)}),500)})),_._dispatcher.on((function(e){e instanceof eo&&(_._unresolvedLogi=e,_._tryResolveConnectionRequest())})),_}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new ai({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=void 0,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=void 0,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Ae({reason:t.error.code})),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t,n;void 0===e&&(e="");var r=this.sdkState,i=r.appId,o=r.appVersion,s=r.userId,a=r.extensions,c=r.sendbirdRuntimeEnvironment,u=this.cacheContext.localCacheEnabled,l=this._sessionManager.auth,d=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,_=!!(null!==(n=this.sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,f=Ue.userAgentWithExtension(a);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(i).concat(o?"&av=".concat(o):"").concat(l.hasSession?"&key=".concat(encodeURIComponent(l.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(d?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&SB-SDK-User-Agent=").concat(encodeURIComponent(Ue.sendbirdSdkUserAgentWithExtension(c)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(u?1:0,"&include_poll_details=1").concat(_?"&uikit_config=1":"")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new to({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Ce(new Re({type:we.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){var t;return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var n,r,i=this;return o(this,(function(o){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=this._url(e),r=new oi,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(n)),[2,r.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(eo.asError(v.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(Q),ro=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new no(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===ti.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===ti.CONNECTING||e.type===ti.RECONNECTING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketClient",{get:function(){return this._websocketClient},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),io=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Re),oo=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=ee.POST,i.path="".concat(pe),i.params={device_id:n,log_entries:r.map((function(e){return Re.payloadify(e)}))},i}return t(n,e),n}(Ne),so=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=so(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Yi||(Yi={}));var ao,co=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=Yi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=Z(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===Yi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===we.API_RESULT||e.type===we.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===we.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==Yi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Re.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof io){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new oo({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof v?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=Yi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Yi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Re({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=t.generation,this.lastFlushedAt=t.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit?(n=Math.min(Math.floor(18e4*Math.random()),100),[4,Ei(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Ce){var t=e.statLog;r.put(t)}else if(e instanceof to){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?Yi.ENABLED:Yi.COLLECT_ONLY:r.enabledState=Yi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===Yi.DISABLED?[3,3]:(e instanceof io?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof io&&t.key===e.key})),1),(n=t[0])?n.data=so(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},n}(Q);!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(ao||(ao={}));var uo,lo=function(){function e(){this.level=ao.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return J($(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return bo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0},r.prototype.serialize=function(){return Zi(this)},r}(Fi);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",e.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",e.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",e.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",e.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",e.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",e.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(po||(po={}));var yo=n({},po),wo=function(e){return e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===po.SYNC_MESSAGE_FILL||e===po.SYNC_MESSAGE_CHANGELOGS||e===po.SYNC_POLL_CHANGELOGS},No=function(e){function n(t){var n=t.messages,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messages=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(X),To=function(e){function n(t){var n=t.messageIds,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messageIds=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(X),So=function(e){function n(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return t(n,e),n}(X),Ao=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(X),Co=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(X),ko=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(X),Oo=function(){function e(e,t){var n;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return w("number",this.limit)&&this.limit>0},e}(),Io=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&N(x,this.channelType)},n}(Oo),Ro=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Do=function(e){function n(t){var n=t.title,r=t.optionTexts,i=t.data,o=t.allowUserSuggestion,s=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=ee.POST,c.path=de,c.params={title:n,options:r,data:i,allow_user_suggestion:o,allow_multiple_votes:s,close_at:a},c}return t(n,e),n}(Ne),Lo=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.poll=new mo(t,n),r}return t(n,e),n}(Te),xo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,o=e.call(this)||this;return o.method=ee.GET,o.path="".concat(de,"/").concat(encodeURIComponent(i)),o.params={channel_url:n,channel_type:r},o}return t(n,e),n}(Ne),Uo=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.poll=new mo(t,n),r}return t(n,e),n}(Te),Mo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,o=t.pollOptionId,s=e.call(this)||this;return s.method=ee.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(o)),s.params={channel_url:n,channel_type:r},s}return t(n,e),n}(Ne),Po=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.pollOption=new bo(t,n),r}return t(n,e),n}(Te),zo=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,o=t.token,s=e.call(this)||this;return s.method=ee.GET,s.path="".concat(ge(n),"/").concat(encodeURIComponent(r),"/polls/changelogs"),s.params=J({change_ts:i,token:o}),s}return t(n,e),n}(Ne),Fo=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedPolls=n.updated.map((function(e){return function(e,t){return new mo(e,t)}(t,e)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return t(n,e),n}(Te),Ho={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Vo=function(e){return w("string",e.title)&&(t=e.optionTexts,S("string",t)&&t.every((function(e){return""!==e.trim()})))&&vo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},Go={channelUrl:"",channelType:x.BASE,pollId:0,pollOptionId:0},qo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&N(x,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},jo={channelUrl:"",channelType:x.BASE,pollId:0},Ko=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&N(x,e.channelType)&&w("number",e.pollId)},Bo={},Zo=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,o=t.requestQueue,s=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=o,this._dispatcher=r,this._logger=s,Bo[e]=this}return e.of=function(e){return Bo[e]},e.prototype.buildPollFromSerializedData=function(e){var t=Wi(e);return new mo(this._iid,mo.payloadify(t))},e.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t,r;return o(this,(function(i){switch(i.label){case 0:return Qi(Ko(e)).throw(v.invalidParameters),t=new xo(n({},e)),[4,this._requestQueue.send(t)];case 1:return r=i.sent(),[2,r.as(Uo).poll]}}))}))},e.prototype.create=function(e){return i(this,void 0,void 0,(function(){var t,r;return o(this,(function(i){switch(i.label){case 0:return Qi(Vo(e)).throw(v.invalidParameters),t=new Do(n({},e)),[4,this._requestQueue.send(t)];case 1:return r=i.sent(),[2,r.as(Lo).poll]}}))}))},e.prototype.getOption=function(e){return i(this,void 0,void 0,(function(){var t,r;return o(this,(function(i){switch(i.label){case 0:return Qi(qo(e)).throw(v.invalidParameters),t=new Mo(n({},e)),[4,this._requestQueue.send(t)];case 1:return r=i.sent(),[2,r.as(Po).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,r){return void 0===r&&(r=po.SYNC_POLL_CHANGELOGS),i(this,void 0,void 0,(function(){var i,s,a,c,u,l,h;return o(this,(function(o){switch(o.label){case 0:return i=new zo($({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(i)];case 1:return s=o.sent(),a=s.as(Fo),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new Ao({polls:c,source:r})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Wo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.token,o=t.limit,s=e.call(this)||this;return s.method=ee.GET,s.path=de,s.params={channel_url:n,channel_type:r,token:i,limit:o},s}return t(n,e),n}(Ne),Qo=function(e){function n(t,n){var r,i=this;return(i=e.call(this,t,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(e){return new mo(t,e)})),i.token=n.next,i}return t(n,e),n}(Te),Yo=function(e){function r(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(r,e),r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_o.of(this._iid).requestQueue,t=new Wo(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Qo),s=i.polls,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},r}(Io),Xo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,o=t.pollOptionId,s=t.token,a=t.limit,c=e.call(this)||this;return c.method=ee.GET,c.path="".concat(de,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(o),"/voters"),c.params={channel_url:n,channel_type:r,token:s,limit:a},c}return t(n,e),n}(Ne),Jo=function(e){function n(t,n){var r,i=this;return(i=e.call(this,t,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(e){return new Xi(t,e)})),i.token=n.next,i}return t(n,e),n}(Te),$o=function(e){function r(t,n){var r=e.call(this,t,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return t(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_o.of(this._iid).requestQueue,t=new Xo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Jo),s=i.voters,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},r}(Io);export{Li as $,ee as A,bi as B,$r as C,ii as D,Q as E,Ji as F,$i as G,xi as H,Ae as I,xe as J,S as K,K as L,d as M,mi as N,N as O,f as P,_ as Q,p as R,I as S,po as T,Xi as U,_o as V,Pe as W,x as X,j as Y,ao as Z,t as _,w as a,O as a$,U as a0,Ui as a1,Bi as a2,ke as a3,Oe as a4,Ie as a5,re as a6,Fi as a7,y as a8,P as a9,g as aA,C as aB,ko as aC,Zo as aD,Oo as aE,R as aF,r as aG,Co as aH,Ao as aI,So as aJ,To as aK,ce as aL,fo as aM,Ho as aN,Vo as aO,jo as aP,Ko as aQ,Go as aR,qo as aS,bo as aT,uo as aU,X as aV,io as aW,we as aX,_e as aY,yo as aZ,M as a_,Zi as aa,H as ab,q as ac,A as ad,z as ae,mo as af,G as ag,ri as ah,ge as ai,be as aj,u as ak,Ei as al,oi as am,V as an,ie as ao,ze as ap,Io as aq,ve as ar,ue as as,me as at,F as au,vo as av,de as aw,Ro as ax,Pi as ay,No as az,i as b,oe as b0,Eo as b1,wo as b2,vi as b3,go as b4,ae as b5,se as b6,Ee as b7,o as c,ne as d,J as e,Ne as f,n as g,Te as h,k as i,he as j,le as k,fe as l,Z as m,De as n,c as o,a as p,v as q,s as r,Qi as s,Yo as t,$ as u,l as v,$o as w,Wi as x,ai as y,ti as z}; diff --git a/lib/__bundle-2e839992.js b/lib/__bundle-2e839992.js new file mode 100644 index 0000000..fc3a03f --- /dev/null +++ b/lib/__bundle-2e839992.js @@ -0,0 +1 @@ +import{_ as e,e as t,u as n,g as r,O as s,a0 as a,X as i,U as o,a7 as u,a$ as c,s as l,q as h,o as d,p as _,b as p,c as f,r as v,K as m,a as g,i as E,ae as C,T as y,aV as M,N as b,A as N,d as U,f as S,h as T,b0 as A,ao as I,aY as w,W as D,ah as L,b1 as P,aa as R,aE as F,V as k,x as O,Y as x,aA as H,B as G,a_ as V,aC as B,aH as q,az as W,aK as j,ak as z,b2 as Q,E as Y,y as K,z as J,an as X,aD as Z,ai as $,b3 as ee,aW as te,aX as ne,m as re,ac as se,ap as ae,b4 as ie,aq as oe,ab as ue,au as ce,al as le,Q as he,aJ as de}from"./__bundle-fdefc164.js";import{w as _e,N as pe,D as fe,G as ve,H as me,E as ge,p as Ee,q as Ce,J as ye,K as Me,z as be,r as Ne,L as Ue,Q as Se,T as Te,V as Ae,W as Ie,X as we,Y as De,Z as Le,_ as Pe,$ as Re,a0 as Fe,a1 as ke,a2 as Oe,a3 as xe,a4 as He,a5 as Ge,a6 as Ve,a7 as Be,a8 as qe,a9 as We,aa as je,ab as ze,ac as Qe,ad as Ye,ae as Ke,af as Je,ag as Xe,ah as Ze,ai as $e,aj as et,ak as tt,al as nt,t as rt,am as st,an as at,ao as it,ap as ot,aq as ut,ar as ct,as as lt,at as ht}from"./__bundle-bd25634c.js";import{G as dt,g as _t,D as pt,c as ft,R as vt,U as mt,a as gt,b as Et,A as Ct}from"./__bundle-8934878d.js";import{C as yt,a as Mt,b as bt,O as Nt,P as Ut,M as St,c as Tt,R as At,U as It,A as wt,T as Dt}from"./__bundle-6f8fc428.js";var Lt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Lt||(Lt={}));var Pt,Rt,Ft,kt,Ot,xt,Ht,Gt,Vt=function(i){function o(e,t){var n=i.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=s(Lt,t.state)?t.state:null,n.role=s(a,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(n.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(n.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(n.isBlockingMe=t.is_blocking_me),n}return e(o,i),o.payloadify=function(e){return t(n(r(r({},i.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))},o}(_e),Bt=function(t){function n(e,n){var r,s,a=this;return(a=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",a.channelType=null!==(s=n.channel_type)&&void 0!==s?s:i.GROUP,a.reader=new o(a._iid,n.user),a.readAt=n.ts,a}return e(n,t),n}(u);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Pt||(Pt={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Rt||(Rt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ft||(Ft={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(kt||(kt={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Ot||(Ot={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(xt||(xt={})),function(e){e.AND="AND",e.OR="OR"}(Ht||(Ht={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Gt||(Gt={}));var qt,Wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Rt.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ft.ALL,this.publicChannelFilter=Pt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=kt.ALL,this.hiddenChannelFilter=Ot.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=Ht.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t,n=new e;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(t=this.searchFilter.query)&&void 0!==t?t:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,r=n.query,s=n.fields;if(r&&s&&s.length>0&&!s.some((function(t){switch(t){case Gt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Gt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case Ht.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case Ht.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Rt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Rt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Rt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Rt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Ot.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Ot.HIDDEN:if(!e.isHidden)return!1;break;case Ot.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Ot.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===kt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Pt.PUBLIC:if(!e.isPublic)return!1;break;case Pt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ft.SUPER:if(!e.isSuper)return!1;break;case Ft.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)},e}(),jt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=r,a._cacheContext=s,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(pe)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),r(r({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return nr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(l&&l===e.url)return!1;break;case dt.CHRONOLOGICAL:if(!a&&e.createdAt>t||a&&e.createdAtt||a&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,r,s,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=v(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(a=s.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}}))}))},n}(u),zt={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},Qt=function(e){return m("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Yt={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},Kt=function(e){return m("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)&&g("boolean",e.includeChatNotification)},Jt={myMemberStateFilter:Rt.ALL},Xt=function(e){return s(Rt,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(qt||(qt={}));var Zt={keys:[]},$t={channelCustomTypesFilter:void 0,superChannelFilter:Ft.ALL},en=function(e){return m("string",e.channelCustomTypesFilter,!0)&&s(Ft,e.superChannelFilter)},tn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},nn=r({},y),rn=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},sn=function(t){function n(e){var n=e.channels,r=e.source,s=e.isWebSocketEventComing,a=void 0!==s&&s,i=e.data,o=void 0===i?null:i,u=e.ts,c=t.call(this)||this;return c.channels=n,c.source=r,c.isWebSocketEventComing=a,c.data=o,c.ts=u,c}return e(n,t),n}(M),an=function(t){function n(e){var n=e.channelUrls,r=e.source,s=e.isWebSocketEventComing,a=void 0!==s&&s,i=t.call(this)||this;return i.channelUrls=n,i.source=r,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),on=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,a=this;this._observers=new Map,s.on((function(e){return p(a,void 0,void 0,(function(){var s,a,i,o,u,c,l,h,d,_,m,g,E,C,y=this;return f(this,(function(M){switch(M.label){case 0:if(!(e instanceof sn))return[3,10];s=e.channels,m=e.source,g=e.isWebSocketEventComing,a=e.data,i=s.filter((function(e){return e instanceof hs})),o=t.filterOffsetChanged(i),M.label=1;case 1:M.trys.push([1,6,7,8]),u=v(o),c=u.next(),M.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:M.sent(),M.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=M.sent(),E={error:h},[3,8];case 7:try{c&&!c.done&&(C=u.return)&&C.call(u)}finally{if(E)throw E.error}return[7];case 8:return[4,t.upsert(i,e.ts)];case 9:return d=M.sent(),g||this._broadcastUpdateEvent(d,m,a),[3,15];case 10:return e instanceof an?(_=e.channelUrls,m=e.source,g=e.isWebSocketEventComing,[4,t.remove(_)]):[3,13];case 11:return M.sent(),[4,b((function(){return p(y,void 0,void 0,(function(){var e,t,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(_),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 12:return M.sent(),g||this._broadcastRemoveEvent(_,m),[3,15];case 13:return e instanceof pt?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:M.sent(),M.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var a=v(this._observers.values()),i=a.next();!i.done;i=a.next()){var o=i.value;o.onUpdate&&o.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),a=s.next();!a.done;a=s.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),un=function(s){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=s.call(this)||this,d=r(r({},Yt),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,s),a}(S),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new hs(e,Object.assign(t,{ts:n.ts}))})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r.ts=n.ts,r}return e(n,t),n}(T),ln=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(r?A:I,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(S),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new hs(e,n),r}return e(n,t),n}(T),dn={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:Rt.ALL,unreadChannelFilter:kt.ALL,superChannelFilter:Ft.ALL,publicChannelFilter:Pt.ALL,hiddenChannelFilter:Ot.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:Ht.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:dt.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},_n=function(n){function r(e){var r=this,s=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,v=e.channelNameContainsFilter,m=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,D=e.includeChatNotification,L=void 0!==D&&D,P=e.createdAfter,R=e.createdBefore;return(r=n.call(this)||this).method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(s),"/my_group_channels"),r.params=t({token:a,limit:i,order:null!=o?o:dn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:dn.includeEmpty,member_state_filter:null!=c?c:dn.myMemberStateFilter,super_mode:null!=l?l:dn.superChannelFilter,public_mode:null!=h?h:dn.publicChannelFilter,unread_filter:null!=d?d:dn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:L,created_after:P,created_before:R}),I&&I.query&&I.fields&&(r.params.search_query=I.query,r.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(r.params.members_include_in=w.userIds,r.params.query_type=w.queryType.toUpperCase()):r.params.members_exactly_in=w.userIds),r}return e(r,n),r}(S),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];var s=n.next,a=n.channels,i=n.ts;return r.token=s,a&&a.length>0&&(r.channels=a.map((function(t){return t.ts=i,new hs(e,t)}))),r.ts=null!=i?i:0,r}return e(n,t),n}(T),fn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,a=r.myMemberStateFilter;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=a?a:Rt.ALL},s}return e(n,t),n}(S),vn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.groupChannelCount=n.group_channel_count,r}return e(n,t),n}(T),mn=function(n){function r(e){var r=e.userId,s=e.filter,a=n.call(this)||this,i=s.keys;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(r),"/unread_item_count"),a.params=t({item_keys:i}),a}return e(r,n),r}(S),gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[qt.SUPER_INVITATION_COUNT]),"number"==typeof n[qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(T),En=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(S),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(T),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=e.includeFeedChannel,a=void 0!==s&&s,i=t.call(this)||this,o=r.channelCustomTypesFilter,u=r.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Ft.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),Mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r.unreadFeedCount=n.unread_feed_count,r}return e(n,t),n}(T),bn=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:Un(r)},s&&(a.params.message_type=s),a}return e(n,t),n}(S),Nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(T),Un=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case ve.PENDING:t.push(me.PENDING);break;case ve.SENT:t.push(me.IN_QUEUE),t.push(me.SENT);break;case ve.CANCELED:t.push(me.CANCELED);break;case ve.FAILED:t.push(me.FAILED)}})),t},Sn=function(n){function r(e){var r=this,s=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(r=n.call(this)||this).method=N.POST,r.path=I,r.params=t({user_ids:d([s],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:v,is_ephemeral:m,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),r}return e(r,n),r}(S),Tn=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).channel=new hs(e,n),s.isCreated=null===(r=n.is_created)||void 0===r||r,s}return e(n,t),n}(T),An=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=N.PUT,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var In=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:a},n}return e(n,t),n}(S),wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new hs(e,n),r}return e(n,t),n}(T),Dn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,a=r.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return s.memberCount=o,s.joinedMemberCount=c,s.members=Array.isArray(h)?h.map((function(t){return new Vt(e,t)})):[new Vt(e,r.data)],s}return e(n,t),n}(yt),Ln=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Pn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,a=r.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new Vt(s._iid,r.data),s}return e(n,t),n}(yt),Rn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(S),Fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new hs(e,n),r}return e(n,t),n}(T),kn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this;s.inviter=null;var a=r.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return s.memberCount=u,s.joinedMemberCount=l,h&&Object.keys(h).length>0&&(s.inviter=new o(e,h)),s.invitees=_.map((function(t){return new Vt(e,t)})),s}return e(n,t),n}(yt),On=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(S);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new hs(e,n),r.channel.myMemberState=Lt.NONE,r}e(n,t)}(T);var xn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,a=r.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return s.memberCount=null!=i?i:0,s.joinedMemberCount=null!=u?u:0,s.inviter=new o(e,c),s.invitee=new Vt(e,l),s}return e(n,t),n}(yt),Hn={hidePreviousMessages:!1,allowAutoUnhide:!0},Gn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:null!=a?a:Hn.hidePreviousMessages,allow_auto_unhide:null!=i?i:Hn.allowAutoUnhide},n}return e(n,t),n}(S),Vn=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(T),Bn=function(t){function n(e,n,r){var s,a,i,o=this;return(o=t.call(this,e,"SYEV",r)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,r.data&&(o.allowAutoUnhide=null!==(s=r.data.allow_auto_unhide)&&void 0!==s?s:null,o.hidePreviousMessages=null!==(a=r.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=r.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(D),qn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(L),Wn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new o(e,r.data),s}return e(n,t),n}(D),jn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(L),zn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new o(e,r.data),s}return e(n,t),n}(D),Qn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(L),Yn=function(t){function a(e,n){var r,s,a,i,o,u,c,l,h,d,_,p,f,v,m,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Rt.ALL,S.unreadChannelFilter=kt.ALL,S.superChannelFilter=Ft.ALL,S.publicChannelFilter=Pt.ALL,S.hiddenChannelFilter=Ot.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:Ht.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=dt.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,S.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Rt.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:kt.ALL,S.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:Ft.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Pt.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:Ot.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:Ht.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:dt.LATEST_LAST_MESSAGE,n.createdAfter&&(S.createdAfter=n.createdAfter),n.createdBefore&&(S.createdBefore=n.createdBefore),S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&m("string",this.channelUrlsFilter,!0)&&m("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&s(Rt,this.myMemberStateFilter)&&s(Ft,this.superChannelFilter)&&s(Pt,this.publicChannelFilter)&&s(kt,this.unreadChannelFilter)&&s(Ot,this.hiddenChannelFilter)&&m(Gt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&m("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&s(Ht,this.userIdsFilter.queryType)&&s(dt,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&m("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)&&P(this.createdAfter,!0)&&P(this.createdBefore,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,s;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,nr.of(this._iid).getMyGroupChannels(this._token,n(r({},this)),this.limit)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,s=e.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(F),Kn=function(t){function n(e,n,s){var a,i=this;return(i=t.call(this,e,"SYEV",s)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(a=s.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=s.data.latest_pinned_message?ge(e,r({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return e(n,t),n}(D),Jn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(L),Xn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new Bt(e,r),s}return e(n,t),n}(D),Zn=function(n){function r(e){var r=e.channelUrl,s=e.userId,a=n.call(this)||this;return(a=n.call(this)||this).method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(r),"/messages/mark_as_delivered"),a.params=t({userId:s}),a}return e(r,n),r}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var $n,er=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(D),tr={},nr=function(o){function u(e,t){var n,s=this;return(s=o.call(this,e,r(r({},t),{channelType:i.GROUP}))||this)._leftChannels=new Map,s._disableMack=!1,s._markAsReadAllLastSentAt=0,s._disableMack=null!==(n=t.disableMack)&&void 0!==n&&n,s._groupChannelHandlers=new Map,s._groupChannelCache=new jt(s._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),s._groupChannelBroadcast=new on({dispatcher:t.dispatcher,groupChannelCache:s._groupChannelCache,messageCache:Ee.of(s._iid),unsentMessageCache:Ce.of(s._iid)}),setInterval((function(){var e,t,n=function(e){e.invalidateTypingStatus()&&(s._dispatcher.dispatch(new sn({channels:[e],source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),s._groupChannelHandlers.forEach((function(t){t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))};try{for(var r=v(s._groupChannelCache.channels),a=r.next();!a.done;a=r.next()){n(a.value)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}}),1e3),s._dispatcher.on((function(e){e instanceof D?s._handleEvent(e):e instanceof ft?p(s,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return t=e.message,[4,this.getChannel(t.channelUrl,!0)];case 1:return n=r.sent(),t instanceof ye?n._autoResendUserMessage(t):t instanceof Me&&n._autoResendFileMessage(t),[2]}}))})):e instanceof vt&&s.reduceDBSize()})),tr[e]||(tr[e]=s),s}return e(u,o),u.of=function(e){return tr[e]||(tr[e]=new u(e,k.of(e))),tr[e]},u.clear=function(e){tr[e]&&delete tr[e]},Object.defineProperty(u.prototype,"handlers",{get:function(){return d([],_(this._groupChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),u.prototype.buildGroupChannelFromSerializedData=function(e){var t=O(e);return new hs(this._iid,hs.payloadify(t))},u.prototype.buildGroupChannelListQueryFromSerializedData=function(e){var t=O(e);return new Yn(this._iid,t)},u.prototype.buildMemberFromSerializedData=function(e){var t=O(e);return new Vt(this._iid,Vt.payloadify(t))},u.prototype.getChannelFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._groupChannelCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},u.prototype.getChannelsFromCache=function(e,t,n,r,s){return p(this,void 0,void 0,(function(){return f(this,(function(a){switch(a.label){case 0:return[4,this._groupChannelCache.fetch({token:e,filter:t,order:n,limit:r,borderlineChannelUrl:s})];case 1:return[2,a.sent()]}}))}))},u.prototype.upsertChannelsToCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._groupChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},u.prototype.removeChannelsFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._groupChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},u.prototype.clearChannelsFromCache=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._groupChannelCache.clear()];case 1:return e.sent(),[2]}}))}))},u.prototype.reduceDBSize=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,a,i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return e=Ee.of(this._iid),t=k.of(this._iid).cacheContext,n=t.localCacheConfig,r=t.nestdb,t.localCacheEnabled&&r&&r.state==Ne.OPENED?(s=1024*n.maxSize*1024,[4,r.estimateUsage()]):[2];case 1:if((a=f.sent())0||I.unreadMentionCount>0)&&(I._updateUnreadCount(0,0),this._dispatcher.dispatch(new sn({channels:[I],source:y.EVENT_CHANNEL_READ})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(I)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==I.unreadMessageCount&&0!==I.unreadMentionCount||(this._dispatcher.dispatch(new sn({channels:[I],source:y.EVENT_CHANNEL_READ})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(I)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new sn({channels:[I],source:y.EVENT_CHANNEL_READ})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(I)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),Un.label=12;case 12:return[3,79];case 13:return w=e.as(er),he=w.channelUrl,D=w.deliveredStateUpdate,L=void 0===D?{}:D,P=this._groupChannelCache.isCachedInMemory(he),[4,this.getChannel(he,!0)];case 14:if(R=Un.sent(),P)for(F in L)R._updateUndeliveredMemberState(F,L[F]);return Object.keys(L).some((function(e){return e!==Nn._sdkState.userId}))&&(this._dispatcher.dispatch(new sn({channels:[R],source:y.EVENT_CHANNEL_DELIVERED})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(R)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 15:return O=e.as(At),he=O.channelUrl,de=O.channelType,x=O.event,de!==i.GROUP?[3,18]:[4,this.getChannel(he,!0)];case 16:return z=Un.sent(),[4,this.getMessageFromCache(x.messageId)];case 17:(J=Un.sent())&&(J.applyReactionEvent(x),this._dispatcher.dispatch(new W({messages:[J],source:y.EVENT_MESSAGE_REACTION_UPDATED}))),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated(z,x)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=18;case 18:return[3,79];case 19:return(Y=e.as(Tt).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(Y.channelUrl,!0)];case 20:return K=Un.sent(),[4,this.getMessageFromCache(Y.targetMessageId)];case 21:(J=Un.sent())&&(J.applyThreadInfoUpdateEvent(Y),this._dispatcher.dispatch(new W({messages:[J],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(K,Y)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=22;case 22:return[3,79];case 23:X=e.as(St).groupChannelMemberCounts,Z=[],Un.label=24;case 24:Un.trys.push([24,29,30,31]),$=v(X),ee=$.next(),Un.label=25;case 25:return ee.done?[3,28]:(te=ee.value,he=te.channelUrl,nt=te.memberCount,rt=te.joinedMemberCount,ne=te.updatedAt,[4,this.getChannelFromCache(he)]);case 26:(re=Un.sent())&&re._setLatestMemberCount(nt,rt,ne)&&Z.push(re),Un.label=27;case 27:return ee=$.next(),[3,25];case 28:return[3,31];case 29:return se=Un.sent(),vn={error:se},[3,31];case 30:try{ee&&!ee.done&&(mn=$.return)&&mn.call($)}finally{if(vn)throw vn.error}return[7];case 31:return Z.length>0&&(this._dispatcher.dispatch(new sn({channels:Z,source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(Z)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 32:return ae=e.as(Ut),ie=ae.event,oe=ae.status,he=ae.channelUrl,de=ae.channelType,he&&de===i.GROUP?[4,this.getChannel(he,!0)]:[3,34];case 33:ue=Un.sent(),this._dispatcher.dispatch(new q({event:ie,source:y.EVENT_POLL_UPDATED})),G(oe===Q?function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(ue,ie.pollId)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(ue,ie)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Un.label=34;case 34:return[3,79];case 35:return ce=e.as(Le),le=ce.event,he=ce.channelUrl,de=ce.channelType,he&&de===i.GROUP?[4,this.getChannel(he,!0)]:[3,37];case 36:_e=Un.sent(),this._dispatcher.dispatch(new B({event:le,source:y.EVENT_POLL_VOTED})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(_e,le)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=37;case 37:return[3,79];case 38:if(!(pe=e.as(yt).event).isGroupChannelEvent)return[3,77];switch(pe.category){case bt.CHANNEL_JOIN:return[3,39];case bt.CHANNEL_LEAVE:return[3,41];case bt.CHANNEL_OPERATOR_UPDATE:return[3,45];case bt.CHANNEL_INVITE:return[3,47];case bt.CHANNEL_DECLINE_INVITE:return[3,49];case bt.TYPING_START:case bt.TYPING_END:return[3,51];case bt.USER_CHANNEL_MUTE:case bt.USER_CHANNEL_UNMUTE:return[3,53];case bt.USER_CHANNEL_BAN:return[3,55];case bt.USER_CHANNEL_UNBAN:return[3,59];case bt.CHANNEL_FREEZE:case bt.CHANNEL_UNFREEZE:return[3,61];case bt.CHANNEL_HIDE:return[3,63];case bt.CHANNEL_UNHIDE:return[3,65];case bt.CHANNEL_DELETED:return[3,67];case bt.CHANNEL_PROP_CHANGED:return[3,69];case bt.CHANNEL_META_DATA_CHANGED:return[3,71];case bt.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case bt.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(pe.channelUrl,!0)];case 40:return fe=Un.sent(),ve=e.as(Dn),me=ve.memberCount,ge=ve.joinedMemberCount,Ee=ve.members,Ce=!1,Ee.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?Ce=Ce||fe._setLatestMemberCount(me,ge,pe.ts):(e.state=Lt.JOINED,fe.addMember(e,pe.ts),Nn._updateJoinedMemberCount(fe)),e.userId===Nn._sdkState.userId&&(fe.myMemberState=Lt.JOINED)})),this._dispatcher.dispatch(new sn({channels:[fe],source:y.EVENT_CHANNEL_JOINED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=v(Ee),s=r.next();!s.done;s=r.next()){var a=s.value;e.onUserJoined&&e.onUserJoined(fe,a)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}fe.isBroadcast&&Ce&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,77];case 41:return(ft=this._leftChannels.get(pe.channelUrl))?(Me=ft.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(pe.channelUrl,!0)];case 43:Me=Un.sent(),Un.label=44;case 44:return ye=Me,be=e.as(Pn),nt=be.memberCount,rt=be.joinedMemberCount,Ne=be.member,He=!1,Ge=k.of(this._iid).appInfo,ye.isExclusive||ye.isSuper||ye.isBroadcast?He=ye._setLatestMemberCount(nt,rt,pe.ts):((null==Ge?void 0:Ge.enabledChannelMemberShipHistory)?((Ve=ye.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=Lt.LEFT),ye.memberCount=nt):ye.removeMember(Ne),this._updateJoinedMemberCount(ye)),Ne.userId===this._sdkState.userId?(ye.myMemberState=Lt.NONE,ye.invitedAt=0,ye.joinedAt=0,ye._updateUnreadCount(0,0),ye.isPublic?this._dispatcher.dispatch(new sn({channels:[ye],source:y.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ye),this._dispatcher.dispatch(new an({channelUrls:[ye.url],source:y.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new sn({channels:[ye],source:y.EVENT_CHANNEL_LEFT})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(ye,Ne),ye.isBroadcast&&He&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(pe.channelUrl,!0)];case 46:Be=Un.sent(),qe=e.as(Nt).operators,We=qe.map((function(e){return e.userId}));try{for(je=v(Be.members),ze=je.next();!ze.done;ze=je.next())(pt=ze.value).role=We.includes(pt.userId)?a.OPERATOR:a.NONE}catch(e){gn={error:e}}finally{try{ze&&!ze.done&&(En=je.return)&&En.call(je)}finally{if(gn)throw gn.error}}return Be.myRole=We.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new sn({channels:[Be],source:y.EVENT_CHANNEL_OPERATOR_UPDATED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Be,qe)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(pe.channelUrl,!0)];case 48:Qe=Un.sent(),Ye=e.as(kn),nt=Ye.memberCount,rt=Ye.joinedMemberCount,Ke=Ye.inviter,(Je=Ye.invitees).forEach((function(e){return e.state=Lt.INVITED}));try{for(Xe=v(Je),Ze=Xe.next();!Ze.done;Ze=Xe.next())$e=Ze.value,Qe.isExclusive||Qe.isSuper||Qe.isBroadcast?Qe._setLatestMemberCount(nt,rt,pe.ts):Qe.addMember($e,pe.ts),this._sdkState.userId===$e.userId&&(Qe.hiddenState=is.UNHIDDEN,Qe.myMemberState!==Lt.JOINED&&(Qe.myMemberState=Lt.INVITED),Qe.invitedAt=pe.ts)}catch(e){Cn={error:e}}finally{try{Ze&&!Ze.done&&(yn=Xe.return)&&yn.call(Xe)}finally{if(Cn)throw Cn.error}}return this._dispatcher.dispatch(new sn({channels:[Qe],source:y.EVENT_CHANNEL_INVITED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Qe,Ke,Je)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(pe.channelUrl,!0)];case 50:return et=Un.sent(),tt=e.as(xn),nt=tt.memberCount,rt=tt.joinedMemberCount,st=tt.inviter,at=tt.invitee,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(nt,rt,pe.ts):et.removeMember(at),this._sdkState.userId===at.userId?(et.invitedAt=0,et.myMemberState=Lt.NONE,et.isPublic?this._dispatcher.dispatch(new sn({channels:[et],source:y.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new an({channelUrls:[et.url],source:y.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new sn({channels:[et],source:y.EVENT_CHANNEL_DECLINED_INVITE})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(et,st,at)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(pe.channelUrl,!0)];case 52:return it=Un.sent(),ot=pe.category===bt.TYPING_START,ut=e.as(ot?Wn:zn).user,it._updateTypingStatus(ut,ot?pe.ts:0),this._dispatcher.dispatch(new sn({channels:[it],source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(it)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(pe.channelUrl,!0)];case 54:ct=Un.sent(),lt=pe.category===bt.USER_CHANNEL_MUTE,(ht=e.as(lt?we:De).user).userId===this._sdkState.userId&&(ct.myMutedState=lt?V.MUTED:V.UNMUTED,ct._myMutedRemainingTime=ht.restrictionInfo.remainingDuration);try{for(dt=v(ct.members),_t=dt.next();!_t.done;_t=dt.next())if((pt=_t.value).userId===ht.userId){pt.isMuted=lt;break}}catch(e){Mn={error:e}}finally{try{_t&&!_t.done&&(bn=dt.return)&&bn.call(dt)}finally{if(Mn)throw Mn.error}}return this._dispatcher.dispatch(new sn({channels:[ct],source:lt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,data:ht.userId})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){lt?e.onUserMuted&&e.onUserMuted(ct,ht):e.onUserUnmuted&&e.onUserUnmuted(ct,ht)})),[2]}))}))})),[3,77];case 55:return(ft=this._leftChannels.get(pe.channelUrl))?(Ct=ft.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(pe.channelUrl,!0)];case 57:Ct=Un.sent(),Un.label=58;case 58:return vt=Ct,this._markAsLeave(vt),Mt=e.as(Ie).user,Mt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new an({channelUrls:[vt.url],source:y.EVENT_CHANNEL_BANNED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(vt,Mt)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(pe.channelUrl,!0)];case 60:return Dt=Un.sent(),Pt=e.as(Ae).user,Pt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new an({channelUrls:[Dt.url],source:y.EVENT_CHANNEL_UNBANNED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Dt,Pt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(pe.channelUrl,!0)];case 62:return Rt=Un.sent(),Ft=e.as(Te).freeze,Rt.isFrozen=Ft,this._dispatcher.dispatch(new sn({channels:[Rt],source:Ft?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ft?e.onChannelFrozen&&e.onChannelFrozen(Rt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Rt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(pe.channelUrl,!0)];case 64:return kt=Un.sent(),Ot=e.as(Bn),xt=Ot.allowAutoUnhide,Ht=Ot.hidePreviousMessages,Gt=Ot.messageOffsetTimestamp,null!==xt&&(kt.hiddenState=xt?is.HIDDEN_ALLOW_AUTO_UNHIDE:is.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ht&&Ht&&kt._updateUnreadCount(0,0),null!==Gt&&(kt.messageOffsetTimestamp=Gt),this._dispatcher.dispatch(new sn({channels:[kt],source:y.EVENT_CHANNEL_HIDDEN})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(kt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(pe.channelUrl,!0)];case 66:return(Vt=Un.sent()).hiddenState=is.UNHIDDEN,this._dispatcher.dispatch(new sn({channels:[Vt],source:y.EVENT_CHANNEL_UNHIDDEN})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Vt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(pe.channelUrl,!0)];case 68:return Bt=Un.sent(),this._dispatcher.dispatch(new an({channelUrls:[pe.channelUrl],source:y.EVENT_CHANNEL_DELETED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(pe.channelUrl,!0)];case 70:return qt=Un.sent(),this._dispatcher.dispatch(new sn({channels:[qt],source:y.EVENT_CHANNEL_UPDATED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(qt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(pe.channelUrl,!0)];case 72:return Wt=Un.sent(),jt=e.as(Se),zt=jt.created,Qt=jt.updated,Yt=jt.deleted,zt&&(Wt._upsertCachedMetaData(zt,pe.ts),this._dispatcher.dispatch(new sn({channels:[Wt],source:y.EVENT_CHANNEL_METADATA_CREATED}))),Qt&&(Wt._upsertCachedMetaData(Qt,pe.ts),this._dispatcher.dispatch(new sn({channels:[Wt],source:y.EVENT_CHANNEL_METADATA_UPDATED}))),Yt&&(Wt._removeFromCachedMetaData(Yt,pe.ts),this._dispatcher.dispatch(new sn({channels:[Wt],source:y.EVENT_CHANNEL_METADATA_DELETED}))),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated&&e.onMetaDataCreated(Wt,zt),Qt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Wt,Qt),Yt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Wt,Yt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(pe.channelUrl,!0)];case 74:return Kt=Un.sent(),Jt=e.as(Ue),Xt=Jt.created,Zt=Jt.updated,$t=Jt.deleted,Xt&&this._dispatcher.dispatch(new sn({channels:[Kt],source:y.EVENT_CHANNEL_METACOUNTER_CREATED})),Zt&&this._dispatcher.dispatch(new sn({channels:[Kt],source:y.EVENT_CHANNEL_METACOUNTER_UPDATED})),$t&&this._dispatcher.dispatch(new sn({channels:[Kt],source:y.EVENT_CHANNEL_METACOUNTER_DELETED})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Xt&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,Xt),Zt&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,Zt),$t&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,$t)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(pe.channelUrl,!0)];case 76:return en=Un.sent(),tn=e.as(Kn),nn=tn.pinnedMessageIds,rn=tn.latestPinnedMessage,(on=tn.ts)>en._pinnedMessagesUpdatedAt&&(en.pinnedMessageIds=nn,en.lastPinnedMessage=rn,en._pinnedMessagesUpdatedAt=on,this._dispatcher.dispatch(new sn({channels:[en],source:y.EVENT_PINNED_MESSAGE_UPDATED})),G((function(){return p(Nn,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(en)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),G((function(){return p(Nn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(en)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((un=e.as(mt).event).category){case gt.USER_BLOCK:cn=Et.getDataAsUserBlockEvent(this._iid,un),hn=cn.blocker,dn=cn.blockee,this._groupChannelCache.block(hn.userId,dn.userId);break;case gt.USER_UNBLOCK:ln=Et.getDataAsUserBlockEvent(this._iid,un),hn=ln.blocker,dn=ln.blockee,this._groupChannelCache.unblock(hn.userId,dn.userId)}return[3,79];case 79:return[3,81];case 80:if(_n=Un.sent(),H(_n))throw _n;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Lt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:l(g("string",e)).throw(h.invalidParameters),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=r.sent())?[2,n]:[3,4];case 3:return r.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,r.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,r,s,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(hn).channel,a=s.unreadMessageCount,i=s.unreadMentionCount,s.myCountPreference){case as.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case as.UNREAD_MENTION_COUNT_ONLY:a=0;break;case as.OFF:a=0,i=0}return s._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([s])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),p(this,void 0,void 0,(function(){var r,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(a=s.as(hn).channel).myMemberState!==Lt.NONE?[3,2]:(this._dispatcher.dispatch(new an({channelUrls:[a.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([a])];case 3:i=u.sent(),this._dispatcher.dispatch(new sn({channels:i,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==z.NON_AUTHORIZED&&o.code!==z.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new an({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,s){return void 0===s&&(s=y.REQUEST_CHANNEL),p(this,void 0,void 0,(function(){var a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:return t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3)),a=new _n(r(r({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(a)];case 1:return i=l.sent(),o=i.as(pn),u=o.channels,c=o.token,this._dispatcher.dispatch(new sn({channels:u,source:s})),[2,{channels:u,token:c}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,s){return void 0===s&&(s=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=r(r({},Yt),t),l((g("string",e)||g("number",e))&&Kt(a)).throw(h.invalidParameters),i=new un(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(cn),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new sn({channels:c,source:s,ts:p})),d.length>0&&this._dispatcher.dispatch(new an({channelUrls:d,source:s})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,s;return f(this,(function(a){switch(a.label){case 0:return t=r(r({},Jt),e),l(Xt(t)).throw(h.invalidParameters),n=new fn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return s=a.sent(),[2,s.as(vn).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,s,a,i,o,u,c,d,_,p,v,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=r(r({},Zt),e),l(function(e){return m(qt,e.keys)}(n)).throw(h.invalidParameters),s=k.of(this._iid),a=s.sdkState,i=s.requestQueue,o=new mn({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(gn),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,v=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:v,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){switch(a.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new En({userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),[2,s.as(Cn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=r(r({},$t),e),l(en(t)).throw(h.invalidParameters),n=k.of(this._iid),s=n.sdkState,a=n.requestQueue,i=new yn({userId:s.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(Mn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=r(r({},tn),e),l(function(e){return g("string",e.channelUrl,!0)&&m(ve,e.scheduledStatus,!0)&&s(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=k.of(this._iid).requestQueue,a=new bn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(Nn).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=k.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=k.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=k.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a;return f(this,(function(i){switch(i.label){case 0:return t=r(r({},zt),e),l(Qt(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Sn(r({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return s=i.sent(),a=s.as(Tn).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new An({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=v(n),s=r.next();!s.done;s=r.next())(a=s.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(m("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new An({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),r=this._groupChannelCache.channels,s=[];try{for(a=v(r),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),s.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return s.length>0?[4,this.upsertChannelsToCache(s)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u}(Mt);!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}($n||($n={}));var rr,sr=function(t){function n(e,n,r,s){var a=t.call(this)||this;return a._state=$n.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===$n.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===$n.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===$n.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(null===(l=this._metadata)||void 0===l?void 0:(a=l.range).intersect.apply(a,d([],_(r),!1)))?this.extendRange(n):this._metadata={range:new Dt({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(null===(c=this._metadata)||void 0===c?void 0:(a=c.range).intersect.apply(a,d([],_(r),!1)))?this.extendRange(n):this._metadata={range:new Dt({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.bottom),v.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return l.sent(),[3,6];case 5:throw s=l.sent(),v.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof K)if(e.stateType===J.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return ar[t]||(ar[t]={}),ar[t][n.url]||(ar[t][n.url]=new e({_iid:t,channel:n})),ar[t][n.url].ref++,ar[t][n.url]},e.clear=function(e,t){ar[e]&&ar[e][t]&&(ar[e][t].close(),delete ar[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Dt({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,k.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&this._metadata&&(this._metadata.token=a),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return i=c.sent(),o.debug("message changelog sync error",i),i instanceof h&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw i;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof K)if(e.stateType===J.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return or[t]||(or[t]={}),or[t][n.url]||(or[t][n.url]=new e({_iid:t,channel:n})),or[t][n.url].ref++,or[t][n.url]},e.clear=function(e,t){or[e]&&or[e][t]&&(or[e][t].close(),delete or[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=k.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,k.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,k.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=k.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=k.of(this._iid),t=e.logger;e.connectionManager,t.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete or[this._iid][this._channel.url])},e}(),cr={},lr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=k.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new sr(d,(function(){return p(s,void 0,void 0,(function(){var e,t,n,s,a,i,o,c;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return l.sent(),u.debug("poll changelog sync from",null===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=k.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Z.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),a=s.hasMore,i=s.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof K)if(e.stateType===J.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cr[t][n.url].ref++,cr[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,k.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:void 0,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,k.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,k.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){k.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){k.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),hr=function(t){function n(e){var n=e.channels,r=e.source,s=e.isWebSocketEventComing,a=void 0!==s&&s,i=e.data,o=void 0===i?null:i,u=t.call(this)||this;return u.channels=n,u.source=r,u.isWebSocketEventComing=a,u.data=o,u}return e(n,t),n}(M),dr=function(t){function n(e){var n=e.channelUrls,r=e.source,s=e.isWebSocketEventComing,a=void 0!==s&&s,i=t.call(this)||this;return i.channelUrls=n,i.source=r,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),_r=function(n){function r(e){var r,s,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat($(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(r=e.threshold)&&void 0!==r?r:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:X.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(r,n),r}(S),pr=function(t){function n(e,n){var r,s,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return ge(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return ge(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(T),fr=function(e,t){return t instanceof Re?e.findIndex((function(e){return e instanceof Re&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},mr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(a<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},gr=function(e){this.source=e},Er=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(gr),Cr=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(gr),yr=function(e){this.source=e},Mr=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(yr),br=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(yr),Nr=6e5,Ur={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(rr||(rr={}));var Sr,Tr,Ar,Ir=function(){function e(){this._onCacheResult=ae,this._onApiResult=ae}return e.prototype._invokeResponse=function(e,t,n){var r=this;G((function(){return p(r,void 0,void 0,(function(){return f(this,(function(r){switch(e){case"local":this._onCacheResult(t,n);break;case"remote":this._onApiResult(t,n)}return[2]}))}))}))},e.prototype.onCacheResult=function(e){return this._onCacheResult=e,this},e.prototype.onApiResult=function(e){return this._onApiResult=e,this},e}(),wr=function(){function e(e,t){var n=t.filter,r=t.startingPoint,s=t.limit,a=t.channel,i=t.channelManager,o=this;this._messages=[],this._unsentMessages=[],this._iid=e,this._key="mc-".concat(re()),this._isDisposed=!1,this.filter=null!=n?n:new be,this._channel=a,this._syncRange=new Dt({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof r?r:Date.now()+Nr,this._limit=s||Ge,this._channelManager=i,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t,n){var r=e.findIndex((function(e){return e.isIdentical(o.channel)}));r>=0&&(o._replaceChannelOfCollection(e[r]),o.channel._runIfHandleableWithGroupChannel((function(e){switch(t){case y.EVENT_CHANNEL_UPDATED:var r=!1;for(var s in o._messages){if(o._messages[s].createdAt>=e.messageOffsetTimestamp){r=!0;var a=parseInt(s);if(a>0){var i=o._messages.splice(0,a);o._removeMessagesFromView(i.map((function(e){return e.messageId})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!r&&o._messages.length>0&&o._removeMessagesFromView(o._messages.map((function(e){return e.messageId})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var u=k.of(o._iid).sdkState,c=n;u.userId===c&&o._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:u=k.of(o._iid).sdkState;var l=n;u.userId===l&&-1!==e._myMutedRemainingTime&&o._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&o._clearCheckMyMutedTimer()}G((function(){return p(o,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=this._createChannelEventContext(t),rn(t)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(e,this.channel),[2]}))}))}))})))},onRemove:function(e,t){e.indexOf(o.channel.url)>=0&&(o._clearCheckMyMutedTimer(),G((function(){return p(o,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=this._createChannelEventContext(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],a=[];try{for(var i=v(e),u=i.next();!u.done;u=i.next()){var c=u.value;c.channelUrl===o._channel.url&&(o.filter.match(c)?s.push(c):a.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}if(ee(t)){if(s.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.SYNC_MESSAGE_CHANGELOGS:o._updateMessagesToView(s,t);break;case y.EVENT_MESSAGE_SENT_PENDING:o._addMessagesToView(s,t);break;case y.EVENT_MESSAGE_RECEIVED:o.hasNext||o._addMessagesToView(s,t);break;case y.SYNC_MESSAGE_FILL:o._addMessagesToView(s,t)}a.length>0&&o._removeMessagesFromView(a,t)}},onRemove:function(e,t){o._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){o._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){o._updatePollsToView(e,t)},onPollUpdate:function(e,t){o._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){o._applyPollVoteEventToView(e,t)}});var u=k.of(this._iid),c=u.cacheContext,l=u.dispatcher,h=u.logger;this._channel._updateMessageCollectionLastAccessedAt();var m=this._createChannelUpdateEventCommand(y.CHANNEL_LASTACCESSEDAT_UPDATED);m&&l.dispatch(m),this._shouldStartBackgroundSync()&&(this._backgroundSync=ir.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ur.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=lr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new sr(this._key,(function(e){return p(o,void 0,void 0,(function(){var t,n,r,s,a;return f(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=i.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof K)switch(e.stateType){case J.CONNECTED:o._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS),b((function(){return p(o,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),h.debug("check huge gap"),o._checkHugeGap();break;case J.LOGOUT:o.dispose();break;default:o._clearCheckMyMutedTimer(),o._prevFill.stop(),o._nextFill.stop()}})),k.of(this._iid).statLogCollector.put(new te({type:ne.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===se.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===se.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=k.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._createChannelEventContext=function(e){switch(!0){case this.channel.isGroupChannel():return new Er(e);case this.channel.isFeedChannel():return new Cr(e);default:throw new h({code:z.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}},e.prototype._createMessageEventContext=function(e){switch(!0){case this.channel.isGroupChannel():return new Mr(e);case this.channel.isFeedChannel():return new br(e);default:throw new h({code:z.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}},e.prototype._createChannelUpdateEventCommand=function(e){switch(!0){case this.channel.isGroupChannel():return new sn({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new hr({channels:[this._channel],source:e});default:return null}},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=v(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=fr(this._messages,l))<0){fr(this._unsentMessages,l)<0&&i.push(l);var h=mr(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Re){(E=fr(this._unsentMessages,l))<0&&fr(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=fr(this._messages,l))<0){var m=fr(this._unsentMessages,l);m<0?i.push(l):(this._unsentMessages.splice(m,1),o.push(l));h=mr(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof Re){var E;(E=fr(this._unsentMessages,l))<0?fr(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}ee(t)&&G((function(){return p(s,void 0,void 0,(function(){var e,n,r,s,a;return f(this,(function(u){return e=this._createMessageEventContext(t),i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(s=this._handler)||void 0===s?void 0:s.onMessagesUpdated)||void 0===a||a.call(s,e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,a=[];try{for(var i=v(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=vr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return a.length>0&&ee(t)&&G((function(){return p(s,void 0,void 0,(function(){var e,n,r;return f(this,(function(s){return e=this._createMessageEventContext(t),a.length>0&&(null===(r=(n=this._handler).onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&ee(t)&&G((function(){return p(n,void 0,void 0,(function(){var e,n,r;return f(this,(function(a){return e=this._createMessageEventContext(t),null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&ee(t)&&G((function(){return p(n,void 0,void 0,(function(){var e,n,r;return f(this,(function(a){return e=this._createMessageEventContext(t),null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,a=[],i=[],o=[];try{for(var u=v(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=fr(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var m=fr(this._unsentMessages,h);if(m>=0){var g=this._unsentMessages.splice(m,1);if(this.hasNext&&g.length>0)o.push(g[0]);else{i.push(h);var E=mr(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof Re)(l=fr(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return ee(t)&&G((function(){return p(s,void 0,void 0,(function(){var e,n,r,s,u;return f(this,(function(c){return e=this._createMessageEventContext(t),i.length>0?null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i):o.length>0?null===(u=null===(s=this._handler)||void 0===s?void 0:s.onMessagesDeleted)||void 0===u||u.call(s,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];a.push(n.messageId),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return ee(t)&&i.length>0&&G((function(){return p(s,void 0,void 0,(function(){var e,n,r;return f(this,(function(s){return e=this._createMessageEventContext(t),null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===r||r.call(n,e,this.channel,a,i),[2]}))}))})),a},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,a=void 0===s?0:s,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,s,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return r>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1)]:[3,4];case 3:return s=c.sent(),[3,5];case 4:s=[],c.label=5;case 5:return n=s,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var s=t.prevLimit,a=void 0===s?0:s,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingContinuousMessages,_=void 0!==d&&d;return p(this,void 0,void 0,(function(){var t,s;return f(this,(function(i){switch(i.label){case 0:return t=He.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(r(r(r({},this.filter),Ur),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_)]:[3,2];case 1:return s=i.sent(),[3,3];case 2:s={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,s]}}))}))},e.prototype._checkHugeGap=function(){var e;return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u,c,l,v,m,g,E,C,M,b,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,s=this._syncRange.bottom,a=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return i=A.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,s,a)];case 2:return o=A.sent(),[4,ie((function(){return p(T,void 0,void 0,(function(){var e,u,c,l,h,v,m,g,E,C,M,b,N,U,S,T,A,I,w,D,L,P=this;return f(this,(function(R){switch(R.label){case 0:return e=k.of(this._iid),u=e.dispatcher,c=e.requestQueue,l=e.cacheContext,h=new _r(r(r({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:i,nextStart:s,nextEnd:a,nextCount:o,checkingContinuousMessages:l.localCacheEnabled},this.filter),Ur)),[4,c.send(h)];case 1:return v=R.sent(),m=v.as(pr),g=m.isHugeGap,E=m.prevMessages,C=void 0===E?[]:E,M=m.prevHasMore,b=m.isContinuousPrevMessages,N=m.nextMessages,U=void 0===N?[]:N,S=m.nextHasmore,T=m.isContinuousNextMessages,g?G((function(){return p(P,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(A=this.viewTop,I=this.viewBottom,w=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,A],_(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,d([0,I],_(U.map((function(e){return e.createdAt}))),!1)),u.dispatch(new W({messages:C,source:y.SYNC_MESSAGE_FILL})),u.dispatch(new W({messages:U,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||T)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),M&&this._prevFill.start(w),S&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return A.sent(),[3,8];case 4:u=k.of(this._iid).cacheContext,c=Math.floor(this._limit/2),l=Date.now(),A.label=5;case 5:return A.trys.push([5,7,,8]),[4,this._getRemoteMessages(l,{prevLimit:c,nextLimit:c,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled})];case 6:if(v=A.sent(),m=v.messages,g=v.isContinuousMessages,m.length>0){for(E=m.map((function(e){return e.createdAt})),C=0,M=0,b=0;b=l&&M++;this._hasPrevious=C>=c,this._hasNext=M>=c,(S=this._syncRange).extends.apply(S,d([],_(E),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(U=A.sent())instanceof h&&U.code===z.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+Nr,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){this._channelManager.refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n=this;return f(this,(function(r){switch(r.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=r.sent(),e=!t.isMuted,[3,5];case 3:return r.sent(),e=!0,[3,5];case 4:return e&&this.channel._runIfHandleableWithGroupChannel((function(e){var t,r;e.myMutedState=V.UNMUTED;var s=n._createChannelEventContext(y.EVENT_CHANNEL_UNMUTED);null===(r=null===(t=n._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===r||r.call(t,s,n.channel)})),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype.initialize=function(e){var t=this,n=new Ir;this._messages=[],this._unsentMessages=[],this._syncRange=new Dt({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(y.REFRESH_CHANNEL),b((function(){return p(t,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===rr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return p(t,void 0,void 0,(function(){var t;return f(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(H(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=k.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,a,i=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(i);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,h=0,p=0;pt._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,d([],_(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(a=t._backgroundSync)||void 0===a||a.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,y.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(H(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=k.of(this._iid),a=s.cacheContext;return s.statLogCollector.put(new te({type:ne.FEATURE_LOCALCACHE,data:{use_local_cache:a.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return p(this,void 0,void 0,(function(){var e,t,n,r=this;return f(this,(function(s){switch(s.label){case 0:if(this._isDisposed)throw new h({code:z.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasPrevious?(e=Math.floor(this._limit/2),t=this.viewTop,n=[],[4,b((function(){return p(r,void 0,void 0,(function(){var r;return f(this,(function(s){switch(s.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{prevLimit:e,inclusive:!1})];case 1:return n=r.apply(this,[s.sent()]),[2]}}))}))}))]):[2,[]];case 1:return s.sent(),n.length=e,n.length>0&&((a=this._syncRange).extends.apply(a,d([],_(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&s.isContinuousMessages&&(null===(o=this._backgroundSync)||void 0===o||o.range.extends(this._syncRange.top))),[2]}}))}))}))]:[3,3];case 2:return s.sent(),this._addMessagesToView(n,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=n.length>=e,n.length>0&&this._addMessagesToView(n,y.REQUEST_MESSAGE),s.label=4;case 4:return[2,n]}}))}))},e.prototype.loadNext=function(){var e;return p(this,void 0,void 0,(function(){var t,n,r,s=this;return f(this,(function(a){switch(a.label){case 0:if(this._isDisposed)throw new h({code:z.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasNext?(t=Math.floor(this._limit/2),n=this.viewBottom,r=[],[4,b((function(){return p(s,void 0,void 0,(function(){var e;return f(this,(function(s){switch(s.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(n,{nextLimit:t,inclusive:!1})];case 1:return r=e.apply(this,[s.sent()]),[2]}}))}))}))]):[2,[]];case 1:return a.sent(),r.length=t,r.length>0&&((a=this._syncRange).extends.apply(a,d([],_(r.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&s.isContinuousMessages&&(null===(o=this._backgroundSync)||void 0===o||o.range.extends(this._syncRange.bottom))),[2]}}))}))}))]:[3,3];case 2:return a.sent(),this._addMessagesToView(r,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=r.length>=t,r.length>0&&this._addMessagesToView(r,y.REQUEST_MESSAGE),a.label=4;case 4:return[2,r]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:z.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n,r=this;if(!this._isDisposed){this._isDisposed=!0;var s=k.of(this._iid),a=s.cacheContext,i=s.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(e){if(e.myMemberState!==Lt.NONE){r._channel._updateMessageCollectionLastAccessedAt();var t=r._createChannelUpdateEventCommand(y.CHANNEL_LASTACCESSEDAT_UPDATED);t&&i.dispatch(t)}})),a.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Dr=function(t){function n(e,n){return t.call(this,e,r(r({},n),{channelManager:nr.of(e)}))||this}return e(n,t),n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n}(wr),Lr={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},Pr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:a,order:i,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(S),Rr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.members=[];var s=n.next,a=n.members;return r.token=s,a&&a.length>0&&(r.members=a.map((function(t){return new Vt(e,t)}))),r}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Sr||(Sr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Tr||(Tr={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Ar||(Ar={}));var Fr=function(t){function a(e,n,r){var s,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,r)||this).mutedMemberFilter=Sr.ALL,c.memberStateFilter=Ar.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=xt.ALL,c.order=Tr.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Sr.ALL,c.memberStateFilter=null!==(a=r.memberStateFilter)&&void 0!==a?a:Ar.ALL,c.nicknameStartsWithFilter=null!==(o=r.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=r.order)&&void 0!==u?u:Tr.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&s(Sr,this.mutedMemberFilter)&&s(Ar,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&s(xt,this.operatorFilter)&&s(Tr,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=k.of(this._iid).requestQueue,t=new Pr(n(r(r({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return s=u.sent(),a=s.as(Rr),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(oe),kr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:a},n}return e(n,t),n}(S),Or=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new hs(e,n),r.channel.myMemberState=Lt.JOINED,r}return e(n,t),n}(T),xr=function(n){function r(e){var r=this,s=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(r=n.call(this)||this).method=N.PUT,r.path="".concat(I,"/").concat(encodeURIComponent(s)),r.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),r}return e(r,n),r}(S),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new hs(e,n),r}return e(n,t),n}(T),Gr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Vr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var Br=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),a.params={count_preference:s},a}return e(n,t),n}(S),qr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(T),Wr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(S),jr=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(T),zr=r(r({},Ve),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Qr=r(r({},qe),{scheduledAt:void 0}),Yr=function(r){function s(e){var s,a=this;a=r.call(this)||this;var i=[];e.mentionType===ue.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat($(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:ce.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return je.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((function(e){return ze.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?Qe.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),a}return e(s,r),s}(S),Kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Me(e,n),r}return e(n,t),n}(T),Jr=function(r){function s(e){var s,a=this;a=r.call(this)||this;var i=[];e.mentionType===ue.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat($(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:ce.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((function(e){return ze.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?Qe.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(s,r),s}(S);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new ye(e,n),r}e(n,t)}(T);var Xr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat($(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),Zr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat($(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),$r=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),a.params={push_trigger_option:s},a}return e(n,t),n}(S),es=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(T),ts=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(S),ns=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(T),rs=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,a=t.call(this)||this;return a.method=N.POST,a.path="".concat($(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var ss=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,a=t.call(this)||this;return a.method=N.DELETE,a.path="".concat($(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),a}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var as,is,os=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=ge(e,n.message),r}return e(n,t),n}(u),us=function(n){function r(e){var r=this,s=e.channelType,a=e.channelUrl,i=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(r=n.call(this)||this).method=N.GET,r.path="".concat($(s),"/").concat(encodeURIComponent(a),"/pinned_messages"),r.params=t({limit:i,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),r}return e(r,n),r}(S),cs=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.pinned_messages,a=n.has_more,i=n.next;return r.pinnedMessages=s.map((function(t){return new os(e,t)})),r.hasMore=a,r.token=i,r}return e(n,t),n}(T),ls=function(t){function n(e,n,r,s){var a=t.call(this,e,n,r,s)||this;return a.includeMetaArray=s.includeMetaArray,a.includeReactions=s.includeReactions,a.includeParentMessageInfo=s.includeParentMessageInfo,a.includeThreadInfo=s.includeThreadInfo,a.includePollDetails=s.includePollDetails,a}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeMetaArray,!0)&&g("boolean",this.includeReactions,!0)&&g("boolean",this.includeParentMessageInfo,!0)&&g("boolean",this.includeThreadInfo,!0)&&g("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=k.of(this._iid).requestQueue,t=new us(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),s=n.as(cs),a=s.pinnedMessages,i=s.hasMore,o=s.token,this._token=o,this._hasNext=!!i,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},n}(oe);!function(e){e.ALL="all",e.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",e.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",e.OFF="off"}(as||(as={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(is||(is={}));var hs=function(u){function c(e,t){var n,c,l,h,p,f,v,m,E,C,y,M,b,N,U,S,T,A,I,w,D=this;return(D=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,D._undeliveredMemberStateMap=new Map,D._typingStatus=new Map,D._lastMemberCountUpdated=0,D._typingStarted=0,D._typingEnded=0,D.isDistinct=!1,D.isSuper=!1,D.isBroadcast=!1,D.isExclusive=!1,D.isPublic=!1,D.isDiscoverable=!0,D.isChatNotification=!1,D.isAccessCodeRequired=!1,D.isPushEnabled=!1,D.unreadMessageCount=0,D.unreadMentionCount=0,D.members=[],D.memberCount=0,D.joinedMemberCount=0,D.hiddenState=is.UNHIDDEN,D.lastMessage=null,D.messageOffsetTimestamp=0,D.messageSurvivalSeconds=-1,D.myMemberState=Lt.NONE,D.myRole=a.NONE,D.myMutedState=V.UNMUTED,D.myLastRead=0,D.myCountPreference=as.ALL,D.myPushTriggerOption=he.DEFAULT,D.inviter=null,D.invitedAt=0,D.joinedAt=0,D.pinnedMessageIds=[],D.lastPinnedMessage=null,D._pinnedMessagesUpdatedAt=0,D._myMutedRemainingTime=-1,D.channelType=i.GROUP,D.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,D.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,D.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,D.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,D.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,D.isDiscoverable=null!==(v=t.is_discoverable)&&void 0!==v?v:D.isPublic,D.isChatNotification=null!==(m=t.is_chat_notification)&&void 0!==m&&m,D.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,D.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=D.members).push.apply(n,d([],_(t.members.map((function(e){return new Vt(D._iid,e)}))),!1)),D.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,D.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,D.hiddenState=s(is,t.hidden_state)?t.hidden_state:is.UNHIDDEN,D.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,D.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,D.lastMessage=t.last_message?ge(D._iid,r({channel_type:D.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&D._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&D._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),D.myMemberState=s(Lt,t.member_state)?t.member_state:Lt.NONE,D.myRole=s(a,t.my_role)?t.my_role:a.NONE,s(V,t.is_muted)?D.myMutedState=t.is_muted:g("boolean",t.is_muted)?D.myMutedState=t.is_muted?V.MUTED:V.UNMUTED:D.myMutedState=V.UNMUTED,D.myCountPreference=s(as,t.count_preference)?t.count_preference:as.ALL,D.myPushTriggerOption=s(he,t.push_trigger_option)?t.push_trigger_option:he.ALL,D.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,D.inviter=t.inviter?new o(D._iid,t.inviter):null,D.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,D.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,D._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),D.pinnedMessageIds=null!==(w=t.pinned_message_ids)&&void 0!==w?w:[],D.lastPinnedMessage=t.latest_pinned_message?ge(D._iid,r({channel_type:D.channelType},t.latest_pinned_message)):null,D}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==is.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var a=_(s.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var a=_(s.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(r(r({},u.payloadify.call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return Vt.payloadify(e)})),last_message:e.lastMessage?Ye(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?Ye(e.lastPinnedMessage):null})))},c.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Re&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===as.ALL||this.myCountPreference===as.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=k.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=n&&e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===as.ALL||this.myCountPreference===as.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},c.prototype.isReadMessage=function(e){var t=k.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Dr(this._iid,r(r({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Fr(this._iid,this.url,e)},c.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new ls(this._iid,this.url,this.channelType,e)},c.prototype.addMember=function(e,t){if(void 0===t&&(t=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n=this.members.findIndex((function(t){return t.userId===e.userId}));if(n>-1){var r=this.members[n];r.state===Lt.JOINED&&(e.state=r.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof Vt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof Re&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=k.of(this._iid).sdkState,s=e.createdAt,a=0;try{for(var i=v(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Lt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=k.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof Re?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==r.userId&&i.userId!==(null==s?void 0:s.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),r=!0)})),r},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,r,s,a,i;return f(this,(function(o){switch(o.label){case 0:return t=k.of(this._iid),n=t.requestQueue,r=t.dispatcher,s=new ln({channelUrl:this.url}),[4,n.send(s)];case 1:return a=o.sent(),i=a.as(hn).channel,this._update(i),e&&r.dispatch(new sn({channels:[i],source:y.REQUEST_CHANNEL})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),k.of(this._iid).dispatcher.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),k.of(this._iid).dispatcher.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=r(r({},Lr),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&m("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=k.of(this._iid),s=n.dispatcher,a=n.requestQueue,i=new xr(r({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Hr).channel,this._update(u),s.dispatch(new sn({channels:[u],source:y.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,a,i;return f(this,(function(o){switch(o.label){case 0:return l(m("string",e)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Rn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return a=o.sent(),i=a.as(Fn).channel,this._update(i),n.dispatch(new sn({channels:[i],source:y.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new In({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(a)];case 1:return i=u.sent(),(o=i.as(wn).channel).myMemberState=this.myMemberState=Lt.JOINED,this._update(o),n.dispatch(new sn({channels:[o],source:y.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(a){switch(a.label){case 0:return t=k.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Ln({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return a.sent(),this.myMemberState=Lt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new kr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(a)];case 1:return i=u.sent(),(o=i.as(Or).channel).myMemberState=this.myMemberState=Lt.JOINED,this._update(o),n.dispatch(new sn({channels:[o],source:y.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new On({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=Lt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new ot,r=k.of(this._iid).dispatcher,s=Ct.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){t.hiddenState===is.HIDDEN_ALLOW_AUTO_UNHIDE&&(t.hiddenState=is.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),nr.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),r.dispatch(new sn({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=k.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return r=o.sent(),s=!1,!r.silent&&this._shouldUpdateLastMessageWith(r)&&(this.lastMessage=r,s=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===r.messageId&&(this.lastPinnedMessage=r,s=!0,a=!0),s&&(nr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new sn({channels:[this],source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}))),a&&nr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new W({messages:[r],source:y.EVENT_MESSAGE_UPDATED})),[2,r]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new ot,r=k.of(this._iid).dispatcher,s=Ct.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=nr.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),r.dispatch(new sn({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new ot,r=k.of(this._iid).dispatcher,s=Ct.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=nr.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),r.dispatch(new sn({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new Ke,r=k.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var s=nr.of(t._iid);t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),r.dispatch(new sn({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})).onFileUploaded((function(e,t,r,s){n._triggerOnFileUploaded(e,t,r,s)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=k.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return r=o.sent(),s=!1,!r.silent&&this._shouldUpdateLastMessageWith(r)&&(this.lastMessage=r,s=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===r.messageId&&(this.lastPinnedMessage=r,s=!0,a=!0),s&&(nr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new sn({channels:[this],source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}))),a&&nr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new W({messages:[r],source:y.EVENT_MESSAGE_UPDATED})),[2,r]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new ot,r=k.of(this._iid).dispatcher,s=Ct.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=nr.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),r.dispatch(new sn({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof Re&&k.of(this._iid).dispatcher.dispatch(new de({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=r(r({},Hn),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=k.of(this._iid),s=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new Gn(r({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(Vn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?is.HIDDEN_ALLOW_AUTO_UNHIDE:is.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),s.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=k.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Vr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=is.UNHIDDEN,t.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=k.of(this._iid).requestQueue,t=new Gr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Jn({channelUrl:this.url}),[4,r.send(s)];case 1:return a=u.sent(),i=a.as(Xn).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),nr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_READ})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Zn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){return e=k.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new qn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){return e=k.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new jn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},c.prototype.createScheduledUserMessage=function(e){e=r(r({},Je),e),l(Xe(e)).throw(h.invalidParameters);var t=new ot;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,a,i;return f(this,(function(o){switch(o.label){case 0:return n=r(r({},Qr),t),l(function(e){return We(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),s=k.of(this._iid).requestQueue,a=new Jr(r({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,s.send(a)];case 1:return i=o.sent(),[2,i.as(ut).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=r(r({},Ze),e),l($e(e)).throw(h.invalidParameters);var n=Date.now(),s=this._generateRequestId(),a=new ot;return le(ct).then((function(){var r=t._createPendingScheduledFileMessage(e,s,n);G((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(r)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,s,n)})):this._createScheduledFileMessage(e,a,s,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,a;return f(this,(function(i){switch(i.label){case 0:return n=r(r({},zr),t),l(function(e){return Be(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return s=new Yr(r({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,k.of(this._iid).requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(Kr).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Xr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,k.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Zr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,k.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,a;return f(this,(function(i){switch(i.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ts({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=i.sent(),a=s.as(ns).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(s(he,e)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,r=t.sdkState,a=t.requestQueue,i=new $r({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(es).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(s(as,e)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,r=t.sdkState,a=t.requestQueue,i=new Br({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(qr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new sn({channels:[this],source:y.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,a;return f(this,(function(i){switch(i.label){case 0:return e=k.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Wr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=i.sent(),a=s.as(jr).messageOffsetTimestamp,this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt0).throw(h.invalidParameters),t=k.of(this._iid).requestQueue,n=new rs({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},c.prototype.unpinMessage=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return l(g("number",e)&&e>0).throw(h.invalidParameters),t=k.of(this._iid).requestQueue,n=new ss({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},c.prototype._uploadFileAndUpdateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,a,i,o,u,c,l,h;return f(this,(function(d){switch(d.label){case 0:return E(e.file)?(t=k.of(this._iid).requestQueue,n=new ht({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(lt),a=s.url,i=s.fileSize,o=void 0===i?e.fileSize:i,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=a,e.fileSize=o,e.thumbnailSizes=c,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},c.prototype.resendMessage=function(e,t){var n,r=this;if(l(e instanceof Re&&!e.scheduledInfo&&e.isResendable).throw(h.invalidParameters),e.isUserMessage()){var s=null!==(n=e.messageParams)&&void 0!==n?n:et(e),a=new ot;return this._sendUserMessage(s,tt.RESEND,e.reqId).onPending((function(e){a._trigger(e)})).onFailed((function(e,t){a._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),a._trigger(e)})),a}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);l(i).throw(h.invalidParameters);s=nt(e,t);var o=new ot;return this._sendFileMessage(s,tt.RESEND,e.reqId).onPending((function(e){o._trigger(e)})).onFailed((function(e,t){o._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),o._trigger(e)})),o}if(e.isMultipleFilesMessage()){s=e.messageParams;var u=new Ke;return this._sendMultipleFilesMessage(s,tt.RESEND,e.reqId).onPending((function(e){u._trigger(e)})).onFailed((function(e,t){u._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),u._trigger(e)})).onFileUploaded((function(e,t,n,r){u._triggerOnFileUploaded(e,t,n,r)})),u}},c.prototype.copyMessage=function(e,t){var n=this;if(l(e instanceof rt&&t instanceof Re&&t.sendingStatus===se.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(h.invalidParameters),t.isUserMessage()){l(!t.poll).throw(h.notSupportedError);var r=st(t),s=new ot;return e._sendUserMessage(r).onPending((function(e){s._trigger(e)})).onFailed((function(e,t){s._triggerFailed(e,t)})).onSucceeded((function(t){e.isGroupChannel()&&n._tryUpdateLastMessageAndCallEvents(e,t),s._trigger(t)})),s}if(t.isFileMessage()){r=at(t);var a=new ot;return e._sendFileMessage(r).onPending((function(e){a._trigger(e)})).onFailed((function(e,t){a._triggerFailed(e,t)})).onSucceeded((function(t){e.isGroupChannel()&&n._tryUpdateLastMessageAndCallEvents(e,t),a._trigger(t)})),a}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){r=it(t);var i=new Ke;return e._sendMultipleFilesMessage(r,tt.COPY).onPending((function(e){i._trigger(e)})).onFailed((function(e,t){i._triggerFailed(e,t)})).onSucceeded((function(t){n._tryUpdateLastMessageAndCallEvents(e,t),i._trigger(t)})).onFileUploaded((function(e,t,n,r){i._triggerOnFileUploaded(e,t,n,r)})),i}throw h.channelTypeNotSupportedError}},c}(rt);export{ls as A,qt as B,as as C,hr as D,Mn as E,dr as F,nr as G,Ot as H,en as I,yn as J,xn as K,kn as L,Vt as M,Xn as N,xt as O,Pt as P,Ht as Q,Bt as R,sr as S,$t as T,kt as U,Qn as V,wr as W,Jn as X,Cr as Y,br as Z,Wt as a,Er as b,hs as c,Ft as d,Yn as e,Yt as f,Jt as g,Xt as h,zt as i,Qt as j,nn as k,Gt as l,is as m,Tr as n,Fr as o,Lt as p,Ar as q,Rt as r,rn as s,Dr as t,Ir as u,Kt as v,rr as w,Mr as x,Sr as y,os as z}; diff --git a/lib/__bundle-4e23f900.js b/lib/__bundle-4e23f900.js deleted file mode 100644 index 882f11e..0000000 --- a/lib/__bundle-4e23f900.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,e as t,u as n,g as s,O as r,a0 as a,X as i,U as o,a7 as u,a$ as c,s as l,q as h,o as d,p as _,b as p,c as f,r as m,K as v,a as g,i as E,ae as C,T as y,aV as M,N as b,A as N,d as U,f as S,h as T,b0 as A,ao as I,aY as w,W as D,ah as L,aa as R,aE as P,V as k,x as O,Y as F,aA as x,B as H,a_ as G,aC as V,aH as B,az as q,aK as W,ak as j,b1 as z,E as Q,y as Y,z as K,an as J,aD as X,ai as Z,b2 as $,aW as ee,aX as te,m as ne,ac as se,b3 as re,aq as ae,ab as ie,au as oe,al as ue,Q as ce,aJ as le}from"./__bundle-1da35e70.js";import{w as he,N as de,D as _e,E as pe,H as fe,z as me,p as ve,q as ge,J as Ee,K as Ce,G as ye,r as Me,L as be,Q as Ne,T as Ue,V as Se,W as Te,X as Ae,Y as Ie,Z as we,_ as De,$ as Le,a0 as Re,a1 as Pe,a2 as ke,a3 as Oe,a4 as Fe,a5 as xe,a6 as He,a7 as Ge,a8 as Ve,a9 as Be,aa as qe,ab as We,ac as je,ad as ze,ae as Qe,af as Ye,ag as Ke,ah as Je,ai as Xe,t as Ze,aj as $e,ak as et,al as tt,am as nt,an as st}from"./__bundle-0099b2f2.js";import{G as rt,g as at,D as it,c as ot,R as ut,U as ct,a as lt,b as ht,A as dt}from"./__bundle-f4ef8eae.js";import{C as _t,a as pt,b as ft,O as mt,P as vt,M as gt,c as Et,R as Ct,U as yt,A as Mt,T as bt}from"./__bundle-d3df41f8.js";var Nt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Nt||(Nt={}));var Ut,St,Tt,At,It,wt,Dt,Lt,Rt=function(i){function o(e,t){var n=i.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=r(Nt,t.state)?t.state:null,n.role=r(a,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(n.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(n.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(n.isBlockingMe=t.is_blocking_me),n}return e(o,i),o.payloadify=function(e){return t(n(s(s({},i.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))},o}(he),Pt=function(t){function n(e,n){var s,r,a=this;return(a=t.call(this,e)||this).channelUrl=null!==(s=n.channel_url)&&void 0!==s?s:"",a.channelType=null!==(r=n.channel_type)&&void 0!==r?r:i.GROUP,a.reader=new o(a._iid,n.user),a.readAt=n.ts,a}return e(n,t),n}(u);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Ut||(Ut={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(St||(St={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Tt||(Tt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(At||(At={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(It||(It={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(wt||(wt={})),function(e){e.AND="AND",e.OR="OR"}(Dt||(Dt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Lt||(Lt={}));var kt,Ot=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=St.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Tt.ALL,this.publicChannelFilter=Ut.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=At.ALL,this.hiddenChannelFilter=It.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=Dt.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t,n=new e;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(t=this.searchFilter.query)&&void 0!==t?t:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((function(e){n[e]=s[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,s=n.query,r=n.fields;if(s&&r&&r.length>0&&!r.some((function(t){switch(t){case Lt.CHANNEL_NAME:return e.name.toLowerCase().includes(s.toLowerCase());case Lt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(s.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,i=a.userIds,o=a.includeMode,u=a.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(i.length>0)switch(u){case Dt.AND:if(i.some((function(e){return!l.includes(e)})))return!1;break;case Dt.OR:if(i.every((function(e){return!l.includes(e)})))return!1}}else{if(i.includes(t)||i.push(t),e.members.length>i.length)return!1;if(!c(i,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case St.JOINED:if("joined"!==e.myMemberState)return!1;break;case St.INVITED:if("invited"!==e.myMemberState)return!1;break;case St.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case St.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case It.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case It.HIDDEN:if(!e.isHidden)return!1;break;case It.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case It.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===At.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Ut.PUBLIC:if(!e.isPublic)return!1;break;case Ut.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Tt.SUPER:if(!e.isSuper)return!1;break;case Tt.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Ft=function(t){function n(e,n){var s=n.sdkState,r=n.cacheContext,a=t.call(this,e)||this;return a._channels=new Map,a._sdkState=s,a._cacheContext=r,a}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return l(!!e).throw(h.databaseError),e.collection(de)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return Yn.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(l&&l===e.url)return!1;break;case rt.CHRONOLOGICAL:if(!a&&e.createdAt>t||a&&e.createdAtt||a&&e.lastMessageUpdatedAt0?[4,this.upsert(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,s,r,a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),s=m(t),r=s.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[4,this.get(a)]);case 3:(null==(i=l.sent())?void 0:i._updateUnreadMemberState(this._sdkState.userId,e))&&(i._updateUnreadCount(0,0),n.push(i)),l.label=4;case 4:return r=s.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{r&&!r.done&&(c=s.return)&&c.call(s)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}}))}))},n}(u),xt={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},Ht=function(e){return v("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Gt={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},Vt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)&&g("boolean",e.includeChatNotification)},Bt={myMemberStateFilter:St.ALL},qt=function(e){return r(St,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(kt||(kt={}));var Wt={keys:[]},jt={channelCustomTypesFilter:void 0,superChannelFilter:Tt.ALL},zt=function(e){return v("string",e.channelCustomTypesFilter,!0)&&r(Tt,e.superChannelFilter)},Qt={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:C.ALL},Yt=s({},y),Kt=function(e){return e.startsWith("EVENT_")||e===y.SYNC_CHANNEL_CHANGELOGS||e===y.REFRESH_CHANNEL},Jt=function(t){function n(e){var n=e.channels,s=e.source,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.data,o=void 0===i?null:i,u=e.ts,c=t.call(this)||this;return c.channels=n,c.source=s,c.isWebSocketEventComing=a,c.data=o,c.ts=u,c}return e(n,t),n}(M),Xt=function(t){function n(e){var n=e.channelUrls,s=e.source,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.source=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),Zt=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,s=e.unsentMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return p(a,void 0,void 0,(function(){var r,a,i,o,u,c,l,h,d,_,v,g,E,C,y=this;return f(this,(function(M){switch(M.label){case 0:if(!(e instanceof Jt))return[3,10];r=e.channels,v=e.source,g=e.isWebSocketEventComing,a=e.data,i=r.filter((function(e){return e instanceof sr})),o=t.filterOffsetChanged(i),M.label=1;case 1:M.trys.push([1,6,7,8]),u=m(o),c=u.next(),M.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:M.sent(),M.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=M.sent(),E={error:h},[3,8];case 7:try{c&&!c.done&&(C=u.return)&&C.call(u)}finally{if(E)throw E.error}return[7];case 8:return[4,t.upsert(i,e.ts)];case 9:return d=M.sent(),g||this._broadcastUpdateEvent(d,v,a),[3,15];case 10:return e instanceof Xt?(_=e.channelUrls,v=e.source,g=e.isWebSocketEventComing,[4,t.remove(_)]):[3,13];case 11:return M.sent(),[4,b((function(){return p(y,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=m(_),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:return u.sent(),[4,s.removeMessagesOfChannel(r)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return a=u.sent(),i={error:a},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))}))];case 12:return M.sent(),g||this._broadcastRemoveEvent(_,v),[3,15];case 13:return e instanceof it?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:M.sent(),M.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var s,r;try{for(var a=m(this._observers.values()),i=a.next();!i.done;i=a.next()){var o=i.value;o.onUpdate&&o.onUpdate(e,t,n)}}catch(e){s={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(s)throw s.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,s;try{for(var r=m(this._observers.values()),a=r.next();!a.done;a=r.next()){var i=a.value;i.onRemove&&i.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),$t=function(r){function a(e){var a=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c,h=r.call(this)||this,d=s(s({},Gt),u),_=d.customTypes,p=d.includeEmpty,f=d.includeFrozen;return h.method=N.GET,h.path="".concat(U,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),h.params=t(n({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:_,show_empty:p,show_frozen:f,include_chat_notification:l})),h}return e(a,r),a}(S),en=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedChannels=n.updated.map((function(t){return new sr(e,Object.assign(t,{ts:n.ts}))})),s.deletedChannelUrls=n.deleted,s.hasMore=n.has_more,s.token=n.next,s.ts=n.ts,s}return e(n,t),n}(T),tn=function(t){function n(e){var n=e.channelUrl,s=e.isInternalCall,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(s?A:I,"/").concat(encodeURIComponent(n)),r.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},r}return e(n,t),n}(S),nn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new sr(e,n),s}return e(n,t),n}(T),sn={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:St.ALL,unreadChannelFilter:At.ALL,superChannelFilter:Tt.ALL,publicChannelFilter:Ut.ALL,hiddenChannelFilter:It.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:Dt.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:rt.LATEST_LAST_MESSAGE},rn=function(n){function s(e){var s=this,r=e.userId,a=e.token,i=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,M=e.metadataKey,b=e.metadataValues,S=e.metadataValueStartsWith,T=e.includeFrozen,A=e.includeMetaData,I=e.searchFilter,w=e.userIdsFilter,D=e.includeChatNotification,L=void 0!==D&&D;return(s=n.call(this)||this).method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(r),"/my_group_channels"),s.params=t({token:a,limit:i,order:null!=o?o:sn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:sn.includeEmpty,member_state_filter:null!=c?c:sn.myMemberStateFilter,super_mode:null!=l?l:sn.superChannelFilter,public_mode:null!=h?h:sn.publicChannelFilter,unread_filter:null!=d?d:sn.unreadChannelFilter,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:E,hidden_mode:C,metadata_order_key:y,metadata_key:M,metadata_values:b,metadata_value_startswith:S,show_frozen:T,show_metadata:A,include_chat_notification:L}),I&&I.query&&I.fields&&(s.params.search_query=I.query,s.params.search_fields=I.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(s.params.members_include_in=w.userIds,s.params.query_type=w.queryType.toUpperCase()):s.params.members_exactly_in=w.userIds),s}return e(s,n),s}(S),an=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.channels=[];var r=n.next,a=n.channels,i=n.ts;return s.token=r,a&&a.length>0&&(s.channels=a.map((function(t){return t.ts=i,new sr(e,t)}))),s.ts=null!=i?i:0,s}return e(n,t),n}(T),on=function(t){function n(e){var n=e.userId,s=e.filter,r=t.call(this)||this,a=s.myMemberStateFilter;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),r.params={state:null!=a?a:St.ALL},r}return e(n,t),n}(S),un=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.groupChannelCount=n.group_channel_count,s}return e(n,t),n}(T),cn=function(n){function s(e){var s=e.userId,r=e.filter,a=n.call(this)||this,i=r.keys;return a.method=N.GET,a.path="".concat(U,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=t({item_keys:i}),a}return e(s,n),s}(S),ln=function(t){function n(e,n){var s=t.call(this,e,n)||this;return"number"==typeof n[kt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=n[kt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[kt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=n[kt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[kt.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=n[kt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[kt.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=n[kt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[kt.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=n[kt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[kt.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=n[kt.SUPER_INVITATION_COUNT]),"number"==typeof n[kt.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=n[kt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[kt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=n[kt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[kt.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=n[kt.NONSUPER_INVITATION_COUNT]),s}return e(n,t),n}(T),hn=function(t){function n(e){var n=e.userId,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),s}return e(n,t),n}(S),dn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s}return e(n,t),n}(T),_n=function(t){function n(e){var n=e.userId,s=e.filter,r=e.includeFeedChannel,a=void 0!==r&&r,i=t.call(this)||this,o=s.channelCustomTypesFilter,u=s.superChannelFilter;return i.method=N.GET,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=u?u:Tt.ALL,custom_types:o,include_feed_channel:a},i}return e(n,t),n}(S),pn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.unreadCount=n.unread_count,s.unreadFeedCount=n.unread_feed_count,s}return e(n,t),n}(T),fn=function(t){function n(e){var n=e.channelUrl,s=e.scheduledStatus,r=e.messageTypeFilter,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(w,"/count"),a.params={channel_url:n,status:vn(s)},r&&(a.params.message_type=r),a}return e(n,t),n}(S),mn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.count=n.count,s}return e(n,t),n}(T),vn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case pe.PENDING:t.push(fe.PENDING);break;case pe.SENT:t.push(fe.IN_QUEUE),t.push(fe.SENT);break;case pe.CANCELED:t.push(fe.CANCELED);break;case pe.FAILED:t.push(fe.FAILED)}})),t},gn=function(n){function s(e){var s=this,r=e.userId,a=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,E=e.name,C=e.data,y=e.customType,M=e.messageSurvivalSeconds,b=e.invitedUserIds,U=e.operatorUserIds;return(s=n.call(this)||this).method=N.POST,s.path=I,s.params=t({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:a,cover_url:i,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:m,is_ephemeral:v,access_code:g,name:E,data:C,custom_type:y,operator_ids:U,message_survival_seconds:M}),s}return e(s,n),s}(S),En=function(t){function n(e,n){var s,r=this;return(r=t.call(this,e,n)||this).channel=new sr(e,n),r.isCreated=null===(s=n.is_created)||void 0===s||s,r}return e(n,t),n}(T),Cn=function(t){function n(e){var n=e.userId,s=e.channelUrls,r=t.call(this)||this;return r.method=N.PUT,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),r.params={channel_urls:s},r}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var yn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/join"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Mn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new sr(e,n),s}return e(n,t),n}(T),bn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u,l=a.users,h=void 0===l?null:l;return r.memberCount=o,r.joinedMemberCount=c,r.members=Array.isArray(h)?h.map((function(t){return new Rt(e,t)})):[new Rt(e,s.data)],r}return e(n,t),n}(_t),Nn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/leave"),n.params={user_id:r,should_remove_operator_status:a},n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Un=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,o=void 0===i?0:i,u=a.joined_member_count,c=void 0===u?0:u;return r.memberCount=o,r.joinedMemberCount=c,r.member=new Rt(r._iid,s.data),r}return e(n,t),n}(_t),Sn=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userIds;return(n=t.call(this)||this).method=N.POST,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/invite"),n.params={user_ids:r},n}return e(n,t),n}(S),Tn=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new sr(e,n),s}return e(n,t),n}(T),An=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this;r.inviter=null;var a=s.data,i=a.member_count,u=void 0===i?0:i,c=a.joined_member_count,l=void 0===c?0:c,h=a.inviter,d=a.invitees,_=void 0===d?[]:d;return r.memberCount=u,r.joinedMemberCount=l,h&&Object.keys(h).length>0&&(r.inviter=new o(e,h)),r.invitees=_.map((function(t){return new Rt(e,t)})),r}return e(n,t),n}(_t),In=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/decline"),n.params={user_id:r},n}return e(n,t),n}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new sr(e,n),s.channel.myMemberState=Nt.NONE,s}e(n,t)}(T);var wn=function(t){function n(e,n,s){var r=t.call(this,e,n,s)||this,a=s.data,i=a.member_count,u=a.joined_member_count,c=a.inviter,l=a.invitee;return r.memberCount=null!=i?i:0,r.joinedMemberCount=null!=u?u:0,r.inviter=new o(e,c),r.invitee=new Rt(e,l),r}return e(n,t),n}(_t),Dn={hidePreviousMessages:!1,allowAutoUnhide:!0},Ln=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.hidePreviousMessages,i=e.allowAutoUnhide;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n.params={user_id:r,hide_previous_messages:null!=a?a:Dn.hidePreviousMessages,allow_auto_unhide:null!=i?i:Dn.allowAutoUnhide},n}return e(n,t),n}(S),Rn=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),Pn=function(t){function n(e,n,s){var r,a,i,o=this;return(o=t.call(this,e,"SYEV",s)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,s.data&&(o.allowAutoUnhide=null!==(r=s.data.allow_auto_unhide)&&void 0!==r?r:null,o.hidePreviousMessages=null!==(a=s.data.hide_previous_messages)&&void 0!==a?a:null),o.messageOffsetTimestamp=null!==(i=s.ts_message_offset)&&void 0!==i?i:null,o}return e(n,t),n}(D),kn=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(L),On=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(D),Fn=function(t){function n(e){var n=e.channelUrl,s=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:s}})||this}return e(n,t),n}(L),xn=function(t){function n(e,n,s){var r=t.call(this,e,"SYEV",s)||this;return r.user=new o(e,s.data),r}return e(n,t),n}(D),Hn=function(t){function n(e){var n=e.channelUrl,s=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:s}})||this}return e(n,t),n}(L),Gn=function(t){function a(e,n){var s,r,a,i,o,u,c,l,h,d,_,p,f,m,v,g,E,C,y,M,b,N,U,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.includeChatNotification=!1,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=St.ALL,S.unreadChannelFilter=At.ALL,S.superChannelFilter=Tt.ALL,S.publicChannelFilter=Ut.ALL,S.hiddenChannelFilter=It.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:Dt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=rt.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,S.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,S.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,S.includeChatNotification=null!==(i=n.includeChatNotification)&&void 0!==i&&i,S.channelUrlsFilter=null!==(o=n.channelUrlsFilter)&&void 0!==o?o:null,S.customTypesFilter=null!==(u=n.customTypesFilter)&&void 0!==u?u:null,S.customTypeStartsWithFilter=null!==(c=n.customTypeStartsWithFilter)&&void 0!==c?c:"",S.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,S.nicknameStartsWithFilter=null!==(h=n.nicknameStartsWithFilter)&&void 0!==h?h:null,S.nicknameExactMatchFilter=null!==(d=n.nicknameExactMatchFilter)&&void 0!==d?d:null,S.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:St.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:At.ALL,S.superChannelFilter=null!==(m=n.superChannelFilter)&&void 0!==m?m:Tt.ALL,S.publicChannelFilter=null!==(v=n.publicChannelFilter)&&void 0!==v?v:Ut.ALL,S.hiddenChannelFilter=null!==(g=n.hiddenChannelFilter)&&void 0!==g?g:It.UNHIDDEN,S.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},S.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:Dt.AND},S.metadataKey=null!==(y=n.metadataKey)&&void 0!==y?y:null,S.metadataValues=null!==(M=n.metadataValues)&&void 0!==M?M:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(N=n.metadataValueStartsWith)&&void 0!==N?N:null,S.order=null!==(U=n.order)&&void 0!==U?U:rt.LATEST_LAST_MESSAGE,S}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&r(St,this.myMemberStateFilter)&&r(Tt,this.superChannelFilter)&&r(Ut,this.publicChannelFilter)&&r(At,this.unreadChannelFilter)&&r(It,this.hiddenChannelFilter)&&v(Lt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&r(Dt,this.userIdsFilter.queryType)&&r(rt,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},a.prototype.serialize=function(){return R(this)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Yn.of(this._iid).getMyGroupChannels(this._token,n(s({},this)),this.limit)]):[3,2]:[3,5];case 1:return e=a.sent(),t=e.channels,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(P),Vn=function(t){function n(e,n,r){var a,i=this;return(i=t.call(this,e,"SYEV",r)||this).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,r.data&&(i.pinnedMessageIds=null!==(a=r.data.pinned_message_ids)&&void 0!==a?a:[],i.latestPinnedMessage=r.data.latest_pinned_message?me(e,s({},r.data.latest_pinned_message)):null),i.ts=r.ts,i}return e(n,t),n}(D),Bn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(L),qn=function(t){function n(e,n,s){var r=t.call(this,e,"READ",s)||this;return r.readStatus=new Pt(e,s),r}return e(n,t),n}(D),Wn=function(n){function s(e){var s=e.channelUrl,r=e.userId,a=n.call(this)||this;return(a=n.call(this)||this).method=N.PUT,a.path="".concat(I,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=t({userId:r}),a}return e(s,n),s}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var jn,zn=function(t){function n(e,n,s){var r=t.call(this,e,"DLVR",s)||this;return r.channelUrl=s.channel_url,r.deliveredStateUpdate=s.updated,r}return e(n,t),n}(D),Qn={},Yn=function(o){function u(e,t){var n,r=this;return(r=o.call(this,e,s(s({},t),{channelType:i.GROUP}))||this)._leftChannels=new Map,r._disableMack=!1,r._markAsReadAllLastSentAt=0,r._disableMack=null!==(n=t.disableMack)&&void 0!==n&&n,r._groupChannelHandlers=new Map,r._groupChannelCache=new Ft(r._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),r._groupChannelBroadcast=new Zt({dispatcher:t.dispatcher,groupChannelCache:r._groupChannelCache,messageCache:ve.of(r._iid),unsentMessageCache:ge.of(r._iid)}),setInterval((function(){var e,t,n=function(e){e.invalidateTypingStatus()&&(r._dispatcher.dispatch(new Jt({channels:[e],source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),r._groupChannelHandlers.forEach((function(t){t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))};try{for(var s=m(r._groupChannelCache.channels),a=s.next();!a.done;a=s.next()){n(a.value)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}}),1e3),r._dispatcher.on((function(e){e instanceof D?r._handleEvent(e):e instanceof ot?p(r,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:return t=e.message,[4,this.getChannel(t.channelUrl,!0)];case 1:return n=s.sent(),t instanceof Ee?n._autoResendUserMessage(t):t instanceof Ce&&n._autoResendFileMessage(t),[2]}}))})):e instanceof ut&&r.reduceDBSize()})),Qn[e]||(Qn[e]=r),r}return e(u,o),u.of=function(e){return Qn[e]||(Qn[e]=new u(e,k.of(e))),Qn[e]},u.clear=function(e){Qn[e]&&delete Qn[e]},Object.defineProperty(u.prototype,"handlers",{get:function(){return d([],_(this._groupChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),u.prototype.buildGroupChannelFromSerializedData=function(e){var t=O(e);return new sr(this._iid,sr.payloadify(t))},u.prototype.buildGroupChannelListQueryFromSerializedData=function(e){var t=O(e);return new Gn(this._iid,t)},u.prototype.buildMemberFromSerializedData=function(e){var t=O(e);return new Rt(this._iid,Rt.payloadify(t))},u.prototype.getChannelFromCache=function(e){var t;return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._groupChannelCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},u.prototype.getChannelsFromCache=function(e,t,n,s,r){return p(this,void 0,void 0,(function(){return f(this,(function(a){switch(a.label){case 0:return[4,this._groupChannelCache.fetch({token:e,filter:t,order:n,limit:s,borderlineChannelUrl:r})];case 1:return[2,a.sent()]}}))}))},u.prototype.upsertChannelsToCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._groupChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},u.prototype.removeChannelsFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._groupChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},u.prototype.clearChannelsFromCache=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._groupChannelCache.clear()];case 1:return e.sent(),[2]}}))}))},u.prototype.reduceDBSize=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o,u,c,l,h,d,_,p;return f(this,(function(f){switch(f.label){case 0:return e=ve.of(this._iid),t=k.of(this._iid).cacheContext,n=t.localCacheConfig,s=t.nestdb,t.localCacheEnabled&&s&&s.state==Me.OPENED?(r=1024*n.maxSize*1024,[4,s.estimateUsage()]):[2];case 1:if((a=f.sent())0||I.unreadMentionCount>0)&&(I._updateUnreadCount(0,0),this._dispatcher.dispatch(new Jt({channels:[I],source:y.EVENT_CHANNEL_READ})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(I)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):0!==I.unreadMessageCount&&0!==I.unreadMentionCount||(this._dispatcher.dispatch(new Jt({channels:[I],source:y.EVENT_CHANNEL_READ})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(I)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new Jt({channels:[I],source:y.EVENT_CHANNEL_READ})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(I)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),Tn.label=12;case 12:return[3,79];case 13:return w=e.as(zn),he=w.channelUrl,D=w.deliveredStateUpdate,L=void 0===D?{}:D,R=this._groupChannelCache.isCachedInMemory(he),[4,this.getChannel(he,!0)];case 14:if(P=Tn.sent(),R)for(O in L)P._updateUndeliveredMemberState(O,L[O]);return Object.keys(L).some((function(e){return e!==Sn._sdkState.userId}))&&(this._dispatcher.dispatch(new Jt({channels:[P],source:y.EVENT_CHANNEL_DELIVERED})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(P)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 15:return F=e.as(Ct),he=F.channelUrl,de=F.channelType,j=F.event,de!==i.GROUP?[3,18]:[4,this.getChannel(he,!0)];case 16:return Q=Tn.sent(),[4,this.getMessageFromCache(j.messageId)];case 17:(J=Tn.sent())&&(J.applyReactionEvent(j),this._dispatcher.dispatch(new q({messages:[J],source:y.EVENT_MESSAGE_REACTION_UPDATED}))),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated(Q,j)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Tn.label=18;case 18:return[3,79];case 19:return(Y=e.as(Et).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(Y.channelUrl,!0)];case 20:return K=Tn.sent(),[4,this.getMessageFromCache(Y.targetMessageId)];case 21:(J=Tn.sent())&&(J.applyThreadInfoUpdateEvent(Y),this._dispatcher.dispatch(new q({messages:[J],source:y.EVENT_MESSAGE_THREADINFO_UPDATED}))),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(K,Y)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Tn.label=22;case 22:return[3,79];case 23:X=e.as(gt).groupChannelMemberCounts,Z=[],Tn.label=24;case 24:Tn.trys.push([24,29,30,31]),$=m(X),ee=$.next(),Tn.label=25;case 25:return ee.done?[3,28]:(te=ee.value,he=te.channelUrl,nt=te.memberCount,st=te.joinedMemberCount,ne=te.updatedAt,[4,this.getChannelFromCache(he)]);case 26:(se=Tn.sent())&&se._setLatestMemberCount(nt,st,ne)&&Z.push(se),Tn.label=27;case 27:return ee=$.next(),[3,25];case 28:return[3,31];case 29:return re=Tn.sent(),mn={error:re},[3,31];case 30:try{ee&&!ee.done&&(vn=$.return)&&vn.call($)}finally{if(mn)throw mn.error}return[7];case 31:return Z.length>0&&(this._dispatcher.dispatch(new Jt({channels:Z,source:y.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(Z)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))),[3,79];case 32:return ae=e.as(vt),ie=ae.event,oe=ae.status,he=ae.channelUrl,de=ae.channelType,he&&de===i.GROUP?[4,this.getChannel(he,!0)]:[3,34];case 33:ue=Tn.sent(),this._dispatcher.dispatch(new B({event:ie,source:y.EVENT_POLL_UPDATED})),H(oe===z?function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(ue,ie.pollId)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}:function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(ue,ie)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))}),Tn.label=34;case 34:return[3,79];case 35:return ce=e.as(we),le=ce.event,he=ce.channelUrl,de=ce.channelType,he&&de===i.GROUP?[4,this.getChannel(he,!0)]:[3,37];case 36:_e=Tn.sent(),this._dispatcher.dispatch(new V({event:le,source:y.EVENT_POLL_VOTED})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(_e,le)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Tn.label=37;case 37:return[3,79];case 38:if(!(pe=e.as(_t).event).isGroupChannelEvent)return[3,77];switch(pe.category){case ft.CHANNEL_JOIN:return[3,39];case ft.CHANNEL_LEAVE:return[3,41];case ft.CHANNEL_OPERATOR_UPDATE:return[3,45];case ft.CHANNEL_INVITE:return[3,47];case ft.CHANNEL_DECLINE_INVITE:return[3,49];case ft.TYPING_START:case ft.TYPING_END:return[3,51];case ft.USER_CHANNEL_MUTE:case ft.USER_CHANNEL_UNMUTE:return[3,53];case ft.USER_CHANNEL_BAN:return[3,55];case ft.USER_CHANNEL_UNBAN:return[3,59];case ft.CHANNEL_FREEZE:case ft.CHANNEL_UNFREEZE:return[3,61];case ft.CHANNEL_HIDE:return[3,63];case ft.CHANNEL_UNHIDE:return[3,65];case ft.CHANNEL_DELETED:return[3,67];case ft.CHANNEL_PROP_CHANGED:return[3,69];case ft.CHANNEL_META_DATA_CHANGED:return[3,71];case ft.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case ft.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(pe.channelUrl,!0)];case 40:return fe=Tn.sent(),me=e.as(bn),ve=me.memberCount,ge=me.joinedMemberCount,Ee=me.members,Ce=!1,Ee.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?Ce=Ce||fe._setLatestMemberCount(ve,ge,pe.ts):(e.state=Nt.JOINED,fe.addMember(e,pe.ts),Sn._updateJoinedMemberCount(fe)),e.userId===Sn._sdkState.userId&&(fe.myMemberState=Nt.JOINED)})),this._dispatcher.dispatch(new Jt({channels:[fe],source:y.EVENT_CHANNEL_JOINED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var s=m(Ee),r=s.next();!r.done;r=s.next()){var a=r.value;e.onUserJoined&&e.onUserJoined(fe,a)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}fe.isBroadcast&&Ce&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,77];case 41:return(At=this._leftChannels.get(pe.channelUrl))?(Me=At.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(pe.channelUrl,!0)];case 43:Me=Tn.sent(),Tn.label=44;case 44:return ye=Me,Fe=e.as(Un),nt=Fe.memberCount,st=Fe.joinedMemberCount,xe=Fe.member,He=!1,Ge=k.of(this._iid).appInfo,ye.isExclusive||ye.isSuper||ye.isBroadcast?He=ye._setLatestMemberCount(nt,st,pe.ts):((null==Ge?void 0:Ge.enabledChannelMemberShipHistory)?((Ve=ye.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=Nt.LEFT),ye.memberCount=nt):ye.removeMember(xe),this._updateJoinedMemberCount(ye)),xe.userId===this._sdkState.userId?(ye.myMemberState=Nt.NONE,ye.invitedAt=0,ye.joinedAt=0,ye._updateUnreadCount(0,0),ye.isPublic?this._dispatcher.dispatch(new Jt({channels:[ye],source:y.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ye),this._dispatcher.dispatch(new Xt({channelUrls:[ye.url],source:y.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new Jt({channels:[ye],source:y.EVENT_CHANNEL_LEFT})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(ye,xe),ye.isBroadcast&&He&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(pe.channelUrl,!0)];case 46:Be=Tn.sent(),qe=e.as(mt).operators,We=qe.map((function(e){return e.userId}));try{for(je=m(Be.members),ze=je.next();!ze.done;ze=je.next())(Tt=ze.value).role=We.includes(Tt.userId)?a.OPERATOR:a.NONE}catch(e){gn={error:e}}finally{try{ze&&!ze.done&&(En=je.return)&&En.call(je)}finally{if(gn)throw gn.error}}return Be.myRole=We.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new Jt({channels:[Be],source:y.EVENT_CHANNEL_OPERATOR_UPDATED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Be,qe)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(pe.channelUrl,!0)];case 48:Qe=Tn.sent(),Ye=e.as(An),nt=Ye.memberCount,st=Ye.joinedMemberCount,Ke=Ye.inviter,(Je=Ye.invitees).forEach((function(e){return e.state=Nt.INVITED}));try{for(Xe=m(Je),Ze=Xe.next();!Ze.done;Ze=Xe.next())$e=Ze.value,Qe.isExclusive||Qe.isSuper||Qe.isBroadcast?Qe._setLatestMemberCount(nt,st,pe.ts):Qe.addMember($e,pe.ts),this._sdkState.userId===$e.userId&&(Qe.hiddenState=Zs.UNHIDDEN,Qe.myMemberState!==Nt.JOINED&&(Qe.myMemberState=Nt.INVITED),Qe.invitedAt=pe.ts)}catch(e){Cn={error:e}}finally{try{Ze&&!Ze.done&&(yn=Xe.return)&&yn.call(Xe)}finally{if(Cn)throw Cn.error}}return this._dispatcher.dispatch(new Jt({channels:[Qe],source:y.EVENT_CHANNEL_INVITED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Qe,Ke,Je)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(pe.channelUrl,!0)];case 50:return et=Tn.sent(),tt=e.as(wn),nt=tt.memberCount,st=tt.joinedMemberCount,rt=tt.inviter,at=tt.invitee,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(nt,st,pe.ts):et.removeMember(at),this._sdkState.userId===at.userId?(et.invitedAt=0,et.myMemberState=Nt.NONE,et.isPublic?this._dispatcher.dispatch(new Jt({channels:[et],source:y.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Xt({channelUrls:[et.url],source:y.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Jt({channels:[et],source:y.EVENT_CHANNEL_DECLINED_INVITE})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(et,rt,at)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(pe.channelUrl,!0)];case 52:return it=Tn.sent(),ot=pe.category===ft.TYPING_START,ut=e.as(ot?On:xn).user,it._updateTypingStatus(ut,ot?pe.ts:0),this._dispatcher.dispatch(new Jt({channels:[it],source:y.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(it)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(pe.channelUrl,!0)];case 54:dt=Tn.sent(),pt=pe.category===ft.USER_CHANNEL_MUTE,(bt=e.as(pt?Ae:Ie).user).userId===this._sdkState.userId&&(dt.myMutedState=pt?G.MUTED:G.UNMUTED,dt._myMutedRemainingTime=bt.restrictionInfo.remainingDuration);try{for(Ut=m(dt.members),St=Ut.next();!St.done;St=Ut.next())if((Tt=St.value).userId===bt.userId){Tt.isMuted=pt;break}}catch(e){Mn={error:e}}finally{try{St&&!St.done&&(Nn=Ut.return)&&Nn.call(Ut)}finally{if(Mn)throw Mn.error}}return this._dispatcher.dispatch(new Jt({channels:[dt],source:pt?y.EVENT_CHANNEL_MUTED:y.EVENT_CHANNEL_UNMUTED,data:bt.userId})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){pt?e.onUserMuted&&e.onUserMuted(dt,bt):e.onUserUnmuted&&e.onUserUnmuted(dt,bt)})),[2]}))}))})),[3,77];case 55:return(At=this._leftChannels.get(pe.channelUrl))?(wt=At.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(pe.channelUrl,!0)];case 57:wt=Tn.sent(),Tn.label=58;case 58:return It=wt,this._markAsLeave(It),Dt=e.as(Te).user,Dt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Xt({channelUrls:[It.url],source:y.EVENT_CHANNEL_BANNED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(It,Dt)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(pe.channelUrl,!0)];case 60:return Lt=Tn.sent(),Rt=e.as(Se).user,Rt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Xt({channelUrls:[Lt.url],source:y.EVENT_CHANNEL_UNBANNED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(Lt,Rt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(pe.channelUrl,!0)];case 62:return Pt=Tn.sent(),kt=e.as(Ue).freeze,Pt.isFrozen=kt,this._dispatcher.dispatch(new Jt({channels:[Pt],source:kt?y.EVENT_CHANNEL_FROZEN:y.EVENT_CHANNEL_UNFROZEN})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){kt?e.onChannelFrozen&&e.onChannelFrozen(Pt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Pt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(pe.channelUrl,!0)];case 64:return Ot=Tn.sent(),Ft=e.as(Pn),xt=Ft.allowAutoUnhide,Ht=Ft.hidePreviousMessages,Gt=Ft.messageOffsetTimestamp,null!==xt&&(Ot.hiddenState=xt?Zs.HIDDEN_ALLOW_AUTO_UNHIDE:Zs.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ht&&Ht&&Ot._updateUnreadCount(0,0),null!==Gt&&(Ot.messageOffsetTimestamp=Gt),this._dispatcher.dispatch(new Jt({channels:[Ot],source:y.EVENT_CHANNEL_HIDDEN})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Ot)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(pe.channelUrl,!0)];case 66:return(Vt=Tn.sent()).hiddenState=Zs.UNHIDDEN,this._dispatcher.dispatch(new Jt({channels:[Vt],source:y.EVENT_CHANNEL_UNHIDDEN})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Vt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(pe.channelUrl,!0)];case 68:return Bt=Tn.sent(),this._dispatcher.dispatch(new Xt({channelUrls:[pe.channelUrl],source:y.EVENT_CHANNEL_DELETED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Bt.url,Bt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(pe.channelUrl,!0)];case 70:return qt=Tn.sent(),this._dispatcher.dispatch(new Jt({channels:[qt],source:y.EVENT_CHANNEL_UPDATED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(qt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(pe.channelUrl,!0)];case 72:return Wt=Tn.sent(),jt=e.as(Ne),zt=jt.created,Qt=jt.updated,Yt=jt.deleted,zt&&(Wt._upsertCachedMetaData(zt,pe.ts),this._dispatcher.dispatch(new Jt({channels:[Wt],source:y.EVENT_CHANNEL_METADATA_CREATED}))),Qt&&(Wt._upsertCachedMetaData(Qt,pe.ts),this._dispatcher.dispatch(new Jt({channels:[Wt],source:y.EVENT_CHANNEL_METADATA_UPDATED}))),Yt&&(Wt._removeFromCachedMetaData(Yt,pe.ts),this._dispatcher.dispatch(new Jt({channels:[Wt],source:y.EVENT_CHANNEL_METADATA_DELETED}))),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated&&e.onMetaDataCreated(Wt,zt),Qt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Wt,Qt),Yt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Wt,Yt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(pe.channelUrl,!0)];case 74:return Kt=Tn.sent(),Zt=e.as(be),$t=Zt.created,en=Zt.updated,tn=Zt.deleted,$t&&this._dispatcher.dispatch(new Jt({channels:[Kt],source:y.EVENT_CHANNEL_METACOUNTER_CREATED})),en&&this._dispatcher.dispatch(new Jt({channels:[Kt],source:y.EVENT_CHANNEL_METACOUNTER_UPDATED})),tn&&this._dispatcher.dispatch(new Jt({channels:[Kt],source:y.EVENT_CHANNEL_METACOUNTER_DELETED})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){$t&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,$t),en&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,en),tn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,tn)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(pe.channelUrl,!0)];case 76:return nn=Tn.sent(),sn=e.as(Vn),rn=sn.pinnedMessageIds,an=sn.latestPinnedMessage,(on=sn.ts)>nn._pinnedMessagesUpdatedAt&&(nn.pinnedMessageIds=rn,nn.lastPinnedMessage=an,nn._pinnedMessagesUpdatedAt=on,this._dispatcher.dispatch(new Jt({channels:[nn],source:y.EVENT_PINNED_MESSAGE_UPDATED})),H((function(){return p(Sn,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(nn)}catch(e){s={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),H((function(){return p(Sn,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(nn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((un=e.as(ct).event).category){case lt.USER_BLOCK:cn=ht.getDataAsUserBlockEvent(this._iid,un),hn=cn.blocker,dn=cn.blockee,this._groupChannelCache.block(hn.userId,dn.userId);break;case lt.USER_UNBLOCK:ln=ht.getDataAsUserBlockEvent(this._iid,un),hn=ln.blocker,dn=ln.blockee,this._groupChannelCache.unblock(hn.userId,dn.userId)}return[3,79];case 79:return[3,81];case 80:if(_n=Tn.sent(),x(_n))throw _n;return[3,81];case 81:return[2]}}))}))},u.prototype._markAsLeave=function(e){var t,n=this,s=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};s.ref++,this._leftChannels.set(e.url,s),setTimeout((function(){s.ref--,0===s.ref&&n._leftChannels.delete(e.url)}),1e4)},u.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},u.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},u.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},u.prototype.subscribeChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},u.prototype.unsubscribeChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},u.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Nt.JOINED})).length},u.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(s){switch(s.label){case 0:l(g("string",e)).throw(h.invalidParameters),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=s.sent())?[2,n]:[3,4];case 3:return s.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,s.sent()]}}))}))},u.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(g("string",e)).throw(h.invalidParameters),n=new tn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(s=o.sent(),r=s.as(nn).channel,a=r.unreadMessageCount,i=r.unreadMentionCount,r.myCountPreference){case Xs.UNREAD_MESSAGE_COUNT_ONLY:i=0;break;case Xs.UNREAD_MENTION_COUNT_ONLY:a=0;break;case Xs.OFF:a=0,i=0}return r._updateUnreadCount(a,i),[4,this.upsertChannelsToCache([r])];case 2:return[2,o.sent()[0]]}}))}))},u.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=y.REFRESH_CHANNEL),p(this,void 0,void 0,(function(){var s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),s=new tn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(s)];case 1:return r=u.sent(),(a=r.as(nn).channel).myMemberState!==Nt.NONE?[3,2]:(this._dispatcher.dispatch(new Xt({channelUrls:[a.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([a])];case 3:i=u.sent(),this._dispatcher.dispatch(new Jt({channels:i,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==j.NON_AUTHORIZED&&o.code!==j.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Xt({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},u.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=y.REQUEST_CHANNEL),p(this,void 0,void 0,(function(){var a,i,o,u,c;return f(this,(function(l){switch(l.label){case 0:return a=new rn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(a)];case 1:return i=l.sent(),o=i.as(an),u=o.channels,c=o.token,this._dispatcher.dispatch(new Jt({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},u.prototype.getMyGroupChannelChangeLogs=function(e,t,r){return void 0===r&&(r=y.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var a,i,o,u,c,d,_,p;return f(this,(function(f){switch(f.label){case 0:return a=s(s({},Gt),t),l((g("string",e)||g("number",e))&&Vt(a)).throw(h.invalidParameters),i=new $t(n({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:a})),[4,this._requestQueue.send(i)];case 1:return o=f.sent(),u=o.as(en),c=u.updatedChannels,d=u.deletedChannelUrls,_=u.hasMore,p=u.ts,c.length>0&&this._dispatcher.dispatch(new Jt({channels:c,source:r,ts:p})),d.length>0&&this._dispatcher.dispatch(new Xt({channelUrls:d,source:r})),[2,{updatedChannels:c,deletedChannelUrls:d,hasMore:_,token:u.token}]}}))}))},u.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=s(s({},Bt),e),l(qt(t)).throw(h.invalidParameters),n=new on({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),[2,r.as(un).groupChannelCount]}}))}))},u.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,u,c,d,_,p,m,g,E,C,y,M;return f(this,(function(f){switch(f.label){case 0:return n=s(s({},Wt),e),l(function(e){return v(kt,e.keys)}(n)).throw(h.invalidParameters),r=k.of(this._iid),a=r.sdkState,i=r.requestQueue,o=new cn({userId:a.userId,filter:n}),[4,i.send(o)];case 1:return u=f.sent(),c=u.as(ln),d=c.groupChannelUnreadMentionCount,_=c.groupChannelUnreadMessageCount,p=c.groupChannelInvitationCount,m=c.superGroupChannelUnreadMentionCount,g=c.superGroupChannelUnreadMessageCount,E=c.superGroupChannelInvitationCount,C=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,M=c.nonSuperGroupChannelInvitationCount,[2,t({groupChannelUnreadMentionCount:d,groupChannelUnreadMessageCount:_,groupChannelInvitationCount:p,superGroupChannelUnreadMentionCount:m,superGroupChannelUnreadMessageCount:g,superGroupChannelInvitationCount:E,nonSuperGroupChannelUnreadMentionCount:C,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:M})]}}))}))},u.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new hn({userId:t.userId}),[4,n.send(s)];case 1:return r=a.sent(),[2,r.as(dn).unreadCount]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return t=s(s({},jt),e),l(zt(t)).throw(h.invalidParameters),n=k.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new _n({userId:r.userId,filter:t}),[4,a.send(i)];case 1:return o=u.sent(),[2,o.as(pn).unreadCount]}}))}))},u.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,a,i;return f(this,(function(o){switch(o.label){case 0:return t=s(s({},Qt),e),l(function(e){return g("string",e.channelUrl,!0)&&v(pe,e.scheduledStatus,!0)&&r(C,e.messageTypeFilter)}(t)).throw(h.invalidParameters),n=k.of(this._iid).requestQueue,a=new fn(t),[4,n.send(a)];case 1:return i=o.sent(),[2,i.as(mn).count]}}))}))},u.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=k.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},u.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=k.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},u.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=k.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},u.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return t=s(s({},xt),e),l(Ht(t)).throw(h.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new gn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),a=r.as(En).channel,[4,this.upsertChannelsToCache([a])];case 2:return i.sent(),[2,a]}}))}))},u.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),l(e-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Cn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(s=m(n),r=s.next();!r.done;r=s.next())(a=r.value)._updateUnreadMemberState(this._sdkState.userId,e),a._updateUnreadCount(0,0)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},u.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=Date.now(),l(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(h.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Cn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:d.sent(),s=this._groupChannelCache.channels,r=[];try{for(a=m(s),i=a.next();!i.done;i=a.next())o=i.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),r.push(o))}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=a.return)&&c.call(a)}finally{if(u)throw u.error}}return r.length>0?[4,this.upsertChannelsToCache(r)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}}))}))},u.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},u}(pt);!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(jn||(jn={}));var Kn,Jn=function(t){function n(e,n,s,r){var a=t.call(this)||this;return a._state=jn.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=n,a}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===jn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===jn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===jn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount0&&(s=n.map((function(e){return e.createdAt})),(null===(l=this._metadata)||void 0===l?void 0:(a=l.range).intersect.apply(a,d([],_(s),!1)))?this.extendRange(n):this._metadata={range:new bt({top:Math.min.apply(Math,d([],_(s),!1)),bottom:Math.max.apply(Math,d([],_(s),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(s=n.map((function(e){return e.createdAt})),(null===(c=this._metadata)||void 0===c?void 0:(a=c.range).intersect.apply(a,d([],_(s),!1)))?this.extendRange(n):this._metadata={range:new bt({top:Math.min.apply(Math,d([],_(s),!1)),bottom:Math.max.apply(Math,d([],_(s),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.bottom),m.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return l.sent(),[3,6];case 5:throw r=l.sent(),m.debug("message background next sync error",r),r;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof Y)if(e.stateType===K.CONNECTED)a.resume();else a.pause()}))}return e.of=function(t,n){return Xn[t]||(Xn[t]={}),Xn[t][n.url]||(Xn[t][n.url]=new e({_iid:t,channel:n})),Xn[t][n.url].ref++,Xn[t][n.url]},e.clear=function(e,t){Xn[e]&&Xn[e][t]&&(Xn[e][t].close(),delete Xn[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new bt({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,k.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||s.length>0)&&this._metadata&&(this._metadata.token=a),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return i=c.sent(),o.debug("message changelog sync error",i),i instanceof h&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw i;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof Y)if(e.stateType===K.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n){return $n[t]||($n[t]={}),$n[t][n.url]||($n[t][n.url]=new e({_iid:t,channel:n})),$n[t][n.url].ref++,$n[t][n.url]},e.clear=function(e,t){$n[e]&&$n[e][t]&&($n[e][t].close(),delete $n[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=k.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:s=r.sent(),this._metadata={token:s?s.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,k.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,k.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=k.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=k.of(this._iid),t=e.logger;e.connectionManager,t.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete $n[this._iid][this._channel.url])},e}(),ts={},ns=function(){function e(e){var t=e._iid,n=e.channel,s=e.hasPollMessage,r=this;this.ref=0,this._iid=t,this._channel=n;var a,i,o=k.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(a=c.userId,i=n.url,"sendbird:".concat(a,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new Jn(d,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,a,i,o,c;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return l.sent(),u.debug("poll changelog sync from",null===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,s()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=k.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,X.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return r=l.sent(),a=r.hasMore,i=r.token,e.hasNext=a,e.nextToken=i,this._metadata.token=i,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof h&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof Y)if(e.stateType===K.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n,s){return ts[t]||(ts[t]={}),ts[t][n.url]||(ts[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:s})),ts[t][n.url].ref++,ts[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,k.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:void 0,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,k.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,k.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){k.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){k.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ts[this._iid][this._channel.url])},e}(),ss=function(t){function n(e){var n=e.channels,s=e.source,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=e.data,o=void 0===i?null:i,u=t.call(this)||this;return u.channels=n,u.source=s,u.isWebSocketEventComing=a,u.data=o,u}return e(n,t),n}(M),rs=function(t){function n(e){var n=e.channelUrls,s=e.source,r=e.isWebSocketEventComing,a=void 0!==r&&r,i=t.call(this)||this;return i.channelUrls=n,i.source=s,i.isWebSocketEventComing=a,i}return e(n,t),n}(M),as=function(n){function s(e){var s,r,a,i,o,u,c,l,h,d,_=this;return(_=n.call(this)||this).method=N.GET,_.path="".concat(Z(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),_.params=t({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(a=e.messageType)&&void 0!==a?a:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:J.NONE,include_reactions:null===(o=e.includeReactions)||void 0===o||o,include_meta_array:null===(u=e.includeMetaArray)||void 0===u||u,include_thread_info:null===(c=e.includeThreadInfo)||void 0===c||c,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(d=e.showSubchannelMessagesOnly)&&void 0!==d&&d,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),_}return e(s,n),s}(S),is=function(t){function n(e,n){var s,r,a,i,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(s=n.prev_messages)&&void 0!==s?s:[]).map((function(t){return me(e,t)})),c.prevHasMore=null!==(r=n.prev_hasmore)&&void 0!==r&&r,c.isContinuousPrevMessages=null!==(a=n.is_continuous_prev_messages)&&void 0!==a&&a,c.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return me(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(T),os=function(e,t){return t instanceof Le?e.findIndex((function(e){return e instanceof Le&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},us=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},cs=function(e,t){if(e.length>0){for(var n=0,s=e.length-1,r=Math.floor((n+s)/2);n0)s=r,r=Math.floor((n+s)/2);else{if(!(a<0))return r;n=r+1,r=Math.floor((n+s)/2)}}return e[r].createdAt>t.createdAt?r:r+1}return e.length},ls=function(e){this.source=e},hs=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(ls),ds=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(ls),_s=function(e){this.source=e},ps=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(_s),fs=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n}(_s),ms=6e5,vs={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(Kn||(Kn={}));var gs,Es,Cs,ys=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var s=this;H((function(){return p(s,void 0,void 0,(function(){return f(this,(function(s){switch(e){case"local":this._onCacheResult(t,n);break;case"remote":this._onApiResult(t,n)}return[2]}))}))}))},e.prototype.onCacheResult=function(e){return this._onCacheResult=e,this},e.prototype.onApiResult=function(e){return this._onApiResult=e,this},e}(),Ms=function(){function e(e,t){var n=t.filter,s=t.startingPoint,r=t.limit,a=t.channel,i=t.channelManager,o=this;this._messages=[],this._unsentMessages=[],this._iid=e,this._key="mc-".concat(ne()),this._isDisposed=!1,this.filter=null!=n?n:new ye,this._channel=a,this._syncRange=new bt({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+ms,this._limit=r||xe,this._channelManager=i,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(e,t,n){var s=e.findIndex((function(e){return e.isIdentical(o.channel)}));s>=0&&(o._replaceChannelOfCollection(e[s]),o.channel._runIfHandleableWithGroupChannel((function(e){switch(t){case y.EVENT_CHANNEL_UPDATED:var s=!1;for(var r in o._messages){if(o._messages[r].createdAt>=e.messageOffsetTimestamp){s=!0;var a=parseInt(r);if(a>0){var i=o._messages.splice(0,a);o._removeMessagesFromView(i.map((function(e){return e.messageId})),y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&o._messages.length>0&&o._removeMessagesFromView(o._messages.map((function(e){return e.messageId})),y.EVENT_MESSAGE_OFFSET_UPDATED);break;case y.EVENT_CHANNEL_UNMUTED:var u=k.of(o._iid).sdkState,c=n;u.userId===c&&o._clearCheckMyMutedTimer();break;case y.EVENT_CHANNEL_MUTED:u=k.of(o._iid).sdkState;var l=n;u.userId===l&&-1!==e._myMutedRemainingTime&&o._startCheckMyMutedTimer(e._myMutedRemainingTime);break;case y.EVENT_CHANNEL_LEFT:e.isPublic&&o._clearCheckMyMutedTimer()}H((function(){return p(o,void 0,void 0,(function(){var e,n;return f(this,(function(s){return e=this._createChannelEventContext(t),Kt(t)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(e,this.channel),[2]}))}))}))})))},onRemove:function(e,t){e.indexOf(o.channel.url)>=0&&(o._clearCheckMyMutedTimer(),H((function(){return p(o,void 0,void 0,(function(){var e,n;return f(this,(function(s){return e=this._createChannelEventContext(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,s,r=[],a=[];try{for(var i=m(e),u=i.next();!u.done;u=i.next()){var c=u.value;c.channelUrl===o._channel.url&&(o.filter.match(c)?r.push(c):a.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}if($(t)){if(r.length>0)switch(t){case y.LOCAL_MESSAGE_CANCELED:case y.LOCAL_MESSAGE_RESEND_STARTED:case y.EVENT_MESSAGE_SENT_FAILED:case y.EVENT_MESSAGE_SENT_SUCCESS:case y.EVENT_MESSAGE_UPDATED:case y.EVENT_MESSAGE_THREADINFO_UPDATED:case y.EVENT_MESSAGE_REACTION_UPDATED:case y.SYNC_MESSAGE_CHANGELOGS:o._updateMessagesToView(r,t);break;case y.EVENT_MESSAGE_SENT_PENDING:o._addMessagesToView(r,t);break;case y.EVENT_MESSAGE_RECEIVED:o.hasNext||o._addMessagesToView(r,t);break;case y.SYNC_MESSAGE_FILL:o._addMessagesToView(r,t)}a.length>0&&o._removeMessagesFromView(a,t)}},onRemove:function(e,t){o._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){o._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){o._updatePollsToView(e,t)},onPollUpdate:function(e,t){o._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){o._applyPollVoteEventToView(e,t)}});var u=k.of(this._iid),c=u.cacheContext,l=u.dispatcher,h=u.logger;this._channel._updateMessageCollectionLastAccessedAt();var v=this._createChannelUpdateEventCommand(y.CHANNEL_LASTACCESSEDAT_UPDATED);v&&l.dispatch(v),this._shouldStartBackgroundSync()&&(this._backgroundSync=Zn.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=es.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=ns.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Jn(this._key,(function(e){return p(o,void 0,void 0,(function(){var t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=i.sent(),n=t.messages,s=t.isContinuousMessages,n.length>0?(r=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(r=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),s&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(r)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof Y)switch(e.stateType){case K.CONNECTED:o._refreshChannel(y.SYNC_CHANNEL_CHANGELOGS),b((function(){return p(o,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),h.debug("check huge gap"),o._checkHugeGap();break;case K.LOGOUT:o.dispose();break;default:o._clearCheckMyMutedTimer(),o._prevFill.stop(),o._nextFill.stop()}})),k.of(this._iid).statLogCollector.put(new ee({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===se.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===se.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype._replaceChannelOfCollection=function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)},e.prototype._shouldStartBackgroundSync=function(){var e=k.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled},e.prototype._createChannelEventContext=function(e){switch(!0){case this.channel.isGroupChannel():return new hs(e);case this.channel.isFeedChannel():return new ds(e);default:throw new h({code:j.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}},e.prototype._createMessageEventContext=function(e){switch(!0){case this.channel.isGroupChannel():return new ps(e);case this.channel.isFeedChannel():return new fs(e);default:throw new h({code:j.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}},e.prototype._createChannelUpdateEventCommand=function(e){switch(!0){case this.channel.isGroupChannel():return new Jt({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new ss({channels:[this._channel],source:e});default:return null}},e.prototype._setBaseMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,s,r=this,a=this._filterUnderOffsetMessage(e),i=[],o=[];try{for(var u=m(a),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===y.SYNC_MESSAGE_FILL){if(l.messageId>0){if((E=os(this._messages,l))<0){os(this._unsentMessages,l)<0&&i.push(l);var h=cs(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Le){(E=os(this._unsentMessages,l))<0&&os(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l))}}else if(l.messageId>0){if((E=os(this._messages,l))<0){var v=os(this._unsentMessages,l);v<0?i.push(l):(this._unsentMessages.splice(v,1),o.push(l));h=cs(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[E]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof Le){var E;(E=os(this._unsentMessages,l))<0?os(this._messages,l)<0&&(this._unsentMessages.push(l),i.push(l)):(o.push(l),this._unsentMessages[E]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}$(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,a;return f(this,(function(u){return e=this._createMessageEventContext(t),i.length>0&&(null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===s||s.call(n,e,this.channel,i)),o.length>0&&(null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,s,r=this,a=[];try{for(var i=m(e),o=i.next();!o.done;o=i.next()){var u=o.value,c=us(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),a.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return a.length>0&&$(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e=this._createMessageEventContext(t),a.length>0&&(null===(s=(n=this._handler).onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,a)),[2]}))}))})),a},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,s=us(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollUpdateEvent(e)&&$(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e=this._createMessageEventContext(t),null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,s=us(this._messages,e.messageId);if(s>=0){var r=this._messages[s];r&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(e)&&$(t)&&H((function(){return p(n,void 0,void 0,(function(){var e,n,s;return f(this,(function(a){return e=this._createMessageEventContext(t),null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,[r]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,s,r=this,a=[],i=[],o=[];try{for(var u=m(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=os(this._messages,h))>=0)i.push(h),this._messages[l]=h;else{var v=os(this._unsentMessages,h);if(v>=0){var g=this._unsentMessages.splice(v,1);if(this.hasNext&&g.length>0)o.push(g[0]);else{i.push(h);var E=cs(this._messages,h);this._messages.splice(E,0,h)}}else{var C=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,d([],_(C),!1))&&!this._hasNext)&&a.push(h)}}else if(h instanceof Le)(l=os(this._unsentMessages,h))>=0&&(i.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(n)throw n.error}}return $(t)&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s,r,u;return f(this,(function(c){return e=this._createMessageEventContext(t),i.length>0?null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===s||s.call(n,e,this.channel,i):o.length>0?null===(u=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===u||u.call(r,e,this.channel,[],o):a.length>0&&this._addMessagesToView(a,t),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,s,r=this,a=[],i=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];a.push(n.messageId),i.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=m(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return $(t)&&i.length>0&&H((function(){return p(r,void 0,void 0,(function(){var e,n,s;return f(this,(function(r){return e=this._createMessageEventContext(t),null===(s=null===(n=this._handler)||void 0===n?void 0:n.onMessagesDeleted)||void 0===s||s.call(n,e,this.channel,a,i),[2]}))}))})),a},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,s=void 0===n?0:n,r=t.nextLimit,a=void 0===r?0:r,i=t.inclusive,o=void 0===i||i;return p(this,void 0,void 0,(function(){var t,n,r,i,u;return f(this,(function(c){switch(c.label){case 0:return t=[],o?[4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:t=c.sent(),c.label=2;case 2:return s>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,s,!1)]:[3,4];case 3:return r=c.sent(),[3,5];case 4:r=[],c.label=5;case 5:return n=r,a>0?[4,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,a,!1)]:[3,7];case 6:return u=c.sent(),[3,8];case 7:u=[],c.label=8;case 8:return i=u,[2,d(d(d([],_(t),!1),_(n),!1),_(i),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var r=t.prevLimit,a=void 0===r?0:r,i=t.nextLimit,o=void 0===i?0:i,u=t.source,c=void 0===u?y.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingContinuousMessages,_=void 0!==d&&d;return p(this,void 0,void 0,(function(){var t,r;return f(this,(function(i){switch(i.label){case 0:return t=Fe.of(this._iid),a>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,n(s(s(s({},this.filter),vs),{isInclusive:!0,reverse:h,prevResultSize:a,nextResultSize:o})),c,_)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){var e;return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c,l,m,v,g,E,C,M,b,N,U,S,T=this;return f(this,(function(A){switch(A.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,a=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return i=A.sent(),[4,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,r,a)];case 2:return o=A.sent(),[4,re((function(){return p(T,void 0,void 0,(function(){var e,u,c,l,h,m,v,g,E,C,M,b,N,U,S,T,A,I,w,D,L,R=this;return f(this,(function(P){switch(P.label){case 0:return e=k.of(this._iid),u=e.dispatcher,c=e.requestQueue,l=e.cacheContext,h=new as(s(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:i,nextStart:r,nextEnd:a,nextCount:o,checkingContinuousMessages:l.localCacheEnabled},this.filter),vs)),[4,c.send(h)];case 1:return m=P.sent(),v=m.as(is),g=v.isHugeGap,E=v.prevMessages,C=void 0===E?[]:E,M=v.prevHasMore,b=v.isContinuousPrevMessages,N=v.nextMessages,U=void 0===N?[]:N,S=v.nextHasmore,T=v.isContinuousNextMessages,g?H((function(){return p(R,void 0,void 0,(function(){var e;return f(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected(),[2]}))}))})):(A=this.viewTop,I=this.viewBottom,w=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,A],_(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,d([0,I],_(U.map((function(e){return e.createdAt}))),!1)),u.dispatch(new q({messages:C,source:y.SYNC_MESSAGE_FILL})),u.dispatch(new q({messages:U,source:y.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||T)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),M&&this._prevFill.start(w),S&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return A.sent(),[3,8];case 4:u=k.of(this._iid).cacheContext,c=Math.floor(this._limit/2),l=Date.now(),A.label=5;case 5:return A.trys.push([5,7,,8]),[4,this._getRemoteMessages(l,{prevLimit:c,nextLimit:c,source:y.SYNC_MESSAGE_FILL,checkingContinuousMessages:u.localCacheEnabled})];case 6:if(m=A.sent(),v=m.messages,g=m.isContinuousMessages,v.length>0){for(E=v.map((function(e){return e.createdAt})),C=0,M=0,b=0;b=l&&M++;this._hasPrevious=C>=c,this._hasNext=M>=c,(S=this._syncRange).extends.apply(S,d([],_(E),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,y.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(U=A.sent())instanceof h&&U.code===j.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=this,[4,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return e._unsentMessages=t.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+ms,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){this._channelManager.refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return p(t,void 0,void 0,(function(){var e,t,n=this;return f(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&this.channel._runIfHandleableWithGroupChannel((function(e){var t,s;e.myMutedState=G.UNMUTED;var r=n._createChannelEventContext(y.EVENT_CHANNEL_UNMUTED);null===(s=null===(t=n._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===s||s.call(t,r,n.channel)})),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype.initialize=function(e){var t=this,n=new ys;this._messages=[],this._unsentMessages=[],this._syncRange=new bt({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(y.REFRESH_CHANNEL),b((function(){return p(t,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var s=Math.floor(this._limit/2);if(e===Kn.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(e){return p(t,void 0,void 0,(function(){var t;return f(this,(function(s){switch(s.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,y.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return s.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(x(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=k.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var r,a,i=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(i);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,h=0,p=0;pt._startingPoint&&h++}t._hasPrevious=l>=s,t._hasNext=h>=s,(r=t._syncRange).extends.apply(r,d([],_(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(a=t._backgroundSync)||void 0===a||a.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,y.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(x(e))throw e;n._invokeResponse("remote",e,null)}))}));var r=k.of(this._iid),a=r.cacheContext;return r.statLogCollector.put(new ee({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:a.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return p(this,void 0,void 0,(function(){var e,t,n,s=this;return f(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new h({code:j.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasPrevious?(e=Math.floor(this._limit/2),t=this.viewTop,n=[],[4,b((function(){return p(s,void 0,void 0,(function(){var s;return f(this,(function(r){switch(r.label){case 0:return s=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{prevLimit:e,inclusive:!1})];case 1:return n=s.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return r.sent(),n.length=e,n.length>0&&((a=this._syncRange).extends.apply(a,d([],_(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(o=this._backgroundSync)||void 0===o||o.range.extends(this._syncRange.top))),[2]}}))}))}))]:[3,3];case 2:return r.sent(),this._addMessagesToView(n,y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=n.length>=e,n.length>0&&this._addMessagesToView(n,y.REQUEST_MESSAGE),r.label=4;case 4:return[2,n]}}))}))},e.prototype.loadNext=function(){var e;return p(this,void 0,void 0,(function(){var t,n,s,r=this;return f(this,(function(a){switch(a.label){case 0:if(this._isDisposed)throw new h({code:j.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasNext?(t=Math.floor(this._limit/2),n=this.viewBottom,s=[],[4,b((function(){return p(r,void 0,void 0,(function(){var e;return f(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(n,{nextLimit:t,inclusive:!1})];case 1:return s=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return a.sent(),s.length=t,s.length>0&&((a=this._syncRange).extends.apply(a,d([],_(s.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(o=this._backgroundSync)||void 0===o||o.range.extends(this._syncRange.bottom))),[2]}}))}))}))]:[3,3];case 2:return a.sent(),this._addMessagesToView(s,y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=s.length>=t,s.length>0&&this._addMessagesToView(s,y.REQUEST_MESSAGE),a.label=4;case 4:return[2,s]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new h({code:j.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,this._channelManager.removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n;if(!this._isDisposed){this._isDisposed=!0;var s=k.of(this._iid),r=s.cacheContext,a=s.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt();var i=this._createChannelUpdateEventCommand(y.CHANNEL_LASTACCESSEDAT_UPDATED);i&&a.dispatch(i),r.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),bs=function(t){function n(e,n){return t.call(this,e,s(s({},n),{channelManager:Yn.of(e)}))||this}return e(n,t),n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n}(Ms),Ns={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},Us=function(t){function n(e){var n=this,s=e.channelUrl,r=e.token,a=e.limit,i=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=N.GET,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/members"),n.params={token:r,limit:a,order:i,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(S),Ss=function(t){function n(e,n){var s=t.call(this,e,n)||this;s.members=[];var r=n.next,a=n.members;return s.token=r,a&&a.length>0&&(s.members=a.map((function(t){return new Rt(e,t)}))),s}return e(n,t),n}(T);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(gs||(gs={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Es||(Es={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Cs||(Cs={}));var Ts=function(t){function a(e,n,s){var r,a,o,u,c=this;return(c=t.call(this,e,n,i.GROUP,s)||this).mutedMemberFilter=gs.ALL,c.memberStateFilter=Cs.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=wt.ALL,c.order=Es.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(r=s.mutedMemberFilter)&&void 0!==r?r:gs.ALL,c.memberStateFilter=null!==(a=s.memberStateFilter)&&void 0!==a?a:Cs.ALL,c.nicknameStartsWithFilter=null!==(o=s.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=s.order)&&void 0!==u?u:Es.MEMBER_NICKNAME_ALPHABETICAL,c}return e(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&r(gs,this.mutedMemberFilter)&&r(Cs,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&r(wt,this.operatorFilter)&&r(Es,this.order)},a.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=k.of(this._iid).requestQueue,t=new Us(n(s(s({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=u.sent(),a=r.as(Ss),i=a.members,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},a}(ae),As=function(t){function n(e){var n=this,s=e.channelUrl,r=e.userId,a=e.accessCode;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/accept"),n.params={user_id:r,access_code:a},n}return e(n,t),n}(S),Is=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new sr(e,n),s.channel.myMemberState=Nt.JOINED,s}return e(n,t),n}(T),ws=function(n){function s(e){var s=this,r=e.channelUrl,a=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(s=n.call(this)||this).method=N.PUT,s.path="".concat(I,"/").concat(encodeURIComponent(r)),s.params=t({is_distinct:a,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:p,message_survival_seconds:f}),s}return e(s,n),s}(S),Ds=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.channel=new sr(e,n),s}return e(n,t),n}(T),Ls=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s)),n}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Rs=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.DELETE,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/hide"),n}return e(n,t),n}(S);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(T);var Ps=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.countPreference,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:r},a}return e(n,t),n}(S),ks=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.countPreference=n.count_preference,s}return e(n,t),n}(T),Os=function(t){function n(e){var n=this,s=e.channelUrl;return(n=t.call(this)||this).method=N.PUT,n.path="".concat(I,"/").concat(encodeURIComponent(s),"/reset_user_history"),n}return e(n,t),n}(S),Fs=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.ts_message_offset;return s.messageOffsetTimestamp=r,s}return e(n,t),n}(T),xs=s(s({},He),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Hs=s(s({},Ve),{scheduledAt:void 0}),Gs=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===ie.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(Z(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:oe.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return qe.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return We.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?je.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S),Vs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ce(e,n),s}return e(n,t),n}(T),Bs=function(s){function r(e){var r,a=this;a=s.call(this)||this;var i=[];e.mentionType===ie.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return a.method=N.PUT,a.path="".concat(Z(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),a.params=t(n({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:oe.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return We.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?je.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),a}return e(r,s),r}(S);!function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=new Ee(e,n),s}e(n,t)}(T);var qs=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.DELETE,n.path="".concat(Z(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a)),n}return e(n,t),n}(S),Ws=function(t){function n(e){var n=t.call(this)||this,s=e.channelType,r=e.channelUrl,a=e.scheduledMessageId;return n.method=N.POST,n.path="".concat(Z(s),"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(a),"/send_now"),n}return e(n,t),n}(S),js=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=e.pushTriggerOption,a=t.call(this)||this;return a.method=N.PUT,a.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:r},a}return e(n,t),n}(S),zs=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),Qs=function(t){function n(e){var n=e.userId,s=e.channelUrl,r=t.call(this)||this;return r.method=N.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(s)),r}return e(n,t),n}(S),Ys=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.pushTriggerOption=n.push_trigger_option,s.enabled=n.enable,s}return e(n,t),n}(T),Ks=function(t){function n(e){var n=e.channelType,s=e.channelUrl,r=e.messageId,a=t.call(this)||this;return a.method=N.POST,a.path="".concat(Z(n),"/").concat(encodeURIComponent(s),"/messages/").concat(r,"/pin"),a}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Js=function(t){function n(e){var n=e.channelType,s=e.channelUrl,r=e.messageId,a=t.call(this)||this;return a.method=N.DELETE,a.path="".concat(Z(n),"/").concat(encodeURIComponent(s),"/messages/").concat(r,"/pin"),a}return e(n,t),n}(S);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(T);var Xs,Zs,$s=function(t){function n(e,n){var s=t.call(this,e)||this;return s.message=me(e,n.message),s}return e(n,t),n}(u),er=function(n){function s(e){var s=this,r=e.channelType,a=e.channelUrl,i=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(s=n.call(this)||this).method=N.GET,s.path="".concat(Z(r),"/").concat(encodeURIComponent(a),"/pinned_messages"),s.params=t({limit:i,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),s}return e(s,n),s}(S),tr=function(t){function n(e,n){var s=t.call(this,e,n)||this,r=n.pinned_messages,a=n.has_more,i=n.next;return s.pinnedMessages=r.map((function(t){return new $s(e,t)})),s.hasMore=a,s.token=i,s}return e(n,t),n}(T),nr=function(t){function n(e,n,s,r){var a=t.call(this,e,n,s,r)||this;return a.includeMetaArray=r.includeMetaArray,a.includeReactions=r.includeReactions,a.includeParentMessageInfo=r.includeParentMessageInfo,a.includeThreadInfo=r.includeThreadInfo,a.includePollDetails=r.includePollDetails,a}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeMetaArray,!0)&&g("boolean",this.includeReactions,!0)&&g("boolean",this.includeParentMessageInfo,!0)&&g("boolean",this.includeThreadInfo,!0)&&g("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=k.of(this._iid).requestQueue,t=new er(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(tr),a=r.pinnedMessages,i=r.hasMore,o=r.token,this._token=o,this._hasNext=!!i,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw h.queryInProgress;case 4:return[3,6];case 5:throw h.invalidParameters;case 6:return[2]}}))}))},n}(ae);!function(e){e.ALL="all",e.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",e.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",e.OFF="off"}(Xs||(Xs={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Zs||(Zs={}));var sr=function(u){function c(e,t){var n,c,l,h,p,f,m,v,E,C,y,M,b,N,U,S,T,A,I,w,D=this;return(D=u.call(this,e,t)||this)._unreadMemberStateMap=new Map,D._undeliveredMemberStateMap=new Map,D._typingStatus=new Map,D._lastMemberCountUpdated=0,D._typingStarted=0,D._typingEnded=0,D.isDistinct=!1,D.isSuper=!1,D.isBroadcast=!1,D.isExclusive=!1,D.isPublic=!1,D.isDiscoverable=!0,D.isChatNotification=!1,D.isAccessCodeRequired=!1,D.isPushEnabled=!1,D.unreadMessageCount=0,D.unreadMentionCount=0,D.members=[],D.memberCount=0,D.joinedMemberCount=0,D.hiddenState=Zs.UNHIDDEN,D.lastMessage=null,D.messageOffsetTimestamp=0,D.messageSurvivalSeconds=-1,D.myMemberState=Nt.NONE,D.myRole=a.NONE,D.myMutedState=G.UNMUTED,D.myLastRead=0,D.myCountPreference=Xs.ALL,D.myPushTriggerOption=ce.DEFAULT,D.inviter=null,D.invitedAt=0,D.joinedAt=0,D.pinnedMessageIds=[],D.lastPinnedMessage=null,D._pinnedMessagesUpdatedAt=0,D._myMutedRemainingTime=-1,D.channelType=i.GROUP,D.isDistinct=null!==(c=t.is_distinct)&&void 0!==c&&c,D.isSuper=null!==(l=t.is_super)&&void 0!==l&&l,D.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,D.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,D.isPublic=null!==(f=t.is_public)&&void 0!==f&&f,D.isDiscoverable=null!==(m=t.is_discoverable)&&void 0!==m?m:D.isPublic,D.isChatNotification=null!==(v=t.is_chat_notification)&&void 0!==v&&v,D.isAccessCodeRequired=null!==(E=t.is_access_code_required)&&void 0!==E&&E,D.isPushEnabled=null!==(C=t.is_push_enabled)&&void 0!==C&&C,Array.isArray(t.members)&&(n=D.members).push.apply(n,d([],_(t.members.map((function(e){return new Rt(D._iid,e)}))),!1)),D.memberCount=null!==(y=t.member_count)&&void 0!==y?y:0,D.joinedMemberCount=null!==(M=t.joined_member_count)&&void 0!==M?M:0,D.hiddenState=r(Zs,t.hidden_state)?t.hidden_state:Zs.UNHIDDEN,D.messageOffsetTimestamp=null!==(b=t.ts_message_offset)&&void 0!==b?b:0,D.messageSurvivalSeconds=null!==(N=t.message_survival_seconds)&&void 0!==N?N:-1,D.lastMessage=t.last_message?me(D._iid,s({channel_type:D.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&D._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&D._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),D.myMemberState=r(Nt,t.member_state)?t.member_state:Nt.NONE,D.myRole=r(a,t.my_role)?t.my_role:a.NONE,r(G,t.is_muted)?D.myMutedState=t.is_muted:g("boolean",t.is_muted)?D.myMutedState=t.is_muted?G.MUTED:G.UNMUTED:D.myMutedState=G.UNMUTED,D.myCountPreference=r(Xs,t.count_preference)?t.count_preference:Xs.ALL,D.myPushTriggerOption=r(ce,t.push_trigger_option)?t.push_trigger_option:ce.ALL,D.myLastRead=null!==(U=t.user_last_read)&&void 0!==U?U:0,D.inviter=t.inviter?new o(D._iid,t.inviter):null,D.invitedAt=null!==(S=t.invited_at)&&void 0!==S?S:0,D.joinedAt=null!==(T=t.joined_ts)&&void 0!==T?T:0,D._updateUnreadCount(null!==(A=t.unread_message_count)&&void 0!==A?A:0,null!==(I=t.unread_mention_count)&&void 0!==I?I:0),D.pinnedMessageIds=null!==(w=t.pinned_message_ids)&&void 0!==w?w:[],D.lastPinnedMessage=t.latest_pinned_message?me(D._iid,s({channel_type:D.channelType},t.latest_pinned_message)):null,D}return e(c,u),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==Zs.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var s=m(this._unreadMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var s=m(this._undeliveredMemberStateMap),r=s.next();!r.done;r=s.next()){var a=_(r.value,2),i=a[0],o=a[1];n[i]=o}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),c.payloadify=function(e){return t(n(s(s({},u.payloadify.call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return Rt.payloadify(e)})),last_message:e.lastMessage?ze(e.lastMessage):null,inviter:e.inviter?o.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?ze(e.lastPinnedMessage):null})))},c.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Le&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===Xs.ALL||this.myCountPreference===Xs.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=k.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=n&&e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===Xs.ALL||this.myCountPreference===Xs.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},c.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},c.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},c.prototype._setLatestMemberCount=function(e,t,n){var s=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,s=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),s},c.prototype.isReadMessage=function(e){var t=k.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return R(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new bs(this._iid,s(s({},e),{channel:this}))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Ts(this._iid,this.url,e)},c.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new nr(this._iid,this.url,this.channelType,e)},c.prototype.addMember=function(e,t){if(void 0===t&&(t=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n=this.members.findIndex((function(t){return t.userId===e.userId}));if(n>-1){var s=this.members[n];s.state===Nt.JOINED&&(e.state=s.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof Rt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},c.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof Le&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var s=k.of(this._iid).sdkState,r=e.createdAt,a=0;try{for(var i=m(this.members),o=i.next();!o.done;o=i.next()){var u=o.value;if(s.userId!==u.userId&&u.state===Nt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&a.push(i)}})),a},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var s=k.of(this._iid).sdkState;if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var r=e instanceof Le?e.sender:null,a=[];return this.members.forEach((function(i){if(t||i.userId!==s.userId&&i.userId!==(null==r?void 0:r.userId)){var o=n._unreadMemberStateMap.get(i.userId);o&&o=t&&(e._typingStatus.delete(a),s=!0)})),s},c.prototype.refresh=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return[2,this._refresh()]}))}))},c.prototype._refresh=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return t=k.of(this._iid),n=t.requestQueue,s=t.dispatcher,r=new tn({channelUrl:this.url}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(nn).channel,this._update(i),e&&s.dispatch(new Jt({channels:[i],source:y.REQUEST_CHANNEL})),[2,this]}}))}))},c.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.freeze.call(this)];case 1:return e.sent(),k.of(this._iid).dispatcher.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,u.prototype.unfreeze.call(this)];case 1:return e.sent(),k.of(this._iid).dispatcher.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0})),[2]}}))}))},c.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return t=s(s({},Ns),e),l(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage,!0))&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(h.invalidParameters),n=k.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new ws(s({channelUrl:this.url},t)),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(Ds).channel,this._update(u),r.dispatch(new Jt({channels:[u],source:y.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return l(e.every((function(e){return e instanceof o}))).throw(h.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i;return f(this,(function(o){switch(o.label){case 0:return l(v("string",e)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,s=t.requestQueue,r=new Sn({channelUrl:this.url,userIds:e}),[4,s.send(r)];case 1:return a=o.sent(),i=a.as(Tn).channel,this._update(i),n.dispatch(new Jt({channels:[i],source:y.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.join=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new yn({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Mn).channel).myMemberState=this.myMemberState=Nt.JOINED,this._update(o),n.dispatch(new Jt({channels:[o],source:y.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,s,r;return f(this,(function(a){switch(a.label){case 0:return t=k.of(this._iid),n=t.sdkState,s=t.requestQueue,r=new Nn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,s.send(r)];case 1:return a.sent(),this.myMemberState=Nt.NONE,[2]}}))}))},c.prototype.acceptInvitation=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o;return f(this,(function(u){switch(u.label){case 0:return l(g("string",e,!0)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,s=t.sdkState,r=t.requestQueue,a=new As({channelUrl:this.url,userId:s.userId,accessCode:e}),[4,r.send(a)];case 1:return i=u.sent(),(o=i.as(Is).channel).myMemberState=this.myMemberState=Nt.JOINED,this._update(o),n.dispatch(new Jt({channels:[o],source:y.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new In({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),this.myMemberState=Nt.NONE,[2,this]}}))}))},c.prototype.sendUserMessage=function(e){var t=this,n=new $e,s=k.of(this._iid).dispatcher,r=dt.of(this._iid);return u.prototype.sendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){t.hiddenState===Zs.HIDDEN_ALLOW_AUTO_UNHIDE&&(t.hiddenState=Zs.UNHIDDEN),r.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),Yn.of(t._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new Jt({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=k.of(this._iid).dispatcher,[4,u.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),r=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,r=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(Yn.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new Jt({channels:[this],source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}))),a&&Yn.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new q({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendUserMessage=function(e){var t=this,n=new $e,s=k.of(this._iid).dispatcher,r=dt.of(this._iid);return u.prototype._autoResendUserMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=Yn.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new Jt({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.sendFileMessage=function(e){var t=this,n=new $e,s=k.of(this._iid).dispatcher,r=dt.of(this._iid);return u.prototype.sendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){t&&r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=Yn.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new Jt({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.sendMultipleFilesMessage=function(e){var t=this,n=new Qe,s=k.of(this._iid).dispatcher;return u.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){n._trigger(e)})).onFailed((function(e,t){n._triggerFailed(e,t)})).onSucceeded((function(e){var r=Yn.of(t._iid);t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new Jt({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})).onFileUploaded((function(e,t,s,r){n._triggerOnFileUploaded(e,t,s,r)})),n},c.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,r,a,i=this;return f(this,(function(o){switch(o.label){case 0:return n=k.of(this._iid).dispatcher,[4,u.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),r=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,r=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,r=!0,a=!0),r&&(Yn.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(i)})),n.dispatch(new Jt({channels:[this],source:a?y.EVENT_PINNED_MESSAGE_UPDATED:y.EVENT_MESSAGE_UPDATED}))),a&&Yn.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(i)})),n.dispatch(new q({messages:[s],source:y.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},c.prototype._autoResendFileMessage=function(e){var t=this,n=new $e,s=k.of(this._iid).dispatcher,r=dt.of(this._iid);return u.prototype._autoResendFileMessage.call(this,e).onPending((function(e){r.completeCurrentAndProcessNextAutoResend(e),n._trigger(e)})).onFailed((function(e,t){r.completeCurrentAndProcessNextAutoResend(t),n._triggerFailed(e,t)})).onSucceeded((function(e){var a=Yn.of(t._iid);r.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),a.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(t)})),s.dispatch(new Jt({channels:[t],source:y.EVENT_MESSAGE_SENT})),n._trigger(e)})),n},c.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,u.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof Le&&k.of(this._iid).dispatcher.dispatch(new le({reqId:e.reqId,source:y.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,a,i,o,u,c;return f(this,(function(d){switch(d.label){case 0:return t=s(s({},Dn),e),l(function(e){return g("boolean",e.hidePreviousMessages,!0)&&g("boolean",e.allowAutoUnhide,!0)}(t)).throw(h.invalidParameters),n=k.of(this._iid),r=n.dispatcher,a=n.sdkState,i=n.requestQueue,o=new Ln(s({channelUrl:this.url,userId:a.userId},t)),[4,i.send(o)];case 1:return u=d.sent(),c=u.as(Rn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?Zs.HIDDEN_ALLOW_AUTO_UNHIDE:Zs.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=k.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new Rs({channelUrl:this.url}),[4,n.send(s)];case 1:return r.sent(),this.hiddenState=Zs.UNHIDDEN,t.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},c.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=k.of(this._iid).requestQueue,t=new Ls({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,o=this;return f(this,(function(u){switch(u.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.dispatcher,s=e.requestQueue,r=new Bn({channelUrl:this.url}),[4,s.send(r)];case 1:return a=u.sent(),i=a.as(qn).readStatus,this._updateUnreadMemberState(t.userId,i.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Yn.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_READ})),[2]}}))}))},c.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,s;return f(this,(function(r){switch(r.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Wn({channelUrl:this.url,userId:t.userId}),[4,n.send(s)];case 1:return r.sent(),[2]}}))}))},c.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){return e=k.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=s,this._typingEnded=0,r=new kn({channelUrl:this.url,time:this._typingStarted}),t.send(r)),[2]}))}))},c.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r;return f(this,(function(a){return e=k.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=s,r=new Fn({channelUrl:this.url,time:this._typingStarted}),t.send(r)),[2]}))}))},c.prototype.createScheduledUserMessage=function(e){e=s(s({},Ye),e),l(Ke(e)).throw(h.invalidParameters);var t=new $e;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i;return f(this,(function(o){switch(o.label){case 0:return n=s(s({},Hs),t),l(function(e){return Be(e)&&g("number",e.scheduledAt,!0)}(n)).throw(h.invalidParameters),r=k.of(this._iid).requestQueue,a=new Bs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(a)];case 1:return i=o.sent(),[2,i.as(et).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},Je),e),l(Xe(e)).throw(h.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new $e;return ue(tt).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);H((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,a._trigger(s)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a},c.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return n=s(s({},xs),t),l(function(e){return Ge(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(h.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Gs(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,k.of(this._iid).requestQueue.send(r)];case 3:return a=i.sent(),[2,a.as(Vs).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new qs({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,k.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Ws({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,k.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=k.of(this._iid),t=e.sdkState,n=e.requestQueue,s=new Qs({userId:t.userId,channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(Ys).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(ce,e)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new js({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(zs).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,s,a,i,o,u;return f(this,(function(c){switch(c.label){case 0:return l(r(Xs,e)).throw(h.invalidParameters),t=k.of(this._iid),n=t.dispatcher,s=t.sdkState,a=t.requestQueue,i=new Ps({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,a.send(i)];case 1:return o=c.sent(),u=o.as(ks).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new Jt({channels:[this],source:y.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},c.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,s,r,a;return f(this,(function(i){switch(i.label){case 0:return e=k.of(this._iid),t=e.dispatcher,n=e.requestQueue,s=new Os({channelUrl:this.url}),[4,n.send(s)];case 1:return r=i.sent(),a=r.as(Fs).messageOffsetTimestamp,this.messageOffsetTimestamp=a,this.lastMessage&&this.lastMessage.createdAt0).throw(h.invalidParameters),t=k.of(this._iid).requestQueue,n=new Ks({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return s.sent(),[2]}}))}))},c.prototype.unpinMessage=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:return l(g("number",e)&&e>0).throw(h.invalidParameters),t=k.of(this._iid).requestQueue,n=new Js({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return s.sent(),[2]}}))}))},c.prototype._uploadFileAndUpdateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,s,r,a,i,o,u,c,l,h;return f(this,(function(d){switch(d.label){case 0:return E(e.file)?(t=k.of(this._iid).requestQueue,n=new st({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:s=d.sent(),r=s.as(nt),a=r.url,i=r.fileSize,o=void 0===i?e.fileSize:i,u=r.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=r.requireAuth,h=void 0!==l&&l,e.fileUrl=a,e.fileSize=o,e.thumbnailSizes=c,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},c}(Ze);export{nr as A,kt as B,Xs as C,ss as D,pn as E,rs as F,Yn as G,It as H,zt as I,_n as J,wn as K,An as L,Rt as M,qn as N,wt as O,Ut as P,Dt as Q,Pt as R,Jn as S,jt as T,At as U,Hn as V,Ms as W,Bn as X,ds as Y,fs as Z,Ot as a,hs as b,sr as c,Tt as d,Gn as e,Gt as f,Bt as g,qt as h,xt as i,Ht as j,Yt as k,Lt as l,Zs as m,Es as n,Ts as o,Nt as p,Cs as q,St as r,Kt as s,bs as t,ys as u,Vt as v,Kn as w,ps as x,gs as y,$s as z}; diff --git a/lib/__bundle-d3df41f8.js b/lib/__bundle-6f8fc428.js similarity index 97% rename from lib/__bundle-d3df41f8.js rename to lib/__bundle-6f8fc428.js index 1af4a25..2b37d71 100644 --- a/lib/__bundle-d3df41f8.js +++ b/lib/__bundle-6f8fc428.js @@ -1 +1 @@ -import{X as e,_ as t,W as n,U as s,o as r,p as o,b as a,c as i,a7 as u,V as c,aj as h,at as l,u as E,b4 as N,ap as _}from"./__bundle-1da35e70.js";import{p as d,q as p,ao as C,a5 as f,ap as m,aq as A,ar as v}from"./__bundle-0099b2f2.js";import{P as g}from"./__bundle-c336221f.js";var U;!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(U||(U={}));var b=function(){function t(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}return Object.defineProperty(t.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.OPEN},enumerable:!1,configurable:!0}),t}(),T=function(e){function n(t,n,s){var r=e.call(this,t,"SYEV",s)||this;return r.event=new b(s),r}return t(n,e),n}(n),M=function(e){function n(t,n,r){var o=e.call(this,t,n,r)||this,a=r.data.operators,i=void 0===a?[]:a;return o.operators=i.map((function(e){return new s(o._iid,e)})),o}return t(n,e),n}(T),H=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,s=e.bottom,r=void 0===s?0:s;this.top=n,this.bottom=r}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return e=g.of(this._iid),(t=new f).replyType=l.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,s.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new I({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(L||(L={}));var v=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new _(e,n),blockee:new _(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new _(e,t)})):[]}},e}(),D=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),T=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),b=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new v(n),r}return e(s,t),s}(A);export{N as A,D,E as G,p as P,T as R,C as S,b as U,L as a,v as b,I as c,R as g}; diff --git a/lib/__bundle-bd25634c.js b/lib/__bundle-bd25634c.js new file mode 100644 index 0000000..ec4dde8 --- /dev/null +++ b/lib/__bundle-bd25634c.js @@ -0,0 +1 @@ +import{_ as e,A as t,a6 as n,e as r,f as i,h as s,u as a,g as o,U as u,a7 as c,K as l,a as d,O as h,o as f,p,r as m,a0 as v,a8 as y,a9 as _,aa as g,X as b,ab as I,ac as E,ad as T,ae as w,b as S,c as M,s as N,q as A,af as U,V as C,ag as O,ah as P,ai as k,aj as R,W as x,y as L,z as D,ak as F,al as q,i as z,am as B,an as K,ao as j,ap as Q,aq as G,ar as V,as as H,at as W,au as Y,av as J,aw as X,ax as Z,ay as $,m as ee,az as te,T as ne,B as re,aA as ie,aB as se,t as ae,w as oe,aC as ue,aD as ce,d as le,aE as de,aF as he,aG as fe,N as pe,aH as me,aI as ve,aJ as ye,aK as _e,x as ge,aL as be,aM as Ie}from"./__bundle-fdefc164.js";var Ee,Te=function(i){function s(e){var s=i.call(this)||this;if(s.method=t.POST,s.path="".concat(n),s.params=r({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var a=0;a0&&d("number",a)&&(this.key=i,this.userIds=s,this.updatedAt=a);var o={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){o[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=o}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return r(a({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case Ee.ADD:t<0&&this.userIds.push(e.userId);break;case Ee.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),Ce=function(){function e(e){this.key=e.key,this.value=l("string",e.value)?f([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return r(a({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),Oe=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return r(a({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))},e}(),Pe=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new Oe(e["og:image"]))}return e.payloadify=function(e){return r(a({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Oe.payloadify(e.defaultImage):null}))},e}(),ke=function(){function e(e){var t,n;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return r(a({name:e.name,volume:e.volume}))},e}(),Re=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).isBlockedByMe=!1,i.role=h(v,n.role)?n.role:v.NONE,i.isBlockedByMe=null!==(r=n.is_blocked_by_me)&&void 0!==r&&r,i}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))},n}(u);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(Me||(Me={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Ne||(Ne={}));var xe=function(e){switch(e){case _.BASE:return"";case _.USER:return"MESG";case _.FILE:return"FILE";case _.ADMIN:return"ADMM"}},Le=function(t){function n(e,n){var r,i,s,a,o,c,l,d,f,p,m,v,y,g,E,T,w=this;(w=t.call(this,e)||this).channelType=b.BASE,w.parentMessage=null,w.silent=!1,w.isOperatorMessage=!1,w.messageType=_.BASE,w.mentionType=null,w.threadInfo=null,w.reactions=[],w.metaArrays=[],w.appleCriticalAlertOptions=null,w.createdAt=0,w.updatedAt=0,w.scheduledInfo=null,w.extendedMessage={},w._isContinuousMessages=!1,w._scheduledStatus=null,w.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,w.channelUrl=n.channel_url,w.channelType=h(b,n.channel_type)?n.channel_type:b.GROUP,n.channel&&(n.channel.channel_url&&(w.channelUrl=n.channel.channel_url),n.channel.channel_type&&(w.channelType=n.channel.channel_type)),w.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,w.data=null!==(a=n.data)&&void 0!==a?a:"",w.customType=null!==(o=n.custom_type)&&void 0!==o?o:"",w.mentionType=h(I,n.mention_type)?n.mention_type:null,w.mentionedUsers=n.mentioned_users?n.mentioned_users.map((function(e){return new u(w._iid,e)})):null,w.mentionedUserIds=null!==(c=n.mentioned_user_ids)&&void 0!==c?c:null,w.mentionedUsers&&!w.mentionedUserIds&&(w.mentionedUserIds=w.mentionedUsers.map((function(e){return e.userId}))),w.mentionedMessageTemplate=null!==(l=n.mentioned_message_template)&&void 0!==l?l:"",w.threadInfo=n.thread_info?new Se(w._iid,n.thread_info):null,w.reactions=n.reactions?n.reactions.map((function(e){return new Ue(e)})):[];var S=null!==(d=n.metaarray)&&void 0!==d?d:{},M=null!==(f=n.metaarray_key_order)&&void 0!==f?f:Object.keys(S).sort((function(e,t){return e.localeCompare(t)}));w.metaArrays=[];for(var N=0;N=t)return this.parentMessage=e,!0}return!1},n}(c),De=function(t){function n(e,n){var r,i,s,a,o=this;if((o=t.call(this,e,n)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=n.user?new Re(o._iid,n.user):n.sender_id,o.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=n.is_reply_to_channel)&&void 0!==s&&s,n.request_state&&h(E,n.request_state)&&(o.sendingStatus=n.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=E.SUCCEEDED;else if(o.scheduledInfo)switch(n.scheduled_status&&(o._scheduledStatus=n.scheduled_status),n.scheduled_status){case Ne.SENT:case Ne.IN_QUEUE:o.sendingStatus=E.SUCCEEDED;break;case Ne.PENDING:o.sendingStatus=E.SCHEDULED;break;case Ne.FAILED:case Ne.REMOVED:o.sendingStatus=E.FAILED;break;case Ne.CANCELED:o.sendingStatus=E.CANCELED}else o.sendingStatus=E.PENDING;return o.errorCode=null!==(a=n.error_code)&&void 0!==a?a:0,o}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{user:Re.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))},Object.defineProperty(n.prototype,"isResendable",{get:function(){return(this.sendingStatus===E.FAILED||this.sendingStatus===E.CANCELED)&&T(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(Le),Fe=function(){function e(e){var t,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return r(a({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),qe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:w.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ze=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&h(w,e.messageTypeFilter)&&l("string",e.customTypesFilter,!0)&&l("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},Be=function(t){function n(e,n){var i,s,u,c,l=this;if((l=t.call(this,e,n)||this).translations={},l.message=null!==(i=n.message)&&void 0!==i?i:"",l.messageType=_.ADMIN,l.translations=null!==(s=n.translations)&&void 0!==s?s:{},n.parent_message_info){var d=n.parent_message_info;l.parentMessage=He(e,r(a(o(o({},d),{message_id:l.parentMessageId,channel_url:l.channelUrl,channel_type:l.channelType,file:d.file,url:null===(u=d.file)||void 0===u?void 0:u.url,require_auth:null===(c=d.file)||void 0===c?void 0:c.require_auth}))))}return l}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return S(this,void 0,void 0,(function(){var n;return M(this,(function(r){switch(r.label){case 0:return n=o(o({},qe),t),N(this.messageId>0&&d("number",e)&&ze(n)).throw(A.invalidParameters),[4,is.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n}(Le),Ke=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return r(a({type:e.type,vendor:e.vendor,detail:e.detail}))},e}(),je=function(t){function n(e,n){var i,s,u,c,l,d,h,f=this;if((f=t.call(this,e,n)||this).message="",f.messageParams=null,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f._poll=null,f.message=n.message,f.messageType=_.USER,f.translations=null!==(u=n.translations)&&void 0!==u?u:{},f.translationTargetLanguages=null!==(c=n.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=m(f.translationTargetLanguages),v=p.next();!v.done;v=p.next()){var y=v.value;f.translations[y]=""}}catch(e){i={error:e}}finally{try{v&&!v.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}if(f.messageSurvivalSeconds=null!==(l=n.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=n.plugins?n.plugins.map((function(e){return new Ke(e)})):[],f._poll=n.poll?new U(f._iid,n.poll):null,n.parent_message_info){var g=n.parent_message_info;f.parentMessage=He(e,r(a(o(o({},g),{created_at:g.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:g.file,url:null===(d=g.file)||void 0===d?void 0:d.url,require_auth:null===(h=g.file)||void 0===h?void 0:h.require_auth}))))}return f}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Ke.payloadify(e)})),poll:e._poll?U.payloadify(e._poll):null,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return S(this,void 0,void 0,(function(){var n;return M(this,(function(r){switch(r.label){case 0:return n=o(o({},qe),t),N(this.messageId>0&&d("number",e)&&ze(n)).throw(A.invalidParameters),[4,is.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(De),Qe=function(t){function n(e,n){var r,i,s,a,u,c=this;(c=t.call(this,e)||this).plainUrl="",c.fileName=null,c.mimeType=null,c.fileSize=0,c.thumbnails=[],c._requireAuth=!1,c.plainUrl=null!==(r=n.url)&&void 0!==r?r:"",c.fileName=null!==(i=n.file_name)&&void 0!==i?i:null,c.mimeType=null!==(s=n.file_type)&&void 0!==s?s:null,c.fileSize=null!==(a=n.file_size)&&void 0!==a?a:0,c._requireAuth=null!==(u=n.require_auth)&&void 0!==u&&u;var l=C.of(c._iid).sessionManager;return c.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new Fe(o(o({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(c._requireAuth?"?auth=".concat(l.ekey):"")}))})):[],c}return e(n,t),n.payloadify=function(e){var t;return r(a({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))},Object.defineProperty(n.prototype,"url",{get:function(){var e=C.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(c),Ge=function(t){function n(e,n){var i,s,u,c,l,d=this;if((d=t.call(this,e,n)||this).messageParams=null,d.fileInfoList=[],d.messageSurvivalSeconds=-1,d.messageType=_.FILE,d.fileInfoList=null!==(s=null===(i=n.files)||void 0===i?void 0:i.map((function(t){return new Qe(e,t)})))&&void 0!==s?s:[],d.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,n.parent_message_info){var h=n.parent_message_info;d.parentMessage=He(e,r(a(o(o({},h),{created_at:h.ts,message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth}))))}return d}return e(n,t),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return S(this,void 0,void 0,(function(){var n;return M(this,(function(r){switch(r.label){case 0:return n=o(o({},qe),t),N(this.messageId>0&&d("number",e)&&ze(n)).throw(A.invalidParameters),[4,is.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Qe.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(De),Ve=function(e){switch(e.messageType){case _.USER:return je.payloadify(e);case _.FILE:return e.fileInfoList?Ge.payloadify(e):We.payloadify(e);case _.ADMIN:return Be.payloadify(e);default:throw A.unknown}},He=function(e,t){switch(t.type){case"MESG":return new je(e,t);case"FILE":return Ge._isMultipleFilesMessagePayload(t)?new Ge(e,t):new We(e,t);case"ADMM":case"BRDM":return new Be(e,t)}throw A.unknown},We=function(t){function n(e,n){var i,s,u,c,l,d,h,f,p,m,v,y,g,b,I=this;(I=t.call(this,e,n)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=_.FILE;var E=n.file;I.plainUrl=(null!==(s=null!==(i=null==E?void 0:E.url)&&void 0!==i?i:n.url)&&void 0!==s?s:"").split("?auth=")[0],I.name=null!==(c=null!==(u=null==E?void 0:E.name)&&void 0!==u?u:n.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:n.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:n.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=n.type)&&void 0!==m?m:"";var T=C.of(I._iid).sessionManager;if(I.requireAuth=null!==(v=n.require_auth)&&void 0!==v&&v,I.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new Fe(o(o({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(I.requireAuth?"?auth=".concat(T.ekey):"")}))})):[],I.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var w=n.parent_message_info;I.parentMessage=He(e,r(a(o(o({},w),{created_at:w.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:w.file,url:null===(g=w.file)||void 0===g?void 0:g.url,require_auth:null===(b=w.file)||void 0===b?void 0:b.require_auth}))))}return I}return e(n,t),n.payloadify=function(e){var n;return r(a(o(o({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},Object.defineProperty(n.prototype,"url",{get:function(){var e=C.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return S(this,void 0,void 0,(function(){var n;return M(this,(function(r){switch(r.label){case 0:return n=o(o({},qe),t),N(this.messageId>0&&d("number",e)&&ze(n)).throw(A.invalidParameters),[4,is.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},n}(De),Ye=function(t){function n(e){var n,i,s,o=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,files:e.files?$e(e.files):null,url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(i=e.mimeType)&&void 0!==i?i:"",size:null!==(s=e.fileSize)&&void 0!==s?s:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==O.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(P),Je=function(n){function i(e){var i,s,o=this;o=n.call(this)||this;var u=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?u=e.mentionedUserIds:e.mentionedUsers&&(u=e.mentionedUsers.map((function(e){return e.userId})))),o.method=t.POST,o.path="".concat(k(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),o.params=r(a({message_type:_.FILE,user_id:e.userId,files:e.files?$e(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:u,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(i=e.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return Fe.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((function(e){return Ce.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage})),o}return e(i,n),i}(i),Xe=function(t){function n(e,n,r){var i,s,a,o,u=this;(u=t.call(this,e,"FILE",r)||this).message=r.files&&r.files.length>=2?new Ge(e,r):new We(e,r);var c=C.of(e).sdkState;return u.isMentioned=R(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return e(n,t),n}(x),Ze=function(t){function n(e,n){var r,i,s,a,o=this;(o=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Ge(e,n):new We(e,n);var u=C.of(e).sdkState;return o.isMentioned=R(o.message.mentionType,null!==(s=null!==(r=o.message.mentionedUserIds)&&void 0!==r?r:null===(i=o.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==s?s:[],u.userId),o.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,o}return e(n,t),n}(s);function $e(e){return e.map((function(e){var t,n;return r(a({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return Fe.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var et;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(et||(et={}));var tt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof L&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===D.CONNECTED||this._connectionState===D.CONNECTING||this._connectionState===D.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return M(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ye(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Xe).message];case 2:return r=new Je(o(o({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Ze).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=o(o({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return S(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return M(this,(function(v){switch(v.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,v.label=1;case 1:v.trys.push([1,15,16,17]),s=m(n.messageQueue),a=s.next(),v.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case et.PENDING:case et.UPLOADING:return[3,3];case et.UPLOADED:return[3,4];case et.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];v.label=5;case 5:return v.trys.push([5,8,,9]),o.state=et.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=v.sent(),o.deferred.resolve(u),[4,q(100)];case 7:return v.sent(),[3,9];case 8:return c=v.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),v.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:A.unknown,o.deferred.reject(l.code===F.REQUEST_CANCELED?A.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=v.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:v.sent(),v.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,v.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return S(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l;return M(this,(function(d){switch(d.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===et.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,l=r.params,u=l.fileInfoList[s],!z(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return d.sent(),[3,3];case 2:r.state=s=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,s;return S(this,void 0,void 0,(function(){var a,o,u,c,l,d,h,f,p,m;return M(this,(function(v){switch(v.label){case 0:return a=new Te({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(a)];case 1:return o=v.sent(),u=o.as(we),c=u.url,l=u.fileSize,d=void 0===l?n.fileSize:l,h=u.thumbnailSizes,f=void 0===h?n.thumbnailSizes:h,p=u.requireAuth,m=void 0!==p&&p,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(s=n.fileSize)&&void 0!==s?s:n.file.size,n.fileUrl=c,n.fileSize=d,n.thumbnailSizes=f,n.requireAuth=m,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,s;return S(this,void 0,void 0,(function(){var a,u,c,l,d,h,f,p,m,v,y,_;return M(this,(function(g){switch(g.label){case 0:return a=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[a],c=new Te({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return l=g.sent(),d=l.as(we),h=d.url,f=d.fileSize,p=void 0===f?u.fileSize:f,m=d.thumbnailSizes,v=void 0===m?u.thumbnailSizes:m,y=d.requireAuth,_=void 0!==y&&y,u.fileName=null!==(r=u.fileName)&&void 0!==r?r:u.file.name,u.mimeType=null!==(i=u.mimeType)&&void 0!==i?i:u.file.type,u.fileSize=null!==(s=u.fileSize)&&void 0!==s?s:u.file.size,u.file=void 0,u.fileUrl=h,u.fileSize=p,u.thumbnailSizes=v,u._uploadedMetaData=o(o({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),S(this,void 0,void 0,(function(){var i,s,a,u,c;return M(this,(function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),s=this._queueMap.get(e.url),a=new B,u={requestId:t,params:n,state:et.PENDING,deferred:a},function(e){return"fileInfoList"in e}(n)&&(c=o({uploadIndex:0,uploadCount:n.fileInfoList.length},r),u.multipleFileUploadInfo=c),s.messageQueue.push(u),this._uploadNextPendingItem(e),[2,a.promise]}))}))},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:f([],p(i.messageQueue),!1);try{for(var a=m(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(u)switch(u.state){case et.PENDING:if(u.state=et.FAILED,u.error=A.requestCanceled,u.multipleFileUploadInfo&&!u.multipleFileUploadInfo.isCopy){var c=u.multipleFileUploadInfo,l=c.uploadIndex,d=c.requestHandler,h=u.params.fileInfoList[l];null==d||d._triggerOnFileUploaded(u.requestId,l,h,A.fileUploadCanceled)}this._resolveMessageQueue(e);break;case et.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e}();var nt,rt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:w.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:K.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},it=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&h(w,e.messageTypeFilter)&&l("string",e.customTypesFilter,!0)&&l("string",e.senderUserIdsFilter,!0)&&h(K,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},st={replyType:K.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},at=function(e){return h(K,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},ot=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.includeMetaArray,o=e.includeReactions,u=e.includeThreadInfo,c=e.includeParentMessageInfo,l=n.call(this)||this;return l.method=t.GET,l.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return e(r,n),r}(i),ut=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=n?He(e,o({},n)):null,r}return e(n,t),n}(s),ct=function(n){function i(e){var i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,m=e.senderUserIdsFilter,v=e.replyType,y=e.includeMetaArray,_=e.includeReactions,g=e.parentMessageId,b=e.includeThreadInfo,I=e.includeParentMessageInfo,E=e.showSubchannelMessagesOnly,T=e.checkingContinuousMessages,w=n.call(this)||this;return w.method=t.GET,w.path="".concat(k(i),"/").concat(encodeURIComponent(s),"/messages"),w.params=r(a({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:m,include_reply_type:v,with_sorted_meta_array:y,include_reactions:_,parent_message_id:g,include_thread_info:b,include_parent_message_info:I,show_subchannel_message_only:E,include_poll_details:!0,checking_continuous_messages:T})),w}return e(i,n),i}(i),lt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.messages=n.messages.map((function(t){return He(e,t)})),r}return e(n,t),n}(s),dt=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,a=e.token,o=e.replyType,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/changelogs"),h.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return e(r,n),r}(i),ht=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedMessages=n.updated.map((function(t){return He(e,t)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return e(n,t),n}(s),ft=function(n){function r(e){var r=e.channelUrl,i=e.scheduledMessageId,s=n.call(this)||this;return s.method=t.GET,s.path="".concat(j,"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(i)),s.params={},s}return e(r,n),r}(i),pt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=n?He(e,o({},n)):null,r}return e(n,t),n}(s);!function(e){e.MUTED="muted",e.BANNED="banned"}(nt||(nt={}));var mt=function(){function e(e){var t,n,r,i;this.restrictionType=null,h(nt,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return e.payloadify=function(e){return r(a({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),vt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.restrictionInfo=new mt(n),r}return e(n,t),n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),mt.payloadify(e.restrictionInfo))))},n}(u),yt=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return e(n,t),n}(u),_t=function(){function e(){this._onPending=Q,this._onFailed=Q,this._onSucceeded=Q}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case E.PENDING:0===e.errorCode&&this._onPending(e);break;case E.SCHEDULED:case E.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case E.FAILED:case E.CANCELED:this._onFailed(e,t.scheduledInfo?null:t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),gt={data:void 0,customType:void 0,mentionType:I.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},bt=function(e){return d("string",e.data,!0)&&d("string",e.customType,!0)&&h(I,e.mentionType)&&l("string",e.mentionedUserIds,!0)&&l(u,e.mentionedUsers,!0)&&d("string",e.mentionedMessageTemplate,!0)&&l(Ce,e.metaArrays,!0)&&d("number",e.parentMessageId,!0)&&d("boolean",e.isReplyToChannel)&&h(O,e.pushNotificationDeliveryOption,!0)&&d(ke,e.appleCriticalAlertOptions,!0)&&d("boolean",e.isPinnedMessage,!0)},It=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Et=o(o({},gt),{message:"",translationTargetLanguages:void 0,pollId:void 0});function Tt(e){var t,n,r;return null!==(t=e.messageParams)&&void 0!==t?t:a(o(o({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:O.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var wt,St=function(e){var t;return r(a({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},Mt=function(e){return bt(e)&&d("string",e.message)&&l("string",e.translationTargetLanguages,!0)&&d("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(wt||(wt={}));var Nt=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},At=function(e){return e===wt.BLOB||e===wt.FILE},Ut=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Ct=o(o({},gt),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1});function Ot(e){var t,n,r,i;return null!==(t=e.messageParams)&&void 0!==t?t:a(o(o({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:O.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:e.requireAuth,isPinnedMessage:!1}))}var Pt,kt=function(e,t){var n;return e.messageParams?(!e.url&&z(t)&&(e.messageParams.file=t),e.messageParams):r(a({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},Rt=function(e){return bt(e)&&(z(e.file)||d("string",e.fileUrl))&&d("string",e.fileName,!0)&&d("string",e.mimeType,!0)&&d("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return d("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},xt={data:void 0,customType:void 0,mentionType:I.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},Lt=function(e){return d("string",e.data,!0)&&d("string",e.customType,!0)&&h(I,e.mentionType)&&l("string",e.mentionedUserIds,!0)&&l(u,e.mentionedUsers,!0)&&d("string",e.mentionedMessageTemplate,!0)&&l(Ce,e.metaArrays,!0)&&h(O,e.pushNotificationDeliveryOption,!0)&&d(ke,e.appleCriticalAlertOptions,!0)},Dt=o(o({},xt),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Ft=function(e){return Lt(e)&&d("string",e.message,!0)&&l("string",e.translationTargetLanguages,!0)&&d("number",e.pollId,!0)},qt=o({},xt),zt=function(n){function r(e){var r=e.channelUrl,i=e.channelType,s=e.token,a=e.limit,o=n.call(this)||this;return o.method=t.GET,o.path="".concat(k(i),"/").concat(encodeURIComponent(r),"/operators"),o.params={token:s,limit:a},o}return e(r,n),r}(i),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.operators=n.operators.map((function(t){return new u(e,t)})),r.token=n.next,r}return e(n,t),n}(s),Kt=function(t){function n(e,n,r,i){return t.call(this,e,n,r,i)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s,a;return M(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=C.of(this._iid).requestQueue,n=new zt(o(o({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Bt),s=i.operators,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,e];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(G),jt=function(t){function n(e,n,r,i){var s,a,o,u,c,l,d,h,f,p,m=this;return(m=t.call(this,e,n,r,i)||this).reverse=!1,m.messageTypeFilter=w.ALL,m.customTypesFilter=null,m.senderUserIdsFilter=null,m.replyType=K.NONE,m.includeMetaArray=!1,m.includeReactions=!1,m.includeParentMessageInfo=!1,m.includeThreadInfo=!1,m.showSubchannelMessagesOnly=!1,m._edge=Number.MAX_SAFE_INTEGER,m.reverse=null!==(s=i.reverse)&&void 0!==s&&s,m.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:w.ALL,m.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,m.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,m.replyType=null!==(c=i.replyType)&&void 0!==c?c:K.NONE,m.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,m.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,m.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,m.includeThreadInfo=null!==(f=i.includeThreadInfo)&&void 0!==f&&f,m.showSubchannelMessagesOnly=null!==(p=i.showSubchannelMessagesOnly)&&void 0!==p&&p,m}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&h(w,this.messageTypeFilter)&&h(K,this.replyType)&&l("string",this.customTypesFilter,!0)&&l("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,is.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,a({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}))]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,f([Number.MAX_SAFE_INTEGER],p(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(G),Qt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.limit,o=e.token;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute"),r.params={limit:a,token:o},r}return e(r,n),r}(i),Gt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map((function(t){return new vt(e,t)}))),r}return e(n,t),n}(s),Vt=function(t){function n(e,n,r,i){return t.call(this,e,n,r,i)||this}return e(n,t),n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,t=new Qt(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(Gt),i=r.mutedUsers,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(G),Ht=function(n){function i(e){var i=this,s=e.channelUrl,a=e.channelType,o=e.limit,u=e.token;return(i=n.call(this)||this).method=t.GET,i.path="".concat(k(a),"/").concat(encodeURIComponent(s),"/ban"),i.params=r({limit:o,token:u}),i}return e(i,n),i}(i),Wt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(t){return new vt(e,t.user)}))),r}return e(n,t),n}(s),Yt=function(t){function n(e,n,r,i){return t.call(this,e,n,r,i)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,t=new Ht(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(Wt),i=r.bannedUsers,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(G);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Pt||(Pt={}));var Jt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.operatorUserIds;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/operators"),r.params={operator_ids:a},r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Xt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.operatorUserIds;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/operators"),r.params={operator_ids:a},r}return e(r,n),r}(i);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(s);var Zt=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute/").concat(a),r}return e(r,n),r}(i),$t=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return e(n,t),n}(s),en=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.keys;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={keys:a,include_ts:!0},r}return e(r,n),r}(i),tn=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return e(n,t),n}(s),nn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metadata;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={metadata:a,include_ts:!0},r}return e(r,n),r}(i),rn=function(t){function n(e,n){var r,i,s=this;return(s=t.call(this,e,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return e(n,t),n}(s),sn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metadata,o=e.upsert;return(r=n.call(this)||this).method=t.PUT,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={metadata:a,include_ts:!0,upsert:null!=o&&o},r}return e(r,n),r}(i),an=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return e(n,t),n}(s),on=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return e(n,t),n}(x),un=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.key;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(a),r.params={include_ts:!0},r}return e(r,n),r}(i),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.ts;return r.ts=i,r}return e(n,t),n}(s),ln=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={include_ts:!0},r}return e(r,n),r}(i),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this,i=n.ts;return r.ts=i,r}return e(n,t),n}(s),hn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.keys;return(r=n.call(this)||this).method=t.GET,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={keys:a},r}return e(r,n),r}(i),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.metaCounter=n,r}return e(n,t),n}(s),pn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metaCounter;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={metacounter:a},r}return e(r,n),r}(i),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.metaCounter=n,r}return e(n,t),n}(s),vn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metaCounter,o=e.upsert,u=void 0!==o&&o,c=e.mode,l=void 0===c?"set":c;return(r=n.call(this)||this).method=t.PUT,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={metacounter:a,upsert:u,mode:l},r}return e(r,n),r}(i),yn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.metaCounter=n,r}return e(n,t),n}(s),_n=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return e(n,t),n}(x),gn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.key;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(a),r.params={},r}return e(r,n),r}(i);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(s);var bn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={},r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var In=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId,o=e.seconds,u=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute"),r.params={user_id:a,seconds:o,description:u},r}return e(r,n),r}(i);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(s);var En=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new vt(e,r.data),i}return e(n,t),n}(x),Tn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(a)),r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var wn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new vt(e,r.data),i}return e(n,t),n}(x),Sn=function(n){function i(e){var i=this,s=e.channelUrl,a=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(i=n.call(this)||this).method=t.POST,i.path="".concat(k(a),"/").concat(encodeURIComponent(s),"/ban"),i.params=r({user_id:o,seconds:u,description:c}),i}return e(i,n),i}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Mn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new vt(e,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return e(n,t),n}(x),Nn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=t.DELETE,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(a)),r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var An=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.user=new vt(e,r.data),i}return e(n,t),n}(x),Un=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.freezing;return(r=n.call(this)||this).method=t.PUT,r.path="".concat(k(s),"/").concat(encodeURIComponent(i),"/freeze"),r.params={freeze:a},r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Cn=function(t){function n(e,n,r){var i=t.call(this,e,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return e(n,t),n}(x),On=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(V(s),"/").concat(encodeURIComponent(i)),r.params={report_category:a,reporting_user_id:o,report_description:u},r}return e(r,n),r}(i),Pn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.offendingUserId,c=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(H,"/users/").concat(u),r.params={channel_url:i,channel_type:s===b.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},r}return e(r,n),r}(i),kn=function(n){function r(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.offendingUserId,c=e.messageId,l=e.description;return(r=n.call(this)||this).method=t.POST,r.path="".concat(V(s),"/").concat(encodeURIComponent(i),"/messages/").concat(c),r.params={report_category:a,reporting_user_id:o,report_description:l,offending_user_id:u},r}return e(r,n),r}(i),Rn=function(t){function n(e){var n=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:n,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==O.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(P),xn=function(t){function n(e,n,r){var i,s,a,o,u=this;(u=t.call(this,e,"MESG",r)||this).message=new je(e,r);var c=C.of(e).sdkState;return u.isMentioned=R(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return e(n,t),n}(x),Ln=function(t){function n(e){var n=null;return e.mentionType===I.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:n,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})||this}return e(n,t),n}(P),Dn=function(t){function n(e,n,r){var i,s,o,u,c,l=this;(l=t.call(this,e,"MEDI",r)||this).message=new je(e,r);var d=C.of(e).sdkState;return l.mentionCountChange=W({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},a({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return e(n,t),n}(x),Fn=function(t){function n(e){var n=null;return e.mentionType===I.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:r(a({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:n,apple_critical_alert_options:e.appleCriticalAlertOptions}))})||this}return e(n,t),n}(P),qn=function(t){function n(e,n,r){var i,s,o,u,c,l=this;(l=t.call(this,e,"FEDI",r)||this).message=new We(e,r);var d=C.of(e).sdkState;return l.mentionCountChange=W({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},a({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return e(n,t),n}(x),zn=function(n){function r(e){var r=n.call(this)||this;return r.method=t.DELETE,r.path="".concat(k(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),r}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Bn=function(t){function n(e,n,r){var i=t.call(this,e,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return e(n,t),n}(x),Kn=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.reactionKey,o=n.call(this)||this;return o.method=t.POST,o.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return e(r,n),r}(i),jn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.reactionEvent=new Ae(n),r}return e(n,t),n}(s),Qn=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.reactionKey,o=n.call(this)||this;return o.method=t.DELETE,o.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return e(r,n),r}(i),Gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.reactionEvent=new Ae(o({},n)),r}return e(n,t),n}(s),Vn=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.translationTargetLanguages,o=n.call(this)||this;return o.method=t.POST,o.path="".concat(k(r),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return e(r,n),r}(i),Hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new je(e,n),r}return e(n,t),n}(s),Wn=function(n){function i(e){var i,s=this;s=n.call(this)||this;var o=[];e.mentionType===I.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(e){return e.userId}))));var u=e.channelType,c=e.channelUrl;return s.method=t.POST,s.path="".concat(k(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=r(a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:Y.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return Ce.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),s}return e(i,n),i}(i),Yn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new je(e,n),r}return e(n,t),n}(s),Jn=function(n){function r(e){var r,i=this;i=n.call(this)||this;var s=[];e.mentionType===I.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl;return i.method=t.POST,i.path="".concat(k(o),"/").concat(encodeURIComponent(u),"/scheduled_messages"),i.params=a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:Y.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return Fe.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=e.metaArrays)||void 0===r?void 0:r.map((function(e){return Ce.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?ke.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}),i}return e(r,n),r}(i),Xn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new We(e,n),r}return e(n,t),n}(s),Zn=function(n){function r(e){var r=e.pollId,i=e.title,s=e.data,a=e.allowUserSuggestion,o=e.allowMultipleVotes,u=e.closeAt,c=n.call(this)||this;return c.method=t.PUT,c.path="".concat(X,"/").concat(encodeURIComponent(r)),c.params={title:i,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return e(r,n),r}(i),$n=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),er=function(n){function r(e){var r=e.pollId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(X,"/").concat(encodeURIComponent(r)),i}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var tr=function(n){function r(e){var r=e.pollId,i=n.call(this)||this;return i.method=t.PUT,i.path="".concat(X,"/").concat(encodeURIComponent(r),"/close"),i}return e(r,n),r}(i),nr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),rr=function(n){function r(e){var r=e.channelUrl,i=e.channelType,s=e.pollId,a=e.optionText,o=n.call(this)||this;return o.method=t.POST,o.path="".concat(X,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:r,channel_type:i,text:a},o}return e(r,n),r}(i),ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),sr=function(n){function r(e){var r=e.pollId,i=e.pollOptionId,s=e.optionText,a=n.call(this)||this;return a.method=t.PUT,a.path="".concat(X,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(i)),a.params={text:s},a}return e(r,n),r}(i),ar=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new U(e,n),r}return e(n,t),n}(s),or=function(n){function r(e){var r=e.pollId,i=e.pollOptionId,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(X,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(i)),s}return e(r,n),r}(i);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var ur=function(t){function n(e){var n=e.reqId,i=e.channelType,s=e.channelUrl,a=e.pollId,o=e.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:r({req_id:n,channel_type:i===b.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return e(n,t),n}(P),cr=function(t){function n(e,n,r){var i=t.call(this,e,"VOTE",r)||this;return i.event=new Z(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return e(n,t),n}(x),lr=100,dr="GroupChannel",hr="url",fr=100,pr="Message",mr="messageId",vr="Poll",yr="pollId",_r=100,gr="FeedChannel",br="url";function Ir(e){var t,n,r;return null!==(t=e.messageParams)&&void 0!==t?t:a(o(o({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:O.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}var Er,Tr=o(o({},gt),{fileInfoList:[]}),wr=function(e){return(z(e.file)||d("string",e.fileUrl))&&d("string",e.fileName,!0)&&d("string",e.mimeType,!0)&&d("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},Sr=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=Q,e}return e(n,t),n.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},n.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},n.prototype.onPending=function(e){return t.prototype.onPending.call(this,e),this},n.prototype.onFailed=function(e){return t.prototype.onFailed.call(this,e),this},n.prototype.onSucceeded=function(e){return t.prototype.onSucceeded.call(this,e),this},n}(_t),Mr=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(Er||(Er={}));var Nr,Ar=function(t){function n(e,n){var r,i,s,a,o,c,l=this;return(l=t.call(this,e)||this)._name="",l._createdAt=0,l.channelType=b.BASE,l.coverUrl="",l.customType="",l.data="",l.isFrozen=!1,l.isEphemeral=!1,l.creator=null,l._messageCollectionLastAccessedAt=0,l._url=n.channel_url,l._name=null!==(r=n.name)&&void 0!==r?r:"",l._createdAt=1e3*n.created_at,l.coverUrl=null!==(i=n.cover_url)&&void 0!==i?i:"",l.customType=null!==(s=n.custom_type)&&void 0!==s?s:"",l.data=null!==(a=n.data)&&void 0!==a?a:"",l.isFrozen=null!==(o=n.freeze)&&void 0!==o&&o,l.isEphemeral=null!==(c=n.is_ephemeral)&&void 0!==c&&c,l.creator=n.created_by?new u(l._iid,n.created_by):null,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(l._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){l._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),l}return e(n,t),Object.defineProperty(n.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),n.prototype.toJSON=function(){return o(o({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},n.payloadify=function(e){return r(a(o(o({},t.payloadify.call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?u.payloadify(e.creator):null,created_at:e.createdAt/1e3})))},n.prototype.isGroupChannel=function(){return this.channelType===b.GROUP},n.prototype.isOpenChannel=function(){return this.channelType===b.OPEN},n.prototype.isFeedChannel=function(){return this.channelType===b.FEED},Object.defineProperty(n.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),n.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},n.prototype._update=function(e){var t=r(e);Object.assign(this,t)},n.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},n.prototype._updateCachedMetaData=function(e,t){var n=this;this._cachedMetaData?this._cachedMetaData.forEach((function(r,i){var s;r.updatedAt<=t&&n._cachedMetaData.set(i,{value:null!==(s=e[i])&&void 0!==s?s:r.value,isRemoved:!e[i],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})))},n.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&l("string",t)).throw(A.invalidParameters),n=C.of(this._iid).requestQueue,r=new Vn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Hn).message]}}))}))},n.prototype._createScheduledUserMessage=function(e,t){var n=this,r=C.of(this._iid).requestQueue,i=Date.now(),s=this._generateRequestId();q(2).then((function(){var r=n._createPendingScheduledUserMessage(e,s,i);re((function(){return S(n,void 0,void 0,(function(){return M(this,(function(e){return[2,t._trigger(r)]}))}))}))}));var a=new Wn(o({reqId:s,channelType:this.channelType,channelUrl:this.url},e));r.send(a).then((function(e){var r=e.as(Yn).message;re((function(){return S(n,void 0,void 0,(function(){return M(this,(function(e){return[2,t._trigger(r)]}))}))}))})).catch((function(r){if(ie(r))throw r;q(2).then((function(){var a=n._createPendingScheduledUserMessage(e,s,i);n._markMessageAsFailed(a,r),re((function(){return S(n,void 0,void 0,(function(){return M(this,(function(e){return[2,t._trigger(a)]}))}))}))}))}))},n.prototype.sendFileMessage=function(e){var t=o(o({},Ct),e);return N(Rt(t)).throw(A.invalidParameters),this._sendFileMessage(t)},n.prototype.sendMultipleFilesMessage=function(e){var t,n=o(o({},Tr),e),r=C.of(this._iid);N(function(e,t){return void 0===t&&(t=$),bt(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return wr(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var i=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return N(!i).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)},n.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=Er.SEND);var i=C.of(this._iid).dispatcher,s=is.of(this._iid).fileMessageQueue,a=null!=n?n:this._generateRequestId(),o=Date.now(),u=new _t;return q(2).then((function(){var n=r._createPendingFileMessage(e,a,o);i.dispatch(new te({messages:[n],source:t===Er.RESEND?ne.LOCAL_MESSAGE_RESEND_STARTED:ne.EVENT_MESSAGE_SENT_PENDING})),re((function(){return S(r,void 0,void 0,(function(){return M(this,(function(e){return[2,u._trigger(n)]}))}))})),s.request(r,a,e).then((function(e){i.dispatch(new te({messages:[e],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),re((function(){return S(r,void 0,void 0,(function(){return M(this,(function(t){return[2,u._trigger(e)]}))}))}))})).catch((function(t){if(ie(t))throw t;q(2).then((function(){var n=r._createPendingFileMessage(e,a,o),s=C.of(r._iid).cacheContext.localCacheEnabled&&se(t.code);r._markMessageAsFailed(n,t,s),i.dispatch(new te({messages:[n],source:n.sendingStatus===E.PENDING?ne.REQUEST_RESEND_MESSAGE:t.code===F.FILE_UPLOAD_CANCEL_FAILED?ne.LOCAL_MESSAGE_CANCELED:ne.EVENT_MESSAGE_SENT_FAILED})),re((function(){return S(r,void 0,void 0,(function(){return M(this,(function(e){return[2,u._triggerFailed(t,n)]}))}))}))}))}))})),u},n.prototype._autoResendFileMessage=function(e){N(e instanceof We&&!!e.messageParams).throw(A.invalidParameters);var t=C.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,Er.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},n.prototype._sendMultipleFilesMessage=function(e,t,n){var r=this,i=C.of(this._iid).dispatcher,s=is.of(this._iid).fileMessageQueue,a=null!=n?n:this._generateRequestId(),o=Date.now(),u=new Sr;return q(2).then((function(){var n=r._createPendingMultipleFilesMessage(e,a,o);i.dispatch(new te({messages:[n],source:t===Er.RESEND?ne.LOCAL_MESSAGE_RESEND_STARTED:ne.EVENT_MESSAGE_SENT_PENDING})),re((function(){return S(r,void 0,void 0,(function(){return M(this,(function(e){return[2,u._trigger(n)]}))}))})),s.request(r,a,e,{requestHandler:u,isCopy:t===Er.COPY}).then((function(e){i.dispatch(new te({messages:[e],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),re((function(){return S(r,void 0,void 0,(function(){return M(this,(function(t){return[2,u._trigger(e)]}))}))}))})).catch((function(t){if(ie(t))throw t;q(2).then((function(){var n=r._createPendingMultipleFilesMessage(e,a,o);r._markMessageAsFailed(n,t),i.dispatch(new te({messages:[n],source:ne.EVENT_MESSAGE_SENT_FAILED})),re((function(){return S(r,void 0,void 0,(function(){return M(this,(function(e){return[2,u._triggerFailed(t,n)]}))}))}))}))}))})),u},n.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,s=C.of(this._iid).requestQueue,a=new Jn(o(o({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));s.send(a).then((function(e){var n=e.as(Xn).message;re((function(){return S(i,void 0,void 0,(function(){return M(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(s){if(ie(s))throw s;q(2).then((function(){var a=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(a,s),re((function(){return S(i,void 0,void 0,(function(){return M(this,(function(e){return[2,t._triggerFailed(s,a)]}))}))}))}))}))},n.prototype.sendFileMessages=function(e){var t,n;N(e.every((function(e){return Rt(o(o({},Ct),e))}))).throw(A.invalidParameters);var r=new _t;try{for(var i=m(e),s=i.next();!s.done;s=i.next()){var a=s.value;this.sendFileMessage(a).onPending((function(e){return r._trigger(e)})).onFailed((function(e,t){return r._triggerFailed(e,t)})).onSucceeded((function(e){return r._trigger(e)}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},n.prototype.resendFileMessage=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return M(this,(function(s){return n=this._validateFailedFileMessageHasFile(e,t),N(e instanceof We&&n&&!e.scheduledInfo).throw(A.invalidParameters),r=new B,i=kt(e,t),this._sendFileMessage(i,Er.RESEND,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},n.prototype.resendMessage=function(e,t){var n,r;if(N(e instanceof De&&!e.scheduledInfo&&e.isResendable).throw(A.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:St(e);return this._sendUserMessage(i,Er.RESEND,e.reqId)}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);N(s).throw(A.invalidParameters);i=null!==(r=e.messageParams)&&void 0!==r?r:kt(e,t);return this._sendFileMessage(i,Er.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw A.channelTypeNotSupportedError},n.prototype.updateFileMessage=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return n=o(o({},qt),t),N(d("number",e)&&function(e){return Lt(e)}(n)).throw(A.invalidParameters),r=C.of(this._iid).requestQueue,i=new Fn(o({channelType:this.channelType,channelUrl:this.url,messageId:e},n)),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(qn).message]}}))}))},n.prototype.cancelUploadingFileMessage=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){return N(d("string",e)).throw(A.invalidParameters),is.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},n.prototype.copyFileMessage=function(e,t){var r,i,s;return S(this,void 0,void 0,(function(){var u,c;return M(this,(function(l){return N(e instanceof n&&t instanceof We&&t.sendingStatus===E.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(A.invalidParameters),u=new B,c=a(o(o({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(i=t.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:O.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=t.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return u.resolve(e)})).onFailed((function(e){return u.reject(e)})),[2,u.promise]}))}))},n.prototype.copyMessage=function(e,t){N(e instanceof n&&t instanceof De&&t.sendingStatus===E.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(A.invalidParameters);var r=t,i=e;if(r.isUserMessage()){N(!r.poll).throw(A.notSupportedError);var s=Tt(r);return i._sendUserMessage(s)}if(r.isFileMessage()){s=Ot(r);return i._sendFileMessage(s)}if(t.isMultipleFilesMessage())throw A.channelTypeNotSupportedError},n.prototype.deleteMessage=function(e){return S(this,void 0,void 0,(function(){var t,n;return M(this,(function(r){switch(r.label){case 0:return N(e instanceof Le).throw(A.invalidParameters),e.messageId>0?(t=C.of(this._iid).requestQueue,n=new zn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},n.prototype.addReaction=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return M(this,(function(s){switch(s.label){case 0:return N(e instanceof Le&&e.messageId>0&&d("string",t)).throw(A.invalidParameters),n=C.of(this._iid).requestQueue,r=new Kn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(jn).reactionEvent]}}))}))},n.prototype.deleteReaction=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return M(this,(function(s){switch(s.label){case 0:return N(e instanceof Le&&e.messageId>0&&d("string",t)).throw(A.invalidParameters),n=C.of(this._iid).requestQueue,r=new Qn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Gn).reactionEvent]}}))}))},n.prototype._updateUserMessageMetaArray=function(e,t,n,r){return S(this,void 0,void 0,(function(){var i,s,a,o,u,c;return M(this,(function(l){switch(l.label){case 0:return i=C.of(this._iid),s=i.dispatcher,a=i.requestQueue,o=new Ln({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(Dn).message,s.dispatch(new te({messages:[c],source:ne.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},n.prototype._updateFileMessageMetaArray=function(e,t,n,r){return S(this,void 0,void 0,(function(){var i,s,a,o,u,c;return M(this,(function(l){switch(l.label){case 0:return i=C.of(this._iid),s=i.dispatcher,a=i.requestQueue,o=new Fn({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(qn).message,s.dispatch(new te({messages:[c],source:ne.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},n.prototype.createMessageMetaArrayKeys=function(e,t){return S(this,void 0,void 0,(function(){var n;return M(this,(function(r){return N(e instanceof Le&&e.messageId>0&&l("string",t)).throw(A.invalidParameters),n=t.map((function(e){return new Ce({key:e})})),e instanceof We?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},n.prototype.deleteMessageMetaArrayKeys=function(e,t){return S(this,void 0,void 0,(function(){var n;return M(this,(function(r){return N(e instanceof Le&&e.messageId>0&&l("string",t)).throw(A.invalidParameters),n=t.map((function(e){return new Ce({key:e})})),e instanceof We?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},n.prototype.addMessageMetaArrayValues=function(e,t){return S(this,void 0,void 0,(function(){return M(this,(function(n){return N(e instanceof Le&&e.messageId>0&&t.every((function(e){return e instanceof Ce}))).throw(A.invalidParameters),e instanceof We?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},n.prototype.removeMessageMetaArrayValues=function(e,t){return S(this,void 0,void 0,(function(){return M(this,(function(n){return N(e instanceof Le&&e.messageId>0&&t.every((function(e){return e instanceof Ce}))).throw(A.invalidParameters),e instanceof We?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},n.prototype.report=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return N(h(Pt,e)&&d("string",t)).throw(A.invalidParameters),n=C.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new On({channelUrl:this.url,channelType:this.channelType,userId:r.userId,category:e,description:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},n.prototype.reportUser=function(e,t,n){return S(this,void 0,void 0,(function(){var r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return N(e instanceof u&&h(Pt,t)&&d("string",n)).throw(A.invalidParameters),r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new Pn({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.userId,category:t,description:n}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},n.prototype.reportMessage=function(e,t,n){return S(this,void 0,void 0,(function(){var r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return N(e instanceof De&&h(Pt,t)&&d("string",n)).throw(A.invalidParameters),r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new kn({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:n}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},n.prototype.updatePoll=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return M(this,(function(s){switch(s.label){case 0:return N(d("number",e)&&function(e){return d("string",e.title,!0)&&J(e.data)&&d("boolean",e.allowUserSuggestion,!0)&&d("boolean",e.allowMultipleVotes,!0)&&d("number",e.closeAt,!0)}(t)).throw(A.invalidParameters),n=C.of(this._iid).requestQueue,r=new Zn(o({pollId:e},t)),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as($n).poll]}}))}))},n.prototype.deletePoll=function(e){return S(this,void 0,void 0,(function(){var t,n,r;return M(this,(function(i){switch(i.label){case 0:return t=d("number",e),N(t).throw(A.invalidParameters),n=C.of(this._iid).requestQueue,r=new er({pollId:e}),[4,n.send(r)];case 1:return i.sent(),[2]}}))}))},n.prototype.closePoll=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i;return M(this,(function(s){switch(s.label){case 0:return t=d("number",e),N(t).throw(A.invalidParameters),n=C.of(this._iid).requestQueue,r=new tr({pollId:e}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(nr).poll]}}))}))},n.prototype.addPollOption=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return n=d("number",e)&&d("string",t)&&""!==t.trim(),N(n).throw(A.invalidParameters),r=C.of(this._iid).requestQueue,i=new rr({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(ir).poll]}}))}))},n.prototype.updatePollOption=function(e,t,n){return S(this,void 0,void 0,(function(){var r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return r=d("number",e)&&d("number",t)&&d("string",n)&&""!==n.trim(),N(r).throw(A.invalidParameters),i=C.of(this._iid).requestQueue,s=new sr({pollId:e,pollOptionId:t,optionText:n}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(ar).poll]}}))}))},n.prototype.deletePollOption=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return M(this,(function(s){switch(s.label){case 0:return n=d("number",e)&&d("number",t),N(n).throw(A.invalidParameters),r=C.of(this._iid).requestQueue,i=new or({pollId:e,pollOptionId:t}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.votePoll=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return M(this,(function(c){switch(c.label){case 0:return n=d("number",e)&&l("number",t),N(n).throw(A.invalidParameters),r=C.of(this._iid),i=r.requestQueue,s=r.dispatcher,a=new ur({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(cr).event,s.dispatch(new ue({event:u,source:ne.EVENT_POLL_VOTED})),[2,u]}}))}))},n.prototype.getPollChangeLogsSinceTimestamp=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return N(d("number",e)).throw(A.invalidParameters),[4,ce.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getPollChangeLogsSinceToken=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return N(d("string",e,!0)),[4,ce.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},n.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new ae(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},n.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new oe(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},n}(c),Ur=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onConnected=Q,this.onReconnectStarted=Q,this.onReconnectSucceeded=Q,this.onReconnectFailed=Q,this.onDisconnected=Q})),Cr=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onSessionExpired=Q,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Q,this.onSessionRefreshed=Q,this.onSessionClosed=Q})),Or=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onFriendsDiscovered=Q,this.onTotalUnreadMessageCountChanged=Q,this.onTotalUnreadMessageCountUpdated=Q})),Pr=function(n){function i(e){var i=e.limit,s=e.token,a=e.userIdsFilter,o=e.metaDataKeyFilter,u=e.metaDataValuesFilter,c=e.nicknameStartsWithFilter,l=n.call(this)||this;return l.method=t.GET,l.path=le,l.params=r({limit:i,token:s,user_ids:a,metadatakey:o,metadatavalues_in:u,nickname_startswith:c}),l}return e(i,n),i}(i),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new u(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Rr=function(t){function n(e,n){var r,i,s,a=this;return(a=t.call(this,e,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&l("string",this.userIdsFilter,!0)&&d("string",this.metaDataKeyFilter,!0)&&l("string",this.metaDataValuesFilter,!0)&&d("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s;return M(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,t=new Pr(a(o(o({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(kr),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(de),xr=function(n){function i(e){var i=e.userId,s=e.limit,a=e.token,o=e.userIdsFilter,u=n.call(this)||this;return u.method=t.GET,u.path="".concat(le,"/").concat(i,"/block"),u.params=r({limit:s,token:a,user_ids:o}),u}return e(i,n),i}(i),Lr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new u(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Dr=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&l("string",this.userIdsFilter,!0)},n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s,u,c;return M(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xr(a(o(o({},this),{userId:t.userId,token:this._token}))),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=l.sent(),s=i.as(Lr),u=s.users,c=s.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(de),Fr=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(le,"/").concat(encodeURIComponent(r),"/friends"),a.params={limit:i,token:s},a}return e(r,n),r}(i),qr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(t){return new u(e,t)})),r.next=n.next,r}return e(n,t),n}(s),zr=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,u,c;return M(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Fr(o(o({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=l.sent(),s=i.as(qr),a=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(de),Br={},Kr=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return Br[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,Br[t]=this),Br[t]}return e.get=function(e){return Br[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Nr||(Nr={}));var jr,Qr=function(t){function n(e){var r=e.code,i=void 0===r?Nr.UNKNOWN_ERROR:r,s=e.message,a=void 0===s?"Unknown error occurred.":s,o=t.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,n.prototype),o}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:Nr.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailable",{get:function(){return new n({code:Nr.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailableInPrivateBrowsing",{get:function(){return new n({code:Nr.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeIsFull",{get:function(){return new n({code:Nr.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotInitialized",{get:function(){return new n({code:Nr.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:Nr.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenIntegrity",{get:function(){return new n({code:Nr.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenBlob",{get:function(){return new n({code:Nr.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeEncryptionInvalid",{get:function(){return new n({code:Nr.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeItemSizeExceeded",{get:function(){return new n({code:Nr.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeReadFailed",{get:function(){return new n({code:Nr.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:Nr.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:Nr.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionNotReady",{get:function(){return new n({code:Nr.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotMatch",{get:function(){return new n({code:Nr.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionQueryNotValid",{get:function(){return new n({code:Nr.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionInsertDuplicate",{get:function(){return new n({code:Nr.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:Nr.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:Nr.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionWriteFailed",{get:function(){return new n({code:Nr.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:Nr.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTableIsRequired",{get:function(){return new n({code:Nr.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:Nr.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"compareTypesNotMatch",{get:function(){return new n({code:Nr.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"circularReferenceFound",{get:function(){return new n({code:Nr.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),n}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(jr||(jr={}));var Gr,Vr=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Qr.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Vr(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=Vr(e[r],t);return t.delete(e),n}return e},Hr=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Qr.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Wr=function(e,t){for(var n=0,r=0;r>>0)%t},Yr=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Jr=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!Jr(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Jr(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(Hr(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Hr(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Hr(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Hr(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Xr=function(){},Zr=function(){return Promise.resolve()},$r=function(e){return e},ei=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Gr||(Gr={}));var ti,ni,ri,ii=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?$r:a,u=e.backward,c=void 0===u?Zr:u,l=e.forward,d=void 0===l?Zr:l,h=e.complete,f=void 0===h?Xr:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return S(this,void 0,void 0,(function(){var e,t,n;return M(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n;return M(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),si=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*Hr(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*Hr(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},h=this,i=0;i-1){var r=this._items[n];return t===ri.PERSISTENT&&(r.state=ni.PERSISTENT),t!==ri.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)mi.includes(this._items[r].state)&&mi.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===ni.VOLATILE})),s=i.length-this._limit;if(s>0){var a=[];try{for(var o=m(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===ni.VOLATILE&&s>0?s--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==ni.VOLATILE}))},e}(),_i=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(ui(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ui(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,f([],p(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s,a,u,c,l,d;return M(this,(function(h){switch(h.label){case 0:n=yi.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return o(o({},e.data),{generation:r})})))];case 2:for(a=h.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),a=yi.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=gi.createFromCacheItem(i),null==s?void 0:s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return n=Kr.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,yi.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(null==(a=s?gi.createFromCacheItem(s):new gi({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:a.add(t))?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return S(this,void 0,void 0,(function(){var e,t,n;return M(this,(function(r){switch(r.label){case 0:return e=li(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),yi.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),Ii={},Ei=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var u=function(e,t,n){return"".concat(ui(e,t),"/index.").concat(n)}(t,n,i.join(">"));return Ii[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=a,this._transaction.on(ti.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(ti.ERROR,this.indexerKey,(function(){return o.abort()}))),Ii[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in Ii)delete Ii[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=p(this.indexOf(n),2),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=p(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var a=m(this.fields),o=a.next();!o.done;o=a.next()){var u=o.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Qr.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=Hr(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,u,c,l,d,h,f,p,v,y;return M(this,(function(_){switch(_.label){case 0:return[4,(e=yi.get(this.dbname)).find(this._store,this.indexerKey,ri.PERSISTENT)];case 1:return(t=_.sent())?[3,11]:(n=li(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=_.sent(),_.label=3;case 3:_.trys.push([3,8,9,10]),i=m(r),s=i.next(),_.label=4;case 4:return s.done?[3,7]:(a=s.value).startsWith(n)?[4,e.find(this._store,a,ri.NO_CACHE)]:[3,6];case 5:if(o=_.sent(),u=gi.createFromCacheItem(o))try{for(v=void 0,c=m(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){v={error:e}}finally{try{l&&!l.done&&(y=c.return)&&y.call(c)}finally{if(v)throw v.error}}_.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return h=_.sent(),f={error:h},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Vr(this._origin),_.label=12;case 12:return Ii[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return yi.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete Ii[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=Vr(this._origin)},e.prototype.abort=function(){this._table=Vr(this._origin)},e}(),Ti=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},wi=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(fi||(fi={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(pi||(pi={}));var Si,Mi={},Ni=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=fi.PROCESSING,this._queue=[],this._activationQueue=[],Mi[e]&&!t.forceCreate||(this.nodeId=wi(),this.key=e,Ti()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,a=i.requestId,o=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&o===n.key)switch(u){case pi.NEWNODE:n._sendSync();break;case pi.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case pi.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,d=l.currentItemRequestId,h=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:pi.REQUEST_LOCK,ts:e.ts})};try{for(var p=m(h),v=p.next();!v.done;v=p.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case pi.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case pi.REQUEST_LOCK:n._requestLock(i);break;case pi.ACQUIRE_LOCK:var y=n._queue.find((function(e){return e.requestId===a}));n._acquire(y);break;case pi.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(pi.REMOVENODE)}))),Mi[e]=this),Mi[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==fi.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:wi(),key:this.key,op:e,data:t.data,ts:Date.now()};return Ti()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(pi.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(pi.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),i=!0;break}i||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))},e.prototype._sendSync=function(){var e;this.isHost&&this._send(pi.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},e.prototype._waitUntilSyncCompleted=function(){return S(this,void 0,void 0,(function(){var e=this;return M(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=fi.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(pi.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(pi.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(pi.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),Ai=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=jr.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=f([[r]],p(s.filter((function(e){return Ei.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new Ni(function(e,t){return"".concat(ui(e,t),".lock")}(t,n)),this._blobContainer=new hi({dbname:t,collectionName:n,store:a}),this._transaction=new _i({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return S(this,void 0,void 0,(function(){var r;return M(this,(function(i){switch(i.label){case 0:return r=ci(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===jr.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,v,y,_=this;return M(this,(function(g){switch(g.label){case 0:return[4,this._mutex.lock()];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,9,,10]),t=Kr.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=g.sent(),this._metadata=n||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:g.sent(),this._blockManager=new bi({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=f([],p(this.indexes),!1),i=[],s=r.map((function(e){return Ei.createKey(e)})),a=n?n.indexes.map((function(e){return Ei.createKey(e)})):[];try{for(o=m(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(Ei.parseKey(c))}catch(e){v={error:e}}finally{try{u&&!u.done&&(y=o.return)&&y.call(o)}finally{if(v)throw v.error}}return(l=[]).push.apply(l,f([],p(r.map((function(e){var t=new Ei({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,f([],p(i.map((function(e){return new Ei({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return g.sent(),[4,this._transaction.commit()];case 6:return g.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=ci(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:g.sent(),g.label=8;case 8:return this._state=jr.READY,this._mutex.unlock(),[3,10];case 9:throw h=g.sent(),this._mutex.unlock(),h;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=jr.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=Ei.createKey(e);try{for(var i=m(this._indexers),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===Ei.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw Qr.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return e=ci(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),n=m(this._indexers),r=n.next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=o.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Qr.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f;return M(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=m(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),a=m(this._indexers),o=a.next(),p.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),h={error:c},[3,23];case 22:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(h)throw h.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return M(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=m(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return a=c.sent(),o={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),n=m(this._indexers),r=n.next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=o.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i;return M(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=m(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return S(this,void 0,void 0,(function(){var t,n;return M(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,Vr(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Qr.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new ai({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Qr.collectionNotReady},e.prototype.insertOne=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Qr.collectionKeyNotGiven;return[4,this._requestInsert(Vr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return M(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Qr.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=m(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Vr(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Qr.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Qr.collectionKeyNotGiven;return[4,this._requestUpsert(Vr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u=this;return M(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Qr.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=m(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Vr(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),a={error:i},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Qr.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Qr.collectionKeyNotGiven;return[4,this._requestUpdate(Vr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p,v,y=this;return M(this,(function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,a=e.backward,o=void 0!==a&&a,u=[],[4,new si({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(e){return S(y,void 0,void 0,(function(){var n,i;return M(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Jr(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),c=m(u),l=c.next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(Vr(d))]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=_.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(v=c.return)&&v.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:return f=_.sent(),[4,this._transaction.clear()];case 14:throw _.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Qr.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,v=this;return M(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,a=void 0!==s&&s,o=[],[4,new si({condition:n,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(i)}).each((function(e){return S(v,void 0,void 0,(function(){var t,r;return M(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Jr(n,t)&&(r=t[this.keyName],o.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=m(o),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return d=y.sent(),f={error:d},[3,11];case 10:try{c&&!c.done&&(p=u.return)&&p.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,o];case 13:throw h=y.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),Qr.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw Qr.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return S(this,void 0,void 0,(function(){return M(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Ui="[NESTDB]",Ci=!0,Oi=function(){function e(){}return e.off=function(){Ci=!1},e.log=function(){for(var e=[],t=0;t1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return S(o,void 0,void 0,(function(){var n,i;return M(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Qr.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return a=u.sent(),[3,5];case 4:a=[r],u.label=5;case 5:return s=a,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,o({},e.value)]}}))}))},e.prototype.setMany=function(e){return S(this,void 0,void 0,(function(){var t,n=this;return M(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,f([],p(e.map((function(e){return n._shardify(e)}))),!1)))];case 1:return r.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i=this;return M(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l=this;return M(this,(function(d){switch(d.label){case 0:t=[],n=function(e){var n,i,s;return M(this,(function(a){switch(a.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=a.sent())&&(s=i.metadata,t.push.apply(t,f([],p(r._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return l._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,d.label=1;case 1:d.trys.push([1,6,7,8]),i=m(e),s=i.next(),d.label=2;case 2:return s.done?[3,5]:(a=s.value,[5,n(a)]);case 3:d.sent(),d.label=4;case 4:return s=i.next(),[3,2];case 5:return[3,8];case 6:return o=d.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:d.sent(),d.label=10;case 10:return[2,e]}}))}))},e}(),Ri={},xi=function(t){function n(e){void 0===e&&(e={});var n,r=this;r=t.call(this,o(o({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=e.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return e(n,t),Object.defineProperty(n.prototype,"rawData",{get:function(){return Ri[this.dbname]},set:function(e){Ri[this.dbname]=e},enumerable:!1,configurable:!0}),n.prototype._getAllRawKeys=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){if(Ri[this.dbname])return[2,Object.keys(Ri[this.dbname])];throw Qr.storeNotAvailable}))}))},n.prototype._getRaw=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return Ri[this.dbname]?[4,Yr(this.delay)]:[3,2];case 1:return t.sent(),[2,Ri[this.dbname][e]?o({key:e},Ri[this.dbname][e]):null];case 2:throw Qr.storeNotAvailable}}))}))},n.prototype._setRaw=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,u;return M(this,(function(c){switch(c.label){case 0:return Ri[this.dbname]?[4,Yr(this.delay)]:[3,2];case 1:c.sent();try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,a=r.metadata,Ri[this.dbname][i]=Object.freeze({data:s,metadata:a})}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Qr.storeNotAvailable;case 3:return[2]}}))}))},n.prototype._removeRaw=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return Ri[this.dbname]?[4,Yr(this.delay)]:[3,2];case 1:a.sent();try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,Ri[this.dbname][r]&&delete Ri[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Qr.storeNotAvailable;case 3:return[2]}}))}))},n.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},n.prototype.checkAvailability=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){return[2]}))}))},n.prototype.init=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return this.dbname=e,Ri[this.dbname]||(Ri[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},n.prototype.set=function(e){return S(this,void 0,void 0,(function(){var n,r;return M(this,(function(i){if((n=this.observer[e.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,t.prototype.set.call(this,e)]}))}))},n.prototype.setMany=function(e){return S(this,void 0,void 0,(function(){var n,r,i,s,a,o,u;return M(this,(function(c){try{for(n=m(e),r=n.next();!r.done;r=n.next())if(i=r.value,(s=this.observer[i.key])&&"function"==typeof s.set&&(a=s.set()))throw a}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2,t.prototype.setMany.call(this,e)]}))}))},n.prototype.clear=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,Yr(this.delay)];case 1:return e.sent(),Ri[this.dbname]={},[2]}}))}))},n}(ki),Li="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Si||(Si={}));var Di=function(t){function n(e){void 0===e&&(e={});var n,r=this;return(r=t.call(this,o(o({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=Li,r._state=Si.UNINITIALIZED,r._openJobQueue=[],r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return e(n,t),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Si.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Li,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=Si.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Si.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=Si.UNINITIALIZED,r(e.target.error)}))}else r(Qr.storeNotAvailable)}))},n.prototype._getObjectStore=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return this._database?[2,this._database.transaction(this._storeName,e).objectStore(this._storeName)]:[3,1];case 1:switch(this._state){case Si.UNINITIALIZED:case Si.OPEN:return[3,2];case Si.OPENING:case Si.CLOSED:return[3,3]}return[3,4];case 2:throw Qr.storeNotInitialized;case 3:return[2,new Promise((function(n){t._openJobQueue.push((function(){return n(t._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,n.sent()]}}))}))},n.prototype._getAllRawKeys=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},n.prototype._getRaw=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return t=n.sent(),[4,new Promise((function(n,r){var i=t.get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return[2,n.sent()]}}))}))},n.prototype._setRaw=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 2:return n.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 2:return n.sent(),[2]}}))}))},n.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},n.prototype.checkAvailability=function(){return S(this,void 0,void 0,(function(){var e,t=this;return M(this,(function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Ti())return[3,4];if(!(Ti()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Qr.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(Qr.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Qr.storeNotAvailableInPrivateBrowsing)}else n(Qr.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Qr.storeNotAvailable;case 5:return[3,7];case 6:throw Qr.storeNotAvailable;case 7:return[2]}}))}))},n.prototype.init=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}}))}))},n.prototype.clear=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},n}(ki),Fi=function(t){function n(e){var n=this,r=e.AsyncStorage,i=e.itemSizeLimit,s=void 0===i?6291456:i,a=fe(e,["AsyncStorage","itemSizeLimit"]);return(n=t.call(this,o(o({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return S(this,void 0,void 0,(function(){var e,t=this;return M(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a,o;return M(this,(function(u){switch(u.label){case 0:t=[];try{for(n=m(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},n.prototype.checkAvailability=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){if(!this._asyncStorage)throw Qr.storeNotAvailable;return[2]}))}))},n.prototype.init=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},n.prototype.clear=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},n}(ki);!function(t){function n(e){var n,r=this;return(r=t.call(this,o(o({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=e.MMKV,r}e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return S(this,void 0,void 0,(function(){var e,t=this;return M(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a;return M(this,(function(o){try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}}return[2]}))}))},n.prototype._removeRaw=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s;return M(this,(function(a){try{for(t=m(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},n.prototype.checkAvailability=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){if(!this._mmkv)throw Qr.storeNotAvailable;return[2]}))}))},n.prototype.init=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}}))}))},n.prototype.clear=function(){return S(this,void 0,void 0,(function(){var e;return M(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(ki);var qi;!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(qi||(qi={}));var zi,Bi=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=qi.INIT,this._config=i||new Kr({dbname:t}),this._store=r,this._event={success:Xr,error:Xr,storeReplaced:Xr,upgrade:ei},this._collections=new Map,this._globalMutex=new Ni("".concat(this.name,".lock")),this._config.disableLogger&&Oi.off(),new yi({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype.estimateUsage=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,(t=this._store,S(void 0,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}}))})))];case 1:return[2,e.sent()]}var t}))}))},e.prototype.commitSchema=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return this._state!==qi.OPENING?[3,2]:[4,Promise.all(e.map((function(e){return S(t,void 0,void 0,(function(){var t,n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return t=e.collectionName,n=e.keyName,r=e.index,i=void 0===r?[]:r,this._collections.has(t)||this._collections.set(t,new Ai({dbname:this.name,collectionName:t,keyName:n,indexes:i,store:this._store})),(s=this._collections.get(t))?[4,s.init()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[3,3];case 2:throw Qr.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},e.prototype.open=function(){var e;return S(this,void 0,void 0,(function(){var t,n,r,i,s=this;return M(this,(function(a){switch(a.label){case 0:return[4,this._globalMutex.lock()];case 1:if(a.sent(),this._state===qi.OPENED)return[3,12];this._state=qi.OPENING,a.label=2;case 2:return a.trys.push([2,5,,12]),[4,this._store.init(this.name)];case 3:return a.sent(),o=this.name,t="".concat(oi(o),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:return r=null!==(e=a.sent())&&void 0!==e?e:n,[2,new Promise((function(e,n){var i=function(e){r.version0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof De))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case K.NONE:if(e.parentMessageId>0)return!1;break;case K.ONLY_REPLY_TO_CHANNEL:if(e instanceof De&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(zi||(zi={}));var ji,Qi=function(e){switch(e){case zi.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case zi.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Gi=o(o({},Et),{scheduledAt:void 0}),Vi=function(e){return Mt(e)&&d("number",e.scheduledAt,!0)},Hi=o(o({},gt),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Wi=function(e){return bt(e)&&d("number",e.scheduledAt)&&(z(e.file)||d("string",e.fileUrl))&&d("string",e.fileName,!0)&&d("string",e.mimeType,!0)&&d("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return d("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Yi="UnsentMessage",Ji="reqId",Xi={},Zi=function(t){function n(e){var n=t.call(this,e)||this;return n._mutex=new Ni("unsendmessagecache.lock"),Xi[e]=n,n}return e(n,t),Object.defineProperty(n.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),n.of=function(e,t){return void 0===t&&(t=!1),Xi[e]&&!t||(Xi[e]=new n(e)),Xi[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Yi);if(!t)throw A.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){if(e.messageId>0)throw A.invalidParameters;var t,n=o({},e.serialize());return e instanceof je?(e.messageParams&&(n.messageParams=It(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,o(o({},It(t)),{scheduledAt:t.scheduledAt})))):e instanceof We?(e.messageParams&&(n.messageParams=Ut(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return o(o({},Ut(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof Ge&&e.messageParams&&(n.messageParams=function(e){return r({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n},n.prototype._deserialize=function(e){return e=o(o({},e),{messageId:parseInt(e.messageId)}),is.of(this._iid).buildMessageFromSerializedData(e)},n.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return S(this,void 0,void 0,(function(){var i,s,a,o,u,c,l=this;return M(this,(function(d){switch(d.label){case 0:return i=is.of(this._iid),s=this._deserialize(e),e.messageParams?s instanceof je?(o=e.messageParams,s.messageParams=i.buildUserMessageCreateParamsFromSerializedData(o,s),[3,6]):[3,1]:[3,6];case 1:return s instanceof We?(o=e.messageParams).fileKey&&"string"==typeof o.fileKey&&At(null!==(t=o.fileType)&&void 0!==t?t:"")?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,3]:[3,4];case 2:a.file=null!==(n=d.sent())&&void 0!==n?n:void 0,d.label=3;case 3:return s.messageParams=i.buildFileMessageCreateParamsFromSerializedData(o,s),[3,6];case 4:return s instanceof Ge&&((o=e.messageParams)&&o.fileInfoList)?(s.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(o,s),[4,Promise.all(s.messageParams.fileInfoList.map((function(e){return S(l,void 0,void 0,(function(){var t,n,r,i,s;return M(this,(function(a){switch(a.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&At(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(s=a.sent())&&void 0!==s?s:void 0,a.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:d.sent(),d.label=6;case 6:return s.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?s instanceof je?(u=e.scheduledInfo.scheduledMessageParams,s.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(u,s),[3,10]):[3,7]:[3,10];case 7:return s instanceof We?(u=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof u.fileKey&&"string"==typeof u.fileType&&At(u.fileType)?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,9]:[3,10];case 8:c.file=null!==(r=d.sent())&&void 0!==r?r:void 0,d.label=9;case 9:s.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(u,s),d.label=10;case 10:return[2,s]}}))}))},n.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},n.prototype.get=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,void 0]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new Ki:n,i=e.order,s=void 0===i?zi.CHANNEL_LATEST:i,a=e.sendingStatus,o=e.backward,u=void 0!==o&&o,c=e.parentMessageId;return S(this,void 0,void 0,(function(){var e,n,i,o,l=this;return M(this,(function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=Qi(s),n={"/where":function(e){return!!(s!==zi.NEWEST_CHILD_MESSAGE||c&&0!==e.parentMessageId&&e.parentMessageId===c)&&r.match(l._deserialize(e))}},t&&(n.channelUrl=t),a&&(n.sendingStatus=a),i={where:n,index:e,backward:u},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return o=d.sent(),[2,Promise.all(o.map((function(e){return S(l,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Ki),S(this,void 0,void 0,(function(){return M(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:zi.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return S(t,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return e instanceof We||e instanceof Ge?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return S(t,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a;return M(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=m(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return S(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.saveBlob=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i=this;return M(this,(function(s){switch(s.label){case 0:return e instanceof We?e.messageParams&&(r=e.messageParams).file&&Nt(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=s.sent(),r.fileKey=n,r.fileType=wt.BLOB,s.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&Nt(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=s.sent(),t.fileKey=n,t.fileType=wt.BLOB,s.label=4;case 4:return[3,7];case 5:return e instanceof Ge&&((r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList))?[4,Promise.all(r.fileInfoList.map((function(t,n){return S(i,void 0,void 0,(function(){var r;return M(this,(function(i){switch(i.label){case 0:return t.file&&Nt(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=wt.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},n}(c),$i={},es=function(t){function n(e){var n=t.call(this,e)||this;return $i[e]=n,n}return e(n,t),Object.defineProperty(n.prototype,"_sdkState",{get:function(){return C.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_unsentMessageCache",{get:function(){return Zi.of(this._iid)},enumerable:!1,configurable:!0}),n.of=function(e,t){return void 0===t&&(t=!1),$i[e]&&!t||($i[e]=new n(e)),$i[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return N(!!e).throw(A.databaseError),e.collection(pr)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){return o(o({},e.serialize()),{messageId:"".concat(e.messageId)})},n.prototype._deserialize=function(e){return e=o(o({},e),{messageId:parseInt(e.messageId)}),is.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,s=e.filter,a=void 0===s?new Ki:s,o=e.order,u=void 0===o?zi.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,d=e.parentMessageId,h=e.isPollOnly,f=void 0!==h&&h,p=e.exactMatch,m=void 0!==p&&p,v=e.inclusive,y=void 0===v||v;return S(this,void 0,void 0,(function(){var e,r,s,o=this;return M(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=Qi(u),r={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case zi.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(l){if(y&&e.createdAtn||!y&&e.createdAt>=n)return!1;break;case zi.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(f&&!e._poll)&&a.match(o._deserialize(e))}},index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({limit:null!=i?i:void 0})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return S(o,void 0,void 0,(function(){return M(this,(function(t){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Ki),S(this,void 0,void 0,(function(){return M(this,(function(n){switch(n.label){case 0:return[4,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:zi.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return S(this,void 0,void 0,(function(){var t,n=this;return M(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,5];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:return r.sent(),[4,this.upsertChildMessages(e)];case 3:return r.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 4:r.sent(),r.label=5;case 5:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return S(t,void 0,void 0,(function(){var t,n;return M(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a;return M(this,(function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),t=m(e),n=t.next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=o.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:Qi(zi.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},n.prototype.removeUnderOffset=function(e,t){return S(this,void 0,void 0,(function(){return M(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Qi(zi.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return S(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.countBetween=function(e,t,n){return S(this,void 0,void 0,(function(){var r,i=this;return M(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Qi(zi.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},n.prototype.saveBlobs=function(e){return S(this,void 0,void 0,(function(){var t=this;return M(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return S(t,void 0,void 0,(function(){var t,n;return M(this,(function(r){switch(r.label){case 0:return e instanceof We&&e.messageParams&&((t=e.messageParams).file&&Nt(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n.prototype._getGroupChannelPreferenceSize=function(e){return S(this,void 0,void 0,(function(){var t,n,r,i,s,a;return M(this,(function(o){switch(o.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return s=o.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=o.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),s&&(t+=JSON.stringify(s).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},n}(c),ts={},ns=function(t){function n(e){var n=t.call(this,e)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on((function(e){return S(n,void 0,void 0,(function(){var t,n,r,i,s,a,o,u,c,l,d,h,f,p,m=this;return M(this,(function(v){switch(v.label){case 0:return e instanceof te?(t=e.messages,f=e.source,s=e.isWebSocketEventComing,n=t.filter((function(e){return e.messageId>0})),r=t.filter((function(e){return 0===e.messageId})),n.length>0?[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map((function(e){return e instanceof De?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:v.sent(),s||this._broadcastUpdateEvent(n,f),v.label=2;case 2:return r.length>0?[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:v.sent(),s||this._broadcastUpdateEvent(r,f),v.label=4;case 4:return[3,21];case 5:return e instanceof _e?(i=e.messageIds,f=e.source,s=e.isWebSocketEventComing,[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.remove(i)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return v.sent(),s||this._broadcastRemoveEvent(i,f),[3,21];case 7:return e instanceof ye?(a=e.reqId,f=e.source,[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([a])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return v.sent(),this._broadcastRemoveUnsentEvent(a,f),[3,21];case 9:return e instanceof ve?(o=e.polls,f=e.source,this._cacheContext.localCacheEnabled?(u=o.map((function(e){return e.messageId})),[4,Promise.all(u.map((function(e){return m._messageCache.get(e)})))]):[3,12]):[3,13];case 10:return(c=v.sent().filter((function(e){return e}))).length>0&&o.forEach((function(e){var t=c.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(c)];case 1:return[2,e.sent()]}}))}))}))];case 11:v.sent(),v.label=12;case 12:return this._broadcastPollChangeLogEvent(o,f),[3,21];case 13:return e instanceof me?(l=e.event,f=e.source,[4,this._messageCache.get(l.messageId)]):[3,17];case 14:return(d=v.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(l)?[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:v.sent(),v.label=16;case 16:return this._broadcastPollUpdateEvent(l,f),[3,21];case 17:return e instanceof ue?(h=e.event,f=e.source,[4,this._messageCache.get(h.messageId)]):[3,21];case 18:return(p=v.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollVoteEvent(h)?[4,pe((function(){return S(m,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:v.sent(),v.label=20;case 20:this._broadcastPollVoteEvent(h,f),v.label=21;case 21:return[2]}}))}))})),n}return e(n,t),Object.defineProperty(n.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_dispatcher",{get:function(){return C.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_messageCache",{get:function(){return es.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_unsentMessageCache",{get:function(){return Zi.of(this._iid)},enumerable:!1,configurable:!0}),n.of=function(e,t){var r;return void 0===t&&(t=!1),ts[e]&&!t||(ts[e]&&(null===(r=ts[e]._dispatcherContext)||void 0===r||r.close()),ts[e]=new n(e)),ts[e]},n.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=m(this._observers.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},n.prototype.subscribe=function(e,t){this._observers.set(e,t)},n.prototype.unsubscribe=function(e){this._observers.delete(e)},n.prototype.unsubscribeAll=function(){this._observers.clear()},n}(c),rs={},is=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,es.of(e),Zi.of(e),ns.of(e),this.fileMessageQueue=new tt(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),rs[e]=this}return e.of=function(e){return rs[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=ge(e);switch(t.messageType){case _.USER:return new je(this._iid,je.payloadify(t));case _.FILE:return Ge._isMultipleFilesMessageSerializedData(t)?new Ge(this._iid,Ge.payloadify(t)):new We(this._iid,We.payloadify(t));case _.ADMIN:return new Be(this._iid,Be.payloadify(t))}throw A.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return r(a({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return r(a({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){return r({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return o(o({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return o(o({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=ge(e);return new Re(this._iid,Re.payloadify(t))},e.prototype.getMessage=function(e){return S(this,void 0,void 0,(function(){var t,n;return M(this,(function(r){switch(r.label){case 0:return t=new ot(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(ut).message]}}))}))},e.prototype.getScheduledMessage=function(e){return S(this,void 0,void 0,(function(){var t,n;return M(this,(function(r){switch(r.label){case 0:return t=new ft(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(pt).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=ne.REQUEST_MESSAGE),S(this,void 0,void 0,(function(){var s,a,u;return M(this,(function(c){switch(c.label){case 0:return s=new ct(o(o({channelType:t,channelUrl:e,token:String(n)},rt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),u=a.as(lt).messages,this._dispatcher.dispatch(new te({messages:u,source:i})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=ne.REQUEST_MESSAGE),S(this,void 0,void 0,(function(){var s,a,u;return M(this,(function(c){switch(c.label){case 0:return s=new ct(o(o({channelType:t,channelUrl:e,timestamp:n},rt),r)),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),u=a.as(lt).messages,this._dispatcher.dispatch(new te({messages:u,source:i})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,s){return void 0===i&&(i=ne.REQUEST_MESSAGE),S(this,void 0,void 0,(function(){var a,u,c,l;return M(this,(function(d){switch(d.label){case 0:return a=new ct(o(o(o({channelType:t,channelUrl:e,timestamp:n},rt),r),{checkingContinuousMessages:s})),[4,this._requestQueue.send(a)];case 1:return u=d.sent(),c=u.payload,l=u.as(lt).messages,this._dispatcher.dispatch(new te({messages:l,source:i})),[2,{messages:l,isContinuousMessages:c}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=ne.REQUEST_THREADED_MESSAGE),S(this,void 0,void 0,(function(){var i,s,a,u;return M(this,(function(c){switch(c.label){case 0:return i=new ct(o(o(o({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},qe),n),{replyType:K.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return s=c.sent(),a=s.as(lt).messages,(u=a.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new te({messages:u,source:r})),[2,{parentMessage:a[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,i,s){return void 0===s&&(s=ne.REQUEST_MESSAGE_CHANGELOGS),S(this,void 0,void 0,(function(){var u,c,l,d,h,f,p,m;return M(this,(function(v){switch(v.label){case 0:return u=new dt(r(a(o(o({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},st),i)))),[4,this._requestQueue.send(u)];case 1:return c=v.sent(),l=c.as(ht),d=l.updatedMessages,h=l.deletedMessagesInfo,f=l.hasMore,p=l.nextToken,m=h.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new te({messages:d,source:s})),m.length>0&&this._dispatcher.dispatch(new _e({messageIds:m,source:s})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:f,token:p}]}}))}))},e}(),ss=function(t){function n(e,n){var r=t.call(this,e)||this;r.targetMessageId=0;var i=n.thread_info,s=n.parent_message_id,a=n.channel_url,o=n.channel_type;return i&&d("object",i)&&d("number",s)&&d("string",a)&&d("string",o)&&(r.threadInfo=new Se(e,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return e(n,t),n}(c),as={channelUrl:"",channelType:b.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},os=function(n){function r(e){var r=e.channelCustomType,i=e.keyword,s=e.limit,a=e.reverse,o=e.exactMatch,u=e.channelUrl,c=e.order,l=e.messageTimestampFrom,d=e.messageTimestampTo,h=e.advancedQuery,f=e.targetFields,p=e.nextToken,m=n.call(this)||this;return m.method=t.GET,m.path="".concat(be,"/messages"),m.params={custom_type:r,query:i,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p},m}return e(r,n),r}(i),us=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.messages=n.results.map((function(t){return He(e,t)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return e(n,t),n}(s);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(ji||(ji={}));var cs=function(t){function n(e,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=ji.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:ji.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&h(ji,this.order)&&d("boolean",this.advancedQuery)&&l("string",this.targetFields,!0)},n.prototype.next=function(){return S(this,void 0,void 0,(function(){var e,t,n,r,i,s,u,c;return M(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,t=new os(a(o(o({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=l.sent(),r=n.as(us),i=r.messages,s=r.hasNext,u=r.nextToken,c=r.totalCount,this._nextToken=u,this._hasNext=s,this._isLoading=!1,this.totalCount=c,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},n}(de),ls={channelUrl:"",scheduledMessageId:0},ds=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new is(e,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},n.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},n.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},n.prototype.getMessage=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){return t=o(o({},as),e),N(function(e){return d("string",e.channelUrl)&&h(b,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeReactions,!0)&&d("boolean",e.includeMetaArray,!0)&&d("boolean",e.includeParentMessageInfo,!0)&&d("boolean",e.includeThreadInfo,!0)}(t)).throw(A.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return S(this,void 0,void 0,(function(){var t;return M(this,(function(n){return t=o(o({},ls),e),N(function(e){return d("string",e.channelUrl)&&""!==e.channelUrl&&d("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(A.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Ie);export{De as $,Fi as A,Dr as B,Ur as C,lr as D,He as E,zr as F,Me as G,Ne as H,Di as I,je as J,We as K,_n as L,zi as M,dr as N,Kt as O,yt as P,on as Q,Pt as R,Cr as S,Cn as T,Or as U,An as V,Mn as W,En as X,wn as Y,cr as Z,Bn as _,hr as a,Dn as a0,qn as a1,xn as a2,Xe as a3,is as a4,fr as a5,xt as a6,Lt as a7,Dt as a8,Ft as a9,ji as aA,Ge as aB,Oe as aC,Pe as aD,jt as aE,Ue as aF,Ee as aG,Re as aH,Se as aI,Qe as aJ,Fe as aa,Ce as ab,ke as ac,Ve as ad,Sr as ae,Gi as af,Vi as ag,Hi as ah,Wi as ai,St as aj,Er as ak,kt as al,Tt as am,Ot as an,Ir as ao,_t as ap,Yn as aq,Mr as ar,we as as,Te as at,ns as au,Be as av,Ae as aw,ss as ax,_r as ay,Le as az,pr as b,mr as c,Yi as d,Ji as e,vr as f,Qi as g,yr as h,gr as i,br as j,xi as k,ds as l,Rr as m,cs as n,Bi as o,es as p,Zi as q,qi as r,Yt as s,Ar as t,Vt as u,Ke as v,vt as w,mt as x,nt as y,Ki as z}; diff --git a/lib/__bundle-f4ef8eae.js b/lib/__bundle-f4ef8eae.js deleted file mode 100644 index db04232..0000000 --- a/lib/__bundle-f4ef8eae.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,aV as t,b as s,c as n,ac as r,aB as a,y as i,z as o,r as u,ak as c,az as d,T as h,U as l,W as _}from"./__bundle-1da35e70.js";import{q as A}from"./__bundle-0099b2f2.js";var g,f,E;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(g||(g={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(f||(f={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(E||(E={}));var p,C=function(e){switch(e){case g.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case g.CHRONOLOGICAL:return["-createdAt","syncIndex"];case g.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},L=function(t){function s(e){var s=e.message,n=t.call(this)||this;return n.message=s,n}return e(s,t),s}(t),R={},I=function(){function e(e,t){var s=t.localCacheEnabled,n=t.dispatcher,r=t.sdkState,a=t.logger,u=this;this._iid=e,R[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=n,this._logger=a,this._sdkState=r,this._localCacheEnabled&&n.on((function(e){if(e instanceof i)switch(e.stateType){case o.CONNECTED:u._isProcessingAutoResend||u.processAutoResendRegisteredPendingMessages().then((function(){return u._processNextAutoResend()}));break;case o.INTERNAL_DISCONNECTED:case o.EXTERNAL_DISCONNECTED:u._isProcessingAutoResend=!1}}))}return e.of=function(e){return R[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,a,i,o;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())0===(a=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=r.FAILED,a.errorCode=c.ACK_TIMEOUT,this._dispatcher.dispatch(new d({messages:[a],source:h.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{s&&!s.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t,s,i,o,c,l,_;return n(this,(function(n){switch(n.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=n.sent();try{for(t=u(e),s=t.next();!s.done;s=t.next())(i=s.value).errorCode&&a(i.errorCode)&&(o=(new Date).getTime(),c=i.createdAt+2592e5,o<=c?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(c).toLocaleString()),i.sendingStatus=r.FAILED,this._dispatcher.dispatch(new d({messages:[i],source:h.LOCAL_MESSAGE_FAILED}))))}catch(e){l={error:e}}finally{try{s&&!s.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===r.SUCCEEDED||e.sendingStatus===r.FAILED&&!a(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return s(this,void 0,void 0,(function(){var e,t;return n(this,(function(s){switch(s.label){case 0:return(e=A.of(this._iid))?[4,e.fetch({sendingStatus:r.PENDING,backward:!0})]:[3,2];case 1:return t=s.sent(),[3,3];case 2:t=[],s.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return s(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new L({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(p||(p={}));var S=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var s=t.data,n=s.blocker,r=s.blockee;return{blocker:new l(e,n),blockee:new l(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var s=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(s)?s.map((function(t){return new l(e,t)})):[]}},e}(),N=function(t){function s(e,s){var n=s.userId,r=t.call(this)||this;return r._iid=e,r.userId=n,r}return e(s,t),s}(t),v=function(t){function s(){return t.call(this)||this}return e(s,t),s}(t),D=function(t){function s(e,s,n){var r=t.call(this,e,"USEV",n)||this;return r.event=new S(n),r}return e(s,t),s}(_);export{I as A,N as D,g as G,f as P,v as R,E as S,D as U,p as a,S as b,L as c,C as g}; diff --git a/lib/__bundle-fdefc164.js b/lib/__bundle-fdefc164.js new file mode 100644 index 0000000..34531aa --- /dev/null +++ b/lib/__bundle-fdefc164.js @@ -0,0 +1 @@ +var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},k=function(e){return e>0&&m.indexOf(e)>=0},O=function(e,t){if(void 0===t&&(t=!1),t&&null==e)return!0;var n="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},I=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),D={encrypt:function(e){return e},decrypt:function(e){return e}},L=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),s?(this._clearOrder=o,this._customClearOrderComparator=s):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),Z=function(){function e(){}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0},e}(),W=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},Q=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=W()}return e.prototype._register=function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)},e}(),Y=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new Q({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new Q({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var o=[];try{for(var a=s(i.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),X=function(){function e(){this._dispatcher=new Y}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),J=function(){},$=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},ee=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){var t=c([],a(e),!1);for(var n in t)t[n]=ee(t[n]);return t}for(var r in e)null===e[r]&&delete e[r];return e}return e}};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open",e.FEED="feed"}(U||(U={})),function(e){e.OPERATOR="operator",e.NONE="none"}(M||(M={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(P||(P={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(z||(z={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(F||(F={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(H||(H={})),function(e){e.USERS="users",e.CHANNEL="channel"}(V||(V={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(G||(G={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(q||(q={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(j||(j={}));var te,ne="v3",re="/".concat(ne,"/users"),ie="/".concat(ne,"/storage/file"),oe="/".concat(ne,"/group_channels"),se="/".concat(ne,"/sdk/group_channels"),ae="/".concat(ne,"/open_channels"),ce="/".concat(ne,"/sdk/open_channels"),ue="/".concat(ne,"/search"),le="/".concat(ne,"/report"),he="/".concat(ne,"/emojis"),de="/".concat(ne,"/emoji_categories"),_e="/".concat(ne,"/polls"),fe="/".concat(ne,"/scheduled_messages"),pe="/".concat(ne,"/sdk/ui_kit/configuration"),Ee="/".concat(ne,"/sdk/statistics"),ge="/".concat(ne,"/notifications"),ve=function(e){switch(e){case U.FEED:case U.GROUP:return oe;case U.OPEN:return ae;default:return null}},be=function(e){switch(e){case U.GROUP:return"".concat(le,"/group_channels");case U.OPEN:return"".concat(le,"/open_channels");default:return null}},me=function(e,t,n){var r,i;switch(e){case V.CHANNEL:return!0;case V.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},ye=function(e,t,n){var r,i,o,s,a=me(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],n),c=me(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!a&&c?1:a&&!c?-1:0},we=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;O(s)?i.append(a,s,null!==(r=s.name)&&void 0!==r?r:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?i.append(a,String(s)):i=we(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(te||(te={}));var Ne,Te=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=W(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=$(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=$(this.params);return Object.keys(e).some((function(t){return O(e[t])}))?we(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(J),Se=function(e){function r(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return t(r,e),Object.defineProperty(r.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),r.prototype.as=function(e){return new e(this._iid,this.payload)},r}(J),Ae=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(J),Ce=function(e){function n(t){var n=t.expires_in,r=t.reason,i=void 0===r?u.SESSION_KEY_EXPIRED:r,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,i){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:case u.USER_AUTH_DEACTIVATED:case u.USER_AUTH_DELETED_OR_NOT_FOUND:o.error=new v({code:i})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)},enumerable:!1,configurable:!0}),n}(J),ke=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(J);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Ne||(Ne={}));var Oe,Ie,Re,De=function(){function e(e){var t=e.type,n=e.data,r=e.ts,i=void 0===r?Date.now():r;this.type=t,this.createdAt=i,this.data=n}return e.payloadify=function(e){return $({stat_type:e.type,ts:e.createdAt,data:$(e.data)})},e}(),Le=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},xe=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};!function(e){e.CHAT="chat",e.CALLS="calls",e.DESK="desk",e.LIVE="live",e.UIKIT_CHAT="uikit-chat",e.UIKIT_LIVE="uikit-live"}(Oe||(Oe={})),function(e){e.ANDROID="android",e.IOS="ios",e.JS="js",e.UNREAL="unreal",e.UNITY="unity",e.REACT_NATIVE="react-native",e.FLUTTER="flutter"}(Ie||(Ie={})),function(e){e.ANDROID="android",e.IOS="ios",e.WEB="web",e.MOBILE_WEB="mobile_web",e.WINDOWS="windows"}(Re||(Re={}));var Ue="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",Me=function(){function e(){}return e.sendbirdSdkUserAgentWithExtension=function(e){var t=Le()?Ie.REACT_NATIVE:Ie.JS,r={main_sdk_info:"chat/".concat(t,"/").concat(h.SDK_VERSION),device_os_platform:xe()?"mobile-web":"web",os_version:h.OS_VERSION};if(e){var i=e.sendbirdExtensions,o=e.deviceOS,s=e.customData,c=void 0===s?{}:s;o.version&&(r.os_version=o.version),o.platform&&(r.device_os_platform=o.platform),i.length>0&&(r.extension_sdk_info=i.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(r=n(n({},r),c))}return Object.entries(r).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},e.userAgentWithExtension=function(e){var t=Le()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):xe()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},e}(),Pe=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof Ae&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var r=this._sdkState,i=r.appId,o=r.appVersion,s=r.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":Me.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Me.sendbirdSdkUserAgentWithExtension(s)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(a["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(a["App-Id"]=i,a["Access-Token"]=this._auth.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new ke(new De({type:Ne.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,E;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![te.GET,te.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:void 0),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-40c7abbd.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h),[2,new Se(this._iid,_)];throw _?(((f=new v(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Ce({reason:f.code})),this._statLogApiResult(e,h,f),f):(f=v.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof v?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?v.requestCanceled:(E=v.networkError,this._logger.debug("fail api request",E),E);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),ze=function(e){function n(t,n,r,i){void 0===i&&(i="");var o,s=this;return(s=e.call(this)||this)._iid=t,s.code=n,s.payload=r,s.requestId=null!==(o=r.req_id)&&void 0!==o?o:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i={};try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(J),Fe=function(){};function He(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ve=256,Ge=286,qe=30,je=15,Ke=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Be=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ze=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),We=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qe=new Array(576);He(Qe);const Ye=new Array(60);He(Ye);const Xe=new Array(512);He(Xe);const Je=new Array(256);He(Je);const $e=new Array(29);He($e);const et=new Array(qe);function tt(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let nt,rt,it;function ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}He(et);const st=e=>e<256?Xe[e]:Xe[256+(e>>>7)],at=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{ct(e,n[2*t],n[2*t+1])},lt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},ht=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=je;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=lt(r[t]++,t))}},dt=e=>{let t;for(t=0;t{e.bi_valid>8?at(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ft=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?ut(e,i,t):(o=Je[i],ut(e,o+Ve+1,t),s=Ke[o],0!==s&&(i-=$e[o],ct(e,i,s)),r--,o=st(r),ut(e,o,n),s=Be[o],0!==s&&(r-=et[o],ct(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)pt(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pt(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,pt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=je;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),ht(n,u,e.bl_count)},vt=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{ct(e,0+(r?1:0),3),_t(e),at(e,n),at(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var wt=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(vt(e,e.dyn_ltree,e.l_desc.max_code),vt(e,e.dyn_dtree,e.d_desc.max_code),gt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*We[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?yt(e,t,n,r):4===e.strategy||o===i?(ct(e,2+(r?1:0),3),Et(e,Qe,Ye)):(ct(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(ct(e,t-257,5),ct(e,n-1,5),ct(e,r-4,4),i=0;i{mt||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for($e[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Je[n]+Ve+1)]++,e.dyn_dtree[2*st(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),ut(e,256,Qe),(e=>{16===e.bi_valid?(at(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Tt=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const St=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var At=(e,t,n,r)=>{const i=St,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},Ct={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},kt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ot,_tr_stored_block:It,_tr_flush_block:Rt,_tr_tally:Dt,_tr_align:Lt}=Nt,{Z_NO_FLUSH:xt,Z_PARTIAL_FLUSH:Ut,Z_FULL_FLUSH:Mt,Z_FINISH:Pt,Z_BLOCK:zt,Z_OK:Ft,Z_STREAM_END:Ht,Z_STREAM_ERROR:Vt,Z_DATA_ERROR:Gt,Z_BUF_ERROR:qt,Z_DEFAULT_COMPRESSION:jt,Z_FILTERED:Kt,Z_HUFFMAN_ONLY:Bt,Z_RLE:Zt,Z_FIXED:Wt,Z_DEFAULT_STRATEGY:Qt,Z_UNKNOWN:Yt,Z_DEFLATED:Xt}=kt,Jt=258,$t=262,en=42,tn=113,nn=666,rn=(e,t)=>(e.msg=Ct[t],t),on=e=>2*e-(e>4?9:0),sn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},an=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let cn=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},ln=(e,t)=>{Rt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,un(e.strm)},hn=(e,t)=>{e.pending_buf[e.pending++]=t},dn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},_n=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=Tt(e.adler,t,i,n):2===e.state.wrap&&(e.adler=At(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},fn=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-$t?e.strstart-(e.w_size-$t):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Jt;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},pn=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-$t)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),an(e),r+=t),0===e.strm.avail_in)break;if(n=_n(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=cn(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=cn(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<$t&&0!==e.strm.avail_in)},En=(e,t)=>{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,un(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(_n(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(_n(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Pt)&&t!==xt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Pt&&0===e.strm.avail_in&&n===r?1:0,It(e,e.block_start,n,s),e.block_start+=n,un(e.strm)),s?3:1)},gn=(e,t)=>{let n,r;for(;;){if(e.lookahead<$t){if(pn(e),e.lookahead<$t&&t===xt)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-$t&&(e.match_length=fn(e,n)),e.match_length>=3)if(r=Dt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=cn(e,e.ins_h,e.window[e.strstart+1]);else r=Dt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(ln(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Pt?(ln(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ln(e,!1),0===e.strm.avail_out)?1:2},vn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<$t){if(pn(e),e.lookahead<$t&&t===xt)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=Dt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(ln(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Dt(e,0,e.window[e.strstart-1]),r&&ln(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Dt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Pt?(ln(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ln(e,!1),0===e.strm.avail_out)?1:2};function bn(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const mn=[new bn(0,0,0,0,En),new bn(4,4,8,4,gn),new bn(4,5,16,8,gn),new bn(4,6,32,32,gn),new bn(4,4,16,16,vn),new bn(8,16,32,32,vn),new bn(8,16,128,128,vn),new bn(8,32,128,256,vn),new bn(32,128,258,1024,vn),new bn(32,258,258,4096,vn)];function yn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Xt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),sn(this.dyn_ltree),sn(this.dyn_dtree),sn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),sn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),sn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const wn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==en&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==tn&&t.status!==nn?1:0},Nn=e=>{if(wn(e))return rn(e,Vt);e.total_in=e.total_out=0,e.data_type=Yt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?en:tn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Ot(t),Ft},Tn=e=>{const t=Nn(e);var n;return t===Ft&&((n=e.state).window_size=2*n.w_size,sn(n.head),n.max_lazy_match=mn[n.level].max_lazy,n.good_match=mn[n.level].good_length,n.nice_match=mn[n.level].nice_length,n.max_chain_length=mn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Sn=(e,t,n,r,i,o)=>{if(!e)return Vt;let s=1;if(t===jt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==Xt||r<8||r>15||t<0||t>9||o<0||o>Wt||8===r&&1!==s)return rn(e,Vt);8===r&&(r=9);const a=new yn;return e.state=a,a.strm=e,a.status=en,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<Sn(e,t,Xt,15,8,Qt),deflateInit2:Sn,deflateReset:Tn,deflateResetKeep:Nn,deflateSetHeader:(e,t)=>wn(e)||2!==e.state.wrap?Vt:(e.state.gzhead=t,Ft),deflate:(e,t)=>{if(wn(e)||t>zt||t<0)return e?rn(e,Vt):Vt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===nn&&t!==Pt)return rn(e,0===e.avail_out?qt:Vt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(un(e),0===e.avail_out)return n.last_flush=-1,Ft}else if(0===e.avail_in&&on(t)<=on(r)&&t!==Pt)return rn(e,qt);if(n.status===nn&&0!==e.avail_in)return rn(e,qt);if(n.status===en&&0===n.wrap&&(n.status=tn),n.status===en){let t=Xt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Bt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,dn(n,t),0!==n.strstart&&(dn(n,e.adler>>>16),dn(n,65535&e.adler)),e.adler=1,n.status=tn,un(e),0!==n.pending)return n.last_flush=-1,Ft}if(57===n.status)if(e.adler=0,hn(n,31),hn(n,139),hn(n,8),n.gzhead)hn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),hn(n,255&n.gzhead.time),hn(n,n.gzhead.time>>8&255),hn(n,n.gzhead.time>>16&255),hn(n,n.gzhead.time>>24&255),hn(n,9===n.level?2:n.strategy>=Bt||n.level<2?4:0),hn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(hn(n,255&n.gzhead.extra.length),hn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=At(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(hn(n,0),hn(n,0),hn(n,0),hn(n,0),hn(n,0),hn(n,9===n.level?2:n.strategy>=Bt||n.level<2?4:0),hn(n,3),n.status=tn,un(e),0!==n.pending)return n.last_flush=-1,Ft;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=At(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,un(e),0!==n.pending)return n.last_flush=-1,Ft;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=At(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=At(e.adler,n.pending_buf,n.pending-r,r)),un(e),0!==n.pending)return n.last_flush=-1,Ft;r=0}t=n.gzindexr&&(e.adler=At(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=At(e.adler,n.pending_buf,n.pending-r,r)),un(e),0!==n.pending)return n.last_flush=-1,Ft;r=0}t=n.gzindexr&&(e.adler=At(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(un(e),0!==n.pending))return n.last_flush=-1,Ft;hn(n,255&e.adler),hn(n,e.adler>>8&255),e.adler=0}if(n.status=tn,un(e),0!==n.pending)return n.last_flush=-1,Ft}if(0!==e.avail_in||0!==n.lookahead||t!==xt&&n.status!==nn){let r=0===n.level?En(n,t):n.strategy===Bt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(pn(e),0===e.lookahead)){if(t===xt)return 1;break}if(e.match_length=0,n=Dt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(ln(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Pt?(ln(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ln(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Zt?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=Jt){if(pn(e),e.lookahead<=Jt&&t===xt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+Jt;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Dt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Dt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(ln(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Pt?(ln(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ln(e,!1),0===e.strm.avail_out)?1:2})(n,t):mn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=nn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Ft;if(2===r&&(t===Ut?Lt(n):t!==zt&&(It(n,0,0,!1),t===Mt&&(sn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),un(e),0===e.avail_out))return n.last_flush=-1,Ft}return t!==Pt?Ft:n.wrap<=0?Ht:(2===n.wrap?(hn(n,255&e.adler),hn(n,e.adler>>8&255),hn(n,e.adler>>16&255),hn(n,e.adler>>24&255),hn(n,255&e.total_in),hn(n,e.total_in>>8&255),hn(n,e.total_in>>16&255),hn(n,e.total_in>>24&255)):(dn(n,e.adler>>>16),dn(n,65535&e.adler)),un(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Ft:Ht)},deflateEnd:e=>{if(wn(e))return Vt;const t=e.state.status;return e.state=null,t===tn?rn(e,Gt):Ft},deflateSetDictionary:(e,t)=>{let n=t.length;if(wn(e))return Vt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==en||r.lookahead)return Vt;if(1===i&&(e.adler=Tt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(sn(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,pn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=cn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,pn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,Ft},deflateInfo:"pako deflate (from Nodeca project)"};const Cn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var kn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Cn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;In[254]=In[254]=1;var Rn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&On)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+In[e[n]]>t?n:t}};var Dn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ln=Object.prototype.toString,{Z_NO_FLUSH:xn,Z_SYNC_FLUSH:Un,Z_FULL_FLUSH:Mn,Z_FINISH:Pn,Z_OK:zn,Z_STREAM_END:Fn,Z_DEFAULT_COMPRESSION:Hn,Z_DEFAULT_STRATEGY:Vn,Z_DEFLATED:Gn}=kt;function qn(e){this.options=kn.assign({level:Hn,method:Gn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Vn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Dn,this.strm.avail_out=0;let n=An.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==zn)throw new Error(Ct[n]);if(t.header&&An.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Rn.string2buf(t.dictionary):"[object ArrayBuffer]"===Ln.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=An.deflateSetDictionary(this.strm,e),n!==zn)throw new Error(Ct[n]);this._dict_set=!0}}function jn(e,t){const n=new qn(t);if(n.push(e,!0),n.err)throw n.msg||Ct[n.err];return n.result}qn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Pn:xn,"string"==typeof e?n.input=Rn.string2buf(e):"[object ArrayBuffer]"===Ln.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Un||o===Mn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=An.deflate(n,o),i===Fn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=An.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===zn;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},qn.prototype.onData=function(e){this.chunks.push(e)},qn.prototype.onEnd=function(e){e===zn&&(this.result=kn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn={Deflate:qn,deflate:jn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,jn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,jn(e,t)},constants:kt};const Bn=16209;var Zn=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,N,T,S;const A=e.state;n=e.next_in,T=e.input,r=n+(e.avail_in-5),i=e.next_out,S=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=A.dmax,c=A.wsize,u=A.whave,l=A.wnext,h=A.window,d=A.hold,_=A.bits,f=A.lencode,p=A.distcode,E=(1<>>24,d>>>=b,_-=b,b=v>>>16&255,0===b)S[i++]=65535&v;else{if(!(16&b)){if(0==(64&b)){v=f[(65535&v)+(d&(1<>>=b,_-=b),_<15&&(d+=T[n++]<<_,_+=8,d+=T[n++]<<_,_+=8),v=p[d&g];n:for(;;){if(b=v>>>24,d>>>=b,_-=b,b=v>>>16&255,!(16&b)){if(0==(64&b)){v=p[(65535&v)+(d&(1<a){e.msg="invalid distance too far back",A.mode=Bn;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&A.sane){e.msg="invalid distance too far back",A.mode=Bn;break e}if(w=0,N=h,0===l){if(w+=c-b,b2;)S[i++]=N[w++],S[i++]=N[w++],S[i++]=N[w++],m-=3;m&&(S[i++]=N[w++],m>1&&(S[i++]=N[w++]))}else{w=i-y;do{S[i++]=S[w++],S[i++]=S[w++],S[i++]=S[w++],m-=3}while(m>2);m&&(S[i++]=S[w++],m>1&&(S[i++]=S[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,E=0,g=0,v=0,b=0,m=0,y=0,w=0,N=0,T=0,S=null;const A=new Uint16Array(16),C=new Uint16Array(16);let k,O,I,R=null;for(p=0;p<=Wn;p++)A[p]=0;for(E=0;E=1&&0===A[v];v--);if(b>v&&(b=v),0===v)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(C[1]=0,p=1;p852||2===e&&N>592)return 1;for(;;){k=p-y,s[E]+1=f?(O=R[s[E]-f],I=S[s[E]-f]):(O=96,I=0),u=1<>y)+l]=k<<24|O<<16|I|0}while(0!==l);for(u=1<>=1;if(0!==u?(T&=u-1,T+=u):T=0,E++,0==--A[p]){if(p===v)break;p=t[n+s[E]]}if(p>b&&(T&d)!==h){for(0===y&&(y=b),_+=g,m=p-y,w=1<852||2===e&&N>592)return 1;h=T&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==T&&(i[_+T]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:er,Z_BLOCK:tr,Z_TREES:nr,Z_OK:rr,Z_STREAM_END:ir,Z_NEED_DICT:or,Z_STREAM_ERROR:sr,Z_DATA_ERROR:ar,Z_MEM_ERROR:cr,Z_BUF_ERROR:ur,Z_DEFLATED:lr}=kt,hr=16180,dr=16190,_r=16191,fr=16192,pr=16194,Er=16199,gr=16200,vr=16206,br=16209,mr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function yr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const wr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Nr=e=>{if(wr(e))return sr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=hr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,rr},Tr=e=>{if(wr(e))return sr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Nr(e)},Sr=(e,t)=>{let n;if(wr(e))return sr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?sr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Tr(e))},Ar=(e,t)=>{if(!e)return sr;const n=new yr;e.state=n,n.strm=e,n.window=null,n.mode=hr;const r=Sr(e,t);return r!==rr&&(e.state=null),r};let Cr,kr,Or=!0;const Ir=e=>{if(Or){Cr=new Int32Array(512),kr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for($n(1,e.lens,0,288,Cr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;$n(2,e.lens,0,32,kr,0,e.work,{bits:5}),Or=!1}e.lencode=Cr,e.lenbits=9,e.distcode=kr,e.distbits=5},Rr=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whaveAr(e,15),inflateInit2:Ar,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,E,g,v,b,m,y,w,N,T=0;const S=new Uint8Array(4);let A,C;const k=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(wr(e)||!e.output||!e.input&&0!==e.avail_in)return sr;n=e.state,n.mode===_r&&(n.mode=fr),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,N=rr;e:for(;;)switch(n.mode){case hr:if(0===n.wrap){n.mode=fr;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=At(n.check,S,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=br;break}if((15&u)!==lr){e.msg="unknown compression method",n.mode=br;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=br;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(S[0]=255&u,S[1]=u>>>8&255,n.check=At(n.check,S,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,S[2]=u>>>16&255,S[3]=u>>>24&255,n.check=At(n.check,S,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(S[0]=255&u,S[1]=u>>>8&255,n.check=At(n.check,S,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=At(n.check,S,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=At(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=_r;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=vr;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Ir(n),n.mode=Er,t===nr){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=br}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=br;break}if(n.length=65535&u,u=0,l=0,n.mode=pr,t===nr)break e;case pr:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=_r;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=br;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[k[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,A={bits:n.lenbits},N=$n(0,n.lens,0,19,n.lencode,0,n.work,A),n.lenbits=A.bits,N){e.msg="invalid code lengths set",n.mode=br;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=r[o++]<>>=E,l-=E,n.lens[n.have++]=v;else{if(16===v){for(C=E+2;l>>=E,l-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=br;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(C=E+3;l>>=E,l-=E,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(C=E+7;l>>=E,l-=E,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=br;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===br)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=br;break}if(n.lenbits=9,A={bits:n.lenbits},N=$n(1,n.lens,0,n.nlen,n.lencode,0,n.work,A),n.lenbits=A.bits,N){e.msg="invalid literal/lengths set",n.mode=br;break}if(n.distbits=6,n.distcode=n.distdyn,A={bits:n.distbits},N=$n(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,A),n.distbits=A.bits,N){e.msg="invalid distances set",n.mode=br;break}if(n.mode=Er,t===nr)break e;case Er:n.mode=gr;case gr:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,Zn(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===_r&&(n.back=-1);break}for(n.back=0;T=n.lencode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,n.length=v,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=_r;break}if(64&g){e.msg="invalid literal/length code",n.mode=br;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(C=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;T=n.distcode[u&(1<>>24,g=T>>>16&255,v=65535&T,!(E<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],E=T>>>24,g=T>>>16&255,v=65535&T,!(b+E<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=E,l-=E,n.back+=E,64&g){e.msg="invalid distance code",n.mode=br;break}n.offset=v,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(C=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=br;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=br;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=gr);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=gr;break;case vr:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(wr(e))return sr;let t=e.state;return t.window&&(t.window=null),e.state=null,rr},inflateGetHeader:(e,t)=>{if(wr(e))return sr;const n=e.state;return 0==(2&n.wrap)?sr:(n.head=t,t.done=!1,rr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return wr(e)?sr:(r=e.state,0!==r.wrap&&r.mode!==dr?sr:r.mode===dr&&(i=1,i=Tt(i,t,n,0),i!==r.check)?ar:(o=Rr(e,t,n,n),o?(r.mode=16210,cr):(r.havedict=1,rr)))},inflateInfo:"pako inflate (from Nodeca project)"};var Lr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const xr=Object.prototype.toString,{Z_NO_FLUSH:Ur,Z_FINISH:Mr,Z_OK:Pr,Z_STREAM_END:zr,Z_NEED_DICT:Fr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:Vr,Z_MEM_ERROR:Gr}=kt;function qr(e){this.options=kn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Dn,this.strm.avail_out=0;let n=Dr.inflateInit2(this.strm,t.windowBits);if(n!==Pr)throw new Error(Ct[n]);if(this.header=new Lr,Dr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Rn.string2buf(t.dictionary):"[object ArrayBuffer]"===xr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Dr.inflateSetDictionary(this.strm,t.dictionary),n!==Pr)))throw new Error(Ct[n])}function jr(e,t){const n=new qr(t);if(n.push(e),n.err)throw n.msg||Ct[n.err];return n.result}qr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Mr:Ur,"[object ArrayBuffer]"===xr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=Dr.inflate(n,s),o===Fr&&i&&(o=Dr.inflateSetDictionary(n,i),o===Pr?o=Dr.inflate(n,s):o===Vr&&(o=Fr));n.avail_in>0&&o===zr&&n.state.wrap>0&&0!==e[n.next_in];)Dr.inflateReset(n),o=Dr.inflate(n,s);switch(o){case Hr:case Vr:case Fr:case Gr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===zr))if("string"===this.options.to){let e=Rn.utf8border(n.output,n.next_out),t=n.next_out-e,i=Rn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Pr||0!==a){if(o===zr)return o=Dr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},qr.prototype.onData=function(e){this.chunks.push(e)},qr.prototype.onEnd=function(e){e===Pr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=kn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kr={Inflate:qr,inflate:jr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,jr(e,t)},ungzip:jr,constants:kt};const{Deflate:Br,deflate:Zr,deflateRaw:Wr,gzip:Qr}=Kn,{Inflate:Yr,inflate:Xr,inflateRaw:Jr,ungzip:$r}=Kr;var ei,ti={Deflate:Br,deflate:Zr,deflateRaw:Wr,gzip:Qr,Inflate:Yr,inflate:Xr,inflateRaw:Jr,ungzip:$r,constants:kt};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(ei||(ei={}));var ni,ri=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===ei.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return ei.CONNECTING;case 1:return ei.OPEN}return ei.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ws",{get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=ze.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Ce(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=ti.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",v.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==ei.CLOSED?(e._ws.onopen=Fe,e._ws.onmessage=Fe,e._ws.onerror=Fe,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()}))},n.prototype.send=function(e){if(!this._ws)throw v.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(Y),ii=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?{}:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:W(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(J),oi=function(e){function n(t){var n=t.all,r=t.feed,i=t.custom_types,o=t.ts,s=e.call(this)||this;return s.all=n,s.feed=r,s.customTypes=i,s.ts=o,s}return t(n,e),n}(J),si=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},ai=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new Pe(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new ri(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new oi(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new v({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(v.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(!this._sdkState.websocket)throw v.connectionRequired;if(t=new si,e.ackRequired){r=function(r,o){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(v.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(void 0,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof Te?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof ii?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw v.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(ni||(ni={}));var ci=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(J),ui=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=ni.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ai(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof ci){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case ni.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case ni.INITIALIZED:case ni.INTERNAL_DISCONNECTED:case ni.EXTERNAL_DISCONNECTED:case ni.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(v.connectionClosed):t.reject(v.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===ni.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===ni.CONNECTING||this._currentConnectionStateType===ni.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof ii?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:return[2,i.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new si,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),v.connectionRequired;case 3:case 7:return[3,9];case 4:return e instanceof Te?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,8];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new si,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=v.connectionRequired,this._logger.debug("fail api request",n),n;case 8:throw v.invalidCommand;case 9:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),e instanceof ii||e instanceof Te?[4,this.commandRouter.send(e)]:[3,2];case 1:return[2,t.sent()];case 2:throw v.invalidCommand}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(v.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),li="sendbird@devicetokens",hi=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return $(ee({type:e.type,token:e.token}))},e}(),di=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(re,"/").concat(n,"/session_key"),s.method=te.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(Te),_i=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?"":o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(ii),fi=function(e){function n(t,n){var r=e.call(this,t,n)||this,i=n.key;return r.key=i,r}return t(n,e),n}(Se),pi=function(e){function n(t,n,r){var i,o=this;return(o=e.call(this,t,"LOGI",r)||this).error=null,o.newKey=null,o.newKey=null!==(i=r.new_key)&&void 0!==i?i:null,o.error=r.error?new v(r.error):null,o}return t(n,e),n}(ze),Ei=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(J),gi=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},vi=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),bi=function(e,t,n){return void 0===n&&(n=new vi),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new _i({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(pi),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new di({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,bi((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(fi).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==ni.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)&&t?[4,this._receiveNewAuthToken()]:[3,9];case 4:return(i=o.sent())?(this.auth.authToken=i,[4,this._refreshSessionKey(this.auth.authToken,!1)]):[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return r=o.sent(),this._isSessionRelatedError(r)?t?[4,this._receiveNewAuthToken()]:[3,18]:[3,20];case 13:return(i=o.sent())?(this.auth.authToken=i,[4,this._refreshSessionKeyByApi(this.auth.authToken)]):[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw r;case 19:return[3,21];case 20:throw r;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new si;return mi((function(){return i(e,void 0,void 0,(function(){var e,n,r,i,s=this;return o(this,(function(o){return this._isRefreshingAuthToken=!0,this.auth.clear(),this.handler.onSessionTokenRequired?(e=null,n=function(){e&&(clearTimeout(e),e=null)},r=function(e){n(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),t.resolve(e))},i=function(e){n(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,t.reject(e))},e=setTimeout((function(){return i()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(r,i)):t.resolve(null),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof v&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,wi.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(li)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(li,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),this.close(),wi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(Y),Ti=function(){function e(){this.type=ni.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),Si=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ni.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new Ri,t)];case 2:return s.sent(),mi((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(Ti),Ai=function(e){function n(){var t=e.call(this)||this;return t.type=ni.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new Ii({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ki,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n}(Ti),Ci=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=ni.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new ki,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new Ii({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ki,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ai,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n}(Ti),ki=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ni.RECONNECTING,t.name="reconnecting",t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new si,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),mi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,bi((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof v&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new Oi,t)];case 3:return h.sent(),mi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),g(c)?[3,7]:c instanceof v?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new Ci({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return mi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new si,this._halt(v.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new Ii({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new si,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Ci({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Ai,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n}(Ti),Oi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ni.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new ki,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new Ci({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ai,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n}(Ti),Ii=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=ni.CONNECTING,r.name="connecting",r._authToken="",r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new si,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,bi((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof v&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new Oi,t)];case 3:return a.sent(),mi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),g(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof v?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new Ri,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return mi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new si,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect,a=void 0!==s&&s;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:v.connectionCanceled),e.hasSession?[4,e.changeState(new Ci({autoReconnect:a}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new Si,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),e.hasSession?[4,e.changeState(new Ai,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new Si,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(v.connectionCanceled),[4,e.changeState(new Si,t)];case 1:return n.sent(),[2]}}))}))},n}(Ti),Ri=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ni.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new Ii({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(Ti),Di=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(ii),Li=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;this.pingDelegate=t,this.sdkState=n,this._logger=r}return Object.defineProperty(e.prototype,"isWaiting",{get:function(){return!!this._pingTimeoutTimer},enumerable:!1,configurable:!0}),e.prototype.ping=function(){var e,t=this;if(!this.sdkState.websocket)throw v.connectionRequired;var n=new Di;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e.prototype.refreshTimer=function(){var e,t=this;if(!this.sdkState.websocket)throw v.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)},e.prototype.start=function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()},e.prototype.stop=function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e}(),xi=function(){function e(e){var t,n,r,i;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(n=e.feed_channels)&&void 0!==n?n:{},this.templateListToken=null!==(r=e.template_list_token)&&void 0!==r?r:null,this.settingsUpdatedAt=null!==(i=e.settings_updated_at)&&void 0!==i?i:0}return e.payloadify=function(e){return $(ee({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))},e}(),Ui=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Mi=function(){function e(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}return e.payloadify=function(e){return $(ee({last_updated_at:e.lastUpdatedAt}))},e}(),Pi=1048576,zi=5,Fi=function(){function e(e){var t,n,r,i,o;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Pi:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(r=e.multiple_file_send_max_size)&&void 0!==r?r:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new Mi(null!==(o=e.uikit_config)&&void 0!==o?o:{}),this.notificationInfo=e.notifications?new xi(e.notifications):null}return e.payloadify=function(e){return $(ee({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Pi,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Mi.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?xi.payloadify(e.notificationInfo):null}))},e}(),Hi=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Vi=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=te.POST,i.path="".concat(re,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(Te),Gi=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(Se),qi=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=te.PUT,o.path="".concat(re,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(Te),ji=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(Se),Ki=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=te.DELETE,i.path="".concat(re,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(Te);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Se);var Bi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=te.DELETE,r.path="".concat(re,"/").concat(n,"/metadata"),r}return t(n,e),n}(Te);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(Se);var Zi,Wi=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Qi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Yi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Zi||(Zi={}));var Xi,Ji=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,E,g=this;return(g=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",g.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",g.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",g.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,g.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},g.connectionStatus=Zi.NON_AVAILABLE,N(Zi,n.is_online)?g.connectionStatus=n.is_online:w("boolean",n.is_online)&&(g.connectionStatus=n.is_online?Zi.ONLINE:Zi.OFFLINE),g.isActive=null===(_=n.is_active)||void 0===_||_,g.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,g.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,g.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,g.friendName=null!==(E=n.friend_name)&&void 0!==E?E:null,g}return t(r,e),r.payloadify=function(t){return $(ee(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})))},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=fo.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return Wi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return Yi(this._isValidMetaData(e)).throw(v.invalidParameters),t=fo.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Vi({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Gi).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return Yi(this._isValidMetaData(e)).throw(v.invalidParameters),n=fo.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new qi({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(ji).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return Yi(w("string",e)).throw(v.invalidParameters),t=fo.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ki({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=fo.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Bi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Hi),$i=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(J),eo=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Fi(t),this.user=new Ji(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return $(ee(n(n(n({},Ji.payloadify(e.user)),Fi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=fo.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new $i({userProfile:this}))},e}(),to=function(e){function r(t,n,r){var i,o,s,a=this;return(a=e.call(this,t,n,r)||this).error=null,a.userProfile=new eo(t,r),a.deviceTokenLastDeletedAt=null!==(i=r.device_token_last_deleted_at)&&void 0!==i?i:0,a.key=null!==(o=r.key)&&void 0!==o?o:"",a.ekey=null!==(s=r.ekey)&&void 0!==s?s:"",a.error=r.error?new v(r):null,a}return t(r,e),r.asError=function(e){return new r("","LOGI",n({user_id:"",error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=fo.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw v.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(ze),no=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(J),ro=function(e){function n(t,n){var r,i=n.sdkState,o=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,c=n.websocketClient,u=n.dispatcher,l=n.logger,h=n.entryState,d=void 0===h?new Ri:h,_=this;return(_=e.call(this)||this)._stateUpdatedAt=0,_._connectingAt=0,_._connectionRequestQueue=[],_._iid=t,_.sdkState=i,_.cacheContext=o,_.connectionHandlers=s,_._sessionManager=a,_._websocketClient=c,_._dispatcher=u,_._logger=l,_._currentState=d,(null===(r=_.sdkState.websocket)||void 0===r?void 0:r.pingerDisabled)||(_._pinger=new Li({pingDelegate:{send:function(e){return _._websocketClient.send(e)},error:function(e){return _._websocketClient.error(e)}},sdkState:_.sdkState,logger:l})),_._websocketClient.on("open",(function(){_._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)_.clearLoginTimer(),_._dispatcher.dispatch(e.as(to))})).on("ping-refresh",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){_._logiProcessingTimer=setTimeout((function(){_._logiProcessingTimer=void 0,_._unresolvedLogi||_._rejectConnectionRequest(v.networkError)}),500)})),_._dispatcher.on((function(e){e instanceof to&&(_._unresolvedLogi=e,_._tryResolveConnectionRequest())})),_}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new ci({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=void 0,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=void 0,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Ce({reason:t.error.code})),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t,n;void 0===e&&(e="");var r=this.sdkState,i=r.appId,o=r.appVersion,s=r.userId,a=r.extensions,c=r.sendbirdRuntimeEnvironment,u=this.cacheContext.localCacheEnabled,l=this._sessionManager.auth,d=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,_=!!(null!==(n=this.sdkState.extensions)&&void 0!==n?n:{}).sb_uikit,f=Me.userAgentWithExtension(a);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(i).concat(o?"&av=".concat(o):"").concat(l.hasSession?"&key=".concat(encodeURIComponent(l.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(d?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&SB-SDK-User-Agent=").concat(encodeURIComponent(Me.sendbirdSdkUserAgentWithExtension(c)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(u?1:0,"&include_poll_details=1").concat(_?"&uikit_config=1":"")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new no({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new ke(new De({type:Ne.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){var t;return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var n,r,i=this;return o(this,(function(o){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(v.connectionCanceled)),n=this._url(e),r=new si,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(v.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(n)),[2,r.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(to.asError(v.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(Y),io=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new ro(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===ni.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===ni.CONNECTING||e.type===ni.RECONNECTING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketClient",{get:function(){return this._websocketClient},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),oo=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(De),so=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=te.POST,i.path="".concat(Ee),i.params={device_id:n,log_entries:r.map((function(e){return De.payloadify(e)}))},i}return t(n,e),n}(Te),ao=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=ao(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Xi||(Xi={}));var co,uo=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=Xi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=W(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===Xi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===Ne.API_RESULT||e.type===Ne.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===Ne.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==Xi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return De.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof oo){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new so({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof v?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=Xi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Xi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new De({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=t.generation,this.lastFlushedAt=t.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit?(n=Math.min(Math.floor(18e4*Math.random()),100),[4,gi(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof ke){var t=e.statLog;r.put(t)}else if(e instanceof no){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?Xi.ENABLED:Xi.COLLECT_ONLY:r.enabledState=Xi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===Xi.DISABLED?[3,3]:(e instanceof oo?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof oo&&t.key===e.key})),1),(n=t[0])?n.data=ao(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},n}(Y);!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(co||(co={}));var lo,ho=function(){function e(){this.level=co.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return $(ee(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return mo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0},r.prototype.serialize=function(){return Wi(this)},r}(Hi);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",e.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",e.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",e.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",e.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",e.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",e.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(Eo||(Eo={}));var wo=n({},Eo),No=function(e){return e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===Eo.SYNC_MESSAGE_FILL||e===Eo.SYNC_MESSAGE_CHANGELOGS||e===Eo.SYNC_POLL_CHANGELOGS},To=function(e){function n(t){var n=t.messages,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messages=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(J),So=function(e){function n(t){var n=t.messageIds,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messageIds=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(J),Ao=function(e){function n(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return t(n,e),n}(J),Co=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(J),ko=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(J),Oo=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(J),Io=function(){function e(e,t){var n;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return w("number",this.limit)&&this.limit>0},e}(),Ro=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&N(U,this.channelType)},n}(Io),Do=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Lo=function(e){function n(t){var n=t.title,r=t.optionTexts,i=t.data,o=t.allowUserSuggestion,s=t.allowMultipleVotes,a=t.closeAt,c=e.call(this)||this;return c.method=te.POST,c.path=_e,c.params={title:n,options:r,data:i,allow_user_suggestion:o,allow_multiple_votes:s,close_at:a},c}return t(n,e),n}(Te),xo=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.poll=new yo(t,n),r}return t(n,e),n}(Se),Uo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,o=e.call(this)||this;return o.method=te.GET,o.path="".concat(_e,"/").concat(encodeURIComponent(i)),o.params={channel_url:n,channel_type:r},o}return t(n,e),n}(Te),Mo=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.poll=new yo(t,n),r}return t(n,e),n}(Se),Po=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,o=t.pollOptionId,s=e.call(this)||this;return s.method=te.GET,s.path="".concat(_e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(o)),s.params={channel_url:n,channel_type:r},s}return t(n,e),n}(Te),zo=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.pollOption=new mo(t,n),r}return t(n,e),n}(Se),Fo=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,o=t.token,s=e.call(this)||this;return s.method=te.GET,s.path="".concat(ve(n),"/").concat(encodeURIComponent(r),"/polls/changelogs"),s.params=$({change_ts:i,token:o}),s}return t(n,e),n}(Te),Ho=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedPolls=n.updated.map((function(e){return function(e,t){return new yo(e,t)}(t,e)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return t(n,e),n}(Se),Vo={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Go=function(e){return w("string",e.title)&&(t=e.optionTexts,S("string",t)&&t.every((function(e){return""!==e.trim()})))&&bo(e.data)&&w("boolean",e.allowUserSuggestion,!0)&&w("boolean",e.allowMultipleVotes,!0)&&w("number",e.closeAt,!0);var t},qo={channelUrl:"",channelType:U.BASE,pollId:0,pollOptionId:0},jo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&N(U,e.channelType)&&w("number",e.pollId)&&e.pollId>0&&w("number",e.pollOptionId)&&e.pollOptionId>0},Ko={channelUrl:"",channelType:U.BASE,pollId:0},Bo=function(e){return w("string",e.channelUrl)&&""!==e.channelUrl&&N(U,e.channelType)&&w("number",e.pollId)},Zo={},Wo=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,o=t.requestQueue,s=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=o,this._dispatcher=r,this._logger=s,Zo[e]=this}return e.of=function(e){return Zo[e]},e.prototype.buildPollFromSerializedData=function(e){var t=Qi(e);return new yo(this._iid,yo.payloadify(t))},e.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t,r;return o(this,(function(i){switch(i.label){case 0:return Yi(Bo(e)).throw(v.invalidParameters),t=new Uo(n({},e)),[4,this._requestQueue.send(t)];case 1:return r=i.sent(),[2,r.as(Mo).poll]}}))}))},e.prototype.create=function(e){return i(this,void 0,void 0,(function(){var t,r;return o(this,(function(i){switch(i.label){case 0:return Yi(Go(e)).throw(v.invalidParameters),t=new Lo(n({},e)),[4,this._requestQueue.send(t)];case 1:return r=i.sent(),[2,r.as(xo).poll]}}))}))},e.prototype.getOption=function(e){return i(this,void 0,void 0,(function(){var t,r;return o(this,(function(i){switch(i.label){case 0:return Yi(jo(e)).throw(v.invalidParameters),t=new Po(n({},e)),[4,this._requestQueue.send(t)];case 1:return r=i.sent(),[2,r.as(zo).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,r){return void 0===r&&(r=Eo.SYNC_POLL_CHANGELOGS),i(this,void 0,void 0,(function(){var i,s,a,c,u,l,h;return o(this,(function(o){switch(o.label){case 0:return i=new Fo(ee({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(i)];case 1:return s=o.sent(),a=s.as(Ho),c=a.updatedPolls,u=a.deletedPollIds,l=a.hasMore,h=a.nextToken,c.length>0&&this._dispatcher.dispatch(new Co({polls:c,source:r})),[2,{updatedPolls:c,deletedPollIds:u,hasMore:l,token:h}]}}))}))},e}(),Qo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.token,o=t.limit,s=e.call(this)||this;return s.method=te.GET,s.path=_e,s.params={channel_url:n,channel_type:r,token:i,limit:o},s}return t(n,e),n}(Te),Yo=function(e){function n(t,n){var r,i=this;return(i=e.call(this,t,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(e){return new yo(t,e)})),i.token=n.next,i}return t(n,e),n}(Se),Xo=function(e){function r(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return t(r,e),r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=fo.of(this._iid).requestQueue,t=new Qo(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as(Yo),s=i.polls,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},r}(Ro),Jo=function(e){function n(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,o=t.pollOptionId,s=t.token,a=t.limit,c=e.call(this)||this;return c.method=te.GET,c.path="".concat(_e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(o),"/voters"),c.params={channel_url:n,channel_type:r,token:s,limit:a},c}return t(n,e),n}(Te),$o=function(e){function n(t,n){var r,i=this;return(i=e.call(this,t,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(e){return new Ji(t,e)})),i.token=n.next,i}return t(n,e),n}(Se),es=function(e){function r(t,n){var r=e.call(this,t,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return t(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&w("number",this.pollId)&&w("number",this.pollOptionId)},r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=fo.of(this._iid).requestQueue,t=new Jo(n(n({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),i=r.as($o),s=i.voters,a=i.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw v.queryInProgress;case 4:return[3,6];case 5:throw v.invalidParameters;case 6:return[2]}}))}))},r}(Ro);export{xi as $,te as A,mi as B,ei as C,oi as D,Y as E,$i as F,eo as G,Ui as H,Ce as I,Ue as J,S as K,B as L,d as M,yi as N,N as O,f as P,_ as Q,p as R,R as S,Eo as T,Ji as U,fo as V,ze as W,U as X,K as Y,co as Z,t as _,w as a,I as a$,M as a0,Mi as a1,Zi as a2,Oe as a3,Ie as a4,Re as a5,ie as a6,Hi as a7,y as a8,z as a9,g as aA,k as aB,Oo as aC,Wo as aD,Io as aE,D as aF,r as aG,ko as aH,Co as aI,Ao as aJ,So as aK,ue as aL,po as aM,Vo as aN,Go as aO,Ko as aP,Bo as aQ,qo as aR,jo as aS,mo as aT,lo as aU,J as aV,oo as aW,Ne as aX,fe as aY,wo as aZ,P as a_,Wi as aa,V as ab,j as ac,C as ad,F as ae,yo as af,q as ag,ii as ah,ve as ai,me as aj,u as ak,gi as al,si as am,G as an,oe as ao,Fe as ap,Ro as aq,be as ar,le as as,ye as at,H as au,bo as av,_e as aw,Do as ax,zi as ay,To as az,i as b,se as b0,A as b1,go as b2,No as b3,bi as b4,vo as b5,ce as b6,ae as b7,ge as b8,o as c,re as d,$ as e,Te as f,n as g,Se as h,O as i,de as j,he as k,pe as l,W as m,Le as n,c as o,a as p,v as q,s as r,Yi as s,Xo as t,ee as u,l as v,es as w,Qi as x,ci as y,ni as z}; diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index 64ea70e..db1b317 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -107,16 +107,32 @@ export declare class BaseChannel { getMessageChangeLogsSinceTimestamp(ts: number, params?: MessageChangeLogsParams): Promise; getMessageChangeLogsSinceToken(token: string, params?: MessageChangeLogsParams): Promise; sendUserMessage(params: UserMessageCreateParams): MessageRequestHandler; + /** + * @deprecated since v4.9.8. Use resendMessage() instead. + */ resendUserMessage(failedMessage: UserMessage): Promise; updateUserMessage(messageId: number, params: UserMessageUpdateParams): Promise; + /** + * @deprecated since v4.9.8. Use copyMessage() instead. + */ copyUserMessage(targetChannel: BaseChannel, message: UserMessage): Promise; translateUserMessage(targetMessage: UserMessage, languages: string[]): Promise; sendFileMessage(params: FileMessageCreateParams): MessageRequestHandler; sendFileMessages(paramsList: FileMessageCreateParams[]): MessageRequestHandler; + /** + * @deprecated since v4.9.8. Use resendMessage() instead. + */ resendFileMessage(failedMessage: FileMessage, file?: FileCompat): Promise; + resendMessage(failedMessage: FileMessage, file?: FileCompat): MessageRequestHandler; + resendMessage(failedMessage: UserMessage): MessageRequestHandler; updateFileMessage(messageId: number, params: FileMessageUpdateParams): Promise; cancelUploadingFileMessage(requestId: string): Promise; + /** + * @deprecated since v4.9.8. Use copyMessage() instead. + */ copyFileMessage(targetChannel: BaseChannel, message: FileMessage): Promise; + copyMessage(channel: BaseChannel, message: FileMessage): MessageRequestHandler; + copyMessage(channel: BaseChannel, message: UserMessage): MessageRequestHandler; deleteMessage(message: BaseMessage): Promise; addReaction(message: BaseMessage, key: string): Promise; deleteReaction(message: BaseMessage, key: string): Promise; @@ -467,7 +483,7 @@ export declare interface Encryption { decrypt: (encrypted: object) => object; } -export declare type FailedMessageHandler = (err: Error, message: SendableMessage | null) => void; +export declare type FailedMessageHandler = (err: Error, message: T | null) => void; export declare class FeedChannel extends BaseChannel { get url(): string; @@ -648,6 +664,12 @@ export declare class GroupChannel extends BaseChannel { resetMyHistory(): Promise; pinMessage(messageId: number): Promise; unpinMessage(messageId: number): Promise; + resendMessage(failedMessage: MultipleFilesMessage): MultipleFilesMessageRequestHandler; + resendMessage(failedMessage: FileMessage, file?: FileCompat): MessageRequestHandler; + resendMessage(failedMessage: UserMessage): MessageRequestHandler; + copyMessage(channel: GroupChannel, message: MultipleFilesMessage): MessageRequestHandler; + copyMessage(channel: BaseChannel, message: FileMessage): MessageRequestHandler; + copyMessage(channel: BaseChannel, message: UserMessage): MessageRequestHandler; } export declare class GroupChannelEventContext extends BaseChannelEventContext {} @@ -820,7 +842,7 @@ export declare class MessageFilter { match(message: BaseMessage): boolean; } -export declare type MessageHandler = (message: SendableMessage) => void; +export declare type MessageHandler = (message: T) => void; export declare interface MessageListParams { prevResultSize: number; @@ -857,10 +879,10 @@ export declare class MessageModule extends Module { getScheduledMessage(params: ScheduledMessageRetrievalParams): Promise; } -export declare class MessageRequestHandler { - onPending(handler: MessageHandler): MessageRequestHandler; - onFailed(handler: FailedMessageHandler): MessageRequestHandler; - onSucceeded(handler: MessageHandler): MessageRequestHandler; +export declare class MessageRequestHandler { + onPending(handler: MessageHandler): MessageRequestHandler; + onFailed(handler: FailedMessageHandler): MessageRequestHandler; + onSucceeded(handler: MessageHandler): MessageRequestHandler; } export declare interface MessageRetrievalParams { @@ -958,11 +980,13 @@ export declare interface MultipleFilesMessageCreateParams extends BaseMessageCre fileInfoList: UploadableFileInfo[]; } -export declare class MultipleFilesMessageRequestHandler extends MessageRequestHandler { - onFileUploaded(handler: FileUploadHandler): MultipleFilesMessageRequestHandler; - onPending(handler: MessageHandler): MultipleFilesMessageRequestHandler; - onFailed(handler: FailedMessageHandler): MultipleFilesMessageRequestHandler; - onSucceeded(handler: MessageHandler): MultipleFilesMessageRequestHandler; +export declare class MultipleFilesMessageRequestHandler< + T extends SendableMessage = SendableMessage, +> extends MessageRequestHandler { + onFileUploaded(handler: FileUploadHandler): MultipleFilesMessageRequestHandler; + onPending(handler: MessageHandler): MultipleFilesMessageRequestHandler; + onFailed(handler: FailedMessageHandler): MultipleFilesMessageRequestHandler; + onSucceeded(handler: MessageHandler): MultipleFilesMessageRequestHandler; } export declare interface MutedInfo { @@ -1922,6 +1946,8 @@ export declare class GroupChannelFilter { unreadChannelFilter: UnreadChannelFilter; hiddenChannelFilter: HiddenChannelFilter; includeFrozen: boolean; + createdAfter: number; + createdBefore: number; get searchFilter(): GroupChannelSearchFilter | null; setSearchFilter(fields?: GroupChannelSearchField[], query?: string): void; get userIdsFilter(): GroupChannelUserIdsFilter | null; @@ -1980,6 +2006,8 @@ declare interface GroupChannelListParams { metadataOrderKeyFilter?: string; metadataValueStartsWith?: string; order?: GroupChannelListOrder; + createdAfter?: number; + createdBefore?: number; } export declare class GroupChannelListQuery extends BaseListQuery { @@ -2006,6 +2034,8 @@ export declare class GroupChannelListQuery extends BaseListQuery { readonly metadataOrderKeyFilter: string | null; readonly metadataValueStartsWith: string | null; readonly order: GroupChannelListOrder; + readonly createdAfter: number; + readonly createdBefore: number; serialize(): object; next(): Promise; } diff --git a/message.js b/message.js index 5ad01d3..09e2ba8 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{ab as MentionType,a9 as MessageType,ae as MessageTypeFilter,ag as PushNotificationDeliveryOption,an as ReplyType,ac as SendingStatus}from"./lib/__bundle-1da35e70.js";export{ap as AdminMessage,ac as AppleCriticalAlertOptions,at as BaseMessage,K as FileMessage,ab as MessageMetaArray,l as MessageModule,aj as MessageRequestHandler,au as MessageSearchOrder,n as MessageSearchQuery,av as MultipleFilesMessage,ae as MultipleFilesMessageRequestHandler,aw as OGImage,ax as OGMetaData,ay as PreviousMessageListQuery,az as Reaction,aq as ReactionEvent,aA as ReactionEventOperation,aB as Sender,aC as ThreadInfo,ar as ThreadInfoUpdateEvent,aa as Thumbnail,aD as UploadedFileInfo,J as UserMessage}from"./lib/__bundle-0099b2f2.js"; +export{ab as MentionType,a9 as MessageType,ae as MessageTypeFilter,ag as PushNotificationDeliveryOption,an as ReplyType,ac as SendingStatus}from"./lib/__bundle-fdefc164.js";export{av as AdminMessage,ac as AppleCriticalAlertOptions,az as BaseMessage,K as FileMessage,ab as MessageMetaArray,l as MessageModule,ap as MessageRequestHandler,aA as MessageSearchOrder,n as MessageSearchQuery,aB as MultipleFilesMessage,ae as MultipleFilesMessageRequestHandler,aC as OGImage,aD as OGMetaData,aE as PreviousMessageListQuery,aF as Reaction,aw as ReactionEvent,aG as ReactionEventOperation,aH as Sender,aI as ThreadInfo,ax as ThreadInfoUpdateEvent,aa as Thumbnail,aJ as UploadedFileInfo,J as UserMessage}from"./lib/__bundle-bd25634c.js"; diff --git a/openChannel.js b/openChannel.js index 3bda5a1..8ee52a7 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as e,b as n,c as t,a7 as r,K as a,a as o,i,A as s,b5 as u,b6 as c,f as l,h,e as d,u as p,ah as f,U as C,x as v,g as _,X as y,ap as U,W as m,y as g,z as E,r as w,aA as T,B as M,aC as b,T as N,aH as P,s as D,q as O,b1 as H,aq as x,V as I,aa as A,aE as L,aM as R}from"./lib/__bundle-1da35e70.js";import{L as F,Q as k,T as S,W as q,V as z,X as Q,Y as K,Z as V,_ as W,a0 as B,a1 as G,a2 as j,a3 as X,P as Y,t as Z,a4 as $}from"./lib/__bundle-0099b2f2.js";import{C as J,a as ee,b as ne,O as te,P as re,M as ae,c as oe,R as ie,U as se,A as ue,B as ce}from"./lib/__bundle-d3df41f8.js";import"./lib/__bundle-c336221f.js";var le=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return!!e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),he={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},de=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=s.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(l),pe=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Pe(e,t),r}return e(t,n),t}(h),fe=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=s.POST,t.path=c,t.params=d(p({channel_url:r,cover_url:o("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:l,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(l);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Pe(e,t),r}e(t,n)}(h);var Ce=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),ve=function(n){function t(e,t,r){var a,o,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(o=r.data.edge_ts)&&void 0!==o?o:0),i}return e(t,n),t}(J),_e=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),ye=function(n){function t(e,t,r){var a,o,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(o=r.data.edge_ts)&&void 0!==o?o:0),i}return e(t,n),t}(J),Ue={},me=function(r){function s(e,a){var o=r.call(this,e,_(_({},a),{channelType:y.OPEN}))||this;return o.subscribeChannelEvent=U,o.unsubscribeChannelEvent=U,o.refreshChannel=function(){return n(o,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},o._openChannelCache=new le(e),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){var n,t;if(e instanceof m)o._handleEvent(e);else if(e instanceof g&&e.stateType===E.CONNECTED){var r=o._openChannelCache.enteredChannels;try{for(var a=w(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),Ue[e]||(Ue[e]=o),o}return e(s,r),s.of=function(e){return Ue[e]},s.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new Pe(this._iid,Pe.payloadify(n))},s.prototype.getChannelFromCache=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},s.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},s.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,o,i,s;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=w(e),r=n.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return o=t.sent(),i={error:o},[3,7];case 6:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},s.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},s.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},s.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,o,i,s,u,c,l,h,d,p,f,C,v,_,U,m,g,E,D,O,x,I,A,L,R,Y,Z,$,ee,ce,le,he,de,pe,fe,Ce,_e,Ue,me,ge,Ee,we,Te,Me,be,Ne,Pe,De,Oe,He,xe,Ie,Ae,Le,Re,Fe,ke,Se,qe,ze,Qe,Ke,Ve,We,Be,Ge,je,Xe=this;return t(this,(function(Ye){switch(Ye.label){case 0:switch(Ye.trys.push([0,57,,58]),e.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"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,56];case 1:return i=null,"MESG"===e.code?i=e.as(j):"FILE"===e.code?i=e.as(X):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(ue)),i?(r=i.message,a=i.isMentioned,r.channelType!==y.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:o=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,i,s,u;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(o.url)&&(i.onMessageReceived&&i.onMessageReceived(o,r),a&&i.onMentionReceived&&i.onMentionReceived(o,r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Ye.label=3;case 3:return[3,56];case 4:return i=null,"MEDI"===e.code?i=e.as(B):"FEDI"===e.code?i=e.as(G):"AEDI"===e.code&&(i=e.as(se)),i?(s=i.message,u=i.mentionCountChange,s.channelType!==y.OPEN?[3,6]:[4,this.getChannel(s.channelUrl,!0)]):[3,6];case 5:c=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated&&r.onMessageUpdated(c,s),u>0&&r.onMentionReceived&&r.onMentionReceived(c,s))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=6;case 6:return[3,56];case 7:return l=e.as(W),ce=l.channelUrl,le=l.channelType,h=l.messageId,le!==y.OPEN?[3,9]:[4,this.getChannel(ce,!0)];case 8:d=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted&&r.onMessageDeleted(d,h)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=9;case 9:return[3,56];case 10:return p=e.as(ie),ce=p.channelUrl,le=p.channelType,f=p.event,le!==y.OPEN?[3,12]:[4,this.getChannel(ce,!0)];case 11:C=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(C.url)&&r.onReactionUpdated&&r.onReactionUpdated(C,f)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=12;case 12:return[3,56];case 13:return(v=e.as(oe).event).channelType!==y.OPEN?[3,15]:[4,this.getChannel(v.channelUrl,!0)];case 14:_=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(_,v)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=15;case 15:return[3,56];case 16:U=e.as(ae).openChannelMemberCounts,m=[],Ye.label=17;case 17:Ye.trys.push([17,22,23,24]),g=w(U),E=g.next(),Ye.label=18;case 18:return E.done?[3,21]:(D=E.value,ce=D.channelUrl,ge=D.participantCount,O=D.updatedAt,[4,this.getChannelFromCache(ce)]);case 19:(x=Ye.sent())&&x._updateParticipantCount(ge,O)&&m.push(x),Ye.label=20;case 20:return E=g.next(),[3,18];case 21:return[3,24];case 22:return I=Ye.sent(),Ge={error:I},[3,24];case 23:try{E&&!E.done&&(je=g.return)&&je.call(g)}finally{if(Ge)throw Ge.error}return[7];case 24:return m.length>0?[4,this.upsertChannelsToCache(m)]:[3,26];case 25:A=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(A)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=26;case 26:return[3,56];case 27:return L=e.as(re),R=L.event,Y=L.status,ce=L.channelUrl,le=L.channelType,ce&&le===y.OPEN?[4,this.getChannel(ce,!0)]:[3,29];case 28:Z=Ye.sent(),this._dispatcher.dispatch(new P({event:R,source:N.EVENT_POLL_UPDATED})),M(Y===H?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted(Z,R.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated(Z,R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),Ye.label=29;case 29:return[3,56];case 30:return $=e.as(V),ee=$.event,ce=$.channelUrl,le=$.channelType,ce&&le===y.OPEN?[4,this.getChannel(ce,!0)]:[3,32];case 31:he=Ye.sent(),this._dispatcher.dispatch(new b({event:ee,source:N.EVENT_POLL_VOTED})),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(he,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=32;case 32:return[3,56];case 33:if(!(de=e.as(J).event).isOpenChannelEvent)return[3,55];switch(de.category){case ne.CHANNEL_ENTER:return[3,34];case ne.CHANNEL_EXIT:return[3,36];case ne.CHANNEL_OPERATOR_UPDATE:return[3,38];case ne.USER_CHANNEL_MUTE:case ne.USER_CHANNEL_UNMUTE:return[3,40];case ne.USER_CHANNEL_BAN:case ne.USER_CHANNEL_UNBAN:return[3,42];case ne.CHANNEL_FREEZE:case ne.CHANNEL_UNFREEZE:return[3,44];case ne.CHANNEL_DELETED:return[3,46];case ne.CHANNEL_PROP_CHANGED:return[3,49];case ne.CHANNEL_META_DATA_CHANGED:return[3,51];case ne.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Ye.sent(),fe=e.as(ve),ge=fe.participantCount,Ce=fe.user,_e=pe._updateParticipantCount(ge,de.ts),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(pe,Ce),_e&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return Ue=Ye.sent(),me=e.as(ye),ge=me.participantCount,Ee=me.user,we=Ue._updateParticipantCount(ge,de.ts),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(Ue,Ee),we&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ue)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Ye.sent(),Me=e.as(te).operators,Te.operators=Me,this.upsertChannelsToCache([Te]),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Te,Me)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Ye.sent(),Ne=de.category===ne.USER_CHANNEL_MUTE,Pe=e.as(Ne?Q:K).user,M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ne?e.onUserMuted&&e.onUserMuted(be,Pe):e.onUserUnmuted&&e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return De=Ye.sent(),Oe=de.category===ne.USER_CHANNEL_BAN,He=e.as(Oe?q:z).user,M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(De,He):e.onUserUnbanned&&e.onUserUnbanned(De,He)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return xe=Ye.sent(),Ie=e.as(S).freeze,xe.isFrozen=Ie,this.upsertChannelsToCache([xe]),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen&&e.onChannelFrozen(xe):e.onChannelUnfrozen&&e.onChannelUnfrozen(xe)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Ye.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Le=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Le)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Re=Ye.sent(),Fe=e.as(k),ke=Fe.created,Se=Fe.updated,qe=Fe.deleted,ke&&Re._upsertCachedMetaData(ke,de.ts),Se&&Re._upsertCachedMetaData(Se,de.ts),qe&&Re._removeFromCachedMetaData(qe,de.ts),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ke&&e.onMetaDataCreated&&e.onMetaDataCreated(Re,ke),Se&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Re,Se),qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Re,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return ze=Ye.sent(),Qe=e.as(F),Ke=Qe.created,Ve=Qe.updated,We=Qe.deleted,M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ke&&e.onMetaCounterCreated&&e.onMetaCounterCreated(ze,Ke),Ve&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(ze,Ve),We&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(ze,We)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(Be=Ye.sent(),T(Be))throw Be;return[3,58];case 58:return[2]}}))}))},s.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},s.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},s.prototype.clearHandler=function(){this._openChannelHandlers.clear()},s.prototype.getChannel=function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:D(o("string",e)).throw(O.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,t.sent()]}}))}))},s.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return D(o("string",e)).throw(O.invalidParameters),n=new de({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(pe).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},s.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u;return t(this,(function(t){switch(t.label){case 0:return n=_(_({},he),e),D(function(e){return a("string",e.operatorUserIds,!0)&&(o("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&o("string",e.name,!0)&&o("string",e.data,!0)&&o("string",e.customType,!0)&&(o("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&o("boolean",e.isEphemeral,!0)}(n)).throw(O.invalidParameters),r=new fe(n),[4,this._requestQueue.send(r)];case 1:return s=t.sent(),u=s.as(pe).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},s}(ee),ge={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Ee=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,o=e.limit;return(t=n.call(this)||this).method=s.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:o},t}return e(t,n),t}(l),we=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,o=t.participants;return r.token=a,r.participants=o.map((function(n){return new Y(e,n)})),r}return e(t,n),t}(h),Te=function(r){function a(e,n,t){return r.call(this,e,n,y.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,n=new Ee(_(_({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(we),o=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},a}(x),Me=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=s.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:o("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:l,custom_type:h,operators:f})),t}return e(t,n),t}(l),be=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Pe(e,t),r}return e(t,n),t}(h),Ne=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=s.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(l);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var Pe=function(r){function s(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=y.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new C(e,n)})):[],a}return e(s,r),s.payloadify=function(e){return d(p(_(_({},Z.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)}))})))},s.prototype.serialize=function(){return A(this)},s.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},s.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},s.prototype.createParticipantListQuery=function(e){return new Te(this._iid,this.url,e)},s.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,me.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},s.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return e=I.of(this._iid).requestQueue,n=new Ce({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ve),o=a.participantCount,i=a.ts,this._updateParticipantCount(o,i),me.of(this._iid).setEnteredToCache(this),[2]}}))}))},s.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return e=I.of(this._iid).requestQueue,n=new _e({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ye),o=a.participantCount,i=a.ts,this._updateParticipantCount(o,i),me.of(this._iid).setExitedToCache(this),$.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},s.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u,c;return t(this,(function(t){switch(t.label){case 0:return n=_(_({},ge),e),D(function(e){return a("string",e.operatorUserIds,!0)&&(o("string",e.coverUrlOrImage)||i(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&o("string",e.name,!0)&&o("string",e.data,!0)&&o("string",e.customType,!0)}(n)).throw(O.invalidParameters),r=I.of(this._iid).requestQueue,s=new Me(_({channelUrl:this.url},n)),[4,r.send(s)];case 1:return u=t.sent(),c=u.as(be).channel,this._update(c),[4,me.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,this]}}))}))},s.prototype.updateChannelWithOperatorUserIds=function(e,r,a,o,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=_(_({},ge),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:o,customType:i}),[2,this.updateChannel(n)]}))}))},s.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=I.of(this._iid).requestQueue,n=new Ne({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,me.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},s.prototype.sendUserMessage=function(e){return D(!e.isPinnedMessage).throw(O.notSupportedError),r.prototype.sendUserMessage.call(this,e)},s.prototype.sendFileMessage=function(e){return D(!e.isPinnedMessage).throw(O.notSupportedError),r.prototype.sendFileMessage.call(this,e)},s}(Z),De=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e}return e(t,n),t}(ce)),Oe=function(n){function t(e){var t=this,r=e.token,a=e.limit,o=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=s.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:o,url_contains:i,custom_types:u,show_frozen:l,show_metadata:h}),t}return e(t,n),t}(l),He=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,o=t.channels,i=t.ts;return r.token=a,o&&o.length>0&&(r.channels=o.map((function(n){return new Pe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),xe=function(r){function i(e,n){var t,a,o,i,s,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(o=n.nameKeyword)&&void 0!==o?o:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(s=n.customTypes)&&void 0!==s?s:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&o("boolean",this.includeFrozen)&&o("boolean",this.includeMetaData)&&o("string",this.nameKeyword,!0)&&o("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,n=new Oe(p(_(_({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(He),o=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,me.of(this._iid).upsertChannelsToCache(o)];case 2:return t.sent(),this._isLoading=!1,[2,o];case 3:return[2,[]];case 4:throw O.queryInProgress;case 5:return[3,7];case 6:throw O.invalidParameters;case 7:return[2]}}))}))},i}(L),Ie=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,o=n.sessionManager,i=n.requestQueue,s=n.logger,u=n.onlineDetector,c=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:o,requestQueue:i,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new me(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:s,cacheContext:c,sessionManager:o})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,o,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=_({},he)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=o,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(R);export{Pe as OpenChannel,De as OpenChannelHandler,xe as OpenChannelListQuery,Ie as OpenChannelModule,Te as ParticipantListQuery}; +import{_ as e,b as n,c as t,a7 as r,K as a,a as o,i,A as s,b6 as u,b7 as c,f as l,h,e as d,u as p,ah as f,U as C,x as v,g as _,X as y,ap as U,W as m,y as g,z as E,r as w,aA as T,B as M,aC as b,T as N,aH as P,s as D,q as O,b2 as H,aq as x,V as I,aa as A,aE as L,aM as R}from"./lib/__bundle-fdefc164.js";import{L as F,Q as k,T as S,W as q,V as z,X as Q,Y as K,Z as V,_ as W,a0 as B,a1 as G,a2 as j,a3 as X,P as Y,t as Z,a4 as $}from"./lib/__bundle-bd25634c.js";import{C as J,a as ee,b as ne,O as te,P as re,M as ae,c as oe,R as ie,U as se,A as ue,B as ce}from"./lib/__bundle-6f8fc428.js";import"./lib/__bundle-c336221f.js";var le=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return!!e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),he={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},de=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=s.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(l),pe=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Pe(e,t),r}return e(t,n),t}(h),fe=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=s.POST,t.path=c,t.params=d(p({channel_url:r,cover_url:o("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:l,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(l);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Pe(e,t),r}e(t,n)}(h);var Ce=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),ve=function(n){function t(e,t,r){var a,o,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(o=r.data.edge_ts)&&void 0!==o?o:0),i}return e(t,n),t}(J),_e=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),ye=function(n){function t(e,t,r){var a,o,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(o=r.data.edge_ts)&&void 0!==o?o:0),i}return e(t,n),t}(J),Ue={},me=function(r){function s(e,a){var o=r.call(this,e,_(_({},a),{channelType:y.OPEN}))||this;return o.subscribeChannelEvent=U,o.unsubscribeChannelEvent=U,o.refreshChannel=function(){return n(o,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},o._openChannelCache=new le(e),o._openChannelHandlers=new Map,o._dispatcher.on((function(e){var n,t;if(e instanceof m)o._handleEvent(e);else if(e instanceof g&&e.stateType===E.CONNECTED){var r=o._openChannelCache.enteredChannels;try{for(var a=w(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),Ue[e]||(Ue[e]=o),o}return e(s,r),s.of=function(e){return Ue[e]},s.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new Pe(this._iid,Pe.payloadify(n))},s.prototype.getChannelFromCache=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},s.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},s.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,o,i,s;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=w(e),r=n.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return o=t.sent(),i={error:o},[3,7];case 6:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},s.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},s.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},s.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,o,i,s,u,c,l,h,d,p,f,C,v,_,U,m,g,E,D,O,x,I,A,L,R,Y,Z,$,ee,ce,le,he,de,pe,fe,Ce,_e,Ue,me,ge,Ee,we,Te,Me,be,Ne,Pe,De,Oe,He,xe,Ie,Ae,Le,Re,Fe,ke,Se,qe,ze,Qe,Ke,Ve,We,Be,Ge,je,Xe=this;return t(this,(function(Ye){switch(Ye.label){case 0:switch(Ye.trys.push([0,57,,58]),e.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"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,56];case 1:return i=null,"MESG"===e.code?i=e.as(j):"FILE"===e.code?i=e.as(X):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(ue)),i?(r=i.message,a=i.isMentioned,r.channelType!==y.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:o=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,i,s,u;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(o.url)&&(i.onMessageReceived&&i.onMessageReceived(o,r),a&&i.onMentionReceived&&i.onMentionReceived(o,r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Ye.label=3;case 3:return[3,56];case 4:return i=null,"MEDI"===e.code?i=e.as(B):"FEDI"===e.code?i=e.as(G):"AEDI"===e.code&&(i=e.as(se)),i?(s=i.message,u=i.mentionCountChange,s.channelType!==y.OPEN?[3,6]:[4,this.getChannel(s.channelUrl,!0)]):[3,6];case 5:c=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated&&r.onMessageUpdated(c,s),u>0&&r.onMentionReceived&&r.onMentionReceived(c,s))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=6;case 6:return[3,56];case 7:return l=e.as(W),ce=l.channelUrl,le=l.channelType,h=l.messageId,le!==y.OPEN?[3,9]:[4,this.getChannel(ce,!0)];case 8:d=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted&&r.onMessageDeleted(d,h)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=9;case 9:return[3,56];case 10:return p=e.as(ie),ce=p.channelUrl,le=p.channelType,f=p.event,le!==y.OPEN?[3,12]:[4,this.getChannel(ce,!0)];case 11:C=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(C.url)&&r.onReactionUpdated&&r.onReactionUpdated(C,f)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=12;case 12:return[3,56];case 13:return(v=e.as(oe).event).channelType!==y.OPEN?[3,15]:[4,this.getChannel(v.channelUrl,!0)];case 14:_=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(_,v)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=15;case 15:return[3,56];case 16:U=e.as(ae).openChannelMemberCounts,m=[],Ye.label=17;case 17:Ye.trys.push([17,22,23,24]),g=w(U),E=g.next(),Ye.label=18;case 18:return E.done?[3,21]:(D=E.value,ce=D.channelUrl,ge=D.participantCount,O=D.updatedAt,[4,this.getChannelFromCache(ce)]);case 19:(x=Ye.sent())&&x._updateParticipantCount(ge,O)&&m.push(x),Ye.label=20;case 20:return E=g.next(),[3,18];case 21:return[3,24];case 22:return I=Ye.sent(),Ge={error:I},[3,24];case 23:try{E&&!E.done&&(je=g.return)&&je.call(g)}finally{if(Ge)throw Ge.error}return[7];case 24:return m.length>0?[4,this.upsertChannelsToCache(m)]:[3,26];case 25:A=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(A)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=26;case 26:return[3,56];case 27:return L=e.as(re),R=L.event,Y=L.status,ce=L.channelUrl,le=L.channelType,ce&&le===y.OPEN?[4,this.getChannel(ce,!0)]:[3,29];case 28:Z=Ye.sent(),this._dispatcher.dispatch(new P({event:R,source:N.EVENT_POLL_UPDATED})),M(Y===H?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted(Z,R.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated(Z,R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),Ye.label=29;case 29:return[3,56];case 30:return $=e.as(V),ee=$.event,ce=$.channelUrl,le=$.channelType,ce&&le===y.OPEN?[4,this.getChannel(ce,!0)]:[3,32];case 31:he=Ye.sent(),this._dispatcher.dispatch(new b({event:ee,source:N.EVENT_POLL_VOTED})),M((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,o;return t(this,(function(t){try{for(e=w(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(he,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=32;case 32:return[3,56];case 33:if(!(de=e.as(J).event).isOpenChannelEvent)return[3,55];switch(de.category){case ne.CHANNEL_ENTER:return[3,34];case ne.CHANNEL_EXIT:return[3,36];case ne.CHANNEL_OPERATOR_UPDATE:return[3,38];case ne.USER_CHANNEL_MUTE:case ne.USER_CHANNEL_UNMUTE:return[3,40];case ne.USER_CHANNEL_BAN:case ne.USER_CHANNEL_UNBAN:return[3,42];case ne.CHANNEL_FREEZE:case ne.CHANNEL_UNFREEZE:return[3,44];case ne.CHANNEL_DELETED:return[3,46];case ne.CHANNEL_PROP_CHANGED:return[3,49];case ne.CHANNEL_META_DATA_CHANGED:return[3,51];case ne.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Ye.sent(),fe=e.as(ve),ge=fe.participantCount,Ce=fe.user,_e=pe._updateParticipantCount(ge,de.ts),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(pe,Ce),_e&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return Ue=Ye.sent(),me=e.as(ye),ge=me.participantCount,Ee=me.user,we=Ue._updateParticipantCount(ge,de.ts),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(Ue,Ee),we&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ue)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Ye.sent(),Me=e.as(te).operators,Te.operators=Me,this.upsertChannelsToCache([Te]),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Te,Me)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Ye.sent(),Ne=de.category===ne.USER_CHANNEL_MUTE,Pe=e.as(Ne?Q:K).user,M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ne?e.onUserMuted&&e.onUserMuted(be,Pe):e.onUserUnmuted&&e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return De=Ye.sent(),Oe=de.category===ne.USER_CHANNEL_BAN,He=e.as(Oe?q:z).user,M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(De,He):e.onUserUnbanned&&e.onUserUnbanned(De,He)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return xe=Ye.sent(),Ie=e.as(S).freeze,xe.isFrozen=Ie,this.upsertChannelsToCache([xe]),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen&&e.onChannelFrozen(xe):e.onChannelUnfrozen&&e.onChannelUnfrozen(xe)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Ye.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Le=Ye.sent(),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Le)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Re=Ye.sent(),Fe=e.as(k),ke=Fe.created,Se=Fe.updated,qe=Fe.deleted,ke&&Re._upsertCachedMetaData(ke,de.ts),Se&&Re._upsertCachedMetaData(Se,de.ts),qe&&Re._removeFromCachedMetaData(qe,de.ts),M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ke&&e.onMetaDataCreated&&e.onMetaDataCreated(Re,ke),Se&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Re,Se),qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Re,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return ze=Ye.sent(),Qe=e.as(F),Ke=Qe.created,Ve=Qe.updated,We=Qe.deleted,M((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ke&&e.onMetaCounterCreated&&e.onMetaCounterCreated(ze,Ke),Ve&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(ze,Ve),We&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(ze,We)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(Be=Ye.sent(),T(Be))throw Be;return[3,58];case 58:return[2]}}))}))},s.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},s.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},s.prototype.clearHandler=function(){this._openChannelHandlers.clear()},s.prototype.getChannel=function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:D(o("string",e)).throw(O.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,t.sent()]}}))}))},s.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return D(o("string",e)).throw(O.invalidParameters),n=new de({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(pe).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},s.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u;return t(this,(function(t){switch(t.label){case 0:return n=_(_({},he),e),D(function(e){return a("string",e.operatorUserIds,!0)&&(o("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&o("string",e.name,!0)&&o("string",e.data,!0)&&o("string",e.customType,!0)&&(o("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&o("boolean",e.isEphemeral,!0)}(n)).throw(O.invalidParameters),r=new fe(n),[4,this._requestQueue.send(r)];case 1:return s=t.sent(),u=s.as(pe).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},s}(ee),ge={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Ee=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,o=e.limit;return(t=n.call(this)||this).method=s.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:o},t}return e(t,n),t}(l),we=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,o=t.participants;return r.token=a,r.participants=o.map((function(n){return new Y(e,n)})),r}return e(t,n),t}(h),Te=function(r){function a(e,n,t){return r.call(this,e,n,y.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,n=new Ee(_(_({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(we),o=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw O.queryInProgress;case 4:return[3,6];case 5:throw O.invalidParameters;case 6:return[2]}}))}))},a}(x),Me=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=s.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:o("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:l,custom_type:h,operators:f})),t}return e(t,n),t}(l),be=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Pe(e,t),r}return e(t,n),t}(h),Ne=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=s.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(l);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var Pe=function(r){function s(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=y.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new C(e,n)})):[],a}return e(s,r),s.payloadify=function(e){return d(p(_(_({},Z.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)}))})))},s.prototype.serialize=function(){return A(this)},s.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},s.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},s.prototype.createParticipantListQuery=function(e){return new Te(this._iid,this.url,e)},s.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,me.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},s.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return e=I.of(this._iid).requestQueue,n=new Ce({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ve),o=a.participantCount,i=a.ts,this._updateParticipantCount(o,i),me.of(this._iid).setEnteredToCache(this),[2]}}))}))},s.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return e=I.of(this._iid).requestQueue,n=new _e({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ye),o=a.participantCount,i=a.ts,this._updateParticipantCount(o,i),me.of(this._iid).setExitedToCache(this),$.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},s.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u,c;return t(this,(function(t){switch(t.label){case 0:return n=_(_({},ge),e),D(function(e){return a("string",e.operatorUserIds,!0)&&(o("string",e.coverUrlOrImage)||i(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&o("string",e.name,!0)&&o("string",e.data,!0)&&o("string",e.customType,!0)}(n)).throw(O.invalidParameters),r=I.of(this._iid).requestQueue,s=new Me(_({channelUrl:this.url},n)),[4,r.send(s)];case 1:return u=t.sent(),c=u.as(be).channel,this._update(c),[4,me.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,this]}}))}))},s.prototype.updateChannelWithOperatorUserIds=function(e,r,a,o,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=_(_({},ge),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:o,customType:i}),[2,this.updateChannel(n)]}))}))},s.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=I.of(this._iid).requestQueue,n=new Ne({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,me.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},s.prototype.sendUserMessage=function(e){return D(!e.isPinnedMessage).throw(O.notSupportedError),r.prototype.sendUserMessage.call(this,e)},s.prototype.sendFileMessage=function(e){return D(!e.isPinnedMessage).throw(O.notSupportedError),r.prototype.sendFileMessage.call(this,e)},s}(Z),De=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e}return e(t,n),t}(ce)),Oe=function(n){function t(e){var t=this,r=e.token,a=e.limit,o=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=s.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:o,url_contains:i,custom_types:u,show_frozen:l,show_metadata:h}),t}return e(t,n),t}(l),He=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,o=t.channels,i=t.ts;return r.token=a,o&&o.length>0&&(r.channels=o.map((function(n){return new Pe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),xe=function(r){function i(e,n){var t,a,o,i,s,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(o=n.nameKeyword)&&void 0!==o?o:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(s=n.customTypes)&&void 0!==s?s:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&o("boolean",this.includeFrozen)&&o("boolean",this.includeMetaData)&&o("string",this.nameKeyword,!0)&&o("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,o,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,n=new Oe(p(_(_({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(He),o=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,me.of(this._iid).upsertChannelsToCache(o)];case 2:return t.sent(),this._isLoading=!1,[2,o];case 3:return[2,[]];case 4:throw O.queryInProgress;case 5:return[3,7];case 6:throw O.invalidParameters;case 7:return[2]}}))}))},i}(L),Ie=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,o=n.sessionManager,i=n.requestQueue,s=n.logger,u=n.onlineDetector,c=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:o,requestQueue:i,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new me(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:s,cacheContext:c,sessionManager:o})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,o,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=_({},he)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=o,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(R);export{Pe as OpenChannel,De as OpenChannelHandler,xe as OpenChannelListQuery,Ie as OpenChannelModule,Te as ParticipantListQuery}; diff --git a/package.json b/package.json index 5c742e2..10c2799 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.9.7", + "version": "4.9.8", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/poll.js b/poll.js index 1d53a75..d906a53 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{_ as e,aD as a,b as r,aM as n,c as o,g as i,aN as s,s as l,aO as u,q as c,aP as p,aQ as d,aR as h,aS as g}from"./lib/__bundle-1da35e70.js";export{af as Poll,t as PollListQuery,aT as PollOption,aU as PollStatus,ax as PollVoteEvent,w as PollVoterListQuery}from"./lib/__bundle-1da35e70.js";export{P as PollUpdateEvent}from"./lib/__bundle-c336221f.js";var f=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="poll",e}return e(n,t),n.prototype.init=function(e,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;t.prototype.init.call(this,e,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new a(e,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},n.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(a){return e=i(i({},s),t),l(u(e)).throw(c.invalidParameters),[2,this._manager.create(e)]}))}))},n.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(a){return e=i(i({},p),t),l(d(e)).throw(c.invalidParameters),[2,this._manager.get(e)]}))}))},n.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(a){return e=i(i({},h),t),l(g(e)).throw(c.invalidParameters),[2,this._manager.getOption(e)]}))}))},n.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},n}(n);export{f as PollModule}; +import{_ as e,aD as a,b as r,aM as n,c as o,g as i,aN as s,s as l,aO as u,q as c,aP as p,aQ as d,aR as h,aS as f}from"./lib/__bundle-fdefc164.js";export{af as Poll,t as PollListQuery,aT as PollOption,aU as PollStatus,ax as PollVoteEvent,w as PollVoterListQuery}from"./lib/__bundle-fdefc164.js";export{P as PollUpdateEvent}from"./lib/__bundle-c336221f.js";var g=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="poll",e}return e(n,t),n.prototype.init=function(e,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;t.prototype.init.call(this,e,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new a(e,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},n.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(a){return e=i(i({},s),t),l(u(e)).throw(c.invalidParameters),[2,this._manager.create(e)]}))}))},n.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(a){return e=i(i({},p),t),l(d(e)).throw(c.invalidParameters),[2,this._manager.get(e)]}))}))},n.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(a){return e=i(i({},h),t),l(f(e)).throw(c.invalidParameters),[2,this._manager.getOption(e)]}))}))},n.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},n}(n);export{g as PollModule}; diff --git a/sendbird.min.js b/sendbird.min.js index 7c2af6e..aa6610b 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:b(e,n,o)}),i}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(a,s,i,o){var u=d(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function b(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===h)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=d(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var a=d(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,h;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var b,w="4.9.7",C=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",e[e.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.SESSION_REVOKED=400310]="SESSION_REVOKED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_COMMAND=700700]="INVALID_COMMAND",e[e.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(b||(b={}));var x,T,S,I,N,A=function(e){return!(e instanceof M&&!e.shouldThrowOutside)},M=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message,u=void 0===o?"":o;return r(this,n),(a=t.call(this,u)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(h(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===b.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===b.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===b.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===b.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===b.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===b.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:b.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:b.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new n({code:b.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new n({code:b.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new n({code:b.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:b.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:b.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:b.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:b.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:b.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:b.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:b.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:b.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:b.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:b.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:b.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:b.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:b.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:b.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:b.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:b.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:b.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:b.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(d(Error)),O=[b.CONNECTION_REQUIRED,b.NETWORK_ERROR,b.ACK_TIMEOUT,b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.FILE_UPLOAD_CANCEL_FAILED,b.REQUEST_CANCELED,b.INTERNAL_SERVER_ERROR,b.RATE_LIMIT_EXCEEDED,b.UNKNOWN_SERVER_ERROR],U=[b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.CONNECTION_REQUIRED],D=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?R(e,t):P(e,t):n(t)===e)},R=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},H=function(e){return e>0&&U.indexOf(e)>=0},q=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null==e)return!0;var t="object"===n(e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},G=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator;r(this,e),this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),o?(this._clearOrder=i,this._customClearOrderComparator=o):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),re=function(){function e(){r(this,e)}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0}}]),e}(),ae=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},se=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ae()}return s(e,[{key:"_register",value:function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)}}]),e}(),ie=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new se({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new se({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),oe=function(){function e(){r(this,e),this._dispatcher=new ie}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),ue=s((function e(){r(this,e)})),ce=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},le=function e(t){if(null!=t){if("object"===n(t)){if(Array.isArray(t)){var r=_(t);for(var a in r)r[a]=e(r[a]);return r}for(var s in t)null===t[s]&&delete t[s];return t}return t}};e.ChannelType=void 0,(B=e.ChannelType||(e.ChannelType={})).BASE="base",B.GROUP="group",B.OPEN="open",B.FEED="feed",e.Role=void 0,(Q=e.Role||(e.Role={})).OPERATOR="operator",Q.NONE="none",e.MutedState=void 0,(K=e.MutedState||(e.MutedState={})).MUTED="muted",K.UNMUTED="unmuted",e.MessageType=void 0,(W=e.MessageType||(e.MessageType={})).BASE="base",W.USER="user",W.FILE="file",W.ADMIN="admin",e.MessageTypeFilter=void 0,(Y=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",Y.USER="MESG",Y.FILE="FILE",Y.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(Z||(Z={})),e.MentionType=void 0,(J=e.MentionType||(e.MentionType={})).USERS="users",J.CHANNEL="channel",e.ReplyType=void 0,(X=e.ReplyType||(e.ReplyType={})).ALL="all",X.NONE="none",X.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,($=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",$.SUPPRESS="suppress",e.SendingStatus=void 0,(ee=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",ee.SCHEDULED="scheduled",ee.SUCCEEDED="succeeded",ee.FAILED="failed",ee.CANCELED="canceled";var de,he="v3",fe="/".concat(he,"/users"),pe="/".concat(he,"/storage/file"),ve="/".concat(he,"/group_channels"),_e="/".concat(he,"/sdk/group_channels"),me="/".concat(he,"/open_channels"),ge="/".concat(he,"/sdk/open_channels"),ye="/".concat(he,"/search"),ke="/".concat(he,"/report"),Ee="/".concat(he,"/emojis"),be="/".concat(he,"/emoji_categories"),we="/".concat(he,"/polls"),Ce="/".concat(he,"/scheduled_messages"),xe="/".concat(he,"/sdk/ui_kit/configuration"),Te="/".concat(he,"/sdk/statistics"),Se=function(t){switch(t){case e.ChannelType.FEED:case e.ChannelType.GROUP:return ve;case e.ChannelType.OPEN:return me;default:return null}},Ie=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ke,"/group_channels");case e.ChannelType.OPEN:return"".concat(ke,"/open_channels");default:return null}},Ne=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},Ae=function(e,t,n){var r,a,s,i,o=Ne(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(a=e.mentionedUserIds)&&void 0!==a?a:[],n),u=Ne(null!==(s=t.mentionType)&&void 0!==s?s:null,null!==(i=t.mentionedUserIds)&&void 0!==i?i:[],n);return!o&&u?1:o&&!u?-1:0},Me=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var u=t[o],c=a?"".concat(a,"[").concat(o,"]"):o;q(u)?i.append(c,u,null!==(s=u.name)&&void 0!==s?s:"filename"):"object"!==n(u)||null===u||Array.isArray(u)||u instanceof Blob?i.append(c,String(u)):i=e(u,i,c)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(de||(de={}));var Oe,Ue=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=ae(),e}return s(a,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ce(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=ce(this.params);return Object.keys(e).some((function(t){return q(e[t])}))?Me(e):JSON.stringify(e)}}]),a}(ue),De=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}(ue),Le=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}(ue),Re=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.expires_in,i=e.reason,o=void 0===i?b.SESSION_KEY_EXPIRED:i;switch(r(this,n),(a=t.call(this)).expiresIn=null!=s?s:0,o){case b.SESSION_KEY_EXPIRED:case b.SESSION_TOKEN_EXPIRED:case b.SESSION_REVOKED:case b.USER_AUTH_DEACTIVATED:case b.USER_AUTH_DELETED_OR_NOT_FOUND:a.error=new M({code:o})}return a}return s(n,[{key:"invalidateSessionToken",get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}]),n}(ue),Pe=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}(ue);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Oe||(Oe={}));var Fe,He,qe,Ge=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ce({stat_type:e.type,ts:e.createdAt,data:ce(e.data)})}}]),e}(),je=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},ze=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(Fe=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",Fe.CALLS="calls",Fe.DESK="desk",Fe.LIVE="live",Fe.UIKIT_CHAT="uikit-chat",Fe.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(He=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",He.IOS="ios",He.JS="js",He.UNREAL="unreal",He.UNITY="unity",He.REACT_NATIVE="react-native",He.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(qe=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",qe.IOS="ios",qe.WEB="web",qe.MOBILE_WEB="mobile_web",qe.WINDOWS="windows";var Ve=s((function e(){r(this,e)}));Ve.sendbirdSdkUserAgentWithExtension=function(t){var n=je()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:ze()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,s=t.deviceOS,i=t.customData,o=void 0===i?{}:i;s.version&&(r.os_version=s.version),s.platform&&(r.device_os_platform=s.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=v(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},Ve.userAgentWithExtension=function(e){var t=je()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):ze()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var Be=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Le&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,s=n.sendbirdRuntimeEnvironment,i=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":Ve.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Ve.sendbirdSdkUserAgentWithExtension(s)});return t||(i["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(i["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(i["App-Id"]=r,i["Access-Token"]=this._auth.authToken),i}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Pe(new Ge({type:Oe.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d,h,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![de.GET,de.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:void 0),l=new AbortController,d=l.signal,this._abortControl.set(e.requestId,l),h=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return t_}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return T_}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:d});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h),t.abrupt("return",new De(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new M(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:v.code})),this._statLogApiResult(e,h,v),v;case 37:throw _=M.requestFailed,this._statLogApiResult(e,h,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,h,t.t0),!(t.t0 instanceof M)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw M.requestCanceled;case 54:throw m=M.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),Qe=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=null!==(o=s.req_id)&&void 0!==o?o:u,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a={};try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(ue),Ke=function(){};function We(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ye=256,Ze=286,Je=30,Xe=15,$e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),et=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),tt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),nt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rt=new Array(576);We(rt);const at=new Array(60);We(at);const st=new Array(512);We(st);const it=new Array(256);We(it);const ot=new Array(29);We(ot);const ut=new Array(Je);function ct(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let lt,dt,ht;function ft(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}We(ut);const pt=e=>e<256?st[e]:st[256+(e>>>7)],vt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},_t=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{_t(e,n[2*t],n[2*t+1])},gt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},yt=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Xe;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=gt(r[t]++,t))}},kt=e=>{let t;for(t=0;t{e.bi_valid>8?vt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},bt=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?mt(e,a,t):(s=it[a],mt(e,s+Ye+1,t),i=$e[s],0!==i&&(a-=ot[s],_t(e,a,i)),r--,s=pt(r),mt(e,s,n),i=et[s],0!==i&&(r-=ut[s],_t(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)wt(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],wt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,wt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=Xe;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(h+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),yt(n,c,e.bl_count)},Tt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{_t(e,0+(r?1:0),3),Et(e),vt(e,n),vt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var At=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(Tt(e,e.dyn_ltree,e.l_desc.max_code),Tt(e,e.dyn_dtree,e.d_desc.max_code),xt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*nt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Nt(e,t,n,r):4===e.strategy||s===a?(_t(e,2+(r?1:0),3),Ct(e,rt,at)):(_t(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(_t(e,t-257,5),_t(e,n-1,5),_t(e,r-4,4),a=0;a{It||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(ot[r]=n,e=0;e<1<<$e[r];e++)it[n++]=r;for(it[n-1]=r,a=0,r=0;r<16;r++)for(ut[r]=a,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(it[n]+Ye+1)]++,e.dyn_dtree[2*pt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{_t(e,2,3),mt(e,256,rt),(e=>{16===e.bi_valid?(vt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ot=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const Ut=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Dt=(e,t,n,r)=>{const a=Ut,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},Lt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Rt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Pt,_tr_stored_block:Ft,_tr_flush_block:Ht,_tr_tally:qt,_tr_align:Gt}=Mt,{Z_NO_FLUSH:jt,Z_PARTIAL_FLUSH:zt,Z_FULL_FLUSH:Vt,Z_FINISH:Bt,Z_BLOCK:Qt,Z_OK:Kt,Z_STREAM_END:Wt,Z_STREAM_ERROR:Yt,Z_DATA_ERROR:Zt,Z_BUF_ERROR:Jt,Z_DEFAULT_COMPRESSION:Xt,Z_FILTERED:$t,Z_HUFFMAN_ONLY:en,Z_RLE:tn,Z_FIXED:nn,Z_DEFAULT_STRATEGY:rn,Z_UNKNOWN:an,Z_DEFLATED:sn}=Rt,on=258,un=262,cn=42,ln=113,dn=666,hn=(e,t)=>(e.msg=Lt[t],t),fn=e=>2*e-(e>4?9:0),pn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},vn=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let _n=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},gn=(e,t)=>{Ht(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,mn(e.strm)},yn=(e,t)=>{e.pending_buf[e.pending++]=t},kn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},En=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ot(e.adler,t,a,n):2===e.state.wrap&&(e.adler=Dt(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},bn=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-un?e.strstart-(e.w_size-un):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+on;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=d[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},wn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-un)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),vn(e),r+=t),0===e.strm.avail_in)break;if(n=En(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=_n(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=_n(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,mn(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(En(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(En(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===Bt)&&t!==jt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Bt&&0===e.strm.avail_in&&n===r?1:0,Ft(e,e.block_start,n,i),e.block_start+=n,mn(e.strm)),i?3:1)},xn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=_n(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-un&&(e.match_length=bn(e,n)),e.match_length>=3)if(r=qt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=_n(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=_n(e,e.ins_h,e.window[e.strstart+1]);else r=qt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(gn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Bt?(gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gn(e,!1),0===e.strm.avail_out)?1:2},Tn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=_n(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=qt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=_n(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(gn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=qt(e,0,e.window[e.strstart-1]),r&&gn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=qt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Bt?(gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gn(e,!1),0===e.strm.avail_out)?1:2};function Sn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const In=[new Sn(0,0,0,0,Cn),new Sn(4,4,8,4,xn),new Sn(4,5,16,8,xn),new Sn(4,6,32,32,xn),new Sn(4,4,16,16,Tn),new Sn(8,16,32,32,Tn),new Sn(8,16,128,128,Tn),new Sn(8,32,128,256,Tn),new Sn(32,128,258,1024,Tn),new Sn(32,258,258,4096,Tn)];function Nn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=sn,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),pn(this.dyn_ltree),pn(this.dyn_dtree),pn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),pn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),pn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const An=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==cn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ln&&t.status!==dn?1:0},Mn=e=>{if(An(e))return hn(e,Yt);e.total_in=e.total_out=0,e.data_type=an;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?cn:ln,e.adler=2===t.wrap?0:1,t.last_flush=-2,Pt(t),Kt},On=e=>{const t=Mn(e);var n;return t===Kt&&((n=e.state).window_size=2*n.w_size,pn(n.head),n.max_lazy_match=In[n.level].max_lazy,n.good_match=In[n.level].good_length,n.nice_match=In[n.level].nice_length,n.max_chain_length=In[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Un=(e,t,n,r,a,s)=>{if(!e)return Yt;let i=1;if(t===Xt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==sn||r<8||r>15||t<0||t>9||s<0||s>nn||8===r&&1!==i)return hn(e,Yt);8===r&&(r=9);const o=new Nn;return e.state=o,o.strm=e,o.status=cn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Un(e,t,sn,15,8,rn),deflateInit2:Un,deflateReset:On,deflateResetKeep:Mn,deflateSetHeader:(e,t)=>An(e)||2!==e.state.wrap?Yt:(e.state.gzhead=t,Kt),deflate:(e,t)=>{if(An(e)||t>Qt||t<0)return e?hn(e,Yt):Yt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===dn&&t!==Bt)return hn(e,0===e.avail_out?Jt:Yt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(mn(e),0===e.avail_out)return n.last_flush=-1,Kt}else if(0===e.avail_in&&fn(t)<=fn(r)&&t!==Bt)return hn(e,Jt);if(n.status===dn&&0!==e.avail_in)return hn(e,Jt);if(n.status===cn&&0===n.wrap&&(n.status=ln),n.status===cn){let t=sn+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=en||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,kn(n,t),0!==n.strstart&&(kn(n,e.adler>>>16),kn(n,65535&e.adler)),e.adler=1,n.status=ln,mn(e),0!==n.pending)return n.last_flush=-1,Kt}if(57===n.status)if(e.adler=0,yn(n,31),yn(n,139),yn(n,8),n.gzhead)yn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),yn(n,255&n.gzhead.time),yn(n,n.gzhead.time>>8&255),yn(n,n.gzhead.time>>16&255),yn(n,n.gzhead.time>>24&255),yn(n,9===n.level?2:n.strategy>=en||n.level<2?4:0),yn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(yn(n,255&n.gzhead.extra.length),yn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Dt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(yn(n,0),yn(n,0),yn(n,0),yn(n,0),yn(n,0),yn(n,9===n.level?2:n.strategy>=en||n.level<2?4:0),yn(n,3),n.status=ln,mn(e),0!==n.pending)return n.last_flush=-1,Kt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Dt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,mn(e),0!==n.pending)return n.last_flush=-1,Kt;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Dt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Dt(e.adler,n.pending_buf,n.pending-r,r)),mn(e),0!==n.pending)return n.last_flush=-1,Kt;r=0}t=n.gzindexr&&(e.adler=Dt(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Dt(e.adler,n.pending_buf,n.pending-r,r)),mn(e),0!==n.pending)return n.last_flush=-1,Kt;r=0}t=n.gzindexr&&(e.adler=Dt(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(mn(e),0!==n.pending))return n.last_flush=-1,Kt;yn(n,255&e.adler),yn(n,e.adler>>8&255),e.adler=0}if(n.status=ln,mn(e),0!==n.pending)return n.last_flush=-1,Kt}if(0!==e.avail_in||0!==n.lookahead||t!==jt&&n.status!==dn){let r=0===n.level?Cn(n,t):n.strategy===en?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(wn(e),0===e.lookahead)){if(t===jt)return 1;break}if(e.match_length=0,n=qt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(gn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Bt?(gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===tn?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=on){if(wn(e),e.lookahead<=on&&t===jt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+on;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=qt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=qt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(gn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Bt?(gn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gn(e,!1),0===e.strm.avail_out)?1:2})(n,t):In[n.level].func(n,t);if(3!==r&&4!==r||(n.status=dn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Kt;if(2===r&&(t===zt?Gt(n):t!==Qt&&(Ft(n,0,0,!1),t===Vt&&(pn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),mn(e),0===e.avail_out))return n.last_flush=-1,Kt}return t!==Bt?Kt:n.wrap<=0?Wt:(2===n.wrap?(yn(n,255&e.adler),yn(n,e.adler>>8&255),yn(n,e.adler>>16&255),yn(n,e.adler>>24&255),yn(n,255&e.total_in),yn(n,e.total_in>>8&255),yn(n,e.total_in>>16&255),yn(n,e.total_in>>24&255)):(kn(n,e.adler>>>16),kn(n,65535&e.adler)),mn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Kt:Wt)},deflateEnd:e=>{if(An(e))return Yt;const t=e.state.status;return e.state=null,t===ln?hn(e,Zt):Kt},deflateSetDictionary:(e,t)=>{let n=t.length;if(An(e))return Yt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==cn||r.lookahead)return Yt;if(1===a&&(e.adler=Ot(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(pn(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,wn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=_n(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,wn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,Kt},deflateInfo:"pako deflate (from Nodeca project)"};const Ln=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Rn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Ln(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Fn[254]=Fn[254]=1;var Hn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Pn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Fn[e[n]]>t?n:t}};var qn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Gn=Object.prototype.toString,{Z_NO_FLUSH:jn,Z_SYNC_FLUSH:zn,Z_FULL_FLUSH:Vn,Z_FINISH:Bn,Z_OK:Qn,Z_STREAM_END:Kn,Z_DEFAULT_COMPRESSION:Wn,Z_DEFAULT_STRATEGY:Yn,Z_DEFLATED:Zn}=Rt;function Jn(e){this.options=Rn.assign({level:Wn,method:Zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qn,this.strm.avail_out=0;let n=Dn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Qn)throw new Error(Lt[n]);if(t.header&&Dn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Hn.string2buf(t.dictionary):"[object ArrayBuffer]"===Gn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Dn.deflateSetDictionary(this.strm,e),n!==Qn)throw new Error(Lt[n]);this._dict_set=!0}}function Xn(e,t){const n=new Jn(t);if(n.push(e,!0),n.err)throw n.msg||Lt[n.err];return n.result}Jn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Bn:jn,"string"==typeof e?n.input=Hn.string2buf(e):"[object ArrayBuffer]"===Gn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===zn||s===Vn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Dn.deflate(n,s),a===Kn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Dn.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Qn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Jn.prototype.onData=function(e){this.chunks.push(e)},Jn.prototype.onEnd=function(e){e===Qn&&(this.result=Rn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var $n={Deflate:Jn,deflate:Xn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Xn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Xn(e,t)},constants:Rt};const er=16209;var tr=function(e,t){let n,r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g,y,k,E,b,w,C,x;const T=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,d=T.window,h=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=C[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(h&(1<o){e.msg="invalid distance too far back",T.mode=er;break e}if(h>>>=y,f-=y,y=a-s,E>y){if(y=E-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=er;break e}if(b=0,w=d,0===l){if(b+=u-y,y2;)x[a++]=w[b++],x[a++]=w[b++],x[a++]=w[b++],k-=3;k&&(x[a++]=w[b++],k>1&&(x[a++]=w[b++]))}else{b=a-E;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],k-=3}while(k>2);k&&(x[a++]=x[b++],k>1&&(x[a++]=x[b++]))}break}}break}}while(n>3,n-=k,f-=k<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,k=0,E=0,b=0,w=0,C=0,x=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=nr;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-E,i[_]+1=p?(N=M[i[_]-p],A=x[i[_]-p]):(N=96,A=0),c=1<>E)+l]=I<<24|N<<16|A|0}while(0!==l);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(C&h)!==d){for(0===E&&(E=y),f+=m,k=v-E,b=1<852||2===e&&w>592)return 1;d=C&h,a[d]=y<<24|k<<16|f-s|0}}return 0!==C&&(a[f+C]=v-E<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:ur,Z_BLOCK:cr,Z_TREES:lr,Z_OK:dr,Z_STREAM_END:hr,Z_NEED_DICT:fr,Z_STREAM_ERROR:pr,Z_DATA_ERROR:vr,Z_MEM_ERROR:_r,Z_BUF_ERROR:mr,Z_DEFLATED:gr}=Rt,yr=16180,kr=16190,Er=16191,br=16192,wr=16194,Cr=16199,xr=16200,Tr=16206,Sr=16209,Ir=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Nr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ar=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Mr=e=>{if(Ar(e))return pr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=yr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,dr},Or=e=>{if(Ar(e))return pr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Mr(e)},Ur=(e,t)=>{let n;if(Ar(e))return pr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?pr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Or(e))},Dr=(e,t)=>{if(!e)return pr;const n=new Nr;e.state=n,n.strm=e,n.window=null,n.mode=yr;const r=Ur(e,t);return r!==dr&&(e.state=null),r};let Lr,Rr,Pr=!0;const Fr=e=>{if(Pr){Lr=new Int32Array(512),Rr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(or(1,e.lens,0,288,Lr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;or(2,e.lens,0,32,Rr,0,e.work,{bits:5}),Pr=!1}e.lencode=Lr,e.lenbits=9,e.distcode=Rr,e.distbits=5},Hr=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveDr(e,15),inflateInit2:Dr,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g,y,k,E,b,w,C=0;const x=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ar(e)||!e.output||!e.input&&0!==e.avail_in)return pr;n=e.state,n.mode===Er&&(n.mode=br),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,w=dr;e:for(;;)switch(n.mode){case yr:if(0===n.wrap){n.mode=br;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=Dt(n.check,x,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Sr;break}if((15&c)!==gr){e.msg="unknown compression method",n.mode=Sr;break}if(c>>>=4,l-=4,b=8+(15&c),0===n.wbits&&(n.wbits=b),b>15||b>n.wbits){e.msg="invalid window size",n.mode=Sr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Dt(n.check,x,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=Dt(n.check,x,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Dt(n.check,x,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=Dt(n.check,x,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(b=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),b)),512&n.flags&&4&n.wrap&&(n.check=Dt(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{b=r[s+f++],n.head&&b&&n.length<65536&&(n.head.name+=String.fromCharCode(b))}while(b&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Er;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=Tr;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(Fr(n),n.mode=Cr,t===lr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Sr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Sr;break}if(n.length=65535&c,c=0,l=0,n.mode=wr,t===lr)break e;case wr:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=Er;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Sr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=or(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=Sr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=Sr;break}b=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,b=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,b=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Sr;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Sr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Sr;break}if(n.lenbits=9,T={bits:n.lenbits},w=or(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=Sr;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=or(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=Sr;break}if(n.mode=Cr,t===lr)break e;case Cr:n.mode=xr;case xr:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,tr(e,h),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Er&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=Er;break}if(64&m){e.msg="invalid literal/length code",n.mode=Sr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Sr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Sr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Sr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=xr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=xr;break;case Tr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(Ar(e))return pr;let t=e.state;return t.window&&(t.window=null),e.state=null,dr},inflateGetHeader:(e,t)=>{if(Ar(e))return pr;const n=e.state;return 0==(2&n.wrap)?pr:(n.head=t,t.done=!1,dr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return Ar(e)?pr:(r=e.state,0!==r.wrap&&r.mode!==kr?pr:r.mode===kr&&(a=1,a=Ot(a,t,n,0),a!==r.check)?vr:(s=Hr(e,t,n,n),s?(r.mode=16210,_r):(r.havedict=1,dr)))},inflateInfo:"pako inflate (from Nodeca project)"};var Gr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const jr=Object.prototype.toString,{Z_NO_FLUSH:zr,Z_FINISH:Vr,Z_OK:Br,Z_STREAM_END:Qr,Z_NEED_DICT:Kr,Z_STREAM_ERROR:Wr,Z_DATA_ERROR:Yr,Z_MEM_ERROR:Zr}=Rt;function Jr(e){this.options=Rn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qn,this.strm.avail_out=0;let n=qr.inflateInit2(this.strm,t.windowBits);if(n!==Br)throw new Error(Lt[n]);if(this.header=new Gr,qr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Hn.string2buf(t.dictionary):"[object ArrayBuffer]"===jr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=qr.inflateSetDictionary(this.strm,t.dictionary),n!==Br)))throw new Error(Lt[n])}function Xr(e,t){const n=new Jr(t);if(n.push(e),n.err)throw n.msg||Lt[n.err];return n.result}Jr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Vr:zr,"[object ArrayBuffer]"===jr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=qr.inflate(n,i),s===Kr&&a&&(s=qr.inflateSetDictionary(n,a),s===Br?s=qr.inflate(n,i):s===Yr&&(s=Kr));n.avail_in>0&&s===Qr&&n.state.wrap>0&&0!==e[n.next_in];)qr.inflateReset(n),s=qr.inflate(n,i);switch(s){case Wr:case Yr:case Kr:case Zr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===Qr))if("string"===this.options.to){let e=Hn.utf8border(n.output,n.next_out),t=n.next_out-e,a=Hn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Br||0!==o){if(s===Qr)return s=qr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Jr.prototype.onData=function(e){this.chunks.push(e)},Jr.prototype.onEnd=function(e){e===Br&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Rn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var $r={Inflate:Jr,inflate:Xr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Xr(e,t)},ungzip:Xr,constants:Rt};const{Deflate:ea,deflate:ta,deflateRaw:na,gzip:ra}=$n,{Inflate:aa,inflate:sa,inflateRaw:ia,ungzip:oa}=$r;var ua,ca={Deflate:ea,deflate:ta,deflateRaw:na,gzip:ra,Inflate:aa,inflate:sa,inflateRaw:ia,ungzip:oa,constants:Rt},la=function(e){return E(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ca.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(ua=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",ua.OPEN="OPEN",ua.CLOSED="CLOSED";var da,ha=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Qe.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Re(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return E(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return E(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,la(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",M.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=Ke,t._ws.onmessage=Ke,t._ws.onerror=Ke,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()}))}},{key:"send",value:function(e){if(!this._ws)throw M.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(ie),fa=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:ae(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}(ue),pa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.feed,o=e.custom_types,u=e.ts;return r(this,n),(a=t.call(this)).all=s,a.feed=i,a.customTypes=o,a.ts=u,a}return s(n)}(ue),va=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),_a=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new Be(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new ha(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new pa(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new M({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(M.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._sdkState.websocket){t.next=2;break}throw M.connectionRequired;case 2:if(r=new va,e.ackRequired){s=function(t,n){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(M.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(void 0,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve()}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ue)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof fa)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw M.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(da||(da={}));var ma,ga=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}(ue),ya=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=da.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new _a(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof ga){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case da.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return E(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case da.INITIALIZED:case da.INTERNAL_DISCONNECTED:case da.EXTERNAL_DISCONNECTED:case da.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return E(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(M.connectionClosed):r.reject(M.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===da.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===da.CONNECTING||this._currentConnectionStateType===da.RECONNECTING}},{key:"send",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof fa)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new va,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),M.connectionRequired;case 17:case 37:t.next=40;break;case 19:if(!(e instanceof Ue)){t.next=39;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new va,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=M.connectionRequired,this._logger.debug("fail api request",s),s;case 39:throw M.invalidCommand;case 40:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof fa||e instanceof Ue)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw M.invalidCommand;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(M.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),ka="sendbird@devicetokens",Ea=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return ce(le({type:e.type,token:e.token}))}}]),e}(),ba=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(fe,"/").concat(s,"/session_key"),a.method=de.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Ue),wa=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?"":o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(fa),Ca=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(De),xa=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=null,i.newKey=null!==(o=s.new_key)&&void 0!==o?o:null,i.error=s.error?new M(s.error):null,i}return s(n)}(Qe),Ta=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(ue),Sa=function(e){return E(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},Ia=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),Na=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Ia;return E(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(e){return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new wa({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(xa),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new ba({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,Na((function(e){return E(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(Ca),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==da.CONNECTED){t.next=26;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=26;break}if(!n){t.next=26;break}return t.next=14,this._receiveNewAuthToken();case 14:if(!(a=t.sent)){t.next=22;break}return this.auth.authToken=a,t.next=19,this._refreshSessionKey(this.auth.authToken,!1);case 19:this.complete(),t.next=25;break;case 22:return t.next=24,this.clear();case 24:this.close();case 25:return t.abrupt("return");case 26:return t.prev=26,t.next=29,this._refreshSessionKeyByApi(e);case 29:this.complete(),t.next=55;break;case 32:if(t.prev=32,t.t1=t.catch(26),!this._isSessionRelatedError(t.t1)){t.next=54;break}if(!n){t.next=51;break}return t.next=38,this._receiveNewAuthToken();case 38:if(!(s=t.sent)){t.next=46;break}return this.auth.authToken=s,t.next=43,this._refreshSessionKeyByApi(this.auth.authToken);case 43:this.complete(),t.next=49;break;case 46:return t.next=48,this.clear();case 48:this.close();case 49:t.next=52;break;case 51:throw t.t1;case 52:t.next=55;break;case 54:throw t.t1;case 55:case"end":return t.stop()}}),r,this,[[1,8],[26,32]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new va;return Aa((function(){return E(e,void 0,void 0,t().mark((function e(){var r,a,s,i,o=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),this.handler.onSessionTokenRequired?(r=null,a=function(){r&&(clearTimeout(r),r=null)},s=function(e){a(),o._isRefreshingAuthToken&&(o._isRefreshingAuthToken=!1,o.dispatch("refresh-authtoken"),n.resolve(e))},i=function(e){a(),o._isRefreshingAuthToken&&(o._isRefreshingAuthToken=!1,n.reject(e))},r=setTimeout((function(){return i()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(s,i)):n.resolve(null);case 3:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof M&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,Oa.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(ka);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(ka,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),this.close(),Oa.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(ie),Da=function(){function e(){r(this,e),this.type=da.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),La=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=da.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new Ga,r);case 6:Aa((function(){return E(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Da),Ra=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=da.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new qa({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Fa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new La,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Da),Pa=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=da.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Fa,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new qa({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Fa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ra,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new La,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Da),Fa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=da.RECONNECTING,e.name="reconnecting",e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new va,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),Aa((function(){return E(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,Na((function(n,r){return E(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===b.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new Ha,r);case 10:Aa((function(){return E(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),A(n.t0)){n.next=23;break}if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===b.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Pa({autoReconnect:!1}),r);case 20:Aa((function(){return E(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new va,this._halt(M.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new qa({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new va,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new Pa({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new Ra,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new La,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Da),Ha=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=da.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Fa,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return E(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Pa({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ra,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new La,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Da),qa=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=da.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new va,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Na((function(n){return E(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===b.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new Ha,r);case 8:Aa((function(){return E(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),A(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===b.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ga,r);case 20:Aa((function(){return E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new va,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect,i=void 0!==s&&s;return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Pa({autoReconnect:i}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new La,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ra,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new La,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new La,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Da),Ga=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=da.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new qa({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Da),ja=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(fa),za=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this;if(!this.sdkState.websocket)throw M.connectionRequired;var n=new ja;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}},{key:"refreshTimer",value:function(){var e,t=this;if(!this.sdkState.websocket)throw M.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}]),e}(),Va=function(){function e(t){var n,a,s,i;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(s=t.template_list_token)&&void 0!==s?s:null,this.settingsUpdatedAt=null!==(i=t.settings_updated_at)&&void 0!==i?i:0}return s(e,null,[{key:"payloadify",value:function(e){return ce(le({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}]),e}(),Ba=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Qa=function(){function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}return s(e,null,[{key:"payloadify",value:function(e){return ce(le({last_updated_at:e.lastUpdatedAt}))}}]),e}(),Ka=1048576,Wa=function(){function e(){var t,n,a,s,i,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=o.emoji_hash||"",this.uploadSizeLimit=o.file_upload_size_limit?o.file_upload_size_limit*Ka:Number.MAX_SAFE_INTEGER,this.useReaction=!!o.use_reaction,this.applicationAttributes=null!==(t=o.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=o.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(a=o.multiple_file_send_max_size)&&void 0!==a?a:5,this.allowSdkStatsUpload=null===(s=o.allow_sdk_log_ingestion)||void 0===s||s,this.uikitConfigInfo=new Qa(null!==(i=o.uikit_config)&&void 0!==i?i:{}),this.notificationInfo=o.notifications?new Va(o.notifications):null}return s(e,null,[{key:"payloadify",value:function(e){return ce(le({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ka,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Qa.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Va.payloadify(e.notificationInfo):null}))}}]),e}(),Ya=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return{}}}]),e}(),Za=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(fe,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Ue),Ja=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(De),Xa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Ue),$a=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(De),es=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Ue),ts=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(s,"/metadata"),a}return s(n)}(Ue),ns=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},rs=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},as=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(ma=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",ma.OFFLINE="offline",ma.NON_AVAILABLE="nonavailable";var ss,is=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(h=null!==(d=n.profile_url)&&void 0!==d?d:n.image)&&void 0!==h?h:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,R(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=Es.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return ns(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(this._isValidMetaData(e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Za({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Ja),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(this._isValidMetaData(e)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Xa({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as($a),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new es({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new ts({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}}]),u}(Ya),os=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}(ue),us=function(){function e(t,n){var a,s,i,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Wa(n),this.user=new is(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=Es.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new os({userProfile:this}))}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign(Object.assign({},is.payloadify(e.user)),Wa.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}}]),e}(),cs=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o,u,c;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new us(e,s),i.deviceTokenLastDeletedAt=null!==(o=s.device_token_last_deleted_at)&&void 0!==o?o:0,i.key=null!==(u=s.key)&&void 0!==u?u:"",i.ekey=null!==(c=s.ekey)&&void 0!==c?c:"",i.error=s.error?new M(s):null,i}return s(a,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=Es.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw M.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a("","LOGI",Object.assign({user_id:"",error:!0},e))}}]),a}(Qe),ls=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}(ue),ds=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o=t.sdkState,u=t.cacheContext,c=t.connectionHandlers,l=t.sessionManager,d=t.websocketClient,h=t.dispatcher,f=t.logger,p=t.entryState,v=void 0===p?new Ga:p;return r(this,a),(s=n.call(this))._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=o,s.cacheContext=u,s.connectionHandlers=c,s._sessionManager=l,s._websocketClient=d,s._dispatcher=h,s._logger=f,s._currentState=v,(null===(i=s.sdkState.websocket)||void 0===i?void 0:i.pingerDisabled)||(s._pinger=new za({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:f})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(cs))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){s._logiProcessingTimer=setTimeout((function(){s._logiProcessingTimer=void 0,s._unresolvedLogi||s._rejectConnectionRequest(M.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof cs&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new ga({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=void 0,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=void 0,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:r.error.code})),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=this.sdkState,a=r.appId,s=r.appVersion,i=r.userId,o=r.extensions,u=r.sendbirdRuntimeEnvironment,c=this.cacheContext.localCacheEnabled,l=this._sessionManager.auth,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,h=!!(null!==(t=this.sdkState.extensions)&&void 0!==t?t:{}).sb_uikit,f=Ve.userAgentWithExtension(o);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(a).concat(s?"&av=".concat(s):"").concat(l.hasSession?"&key=".concat(encodeURIComponent(l.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(n)),"&pmce=").concat(d?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&SB-SDK-User-Agent=").concat(encodeURIComponent(Ve.sendbirdSdkUserAgentWithExtension(u)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(c?1:0,"&include_poll_details=1").concat(h?"&uikit_config=1":"")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new ls({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new Pe(new Ge({type:Oe.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,t().mark((function r(){var a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(M.connectionCanceled)),a=this._url(n),s=new va,this._connectionRequestQueue.push(s),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(M.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),n&&(this._sessionManager.auth.authToken=n),this._websocketClient.connect(a)),t.abrupt("return",s.promise);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(cs.asError(M.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}]),a}(ie),hs=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,d=n.disableWebSocketCloseEventHandling,h=void 0!==d&&d;r(this,e),this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=h,this._context=new ds(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}},{key:"isConnected",get:function(){return this._context.currentState.type===da.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===da.CONNECTING||e.type===da.RECONNECTING}},{key:"websocketClient",get:function(){return this._websocketClient}},{key:"connect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),fs=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,n),(a=t.call(this,{type:c,data:l,ts:h})).date=new Date(h),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(Ge),ps=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(Te),a.params={device_id:s,log_entries:i.map((function(e){return Ge.payloadify(e)}))},a}return s(n)}(Ue),vs=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),d=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===d?o[c]=t[c]:l!==d?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(ss||(ss={}));var _s,ms=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,d=void 0===l?1e3:l,h=e.minLimit,f=void 0===h?10:h;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=ss.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=ae(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=d,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===ss.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Oe.API_RESULT||e.type===Oe.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Oe.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==ss.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Ge.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof fs){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new ps({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof M)){e.next=30;break}if(e.t0.code!==b.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=ss.DISABLED,e.next=30;break;case 29:e.t0.code===b.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=ss.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new Ge({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,Sa(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Pe){var t=e.statLog;s.put(t)}else if(e instanceof ls){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?ss.ENABLED:ss.COLLECT_ONLY:s.enabledState=ss.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===ss.DISABLED){t.next=7;break}return e instanceof fs?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof fs&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=vs(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}]),a}(ie);e.LogLevel=void 0,(_s=e.LogLevel||(e.LogLevel={}))[_s.NONE=0]="NONE",_s[_s.VERBOSE=1]="VERBOSE",_s[_s.DEBUG=2]="DEBUG",_s[_s.INFO=3]="INFO",_s[_s.WARN=4]="WARN",_s[_s.ERROR=5]="ERROR";var gs,ys=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return ce(le({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}]),t}(),As=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return ce(le({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}]),e}(),Ms=function(){function e(t){r(this,e),this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return ce(le({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))}}]),e}(),Os=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new Ms(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return ce(le({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Ms.payloadify(e.defaultImage):null}))}}]),e}(),Us=function(){function e(t){var n,a;r(this,e),this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return ce(le({name:e.name,volume:e.volume}))}}]),e}(),Ds=function(t){i(a,t);var n=f(a);function a(t,s){var i,o;return r(this,a),(i=n.call(this,t,s)).isBlockedByMe=!1,i.role=R(e.Role,s.role)?s.role:e.Role.NONE,i.isBlockedByMe=null!==(o=s.is_blocked_by_me)&&void 0!==o&&o,i}return s(a,null,[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}]),a}(is);e.ScheduledStatus=void 0,(Ts=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Ts.SENT="sent",Ts.FAILED="failed",Ts.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Ss||(Ss={}));var Ls,Rs=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Ps=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,d,h,f,p,v,_,m,g,y,k,E,b;r(this,a),(i=n.call(this,t)).channelType=e.ChannelType.BASE,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.mentionType=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=R(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(d=s.custom_type)&&void 0!==d?d:"",i.mentionType=R(e.MentionType,s.mention_type)?s.mention_type:null,i.mentionedUsers=s.mentioned_users?s.mentioned_users.map((function(e){return new is(i._iid,e)})):null,i.mentionedUserIds=null!==(h=s.mentioned_user_ids)&&void 0!==h?h:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(f=s.mentioned_message_template)&&void 0!==f?f:"",i.threadInfo=s.thread_info?new xs(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new Ns(e)})):[];var w=null!==(p=s.metaarray)&&void 0!==p?p:{},C=null!==(v=s.metaarray_key_order)&&void 0!==v?v:Object.keys(w).sort((function(e,t){return e.localeCompare(t)}));i.metaArrays=[];for(var x=0;x=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return ce(le(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Rs(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return is.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?xs.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return Ns.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return As.payloadify(e)})),og_tag:e.ogMetaData?Os.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?Us.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}},{key:"_getParentMessageInfoPayload",value:function(e){return ce(le({type:Rs(e.messageType),ts:e.createdAt,user:e.sender?Ds.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}}]),a}(Ya),Fs=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).reqId="",i.replyToChannel=!1,i.errorCode=0,i.sender=s.user?new Ds(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&R(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(s.scheduled_status&&(i._scheduledStatus=s.scheduled_status),s.scheduled_status){case Ss.SENT:case Ss.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Ss.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case Ss.FAILED:case Ss.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case Ss.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Ds.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}}]),a}(Ps),Hs=function(){function e(t){var n,a;r(this,e),this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return ce(le({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}}]),e}(),qs={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Gs=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},js=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var d=n.parent_message_info;s.parentMessage=$s(t,ce(le(Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(c=d.file)||void 0===c?void 0:c.url,require_auth:null===(l=d.file)||void 0===l?void 0:l.require_auth}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},qs),n),as(this.messageId>0&&L("number",e)&&Gs(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ps),zs=function(){function e(t){var n,a;r(this,e),this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.detail&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return ce(le({type:e.type,vendor:e.vendor,detail:e.detail}))}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ls||(Ls={}));var Vs="removed",Bs=function(e){switch(e){case"open":return Ls.OPEN;case"closed":return Ls.CLOSED;default:return null}},Qs=function(e){return!e||!!e.text&&L("string",e.text)},Ks=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,d,h;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,s.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,s}return s(n,null,[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}]),n}(Ya),Ws=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=Ls.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(d=Bs(a.status))&&void 0!==d?d:Ls.CLOSED,s.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Ks(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=Bs(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Ks(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return ns(this)}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Ks.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}]),n}(Ya),Ys=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var h,f=y(s.translationTargetLanguages);try{for(f.s();!(h=f.n()).done;){var p=h.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new zs(e)})):[],s._poll=n.poll?new Ws(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;s.parentMessage=$s(t,ce(le(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(d=v.file)||void 0===d?void 0:d.require_auth}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},qs),n),as(this.messageId>0&&L("number",e)&&Gs(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return zs.payloadify(e)})),poll:e._poll?Ws.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Fs),Zs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l;r(this,n),(s=t.call(this,e)).plainUrl="",s.fileName=null,s.mimeType=null,s.fileSize=0,s.thumbnails=[],s._requireAuth=!1,s.plainUrl=null!==(i=a.url)&&void 0!==i?i:"",s.fileName=null!==(o=a.file_name)&&void 0!==o?o:null,s.mimeType=null!==(u=a.file_type)&&void 0!==u?u:null,s.fileSize=null!==(c=a.file_size)&&void 0!==c?c:0,s._requireAuth=null!==(l=a.require_auth)&&void 0!==l&&l;var d=Es.of(s._iid).sessionManager;return s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new Hs(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(d.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=Es.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return ce(le({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}}]),n}(Ya),Js=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d;if(r(this,u),(s=a.call(this,t,n)).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.fileInfoList=null!==(o=null===(i=n.files)||void 0===i?void 0:i.map((function(e){return new Zs(t,e)})))&&void 0!==o?o:[],s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var h=n.parent_message_info;s.parentMessage=$s(t,ce(le(Object.assign(Object.assign({},h),{created_at:h.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(l=h.file)||void 0===l?void 0:l.url,require_auth:null===(d=h.file)||void 0===d?void 0:d.require_auth}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},qs),n),as(this.messageId>0&&L("number",e)&&Gs(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Zs.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Fs),Xs=function(t){switch(t.messageType){case e.MessageType.USER:return Ys.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?Js.payloadify(t):ei.payloadify(t);case e.MessageType.ADMIN:return js.payloadify(t);default:throw M.unknown}},$s=function(e,t){switch(t.type){case"MESG":return new Ys(e,t);case"FILE":return Js._isMultipleFilesMessagePayload(t)?new Js(e,t):new ei(e,t);case"ADMM":case"BRDM":return new js(e,t)}throw M.unknown},ei=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h,f,p,v,_,m,g,y,k;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=n.file;s.plainUrl=(null!==(o=null!==(i=null==E?void 0:E.url)&&void 0!==i?i:n.url)&&void 0!==o?o:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==E?void 0:E.name)&&void 0!==c?c:n.name)&&void 0!==l?l:"File",s.size=null!==(h=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==h?h:0,s.data=null!==(p=null!==(f=null==E?void 0:E.data)&&void 0!==f?f:n.custom)&&void 0!==p?p:"",s.type=E?null!==(v=E.type)&&void 0!==v?v:"":null!==(_=n.type)&&void 0!==_?_:"";var b=Es.of(s._iid).sessionManager;if(s.requireAuth=null!==(m=n.require_auth)&&void 0!==m&&m,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new Hs(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(b.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(g=n.message_survival_seconds)&&void 0!==g?g:-1,n.parent_message_info){var w=n.parent_message_info;s.parentMessage=$s(t,ce(le(Object.assign(Object.assign({},w),{created_at:w.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:w.file,url:null===(y=w.file)||void 0===y?void 0:y.url,require_auth:null===(k=w.file)||void 0===k?void 0:k.require_auth}))))}return s}return s(u,[{key:"url",get:function(){var e=Es.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},qs),n),as(this.messageId>0&&L("number",e)&&Gs(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){var t;return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Fs),ti=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ce(le({channel_url:t.channelUrl,files:t.files?si(t.files):null,url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage}))})}return s(a)}(fa),ni=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a),s=n.call(this);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),s.method=de.POST,s.path="".concat(Se(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ce(le({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?si(t.files):null,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(i=t.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return Hs.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return As.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),s}return s(a)}(Ue),ri=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new Js(e,s):new ei(e,s);var d=Es.of(e).sdkState;return i.isMentioned=Ne(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(Qe),ai=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c;r(this,n),(s=t.call(this,e,a)).message=a.files&&a.files.length>=2?new Js(e,a):new ei(e,a);var l=Es.of(e).sdkState;return s.isMentioned=Ne(s.message.mentionType,null!==(u=null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:null===(o=s.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),s.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,s}return s(n)}(De);function si(e){return e.map((function(e){var t,n;return ce(le({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return Hs.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var ii;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(ii||(ii={}));var oi=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof ga&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===da.CONNECTED||this._connectionState===da.CONNECTING||this._connectionState===da.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._createSendFileMessageRequestParams(e,n),!this._shouldSendThroughWebSocket){t.next=10;break}return s=new ti(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(ri),u=o.message,t.abrupt("return",u);case 10:return c=new ni(Object.assign(Object.assign({},a),{userId:this._sdkState.userId})),t.next=13,this._requestQueue.send(c);case 13:return l=t.sent,d=l.as(ai),h=d.message,t.abrupt("return",h);case 16:case"end":return t.stop()}}),r,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this._queueMap.get(e.url))){t.next=58;break}if(a.isResolving){t.next=57;break}a.isResolving=!0,s=[],i=!0,o=y(a.messageQueue),t.prev=7,o.s();case 9:if((u=o.n()).done){t.next=40;break}c=u.value,t.t0=c.state,t.next=t.t0===ii.PENDING||t.t0===ii.UPLOADING?14:t.t0===ii.UPLOADED?17:t.t0===ii.FAILED?35:38;break;case 14:return i=!1,s.push(c),t.abrupt("break",38);case 17:if(!i){t.next=33;break}return t.prev=18,c.state=ii.SENDING,t.next=22,this._sendFileMessage(e,c);case 22:return l=t.sent,c.deferred.resolve(l),t.next=26,Sa(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),c.deferred.reject(t.t1);case 31:t.next=34;break;case 33:s.push(c);case 34:return t.abrupt("break",38);case 35:return d=null!==(n=c.error)&&void 0!==n?n:M.unknown,c.deferred.reject(d.code===b.REQUEST_CANCELED?M.fileUploadCanceled:d),t.abrupt("break",38);case 38:t.next=9;break;case 40:t.next=45;break;case 42:t.prev=42,t.t2=t.catch(7),o.e(t.t2);case 45:return t.prev=45,o.f(),t.finish(45);case 48:if(h=a.isResolveRequestPending,a.messageQueue=s,a.isResolving=!1,a.isResolveRequestPending=!1,!h){t.next=55;break}return t.next=55,this._resolveMessageQueue(e);case 55:t.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return t.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this._queueMap.get(e.url))){t.next=30;break}if(!(s=a.messageQueue.find((function(e){return e.state===ii.PENDING})))){t.next=30;break}if(!s.multipleFileUploadInfo){t.next=19;break}if(i=s.multipleFileUploadInfo,o=i.uploadIndex,u=i.uploadCount,c=i.requestHandler,l=s.params,d=l.fileInfoList[o],!q(d.file)||(null===(n=d._uploadedMetaData)||void 0===n?void 0:n.isUploaded)){t.next=13;break}return t.next=11,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 11:t.next=14;break;case 13:s.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,s,i;return E(this,void 0,void 0,t().mark((function o(){var u,c,l,d,h,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new ws({file:r.file,channelUrl:e.url,thumbnailSizes:r.thumbnailSizes,requestId:n.requestId}),t.next=3,this._requestQueue.send(u);case 3:c=t.sent,l=c.as(Cs),d=l.url,h=l.fileSize,f=void 0===h?r.fileSize:h,p=l.thumbnailSizes,v=void 0===p?r.thumbnailSizes:p,_=l.requireAuth,m=void 0!==_&&_,r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size,r.fileUrl=d,r.fileSize=f,r.thumbnailSizes=v,r.requireAuth=m;case 12:case"end":return t.stop()}}),o,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,n,r){var a,s,i;return E(this,void 0,void 0,t().mark((function o(){var u,c,l,d,h,f,p,v,_,m,g,y;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.multipleFileUploadInfo.uploadIndex,c=r.fileInfoList[u],l=new ws({file:c.file,channelUrl:e.url,thumbnailSizes:c.thumbnailSizes,requestId:n.requestId}),t.next=5,this._requestQueue.send(l);case 5:d=t.sent,h=d.as(Cs),f=h.url,p=h.fileSize,v=void 0===p?c.fileSize:p,_=h.thumbnailSizes,m=void 0===_?c.thumbnailSizes:_,g=h.requireAuth,y=void 0!==g&&g,c.fileName=null!==(a=c.fileName)&&void 0!==a?a:c.file.name,c.mimeType=null!==(s=c.mimeType)&&void 0!==s?s:c.file.type,c.fileSize=null!==(i=c.fileSize)&&void 0!==i?i:c.file.size,c.file=void 0,c.fileUrl=f,c.fileSize=v,c.thumbnailSizes=m,c._uploadedMetaData=Object.assign(Object.assign({},c._uploadedMetaData),{requireAuth:y,isUploaded:!0});case 15:case"end":return t.stop()}}),o,this)})))}},{key:"request",value:function(e,n,r,a){return E(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),o=this._queueMap.get(e.url),u=new va,c={requestId:n,params:r,state:ii.PENDING,deferred:u},ui(r)&&(l={uploadIndex:0,uploadCount:r.fileInfoList.length,requestHandler:a},c.multipleFileUploadInfo=l),o.messageQueue.push(c),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"cancel",value:function(e,t){var n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case ii.PENDING:i.state=ii.FAILED,i.error=M.requestCanceled,this._resolveMessageQueue(e);break;case ii.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function ui(e){return"fileInfoList"in e}var ci,li={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},di=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&R(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&R(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},hi={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},fi=function(t){return R(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.CollectionEventSource=void 0,(ci=e.CollectionEventSource||(e.CollectionEventSource={})).UNKNOWN="UNKNOWN",ci.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",ci.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",ci.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",ci.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",ci.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",ci.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",ci.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",ci.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",ci.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",ci.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",ci.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",ci.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",ci.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",ci.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",ci.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",ci.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",ci.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",ci.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",ci.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",ci.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",ci.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",ci.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",ci.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",ci.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",ci.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",ci.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",ci.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",ci.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",ci.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",ci.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ci.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ci.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",ci.REQUEST_CHANNEL="REQUEST_CHANNEL",ci.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",ci.REFRESH_CHANNEL="REFRESH_CHANNEL",ci.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",ci.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",ci.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",ci.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ci.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ci.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ci.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ci.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ci.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ci.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ci.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ci.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ci.REQUEST_MESSAGE="REQUEST_MESSAGE",ci.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ci.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ci.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ci.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ci.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ci.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ci.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ci.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ci.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ci.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ci.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ci.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ci.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var pi,vi=Object.assign({},e.CollectionEventSource),_i=function(t){return t.startsWith("EVENT_")||t.startsWith("LOCAL_MESSAGE_")||t===e.CollectionEventSource.SYNC_MESSAGE_FILL||t===e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.CollectionEventSource.SYNC_POLL_CHANGELOGS},mi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(ue),gi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(ue),yi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}(ue),ki=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}(ue),Ei=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(ue),bi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(ue),wi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return s(n)}(Ue),Ci=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?$s(e,Object.assign({},a)):null,s}return s(n)}(De),xi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,k=e.includeThreadInfo,E=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,w=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ce(le({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:v,include_reply_type:_,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:k,include_parent_message_info:E,show_subchannel_message_only:b,include_poll_details:!0,checking_continuous_messages:w})),a}return s(n)}(Ue),Ti=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return $s(e,t)})),s}return s(n)}(De),Si=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(Ue),Ii=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return $s(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(De),Ni=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Ue),Ai=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?$s(e,Object.assign({},a)):null,s}return s(n)}(De);e.RestrictionType=void 0,(pi=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",pi.BANNED="banned";var Mi,Oi=function(){function t(n){var a,s,i,o;r(this,t),this.restrictionType=null,R(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(i=null!==(s=n.end_at)&&void 0!==s?s:n.muted_end_at)&&void 0!==i?i:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}return s(t,null,[{key:"payloadify",value:function(e){return ce(le({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}]),t}(),Ui=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).restrictionInfo=new Oi(a),s}return s(n,null,[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),Oi.payloadify(e.restrictionInfo))))}}]),n}(is),Di=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.isMuted=null!==(i=a.is_muted)&&void 0!==i&&i,s}return s(n)}(is),Li=function(){function t(){r(this,t),this._onPending=Ke,this._onFailed=Ke,this._onSucceeded=Ke}return s(t,[{key:"_trigger",value:function(t){switch(null==t?void 0:t.sendingStatus){case e.SendingStatus.PENDING:0===t.errorCode&&this._onPending(t);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(t)}}},{key:"_triggerFailed",value:function(t,n){switch(null==n?void 0:n.sendingStatus){case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),Ri={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},Pi=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(is,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(As,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(Us,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},Fi=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Hi=Object.assign(Object.assign({},Ri),{message:"",translationTargetLanguages:void 0,pollId:void 0}),qi=function(e){var t;return ce(le({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},Gi=function(e){return Pi(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Mi||(Mi={}));var ji,zi=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Vi=function(e){return e===Mi.BLOB||e===Mi.FILE},Bi=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Qi=Object.assign(Object.assign({},Ri),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ki=function(e,t){var n;return e.messageParams?(!e.url&&q(t)&&(e.messageParams.file=t),e.messageParams):ce(le({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},Wi=function(e){return Pi(e)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Yi={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},Zi=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&R(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(is,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(As,t.metaArrays,!0)&&R(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(Us,t.appleCriticalAlertOptions,!0)},Ji=Object.assign(Object.assign({},Yi),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Xi=function(e){return Zi(e)&&L("string",e.message,!0)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)},$i=Object.assign({},Yi),eo=function(e){return Zi(e)},to=function(){function e(t,n){var a;r(this,e),this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),no=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&R(e.ChannelType,this.channelType)}}]),a}(to),ro=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={token:o,limit:u},a}return s(n)}(Ue),ao=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).operators=a.operators.map((function(t){return new is(e,t)})),s.token=a.next,s}return s(n)}(De),so=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=Es.of(this._iid),a=r.requestQueue,s=new ro(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(ao),u=o.operators,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),a}(no),io=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,d,h,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(d=i.customTypesFilter)&&void 0!==d?d:null,o.senderUserIdsFilter=null!==(h=i.senderUserIdsFilter)&&void 0!==h?h:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&R(e.MessageTypeFilter,this.messageTypeFilter)&&R(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=Ll.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,le({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw M.queryInProgress;case 16:e.next=19;break;case 18:throw M.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(no),oo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=de.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={limit:o,token:u},a}return s(n)}(Ue),uo=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).mutedUsers=[];var i=a.next,o=a.muted_list;return s.token=i,o&&o.length>0&&(s.mutedUsers=o.map((function(t){return new Ui(e,t)}))),s}return s(n)}(De),co=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new oo(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(uo),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(no),lo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=de.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ce({limit:o,token:u}),a}return s(n)}(Ue),ho=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new Ui(e,t.user)}))),s}return s(n)}(De),fo=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new lo(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ho),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(no);e.ReportCategory=void 0,(ji=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",ji.HARASSING="harassing",ji.SUSPICIOUS="suspicious",ji.INAPPROPRIATE="inappropriate";var po,vo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=de.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ue),_o=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ue),mo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=de.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Ue),go=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=0,s.endAt=0;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(De),yo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=de.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Ue),ko=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(De),Eo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=de.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Ue),bo=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(De),wo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=de.PUT,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Ue),Co=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(De),xo=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Qe),To=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Ue),So=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts;return s.ts=i,s}return s(n)}(De),Io=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Ue),No=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts;return s.ts=i,s}return s(n)}(De),Ao=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=de.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Ue),Mo=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(De),Oo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=de.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Ue),Uo=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(De),Do=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=t.call(this)).method=de.PUT,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return s(n)}(Ue),Lo=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(De),Ro=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Qe),Po=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params={},a}return s(n)}(Ue),Fo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={},a}return s(n)}(Ue),Ho=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=de.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Ue),qo=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ui(e,s.data),i}return s(n)}(Qe),Go=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Ue),jo=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ui(e,s.data),i}return s(n)}(Qe),zo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=de.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ce({user_id:o,seconds:u,description:c}),a}return s(n)}(Ue),Vo=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ui(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(Qe),Bo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Ue),Qo=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ui(e,s.data),i}return s(n)}(Qe),Ko=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=de.PUT,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Ue),Wo=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(Qe),Yo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=de.POST,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(Ue),Zo=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(s=n.call(this)).method=de.POST,s.path="".concat(ke,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},s}return s(a)}(Ue),Jo=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description;return(a=t.call(this)).method=de.POST,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c},a}return s(n)}(Ue),Xo=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ce(le({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage}))})}return s(a)}(fa),$o=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"MESG",s)).message=new Ys(e,s);var d=Es.of(e).sdkState;return i.isMentioned=Ne(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(Qe),eu=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ce(le({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})}return s(a)}(fa),tu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,d;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new Ys(e,s);var h=Es.of(e).sdkState;return i.mentionCountChange=Ae({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},le({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),i}return s(n)}(Qe),nu=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ce(le({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions}))})}return s(a)}(fa),ru=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,d;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new ei(e,s);var h=Es.of(e).sdkState;return i.mentionCountChange=Ae({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},le({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),i}return s(n)}(Qe),au=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Ue),su=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(Qe),iu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ue),ou=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new Is(a),s}return s(n)}(De),uu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ue),cu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new Is(Object.assign({},a)),s}return s(n)}(De),lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Ue),du=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Ys(e,a),s}return s(n)}(De),hu=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=de.POST,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ce(le({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Z.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return As.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Ue),fu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Ys(e,a),s}return s(n)}(De),pu=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=de.POST,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=le({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Z.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Hs.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return As.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ue),vu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new ei(e,a),s}return s(n)}(De),_u=function(e){return L("string",e.title,!0)&&Qs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(we,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ue),gu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Ws(e,a),s}return s(n)}(De),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(we,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ue),ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(we,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Ue),Eu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Ws(e,a),s}return s(n)}(De),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(we,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Ue),wu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Ws(e,a),s}return s(n)}(De),Cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(we,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Ue),xu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Ws(e,a),s}return s(n)}(De),Tu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(we,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Ue),Su=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ce({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(fa),Iu=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),Nu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=new Iu(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Qe),Au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=de.POST,a.path=we,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ue),Mu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Ws(e,a),s}return s(n)}(De),Ou=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(we,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ue),Uu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Ws(e,a),s}return s(n)}(De),Du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(we,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ue),Lu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Ks(e,a),s}return s(n)}(De),Ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ce({change_ts:o,token:u}),a}return s(n)}(Ue),Pu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return new Ws(e,t)}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(De),Fu={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Hu=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Qs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},qu={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Gu=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&L("number",t.pollId)&&t.pollId>0&&L("number",t.pollOptionId)&&t.pollOptionId>0},ju={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},zu=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&R(e.ChannelType,t.channelType)&&L("number",t.pollId)},Vu={},Bu=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,Vu[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=rs(e);return new Ws(this._iid,Ws.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(zu(e)).throw(M.invalidParameters),r=new Ou(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Uu),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(Hu(e)).throw(M.invalidParameters),r=new Au(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Mu),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(Gu(e)).throw(M.invalidParameters),r=new Du(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Lu),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Ru(le({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Pu),c=u.updatedPolls,l=u.deletedPollIds,d=u.hasMore,h=u.nextToken,c.length>0&&this._dispatcher.dispatch(new ki({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:d,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Vu[e]}}]),n}(),Qu="GroupChannel",Ku="Message",Wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=de.GET,a.path=we,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Ue),Yu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new Ws(e,t)})),s.token=a.next,s}return s(n)}(De),Zu=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new Wu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Yu),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(no),Ju=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(we,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(Ue),Xu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new is(e,t)})),s.token=a.next,s}return s(n)}(De),$u=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new Ju(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Xu),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(no),ec=Object.assign(Object.assign({},Ri),{fileInfoList:[]}),tc=function(e){return(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},nc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=Ke,e}return s(n,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(o(n.prototype),"onPending",this).call(this,e),this}},{key:"onFailed",value:function(e){return p(o(n.prototype),"onFailed",this).call(this,e),this}},{key:"onSucceeded",value:function(e){return p(o(n.prototype),"onSucceeded",this).call(this,e),this}}]),n}(Li),rc=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h;return r(this,u),(s=a.call(this,t))._name="",s._createdAt=0,s.channelType=e.ChannelType.BASE,s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s._messageCollectionLastAccessedAt=0,s._url=n.channel_url,s._name=null!==(i=n.name)&&void 0!==i?i:"",s._createdAt=1e3*n.created_at,s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=null!==(d=n.freeze)&&void 0!==d&&d,s.isEphemeral=null!==(h=n.is_ephemeral)&&void 0!==h&&h,s.creator=n.created_by?new is(s._iid,n.created_by):null,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(s._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),s}return s(u,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=ce(e);Object.assign(this,t)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_updateCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData?this._cachedMetaData.forEach((function(r,a){var s;r.updatedAt<=t&&n._cachedMetaData.set(a,{value:null!==(s=e[a])&&void 0!==s?s:r.value,isRemoved:!e[a],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new so(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new co(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fo(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new io(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new vo({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new _o({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new mo({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(go),u=o.isMuted,c=o.startAt,l=o.endAt,d=o.remainingDuration,h=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:d,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new yo({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(ko),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new yo({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ko),o=i.metadata,u=i.ts,this._updateCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.requestQueue,s=new Eo({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(bo),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Es.of(this._iid),s=a.requestQueue,i=new wo({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Co),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new To({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(So),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Io({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(No),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new Ao({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Mo),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Ao({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Mo),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.requestQueue,s=new Oo({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Uo),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Es.of(this._iid),s=a.requestQueue,i=new Do({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Lo),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.requestQueue,s=new Do({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Lo),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.requestQueue,s=new Do({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Lo),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new Po({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Fo({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new Ho({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new Go({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new zo({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new Bo({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Ko({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Ko({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},li),n),as(L("number",e)&&di(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},li),n),as(L("number",e)&&di(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},hi),n),as(L("number",e)&&fi(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},hi),n),as(L("string",e)&&fi(a)).throw(M.invalidParameters),s=Ll.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,s=Es.of(this._iid).sessionManager;return ce(le({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return As.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:s.currentUser?Ds.payloadify(s.currentUser):null,req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return is.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ce(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new Ys(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a,s,i,o,u,c,l=ce(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(a=t.fileName)&&void 0!==a?a:null===(s=t.file)||void 0===s?void 0:s.name,size:null!==(i=t.fileSize)&&void 0!==i?i:null===(o=t.file)||void 0===o?void 0:o.size,type:null!==(u=t.mimeType)&&void 0!==u?u:null===(c=t.file)||void 0===c?void 0:c.type,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),d=new ei(this._iid,l);return d.messageParams=t,d}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=ce(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE})),s=new Js(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===b.REQUEST_CANCELED||n.code===b.FILE_UPLOAD_CANCEL_FAILED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},Hi),e);return as(Gi(t)).throw(M.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n,r){var a=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Es.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),d=new Li;return c||(c=this._generateRequestId()),Sa(2).then((function(){var r=a._createPendingUserMessage(n,c,l);o.dispatch(new mi({messages:[r],source:s?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",d._trigger(r));case 1:case"end":return e.stop()}}),e)})))}));var i=new Xo(Object.assign(Object.assign({},n),{channelUrl:a.url,channelType:a.channelType,reqId:c}));u.send(i).then((function(n){var r=n.as($o).message;o.dispatch(new mi({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",d._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Sa(2).then((function(){var s=a._createPendingUserMessage(n,c,l),i=Es.of(a._iid).cacheContext.localCacheEnabled&&H(r.code);a._markMessageAsFailed(s,r,i),o.dispatch(new mi({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",d._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),d}},{key:"_autoResendUserMessage",value:function(e){return as(e instanceof Ys&&!!e.messageParams).throw(M.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e instanceof Ys&&!e.scheduledInfo).throw(M.invalidParameters),a=new va,s=null!==(n=e.messageParams)&&void 0!==n?n:qi(e),this._sendUserMessage(s,e.reqId,!0).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Ji),n),as(L("number",e)&&Xi(a)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new eu(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(tu),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return E(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(n instanceof u&&r instanceof Ys&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),as(!r.poll).throw(M.notSupportedError),c=new va,l=null!==(a=r.messageParams)&&void 0!==a?a:le(Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e instanceof Ys&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new lu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(du),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=Es.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();Sa(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);Aa((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new hu(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(fu).message;Aa((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;Sa(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),Aa((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Qi),e);return as(Wi(t)).throw(M.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},ec),e),r=Es.of(this._iid);as(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Pi(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return tc(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(M.invalidParameters);var a=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return as(!a).throw(M.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(n,r){var a=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Es.of(this._iid).dispatcher,o=Ll.of(this._iid).fileMessageQueue,u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Li;return u||(u=this._generateRequestId()),Sa(2).then((function(){var r=a._createPendingFileMessage(n,u,c);i.dispatch(new mi({messages:[r],source:s?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),o.request(a,u,n).then((function(n){i.dispatch(new mi({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Sa(2).then((function(){var s=a._createPendingFileMessage(n,u,c),o=Es.of(a._iid).cacheContext.localCacheEnabled&&H(r.code);a._markMessageAsFailed(s,r,o),i.dispatch(new mi({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:r.code===b.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendFileMessage",value:function(e){as(e instanceof ei&&!!e.messageParams).throw(M.invalidParameters);var t=Es.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(n,r){var a=this,s=Es.of(this._iid).dispatcher,i=Ll.of(this._iid).fileMessageQueue,o=null!=r?r:this._generateRequestId(),u=Date.now(),c=new nc;return o||(o=this._generateRequestId()),Sa(2).then((function(){var r=a._createPendingMultipleFilesMessage(n,o,u);s.dispatch(new mi({messages:[r],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),i.request(a,o,n,c).then((function(n){s.dispatch(new mi({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Sa(2).then((function(){var i=a._createPendingMultipleFilesMessage(n,o,u);a._markMessageAsFailed(i,r),s.dispatch(new mi({messages:[i],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Aa((function(){return E(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._triggerFailed(r,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),c}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=Es.of(this._iid).requestQueue,o=new pu(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(vu).message;Aa((function(){return E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(A(i))throw i;Sa(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),Aa((function(){return E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._triggerFailed(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){as(e.every((function(e){return Wi(Object.assign(Object.assign({},Qi),e))}))).throw(M.invalidParameters);var t,n=new Li,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(e)})).onFailed((function(e,t){return n._triggerFailed(e,t)})).onSucceeded((function(e){return n._trigger(e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return E(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||q(n)||q(null===(r=e.messageParams)||void 0===r?void 0:r.file),as(e instanceof ei&&s&&!e.scheduledInfo).throw(M.invalidParameters),i=new va,o=Ki(e,n),this._sendFileMessage(o,e.reqId,!0).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},$i),n),as(L("number",e)&&eo(a)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new nu(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(ru),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Ll.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s,i;return E(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(n instanceof u&&r instanceof ei&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),c=new va,l=le(Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1})),n._sendFileMessage(l).onSucceeded((function(e){return c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 5:case"end":return t.stop()}}),o,this)})))}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(as(e instanceof Ps).throw(M.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=Es.of(this._iid),a=r.requestQueue,s=new au({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e instanceof Ps&&e.messageId>0&&L("string",n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new iu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ou),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e instanceof Ps&&e.messageId>0&&L("string",n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new uu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(cu),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return E(this,void 0,void 0,t().mark((function i(){var o,u,c,l,d,h,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Es.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new eu({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return d=t.sent,h=d.as(tu),f=h.message,u.dispatch(new mi({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return E(this,void 0,void 0,t().mark((function i(){var o,u,c,l,d,h,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Es.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new nu({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return d=t.sent,h=d.as(ru),f=h.message,u.dispatch(new mi({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(as(e instanceof Ps&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new As({key:e})})),!(e instanceof ei)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(as(e instanceof Ps&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new As({key:e})})),!(e instanceof ei)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(as(e instanceof Ps&&e.messageId>0&&n.every((function(e){return e instanceof As}))).throw(M.invalidParameters),!(e instanceof ei)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(as(e instanceof Ps&&e.messageId>0&&n.every((function(e){return e instanceof As}))).throw(M.invalidParameters),!(e instanceof ei)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(R(e.ReportCategory,n)&&L("string",r)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Yo({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return E(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(n instanceof is&&R(e.ReportCategory,r)&&L("string",a)).throw(M.invalidParameters),i=Es.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new Zo({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return E(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(n instanceof Fs&&R(e.ReportCategory,r)&&L("string",a)).throw(M.invalidParameters),i=Es.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new Jo({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("number",e)&&_u(n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new mu(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(gu),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),as(r).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new yu({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),as(r).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new ku({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Eu),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),as(a).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new bu({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(wu),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),as(s).throw(M.invalidParameters),i=Es.of(this._iid),o=i.requestQueue,u=new Cu({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(xu),d=l.poll,t.abrupt("return",d);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),as(a).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new Tu({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),as(s).throw(M.invalidParameters),i=Es.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new Su({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,d=l.as(Nu),h=d.event,u.dispatch(new bi({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("number",e)).throw(M.invalidParameters),r=Bu.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e,!0)),r=Bu.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new Zu(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new $u(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?is.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}}]),u}(Ya),ac=s((function e(t){r(this,e),this.key=t.key,this.url=t.url})),sc=s((function e(t){r(this,e),this.id=t.id,this.name=t.name,this.url=t.url,this.emojis=t.emojis?t.emojis.map((function(e){return new ac(e)})):[]})),ic=s((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new sc(e)})):[]})),oc=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=Ke,this.onReconnectStarted=Ke,this.onReconnectSucceeded=Ke,this.onReconnectFailed=Ke,this.onDisconnected=Ke}))),uc=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=Ke,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=Ke,this.onSessionRefreshed=Ke,this.onSessionClosed=Ke}))),cc=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=Ke,this.onTotalUnreadMessageCountChanged=Ke,this.onTotalUnreadMessageCountUpdated=Ke}))),lc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=de.GET,a.path=fe,a.params=ce({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Ue),dc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new is(e,t)})),s.next=a.next,s}return s(n)}(De),hc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new lc(le(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(dc),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(to),fc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(s,"/block"),a.params=ce({limit:i,token:o,user_ids:u}),a}return s(n)}(Ue),pc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new is(e,t)})),s.next=a.next,s}return s(n)}(De),vc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new fc(le(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token}))),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(pc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(to),_c=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Ue),mc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new is(e,t)})),s.next=a.next,s}return s(n)}(De),gc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new _c(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(mc),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(to),yc={},kc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),yc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,yc[n]=this),yc[n]}return s(e,null,[{key:"get",value:function(e){return yc[e]}}]),e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(po||(po={}));var Ec,bc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?po.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(h(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:po.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:po.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:po.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:po.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:po.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:po.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:po.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:po.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:po.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:po.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:po.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:po.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:po.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:po.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:po.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:po.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:po.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:po.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:po.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:po.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:po.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:po.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:po.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:po.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:po.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(d(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ec||(Ec={}));var wc,Cc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw bc.circularReferenceFound;var a;if(r.set(t,!0),Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},xc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw bc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Tc=function(e,t){for(var n=0,r=0;r>>0)%t},Sc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Ic=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(xc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],d=i[o];if(!(xc(l,d)>=0))return!1;break;case"/lt":case"<":var h=r[s],f=i[o];if(!(xc(h,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(xc(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var E=r[s];if(!(0,i[o])(E))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Nc=function(){},Ac=function(){return Promise.resolve()},Mc=function(e){return e},Oc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(wc||(wc={}));var Uc,Dc,Lc,Rc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Mc:u,l=t.backward,d=void 0===l?Ac:l,h=t.forward,f=void 0===h?Ac:h,p=t.complete,v=void 0===p?Nc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),Pc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*xc(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var d=a;d>=0;d--)if(o*xc(this._indexer.origin[d].columnValues[s],this.condition[i])<=0){a=d;break}}return Math.min(a+1,this._indexer.origin.length-1)}var h=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=h;o=0){h=o;break}}));else for(var o=h;o=0){h=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw bc.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(zc(e,t)).concat(n,".").concat(r)},Bc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Vc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o}});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=zc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return E(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Uc||(Uc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Dc||(Dc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Lc||(Lc={}));var Qc,Kc,Wc=[Dc.PENDING,Dc.VOLATILE],Yc={},Zc=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),Yc[n]||(this.dbname=n,this._items=[],this._limit=s,Yc[n]=this),Yc[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Lc.DEFAULT;return E(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,state:r===Lc.PERSISTENT?Dc.PERSISTENT:Dc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===Lc.PERSISTENT&&(s.state=Dc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Lc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Lc.PERSISTENT&&(r.state=Dc.PERSISTENT),t!==Lc.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)Wc.includes(this._items[t].state)&&Wc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Dc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===Dc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Dc.VOLATILE}))}}],[{key:"get",value:function(e){return Yc[e]}}]),e}(),Jc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(qc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(qc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Zc.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(l=Zc.get(this.dbname),d=0;d1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Tc)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(jc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=Zc.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=Xc.createFromCacheItem(i),!(null==o?void 0:o.getItemByKey(e))){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=kc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=Zc.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?Xc.createFromCacheItem(u):new Xc({blockId:s,keyName:this.keyName,items:[],limit:i}))?void 0:c.add(n))){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=jc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:Zc.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),el={},tl=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(qc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return el[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Uc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Uc.ERROR,this.indexerKey,(function(){return n.abort()}))),el[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw bc.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=xc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,d,h,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Zc.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Lc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=jc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(a)){e.next=20;break}return e.next=17,n.find(this._store,u,Lc.NO_CACHE);case 17:if(c=e.sent,l=Xc.createFromCacheItem(c)){d=y(l.items);try{for(d.s();!(h=d.n()).done;)f=h.value,this._addItem(f)}catch(e){d.e(e)}finally{d.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=r.value,this._table=Cc(this._origin);case 35:el[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Zc.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete el[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Cc(this._origin)}},{key:"abort",value:function(){this._table=Cc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in el)delete el[e]}}]),e}(),nl=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},rl=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Qc||(Qc={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Kc||(Kc={}));var al,sl={},il=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Qc.PROCESSING,this._queue=[],this._activationQueue=[],sl[t]&&!a.forceCreate||(this.nodeId=rl(),this.key=t,nl()&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Kc.NEWNODE:n._sendSync();break;case Kc.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Kc.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var d=function(){var e=u.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Kc.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)d()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Kc.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Kc.REQUEST_LOCK:n._requestLock(t);break;case Kc.ACQUIRE_LOCK:var h=n._queue.find((function(e){return e.requestId===a}));n._acquire(h);break;case Kc.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Kc.REMOVENODE)}))),sl[t]=this),sl[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Qc.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:rl(),key:this.key,op:e,data:n.data,ts:Date.now()};return nl()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Kc.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Kc.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Kc.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Qc.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Kc.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Kc.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Kc.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}]),e}(),ol=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Ec.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return tl.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new il(function(e,t){return"".concat(qc(e,t),".lock")}(a,s)),this._blobContainer=new Bc({dbname:a,collectionName:s,store:c}),this._transaction=new Jc({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Ec.READY}},{key:"init",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d,h,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=kc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new $c({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return tl.createKey(e)})),u=a?a.indexes.map((function(e){return tl.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)d=l.value,o.includes(d)||i.push(tl.parseKey(d))}catch(e){c.e(e)}finally{c.f()}return(h=[]).push.apply(h,_(s.map((function(e){var t=new tl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),h.push.apply(h,_(i.map((function(e){return new tl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(h);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Gc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=Ec.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Ec.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=tl.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===tl.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw bc.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Gc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw bc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",Cc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw bc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new Fc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw bc.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw bc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Cc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw bc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw bc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(Cc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw bc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw bc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Cc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw bc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw bc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(Cc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw bc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw bc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Cc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw bc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],d=new Pc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,d.each((function(e){return E(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,Ic(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:h=0,f=l;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(n=e.sent,r={encrypted:dl.map((function(e){var t;return null===(t=o.encryption)||void 0===t?void 0:t.encrypt(e)}))},!(n&&n.encrypted&&Array.isArray(n.encrypted))){e.next=17;break}e.t0=t().keys(n.encrypted);case 6:if((e.t1=e.t0()).done){e.next=17;break}if(a=e.t1.value,s=JSON.stringify(n.encrypted[a]),i=JSON.stringify(r.encrypted[a]),s===i){e.next=15;break}return ll.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=14,this.clear();case 14:return e.abrupt("break",17);case 15:e.next=6;break;case 17:return e.next=19,this.set({key:this._encryptionCheckKey,value:r});case 19:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!r._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)&&i.shards>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return E(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw bc.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],t.next=3,this._setRaw(r.concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),fl={},pl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return fl[this.dbname]},set:function(e){fl[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!fl[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(fl[this.dbname]));case 4:throw bc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!fl[this.dbname]){t.next=6;break}return t.next=3,Sc(this.delay);case 3:return t.abrupt("return",fl[this.dbname][e]?Object.assign({key:e},fl[this.dbname][e]):null);case 6:throw bc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!fl[this.dbname]){t.next=7;break}return t.next=3,Sc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,fl[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw bc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!fl[this.dbname]){t.next=7;break}return t.next=3,Sc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,fl[this.dbname][s]&&delete fl[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw bc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,fl[this.dbname]||(fl[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this.observer[e.key])||"function"!=typeof a.set){t.next=5;break}if(!(s=a.set())){t.next=5;break}throw s;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=12;break}if(i=s.value,!(o=this.observer[i.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),a.e(t.t0);case 17:return t.prev=17,a.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),n,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Sc(this.delay);case 2:fl[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(hl),vl="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(al||(al={}));var _l,ml=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=vl,e._state=al.UNINITIALIZED,e._openJobQueue=[],e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return s(a,[{key:"state",get:function(){return this._state}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=al.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(vl,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=al.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=al.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=al.UNINITIALIZED,r(e.target.error)}))}else r(bc.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===al.UNINITIALIZED||t.t0===al.OPEN?7:t.t0===al.OPENING||t.t0===al.CLOSED?8:9;break;case 7:throw bc.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){r._openJobQueue.push((function(){return t(r._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return r=t.sent,t.next=5,new Promise((function(t,n){var a=r.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=16;break}if(this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,!this._window||!nl()){e.next=13;break}if(!(nl()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw bc.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(r._indexedDb)try{var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(bc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(bc.storeNotAvailableInPrivateBrowsing)}else t(bc.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw bc.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,this._openDatabase(e);case 5:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readwrite");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}]),a}(hl),gl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Fs))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Fs&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(kl||(kl={}));var wl,Cl=function(e){switch(e){case kl.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case kl.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},xl=Object.assign(Object.assign({},Hi),{scheduledAt:void 0}),Tl=Object.assign(Object.assign({},Ri),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Sl="UnsentMessage",Il={},Nl=function(e){i(a,e);var n=f(a);function a(e){var t;return r(this,a),(t=n.call(this,e))._mutex=new il("unsendmessagecache.lock"),Il[e]=h(t),t}return s(a,[{key:"_cacheContext",get:function(){return Es.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Sl);if(!t)throw M.databaseError;return t}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw M.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof Ys?(e.messageParams&&(n.messageParams=Fi(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Fi(t)),{scheduledAt:t.scheduledAt})))):e instanceof ei?(e.messageParams&&(n.messageParams=Bi(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Bi(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof Js&&e.messageParams&&(n.messageParams=function(e){return ce({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ll.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var n,r,a;return E(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l,d,h,f=this;return t().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(i=Ll.of(this._iid),o=this._deserialize(e),!e.messageParams){s.next=32;break}if(!(o instanceof Ys)){s.next=8;break}u=e.messageParams,o.messageParams=i.buildUserMessageCreateParamsFromSerializedData(u,o),s.next=32;break;case 8:if(!(o instanceof ei)){s.next=26;break}if(!(c=e.messageParams).fileKey||"string"!=typeof c.fileKey||!Vi(null!==(n=c.fileType)&&void 0!==n?n:"")){s.next=23;break}return s.next=13,this.collection.getBlob(c.fileKey);case 13:if(s.t1=r=s.sent,s.t0=null!==s.t1,!s.t0){s.next=17;break}s.t0=void 0!==r;case 17:if(!s.t0){s.next=21;break}s.t2=r,s.next=22;break;case 21:s.t2=void 0;case 22:c.file=s.t2;case 23:o.messageParams=i.buildFileMessageCreateParamsFromSerializedData(c,o),s.next=32;break;case 26:if(!(o instanceof Js)){s.next=32;break}if(!(l=e.messageParams)||!l.fileInfoList){s.next=32;break}return o.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(l,o),s.next=32,Promise.all(o.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Vi(null!==(s=null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)&&void 0!==s?s:"")){t.next=13;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:if(t.t1=i=t.sent,t.t0=null!==t.t1,!t.t0){t.next=7;break}t.t0=void 0!==i;case 7:if(!t.t0){t.next=11;break}t.t2=i,t.next=12;break;case 11:t.t2=void 0;case 12:e.file=t.t2;case 13:case"end":return t.stop()}}),n,this)})))})));case 32:if(!(o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){s.next=54;break}if(!(o instanceof Ys)){s.next=38;break}d=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(d,o),s.next=54;break;case 38:if(!(o instanceof ei)){s.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!Vi(h.fileType)){s.next=53;break}return s.next=43,this.collection.getBlob(h.fileKey);case 43:if(s.t4=a=s.sent,s.t3=null!==s.t4,!s.t3){s.next=47;break}s.t3=void 0!==a;case 47:if(!s.t3){s.next=51;break}s.t5=a,s.next=52;break;case 51:s.t5=void 0;case 52:h.file=s.t5;case 53:o.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(h,o);case 54:return s.abrupt("return",o);case 55:case"end":return s.stop()}}),s,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.filter,a=void 0===r?new bl:r,s=e.order,i=void 0===s?kl.CHANNEL_LATEST:s,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return E(this,void 0,void 0,t().mark((function e(){var r,s,u,d,h,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return r=Cl(i),s={"/where":function(e){return!!(i!==kl.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&a.match(f._deserialize(e))}},n&&(s.channelUrl=n),o&&(s.sendingStatus=o),u={where:s,index:r,backward:c},e.next=8,this.collection.query(u);case 8:return d=e.sent,e.next=11,d.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bl;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:kl.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ei||e instanceof Js)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ei)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!zi(r.file)){n.next=9;break}return n.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=n.sent,r.fileKey=a,r.fileType=Mi.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!zi(s.file)){n.next=17;break}return n.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=n.sent,s.fileKey=i,s.fileType=Mi.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof Js)){n.next=24;break}if(!((o=e.messageParams)&&o.fileInfoList&&Array.isArray(o.fileInfoList))){n.next=24;break}return n.next=24,Promise.all(o.fileInfoList.map((function(n,r){return E(u,void 0,void 0,t().mark((function a(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.file||!zi(n.file)){t.next=7;break}return t.next=3,this.collection.saveBlob(n.file,this._getFileInfoBlobKey(e.reqId,r));case 3:s=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=s,n._uploadedMetaData.fileType=Mi.BLOB;case 7:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Il[e]&&!t||(Il[e]=new a(e)),Il[e]}}]),a}(Ya),Al={},Ml=function(e){i(a,e);var n=f(a);function a(e){var t;return r(this,a),t=n.call(this,e),Al[e]=h(t),t}return s(a,[{key:"_sdkState",get:function(){return Es.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return Es.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return Nl.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return as(!!e).throw(M.databaseError),e.collection(Ku)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ll.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?100:a,i=e.filter,o=void 0===i?new bl:i,u=e.order,c=void 0===u?kl.CHANNEL_LATEST:u,l=e.backward,d=void 0!==l&&l,h=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f,v=e.exactMatch,_=void 0!==v&&v,m=e.inclusive,g=void 0===m||m;return E(this,void 0,void 0,t().mark((function e(){var a,i,u,l,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=Cl(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case kl.CHANNEL_LATEST:if(_&&e.createdAt!==r)return!1;if(d){if(g&&e.createdAtr||!g&&e.createdAt>=r)return!1;break;case kl.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&o.match(f._deserialize(e))}},index:a,backward:d},e.next=5,this.collection.query(i);case 5:return u=e.sent,e.next=8,u.fetch({limit:null!=s?s:void 0});case 8:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return E(f,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._deserialize(e));case 1:case"end":return t.stop()}}),n,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bl;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:kl.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:Cl(kl.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:Cl(kl.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=Cl(kl.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ei&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!zi(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Al[e]&&!t||(Al[e]=new a(e)),Al[e]}}]),a}(Ya),Ol={},Ul=function(e){i(a,e);var n=f(a);function a(e){var s;return r(this,a),(s=n.call(this,e))._observers=new Map,s._dispatcherContext=s._dispatcher.on((function(e){return E(h(s),void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g,y,k,b,w,C=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof mi)){n.next=14;break}if(r=e.messages,a=e.source,s=e.isWebSocketEventComing,i=r.filter((function(e){return e.messageId>0})),o=r.filter((function(e){return 0===e.messageId})),!(i.length>0)){n.next=8;break}return n.next=7,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(i);case 2:return e.next=4,this._unsentMessageCache.remove(i.map((function(e){return e instanceof Fs?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 7:s||this._broadcastUpdateEvent(i,a);case 8:if(!(o.length>0)){n.next=12;break}return n.next=11,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 11:s||this._broadcastUpdateEvent(o,a);case 12:n.next=61;break;case 14:if(!(e instanceof gi)){n.next=21;break}return u=e.messageIds,c=e.source,l=e.isWebSocketEventComing,n.next=18,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.remove(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 18:l||this._broadcastRemoveEvent(u,c),n.next=61;break;case 21:if(!(e instanceof yi)){n.next=28;break}return d=e.reqId,h=e.source,n.next=25,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([d]);case 2:case"end":return e.stop()}}),e,this)})))}));case 25:this._broadcastRemoveUnsentEvent(d,h),n.next=61;break;case 28:if(!(e instanceof ki)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return C._messageCache.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof Ei)){n.next=52;break}return m=e.event,g=e.source,n.next=45,this._messageCache.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof bi)){n.next=61;break}return k=e.event,b=e.source,n.next=56,this._messageCache.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,Ma((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 60:this._broadcastPollVoteEvent(k,b);case 61:case"end":return n.stop()}}),n,this)})))})),s}return s(a,[{key:"_cacheContext",get:function(){return Es.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return Es.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Ml.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return Nl.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Ol[e]&&!n||(Ol[e]&&(null===(t=Ol[e]._dispatcherContext)||void 0===t||t.close()),Ol[e]=new a(e)),Ol[e]}}]),a}(Ya),Dl={},Ll=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,Ml.of(e),Nl.of(e),Ul.of(e),this.fileMessageQueue=new oi(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),Dl[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=rs(t);switch(n.messageType){case e.MessageType.USER:return new Ys(this._iid,Ys.payloadify(n));case e.MessageType.FILE:return Js._isMultipleFilesMessageSerializedData(n)?new Js(this._iid,Js.payloadify(n)):new ei(this._iid,ei.payloadify(n));case e.MessageType.ADMIN:return new js(this._iid,js.payloadify(n))}throw M.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ce(le({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return ce(le({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){return ce({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=rs(e);return new Ds(this._iid,Ds.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new wi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(Ci),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Ni(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(Ai),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new xi(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},li),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(Ti),l=c.messages,this._dispatcher.dispatch(new mi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new xi(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},li),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(Ti),l=c.messages,this._dispatcher.dispatch(new mi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return E(this,void 0,void 0,t().mark((function e(){var u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new xi(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},li),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,d=c.as(Ti),h=d.messages,this._dispatcher.dispatch(new mi({messages:h,source:i})),e.abrupt("return",{messages:h,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,t().mark((function i(){var o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new xi(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},qs),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(Ti),l=c.messages,(d=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new mi({messages:d,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:d});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,t().mark((function e(){var o,u,c,l,d,h,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new Si(ce(le(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},hi),s)))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(Ii),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,f=c.nextToken,p=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new mi({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new gi({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Dl[e]}}]),n}(),Rl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).targetMessageId=0;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new xs(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(Ya),Pl={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Fl=function(t){return L("string",t.channelUrl)&&R(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeReactions,!0)&&L("boolean",t.includeMetaArray,!0)&&L("boolean",t.includeParentMessageInfo,!0)&&L("boolean",t.includeThreadInfo,!0)},Hl=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(ye,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return s(n)}(Ue),ql=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return $s(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(De);e.MessageSearchOrder=void 0,(wl=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",wl.TIMESTAMP="ts";var Gl,jl,zl,Vl=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(d=n.messageTimestampFrom)&&void 0!==d?d:null,s.messageTimestampTo=null!==(h=n.messageTimestampTo)&&void 0!==h?h:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&R(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new Hl(le(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ql),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(to),Bl={channelUrl:"",scheduledMessageId:0},Ql=function(e){return L("string",e.channelUrl)&&""!==e.channelUrl&&L("number",e.scheduledMessageId)&&e.scheduledMessageId>0},Kl=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ll(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Pl),e),as(Fl(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Bl),e),as(Ql(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(bs),Wl=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),Yl=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Bu(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Fu),e),as(Hu(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},ju),e),as(zu(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},qu),e),as(Gu(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(bs),Zl={profileImage:void 0,profileUrl:void 0,nickname:void 0},Jl=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(Gl=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Gl.CHRONOLOGICAL="chronological",Gl.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Gl.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(jl=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",jl.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",jl.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(zl=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",zl.SCHEDULED_AT="scheduled_at";var Xl,$l=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},ed=function(t){return{v2:t.commitSchema([{collectionName:Qu,keyName:"url",index:[$l(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),$l(e.GroupChannelListOrder.CHRONOLOGICAL),$l(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ku,keyName:"messageId",index:[Cl(kl.CHANNEL_LATEST),Cl(kl.NEWEST_CHILD_MESSAGE)]},{collectionName:Sl,keyName:"reqId",index:[Cl(kl.CHANNEL_LATEST),Cl(kl.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]),v3:t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}])}},td=function(e,t){return function(n,r){switch(n){case 1:e.clear().then((function(){t.clear().then((function(){ed(e).v2.then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));break;case 2:ed(e).v3.then((function(){return r()})).catch((function(e){return r(e)}));break;default:r()}}},nd=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},rd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?nd:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,f=void 0===d?3e4:d;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(h(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(ie),ad=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:de.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),sd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}(ue),id={},od=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,id[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof ga)switch(e.stateType){case da.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case da.INTERNAL_DISCONNECTED:case da.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=b.ACK_TIMEOUT,this._dispatcher.dispatch(new mi({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&H(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new mi({messages:[i],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!H(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=Nl.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new sd({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return id[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Xl||(Xl={}));var ud,cd,ld=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new is(e,r),blockee:new is(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new is(e,t)})):[]}}}]),e}(),dd=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}(ue),hd=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(ue),fd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new ld(s),i}return s(n)}(Qe),pd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a.params=ce(le({nickname:i,profile_url:o,profile_file:u,preferred_languages:c})),a}return s(n)}(Ue),vd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=new is(e,Object.assign({},a)),s}return s(n)}(De),_d=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Ue),md=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(Ue),gd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Ue),yd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Ue),kd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Ue),Ed=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Ue),bd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Ue),wd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(De),Cd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Ue),xd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(De),Td=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Ue),Sd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(De),Id=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ue),Nd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(De),Ad=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return s(n)}(Ue),Md=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(De),Od=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ue),Ud=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(De),Dd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Ue),Ld=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(De),Rd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Ue),Pd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Ue),Fd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ue),Hd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(De),qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Ue),Gd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(De),jd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Ue),zd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(De),Vd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Ue),Bd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(De),Qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Ue),Kd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new is(e,t)})),updatedUsers:a.updated.map((function(t){return new is(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(De),Wd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(Ue),Yd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(De),Zd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Ue),Jd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ue),Xd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new is(e,t)})),s}return s(n)}(De),$d=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ue),eh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Ue),th=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(De),nh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Ue),rh=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=de.GET,e.path=be,e}return s(n)}(Ue),ah=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new ic(a),s}return s(n)}(De),sh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(be,"/").concat(s),a}return s(n)}(Ue),ih=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new sc(a),s}return s(n)}(De),oh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Ee,"/").concat(s),a}return s(n)}(Ue),uh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new ac(a),s}return s(n)}(De),ch=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=de.GET,e.path="".concat(xe),e}return s(n)}(Ue),lh=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;r(this,n);var o=null!=a?a:{};return(s=t.call(this,e,a)).uikitConfiguration={string:JSON.stringify(o),json:o},s.updatedAt=null!==(i=null==a?void 0:a.updated_at)&&void 0!==i?i:0,s}return s(n)}(De),dh=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._iid=e,this.options=a;var o=Es.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,d=o.sessionManager,h=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new ad({logger:f,connectionDelegate:{reconnect:function(){var t=Es.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){Es.of(e).connectionManager.disconnect()}}});var _=new od(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:d,requestQueue:h,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new rd({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){var r;if(n instanceof ga){if(n.stateType===da.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof Qe){if("USEV"===n.code){var a=n.as(fd).event;if(a.category===Xl.FRIEND_DISCOVERED){var s=ld.getDataAsFriendDiscoveredEvent(e,a).friendDiscoveries;Aa((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(s)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof pa){var o=Es.of(i._iid).subscribedUnreadMessageCount,l=!1,d=n.ts;if("number"==typeof d&&d>o.ts){if(o.all!==n.all&&(l=!0),o.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)o.customTypes[h]!==n.customTypes[h]&&(l=!0),o.customTypes[h]=n.customTypes[h];l=l&&o.ts>0,o.ts=d}l&&Aa((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:o.all,feedChannelCount:o.feed,customTypeUnreadCount:o.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(o.all,o.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof os?(c.preference.set(i._getUserProfileCacheKey(u.userId),us.payloadify(n.userProfile)),(null===(r=n.userProfile.appInfo.notificationInfo)||void 0===r?void 0:r.isEnabled)&&c.preference.set(Ba(i.appId),{value:!0})):n instanceof Re&&n.error&&(n.error.isSessionRevokedError||n.error.isUserAuthDeactivedError||n.error.isUserAuthDeletedOrNotFoundError)&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return Es.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=Es.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=Es.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!Es.of(this._iid).debugMode}},{key:"logLevel",get:function(){return Es.of(this._iid).logger.level},set:function(e){Es.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return Es.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=Es.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return Es.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=Es.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=Es.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=Es.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}},{key:"apnsPushToken",get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}},{key:"_getNestDBVersion",value:function(){return 3}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=Es.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof pl?n.store:null;throw M.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=Es.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=Es.of(this._iid),a=r.logger,s=r.sdkState,i=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!i.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o0&&void 0!==arguments[0]?arguments[0]:{};return new hc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new gc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Vl(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new Zu(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new $u(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=rs(e);return new is(this._iid,is.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},Zl),e),as(Jl(r)).throw(M.invalidParameters),!this.currentUser){t.next=13;break}return a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new pd(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(vd),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw M.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(as(F("string",e)).throw(M.invalidParameters),!this.currentUser){t.next=12;break}return r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new pd({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(vd),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw M.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(as(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=Es.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new md({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,Ma((function(){return E(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(as(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=Es.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new yd({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,Ma((function(){return E(d,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=Es.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new Ed({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,Ma((function(){return E(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(as(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=Es.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new _d({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,Ma((function(){return E(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(as(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=Es.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new gd({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,Ma((function(){return E(d,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=Es.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new kd({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,Ma((function(){return E(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Cd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(xd),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("boolean",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Td({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Sd),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Id({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Nd),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,t().mark((function o(){var u,c,l,d,h,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(M.invalidParameters),u=Es.of(this._iid),c=u.sdkState,l=u.requestQueue,d=new Ad({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(d);case 5:return h=t.sent,f=h.as(Md),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Od({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ud),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("boolean",e)&&L("number",n)&&L("number",r)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Dd({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Ld),d=l.snoozePeriod,t.abrupt("return",d);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,d,h,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",n)&&R(e.PushTokenType,r)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new bd({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,d=l.as(wd),h=d.pushTokens,f=y(h.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(h.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",h);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Fd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Hd).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(R(e.PushTriggerOption,n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new qd({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Gd).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new jd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(zd).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(R(e.PushTemplate,n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Vd({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Bd).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e instanceof is||L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Rd({userId:a.userId,blockedUserId:e instanceof is?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e instanceof is||L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Pd({userId:a.userId,unblockedUserId:e instanceof is?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Qd({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Kd),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new eh({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(th),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("boolean",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new nh({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Wd({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Yd),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Zd({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Jd({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Xd),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",e)).throw(M.invalidParameters),r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new $d({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new rh,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ah),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.requestQueue,s=new sh({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ih),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.requestQueue,s=new oh({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(uh),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),as(n.hasExtension("sb_uikit")).throw(M.notSupportedError),r=n.requestQueue,a=new ch,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(lh),o=i.uikitConfiguration,e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=e.modules,s=void 0===a?[]:a,i=e.options,o=void 0===i?new G:i,u=e.debugMode,c=void 0!==u&&u,l=e.customApiHost,d=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,m=void 0!==v&&v,g=e.localCacheConfig,y=void 0===g?new ne:g,k=e.localCacheEncryption,E=e.useAsyncStorageStore,b=void 0===E?null:E,w=e.appStateToggleEnabled,C=void 0===w||w;if(!ud||f){var x="su-".concat(ae()),T=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},S=new pl({encryption:T});c||(S=je()?b?new gl({AsyncStorage:b,encryption:T}):new pl({encryption:T}):new ml({encryption:T})),new Es(x,{appId:t,appVersion:r,options:o,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:S,encryption:T,logLevel:p,localCacheEnabled:m,localCacheConfig:y,debugMode:c,appStateToggleEnabled:C});var I=[new Kl,new Yl],N=new n(x,o,[].concat(_(s),I));return ud||(ud=N),N}return ud}},{key:"instance",get:function(){return ud}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(cd=e.MemberState||(e.MemberState={})).NONE="none",cd.JOINED="joined",cd.INVITED="invited",cd.LEFT="left";var hh,fh,ph,vh,_h,mh,gh,yh,kh=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=R(e.MemberState,s.state)?s.state:null,i.role=R(e.Role,s.role)?s.role:null,"boolean"==typeof s.is_muted&&(i.isMuted=s.is_muted),"boolean"==typeof s.is_blocked_by_me&&(i.isBlockedByMe=s.is_blocked_by_me),"boolean"==typeof s.is_blocking_me&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}]),a}(Ui),Eh=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new is(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(Ya);e.PublicChannelFilter=void 0,(hh=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",hh.PUBLIC="public",hh.PRIVATE="private",e.MyMemberStateFilter=void 0,(fh=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",fh.JOINED="joined_only",fh.INVITED="invited_only",fh.INVITED_BY_FRIEND="invited_by_friend",fh.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(ph=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",ph.SUPER="super",ph.NON_SUPER="nonsuper",ph.BROADCAST_ONLY="broadcast_only",ph.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(vh=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",vh.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(_h=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",_h.UNHIDDEN="unhidden_only",_h.HIDDEN="hidden_only",_h.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",_h.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(mh=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",mh.OPERATOR="operator",mh.NONOPERATOR="nonoperator",e.QueryType=void 0,(gh=e.QueryType||(e.QueryType={})).AND="AND",gh.OR="OR",e.GroupChannelSearchField=void 0,(yh=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",yh.CHANNEL_NAME="channel_name";var bh,wh=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e,n=new t;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),Ch=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return as(!!e).throw(M.databaseError),e.collection(Qu)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Zf.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(null==(u=t.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(Ya);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(bh||(bh={}));var xh,Th=function(){function t(e){var n;r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),Sh={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},Ih=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage,!0))&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},Nh={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},Ah=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)&&L("boolean",e.includeChatNotification)},Mh={myMemberStateFilter:e.MyMemberStateFilter.ALL},Oh=function(t){return R(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(xh=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",xh.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",xh.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",xh.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",xh.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",xh.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",xh.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",xh.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",xh.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var Uh,Dh={keys:[]},Lh=function(t){return F(e.UnreadItemKey,t.keys)},Rh={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},Ph=function(t){return F("string",t.channelCustomTypesFilter,!0)&&R(e.SuperChannelFilter,t.superChannelFilter)},Fh={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Hh=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&R(e.MessageTypeFilter,t.messageTypeFilter)},qh=Object.assign({},e.CollectionEventSource),Gh=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},jh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c,d=e.ts;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.isWebSocketEventComing=u,a.data=l,a.ts=d,a}return s(n)}(ue),zh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(ue),Vh=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return E(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,d,h,f,p,v,_,m,g,k=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof jh)){n.next=27;break}r=e.channels,a=e.source,u=e.isWebSocketEventComing,c=e.data,l=r.filter((function(e){return e instanceof ov})),d=s.filterOffsetChanged(l),h=y(d),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,i.removeUnderOffset(p.url,p.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,s.upsert(l,e.ts);case 23:v=n.sent,u||this._broadcastUpdateEvent(v,a,c),n.next=39;break;case 27:if(!(e instanceof zh)){n.next=36;break}return _=e.channelUrls,m=e.source,g=e.isWebSocketEventComing,n.next=31,s.remove(_);case 31:return n.next=33,Ma((function(){return E(k,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(_),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 33:g||this._broadcastRemoveEvent(_,m),n.next=39;break;case 36:if(!(e instanceof dd)){n.next=39;break}return n.next=39,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 39:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){var s=r.value;s.onUpdate&&s.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Bh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,n),a=t.call(this);var d=Object.assign(Object.assign({},Nh),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ce(le({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return s(n)}(Ue),Qh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new ov(e,Object.assign(t,{ts:a.ts}))})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s.ts=a.ts,s}return s(n)}(De),Kh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(i?_e:ve,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ue),Wh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new ov(e,a),s}return s(n)}(De),Yh={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:e.MyMemberStateFilter.ALL,unreadChannelFilter:e.UnreadChannelFilter.ALL,superChannelFilter:e.SuperChannelFilter.ALL,publicChannelFilter:e.PublicChannelFilter.ALL,hiddenChannelFilter:e.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:e.GroupChannelListOrder.LATEST_LAST_MESSAGE},Zh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,E=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A;return(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ce({token:i,limit:o,order:null!=u?u:Yh.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Yh.includeEmpty,member_state_filter:null!=l?l:Yh.myMemberStateFilter,super_mode:null!=d?d:Yh.superChannelFilter,public_mode:null!=h?h:Yh.publicChannelFilter,unread_filter:null!=f?f:Yh.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:E,metadata_order_key:b,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:T,show_metadata:S,include_chat_notification:M}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(Ue),Jh=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new ov(e,t)}))),s.ts=null!=u?u:0,s}return s(n)}(De),Xh=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=de.GET,s.path="".concat(fe,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Ue),$h=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(De),ef=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=ce({item_keys:o}),a}return s(n)}(Ue),tf=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(De),nf=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Ue),rf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(De),af=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),s=n.call(this);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return s.method=de.GET,s.path="".concat(fe,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},s}return s(a)}(Ue),sf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s.unreadFeedCount=a.unread_feed_count,s}return s(n)}(De),of=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(Ce,"/count"),a.params={channel_url:s,status:cf(i)},o&&(a.params.message_type=o),a}return s(n)}(Ue),uf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(De),cf=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Ss.PENDING);break;case e.ScheduledStatus.SENT:n.push(Ss.IN_QUEUE),n.push(Ss.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Ss.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Ss.FAILED)}})),n},lf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,E=e.customType,b=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=de.POST,a.path=ve,a.params=ce({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:E,operator_ids:C,message_survival_seconds:b}),a}return s(n)}(Ue),df=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).channel=new ov(e,a),s.isCreated=null===(i=a.is_created)||void 0===i||i,s}return s(n)}(De),hf=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Ue),ff=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new Th(s),i}return s(n)}(Qe),pf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Ue),vf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new ov(e,a),s}return s(n)}(De),_f=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return i.memberCount=c,i.joinedMemberCount=d,i.members=Array.isArray(f)?f.map((function(t){return new kh(e,t)})):[new kh(e,s.data)],i}return s(n)}(ff),mf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(Ue),gf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return i.memberCount=c,i.joinedMemberCount=d,i.member=new kh(i._iid,s.data),i}return s(n)}(ff),yf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=de.POST,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Ue),kf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new ov(e,a),s}return s(n)}(De),Ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),(i=t.call(this,e,a,s)).inviter=null;var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return i.memberCount=c,i.joinedMemberCount=d,h&&Object.keys(h).length>0&&(i.inviter=new is(e,h)),i.invitees=p.map((function(t){return new kh(e,t)})),i}return s(n)}(ff),bf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Ue),wf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return i.memberCount=null!=u?u:0,i.joinedMemberCount=null!=c?c:0,i.inviter=new is(e,l),i.invitee=new kh(e,d),i}return s(n)}(ff),Cf={hidePreviousMessages:!1,allowAutoUnhide:!0},xf=function(e){return L("boolean",e.hidePreviousMessages,!0)&&L("boolean",e.allowAutoUnhide,!0)},Tf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:null!=o?o:Cf.hidePreviousMessages,allow_auto_unhide:null!=u?u:Cf.allowAutoUnhide},a}return s(n)}(Ue),Sf=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(De),If=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=null!==(o=s.data.allow_auto_unhide)&&void 0!==o?o:null,i.hidePreviousMessages=null!==(u=s.data.hide_previous_messages)&&void 0!==u?u:null),i.messageOffsetTimestamp=null!==(c=s.ts_message_offset)&&void 0!==c?c:null,i}return s(n)}(Qe),Nf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(fa),Af=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new is(e,s.data),i}return s(n)}(Qe),Mf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(fa),Of=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new is(e,s.data),i}return s(n)}(Qe),Uf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new is(i._iid,e)})),i}return s(n)}(ff),Df=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(fa),Lf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h,f,p,v,_,m,g,y,k,E,b,w,C,x,T,S,I,N;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.includeChatNotification=!1,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.includeChatNotification=null!==(l=n.includeChatNotification)&&void 0!==l&&l,s.channelUrlsFilter=null!==(d=n.channelUrlsFilter)&&void 0!==d?d:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(f=n.customTypeStartsWithFilter)&&void 0!==f?f:"",s.nicknameContainsFilter=null!==(p=n.nicknameContainsFilter)&&void 0!==p?p:null,s.nicknameStartsWithFilter=null!==(v=n.nicknameStartsWithFilter)&&void 0!==v?v:null,s.nicknameExactMatchFilter=null!==(_=n.nicknameExactMatchFilter)&&void 0!==_?_:null,s.channelNameContainsFilter=null!==(m=n.channelNameContainsFilter)&&void 0!==m?m:"",s.myMemberStateFilter=null!==(g=n.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(y=n.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(k=n.superChannelFilter)&&void 0!==k?k:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(E=n.publicChannelFilter)&&void 0!==E?E:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(w=n.searchFilter)&&void 0!==w?w:{fields:[],query:null},s.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=n.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(T=n.metadataValues)&&void 0!==T?T:null,s.metadataOrderKeyFilter=null!==(S=n.metadataOrderKeyFilter)&&void 0!==S?S:null,s.metadataValueStartsWith=null!==(I=n.metadataValueStartsWith)&&void 0!==I?I:null,s.order=null!==(N=n.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&R(e.MyMemberStateFilter,this.myMemberStateFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicChannelFilter,this.publicChannelFilter)&&R(e.UnreadChannelFilter,this.unreadChannelFilter)&&R(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&R(e.QueryType,this.userIdsFilter.queryType)&&R(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return ns(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Zf.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,le(Object.assign({},this)),this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(to),Rf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o;return r(this,n),(i=t.call(this,e,"SYEV",s)).pinnedMessageIds=[],i.latestPinnedMessage=null,i.ts=0,s.data&&(i.pinnedMessageIds=null!==(o=s.data.pinned_message_ids)&&void 0!==o?o:[],i.latestPinnedMessage=s.data.latest_pinned_message?$s(e,Object.assign({},s.data.latest_pinned_message)):null),i.ts=s.ts,i}return s(n)}(Qe),Pf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r4&&void 0!==arguments[4]?arguments[4]:100,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,t().mark((function o(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r,inclusive:i});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),o,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r,a){return E(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return E(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new Pf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}}]),a}(Ya),Hf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new js(e,s);var d=Es.of(e).sdkState;return i.isMentioned=Ne(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(Qe),qf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,d;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new js(e,s);var h=Es.of(e).sdkState;return i.mentionCountChange=Ae({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},le({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),i}return s(n)}(Qe),Gf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(fa),jf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new Eh(e,s),i}return s(n)}(Qe),zf=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ce({userId:i}),a}return s(n)}(Ue),Vf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(Qe),Bf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new Is(s),i}return s(n)}(Qe),Qf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new Rl(e,s),i}return s(n)}(Qe),Kf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(Qe),Wf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=new Wl(e,s),i.status=Bs(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Qe),Yf={},Zf=function(n){i(o,n);var a=f(o);function o(n,s){var i,u;return r(this,o),(i=a.call(this,n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.GROUP})))._leftChannels=new Map,i._disableMack=!1,i._markAsReadAllLastSentAt=0,i._disableMack=null!==(u=s.disableMack)&&void 0!==u&&u,i._groupChannelHandlers=new Map,i._groupChannelCache=new Ch(i._iid,{sdkState:s.sdkState,cacheContext:s.cacheContext}),i._groupChannelBroadcast=new Vh({dispatcher:s.dispatcher,groupChannelCache:i._groupChannelCache,messageCache:Ml.of(i._iid),unsentMessageCache:Nl.of(i._iid)}),setInterval((function(){var t,n=y(i._groupChannelCache.channels);try{var r=function(){var n=t.value;n.invalidateTypingStatus()&&(i._dispatcher.dispatch(new jh({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),i._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(n)})))};for(n.s();!(t=n.n()).done;)r()}catch(e){n.e(e)}finally{n.f()}}),1e3),i._dispatcher.on((function(e){e instanceof Qe?i._handleEvent(e):e instanceof sd?E(h(i),void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.message,t.next=3,this.getChannel(r.channelUrl,!0);case 3:a=t.sent,r instanceof Ys?a._autoResendUserMessage(r):r instanceof ei&&a._autoResendFileMessage(r);case 5:case"end":return t.stop()}}),n,this)}))):e instanceof hd&&i.reduceDBSize()})),Yf[n]||(Yf[n]=h(i)),i}return s(o,[{key:"handlers",get:function(){return _(this._groupChannelHandlers.values())}},{key:"buildGroupChannelFromSerializedData",value:function(e){var t=rs(e);return new ov(this._iid,ov.payloadify(t))}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){var t=rs(e);return new Lf(this._iid,t)}},{key:"buildMemberFromSerializedData",value:function(e){var t=rs(e);return new kh(this._iid,kh.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"getChannelsFromCache",value:function(e,n,r,a,s){return E(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.fetch({token:e,filter:n,order:r,limit:a,borderlineChannelUrl:s});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clearChannelsFromCache",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._groupChannelCache.clear();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"reduceDBSize",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Ml.of(this._iid),r=Es.of(this._iid),a=r.cacheContext,s=a.localCacheConfig,i=a.nestdb,a.localCacheEnabled&&i&&i.state==_l.OPENED){e.next=5;break}return e.abrupt("return");case 5:return o=1024*s.maxSize*1024,e.next=8,i.estimateUsage();case 8:if(!((u=e.sent)0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new jh({channels:[G],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new jh({channels:[G],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new jh({channels:[G],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUnreadMemberStatusUpdated&&a.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return a.abrupt("break",342);case 81:return j=n.as(Vf),z=j.channelUrl,V=j.deliveredStateUpdate,B=void 0===V?{}:V,Q=this._groupChannelCache.isCachedInMemory(z),a.next=85,this.getChannel(z,!0);case 85:if(K=a.sent,Q)for(W in B)K._updateUndeliveredMemberState(W,B[W]);return Object.keys(B).some((function(e){return e!==hn._sdkState.userId}))&&(this._dispatcher.dispatch(new jh({channels:[K],source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUndeliveredMemberStatusUpdated&&a.onUndeliveredMemberStatusUpdated(K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",342);case 89:if(Y=n.as(Bf),Z=Y.channelUrl,J=Y.channelType,X=Y.event,J!==e.ChannelType.GROUP){a.next=99;break}return a.next=93,this.getChannel(Z,!0);case 93:return $=a.sent,a.next=96,this.getMessageFromCache(X.messageId);case 96:(ee=a.sent)&&(ee.applyReactionEvent(X),this._dispatcher.dispatch(new mi({messages:[ee],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onReactionUpdated&&a.onReactionUpdated($,X)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return a.abrupt("break",342);case 100:if(te=n.as(Qf),(ne=te.event).channelType!==e.ChannelType.GROUP){a.next=110;break}return a.next=104,this.getChannel(ne.channelUrl,!0);case 104:return re=a.sent,a.next=107,this.getMessageFromCache(ne.targetMessageId);case 107:(ae=a.sent)&&(ae.applyThreadInfoUpdateEvent(ne),this._dispatcher.dispatch(new mi({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onThreadInfoUpdated&&a.onThreadInfoUpdated(re,ne)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return a.abrupt("break",342);case 111:se=n.as(Kf),ie=se.groupChannelMemberCounts,oe=[],ue=y(ie),a.prev=114,ue.s();case 116:if((ce=ue.n()).done){a.next=125;break}return le=ce.value,de=le.channelUrl,he=le.memberCount,fe=le.joinedMemberCount,pe=le.updatedAt,a.next=121,this.getChannelFromCache(de);case 121:(ve=a.sent)&&ve._setLatestMemberCount(he,fe,pe)&&oe.push(ve);case 123:a.next=116;break;case 125:a.next=130;break;case 127:a.prev=127,a.t2=a.catch(114),ue.e(a.t2);case 130:return a.prev=130,ue.f(),a.finish(130);case 133:return oe.length>0&&(this._dispatcher.dispatch(new jh({channels:oe,source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(oe)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",342);case 135:if(_e=n.as(Wf),me=_e.event,ge=_e.status,ye=_e.channelUrl,ke=_e.channelType,!ye||ke!==e.ChannelType.GROUP){a.next=142;break}return a.next=139,this.getChannel(ye,!0);case 139:Ee=a.sent,this._dispatcher.dispatch(new Ei({event:me,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),Aa(ge===Vs?function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(Ee,me.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(Ee,me)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return a.abrupt("break",342);case 143:if(be=n.as(Nu),we=be.event,Ce=be.channelUrl,xe=be.channelType,!Ce||xe!==e.ChannelType.GROUP){a.next=150;break}return a.next=147,this.getChannel(Ce,!0);case 147:Te=a.sent,this._dispatcher.dispatch(new bi({event:we,source:e.CollectionEventSource.EVENT_POLL_VOTED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(Te,we)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return a.abrupt("break",342);case 151:if(Se=n.as(ff),!(Ie=Se.event).isGroupChannelEvent){a.next=330;break}a.t3=Ie.category,a.next=a.t3===bh.CHANNEL_JOIN?156:a.t3===bh.CHANNEL_LEAVE?165:a.t3===bh.CHANNEL_OPERATOR_UPDATE?181:a.t3===bh.CHANNEL_INVITE?192:a.t3===bh.CHANNEL_DECLINE_INVITE?202:a.t3===bh.TYPING_START||a.t3===bh.TYPING_END?210:a.t3===bh.USER_CHANNEL_MUTE||a.t3===bh.USER_CHANNEL_UNMUTE?219:a.t3===bh.USER_CHANNEL_BAN?246:a.t3===bh.USER_CHANNEL_UNBAN?261:a.t3===bh.CHANNEL_FREEZE||a.t3===bh.CHANNEL_UNFREEZE?269:a.t3===bh.CHANNEL_HIDE?277:a.t3===bh.CHANNEL_UNHIDE?287:a.t3===bh.CHANNEL_DELETED?294:a.t3===bh.CHANNEL_PROP_CHANGED?300:a.t3===bh.CHANNEL_META_DATA_CHANGED?306:a.t3===bh.CHANNEL_META_COUNTERS_CHANGED?315:a.t3===bh.PINNED_MESSAGE_CHANGED?324:330;break;case 156:return a.next=158,this.getChannel(Ie.channelUrl,!0);case 158:return Ne=a.sent,Ae=n.as(_f),Me=Ae.memberCount,Oe=Ae.joinedMemberCount,Ue=Ae.members,De=!1,Ue.forEach((function(t){Ne.isExclusive||Ne.isSuper||Ne.isBroadcast?De=De||Ne._setLatestMemberCount(Me,Oe,Ie.ts):(t.state=e.MemberState.JOINED,Ne.addMember(t,Ie.ts),hn._updateJoinedMemberCount(Ne)),t.userId===hn._sdkState.userId&&(Ne.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new jh({channels:[Ne],source:e.CollectionEventSource.EVENT_CHANNEL_JOINED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Ue);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ne,r)}}catch(e){n.e(e)}finally{n.f()}Ne.isBroadcast&&De&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ne])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 165:if(!(Le=this._leftChannels.get(Ie.channelUrl))){a.next=170;break}a.t4=Le.channel,a.next=173;break;case 170:return a.next=172,this.getChannel(Ie.channelUrl,!0);case 172:a.t4=a.sent;case 173:return Re=a.t4,Pe=n.as(gf),Fe=Pe.memberCount,He=Pe.joinedMemberCount,qe=Pe.member,Ge=!1,je=Es.of(this._iid),ze=je.appInfo,Re.isExclusive||Re.isSuper||Re.isBroadcast?Ge=Re._setLatestMemberCount(Fe,He,Ie.ts):((null==ze?void 0:ze.enabledChannelMemberShipHistory)?((Ve=Re.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=e.MemberState.LEFT),Re.memberCount=Fe):Re.removeMember(qe),this._updateJoinedMemberCount(Re)),qe.userId===this._sdkState.userId?(Re.myMemberState=e.MemberState.NONE,Re.invitedAt=0,Re.joinedAt=0,Re._updateUnreadCount(0,0),Re.isPublic?this._dispatcher.dispatch(new jh({channels:[Re],source:e.CollectionEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Re),this._dispatcher.dispatch(new zh({channelUrls:[Re.url],source:e.CollectionEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new jh({channels:[Re],source:e.CollectionEventSource.EVENT_CHANNEL_LEFT})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Re,qe),Re.isBroadcast&&Ge&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 181:return a.next=183,this.getChannel(Ie.channelUrl,!0);case 183:Be=a.sent,Qe=n.as(Uf),Ke=Qe.operators,We=Ke.map((function(e){return e.userId})),Ye=y(Be.members);try{for(Ye.s();!(Ze=Ye.n()).done;)(Je=Ze.value).role=We.includes(Je.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Ye.e(e)}finally{Ye.f()}return Be.myRole=We.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new jh({channels:[Be],source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Be,Ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 192:return a.next=194,this.getChannel(Ie.channelUrl,!0);case 194:Xe=a.sent,$e=n.as(Ef),et=$e.memberCount,tt=$e.joinedMemberCount,nt=$e.inviter,(rt=$e.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),at=y(rt);try{for(at.s();!(st=at.n()).done;)it=st.value,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(et,tt,Ie.ts):Xe.addMember(it,Ie.ts),this._sdkState.userId===it.userId&&(Xe.hiddenState=e.HiddenState.UNHIDDEN,Xe.myMemberState!==e.MemberState.JOINED&&(Xe.myMemberState=e.MemberState.INVITED),Xe.invitedAt=Ie.ts)}catch(e){at.e(e)}finally{at.f()}return this._dispatcher.dispatch(new jh({channels:[Xe],source:e.CollectionEventSource.EVENT_CHANNEL_INVITED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Xe,nt,rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 202:return a.next=204,this.getChannel(Ie.channelUrl,!0);case 204:return ot=a.sent,ut=n.as(wf),ct=ut.memberCount,lt=ut.joinedMemberCount,dt=ut.inviter,ht=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ie.ts):ot.removeMember(ht),this._sdkState.userId===ht.userId?(ot.invitedAt=0,ot.myMemberState=e.MemberState.NONE,ot.isPublic?this._dispatcher.dispatch(new jh({channels:[ot],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new zh({channelUrls:[ot.url],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new jh({channels:[ot],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,dt,ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 210:return a.next=212,this.getChannel(Ie.channelUrl,!0);case 212:return ft=a.sent,pt=Ie.category===bh.TYPING_START,vt=n.as(pt?Af:Of),_t=vt.user,ft._updateTypingStatus(_t,pt?Ie.ts:0),this._dispatcher.dispatch(new jh({channels:[ft],source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 219:return a.next=221,this.getChannel(Ie.channelUrl,!0);case 221:mt=a.sent,gt=Ie.category===bh.USER_CHANNEL_MUTE,yt=n.as(gt?qo:jo),(kt=yt.user).userId===this._sdkState.userId&&(mt.myMutedState=gt?e.MutedState.MUTED:e.MutedState.UNMUTED,mt._myMutedRemainingTime=kt.restrictionInfo.remainingDuration),Et=y(mt.members),a.prev=226,Et.s();case 228:if((bt=Et.n()).done){a.next=235;break}if((wt=bt.value).userId!==kt.userId){a.next=233;break}return wt.isMuted=gt,a.abrupt("break",235);case 233:a.next=228;break;case 235:a.next=240;break;case 237:a.prev=237,a.t5=a.catch(226),Et.e(a.t5);case 240:return a.prev=240,Et.f(),a.finish(240);case 243:return this._dispatcher.dispatch(new jh({channels:[mt],source:gt?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,data:kt.userId})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){gt?e.onUserMuted&&e.onUserMuted(mt,kt):e.onUserUnmuted&&e.onUserUnmuted(mt,kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 246:if(!(Ct=this._leftChannels.get(Ie.channelUrl))){a.next=251;break}a.t6=Ct.channel,a.next=254;break;case 251:return a.next=253,this.getChannel(Ie.channelUrl,!0);case 253:a.t6=a.sent;case 254:return xt=a.t6,this._markAsLeave(xt),Tt=n.as(Vo),St=Tt.user,St.userId===this._sdkState.userId&&this._dispatcher.dispatch(new zh({channelUrls:[xt.url],source:e.CollectionEventSource.EVENT_CHANNEL_BANNED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 261:return a.next=263,this.getChannel(Ie.channelUrl,!0);case 263:return It=a.sent,Nt=n.as(Qo),At=Nt.user,At.userId===this._sdkState.userId&&this._dispatcher.dispatch(new zh({channelUrls:[It.url],source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(It,At)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 269:return a.next=271,this.getChannel(Ie.channelUrl,!0);case 271:return Mt=a.sent,Ot=n.as(Wo),Ut=Ot.freeze,Mt.isFrozen=Ut,this._dispatcher.dispatch(new jh({channels:[Mt],source:Ut?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ut?e.onChannelFrozen&&e.onChannelFrozen(Mt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 277:return a.next=279,this.getChannel(Ie.channelUrl,!0);case 279:return Dt=a.sent,Lt=n.as(If),Rt=Lt.allowAutoUnhide,Pt=Lt.hidePreviousMessages,Ft=Lt.messageOffsetTimestamp,null!==Rt&&(Dt.hiddenState=Rt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Dt._updateUnreadCount(0,0),null!==Ft&&(Dt.messageOffsetTimestamp=Ft),this._dispatcher.dispatch(new jh({channels:[Dt],source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 287:return a.next=289,this.getChannel(Ie.channelUrl,!0);case 289:return(Ht=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new jh({channels:[Ht],source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 294:return a.next=296,this.getChannel(Ie.channelUrl,!0);case 296:return qt=a.sent,this._dispatcher.dispatch(new zh({channelUrls:[Ie.channelUrl],source:e.CollectionEventSource.EVENT_CHANNEL_DELETED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(qt.url,qt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 300:return a.next=302,this.getChannelWithoutCache(Ie.channelUrl,!0);case 302:return Gt=a.sent,this._dispatcher.dispatch(new jh({channels:[Gt],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 306:return a.next=308,this.getChannel(Ie.channelUrl,!0);case 308:return jt=a.sent,zt=n.as(xo),Vt=zt.created,Bt=zt.updated,Qt=zt.deleted,Vt&&(jt._upsertCachedMetaData(Vt,Ie.ts),this._dispatcher.dispatch(new jh({channels:[jt],source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED}))),Bt&&(jt._upsertCachedMetaData(Bt,Ie.ts),this._dispatcher.dispatch(new jh({channels:[jt],source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED}))),Qt&&(jt._removeFromCachedMetaData(Qt,Ie.ts),this._dispatcher.dispatch(new jh({channels:[jt],source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED}))),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Vt&&e.onMetaDataCreated&&e.onMetaDataCreated(jt,Vt),Bt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Bt),Qt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 315:return a.next=317,this.getChannel(Ie.channelUrl,!0);case 317:return Kt=a.sent,Wt=n.as(Ro),Yt=Wt.created,Zt=Wt.updated,Jt=Wt.deleted,Yt&&this._dispatcher.dispatch(new jh({channels:[Kt],source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED})),Zt&&this._dispatcher.dispatch(new jh({channels:[Kt],source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED})),Jt&&this._dispatcher.dispatch(new jh({channels:[Kt],source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,Yt),Zt&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,Zt),Jt&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 324:return a.next=326,this.getChannel(Ie.channelUrl,!0);case 326:return Xt=a.sent,$t=n.as(Rf),en=$t.pinnedMessageIds,tn=$t.latestPinnedMessage,(nn=$t.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=en,Xt.lastPinnedMessage=tn,Xt._pinnedMessagesUpdatedAt=nn,this._dispatcher.dispatch(new jh({channels:[Xt],source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(Xt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Aa((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",330);case 330:return a.abrupt("break",342);case 331:rn=n.as(fd),an=rn.event,a.t7=an.category,a.next=a.t7===Xl.USER_BLOCK?335:a.t7===Xl.USER_UNBLOCK?338:341;break;case 335:return sn=ld.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),a.abrupt("break",341);case 338:return cn=ld.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,dn=cn.blockee,this._groupChannelCache.unblock(ln.userId,dn.userId),a.abrupt("break",341);case 341:return a.abrupt("break",342);case 342:a.next=348;break;case 344:if(a.prev=344,a.t8=a.catch(0),!A(a.t8)){a.next=348;break}throw a.t8;case 348:case"end":return a.stop()}}),a,this,[[0,344],[19,30,33,36],[114,127,130,133],[226,237,240,243]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",n)).throw(M.invalidParameters),s=new Kh({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Wh),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",t.sent[0]);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL;return E(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Kh({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Wh),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new zh({channelUrls:[c.url],source:a})),t.next=14;break;case 10:return t.next=12,this.upsertChannelsToCache([c]);case 12:l=t.sent,this._dispatcher.dispatch(new jh({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==b.NON_AUTHORIZED&&t.t0.code!==b.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new zh({channelUrls:[n],source:a}));case 19:case"end":return t.stop()}}),s,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL;return E(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Zh(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Jh),c=u.channels,l=u.token,this._dispatcher.dispatch(new jh({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},Nh),r),as((L("string",n)||L("number",n))&&Ah(s)).throw(M.invalidParameters),i=new Bh(le({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(Qh),c=u.updatedChannels,l=u.deletedChannelUrls,d=u.hasMore,h=u.ts,c.length>0&&this._dispatcher.dispatch(new jh({channels:c,source:a,ts:h})),l.length>0&&this._dispatcher.dispatch(new zh({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:d,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Mh),e),as(Oh(r)).throw(M.invalidParameters),a=new Xh({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as($h),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d,h,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Dh),e),as(Lh(r)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new ef({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(tf),l=c.groupChannelUnreadMentionCount,d=c.groupChannelUnreadMessageCount,h=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ce({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:d,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new nf({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(rf),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Rh),e),as(Ph(r)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new af({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(sf),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Fh),e),as(Hh(r)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new of(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(uf),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=Es.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=Es.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=Es.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Sh),e),as(Ih(r)).throw(M.invalidParameters),r.isPublic||(r.accessCode=void 0),a=new lf(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as(df),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),as(n-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new hf({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),as(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new hf({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Yf[e]||(Yf[e]=new o(e,Es.of(e))),Yf[e]}},{key:"clear",value:function(e){Yf[e]&&delete Yf[e]}}]),o}(Ff);!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Uh||(Uh={}));var Jf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._state=Uh.IDLE,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===Uh.IDLE}},{key:"isRunning",get:function(){return this._state===Uh.RUNNING}},{key:"isDone",get:function(){return this._state===Uh.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(f=d.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(h=u.range).intersect.apply(h,_(f)))?this.extendRange(d):this._metadata={range:new Pf({top:Math.min.apply(Math,_(f)),bottom:Math.max.apply(Math,_(f))}),previousComplete:!1}),c.hasNext=d.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(c.nextToken=this._metadata.range.top,this._metadata.previousComplete=d.length0&&(h=l.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(d=o.range).intersect.apply(d,_(h)))?this.extendRange(l):this._metadata={range:new Pf({top:Math.min.apply(Math,_(h)),bottom:Math.max.apply(Math,_(h))}),previousComplete:!1}),u.hasNext=l.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(u.nextToken=this._metadata.range.bottom),v.debug("message background next sync progress",u),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",u);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ga)if(e.stateType===da.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Pf({})}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=Es.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=Es.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){Es.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Xf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Xf[e]||(Xf[e]={}),Xf[e][t.url]||(Xf[e][t.url]=new n({_iid:e,channel:t})),Xf[e][t.url].ref++,Xf[e][t.url]}},{key:"clear",value:function(e,t){Xf[e]&&Xf[e][t]&&(Xf[e][t].close(),delete Xf[e])}}]),n}(),ep={},tp=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this.ref=0,this._iid=i,this._channel=o;var u,c,l=Es.of(this._iid),d=l.logger,h=l.sdkState,f=l.dispatcher;this._metadataKey=(u=h.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(h.userId,this._channel.url);this._sync=new Jf(p,(function(){return E(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return d.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=Ll.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&this._metadata&&(this._metadata.token=l),d.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),d.debug("message changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ga)if(e.stateType===da.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=Es.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=Es.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=Es.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=Es.of(this._iid),t=e.logger;e.connectionManager,t.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ep[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return ep[e]||(ep[e]={}),ep[e][t.url]||(ep[e][t.url]=new n({_iid:e,channel:t})),ep[e][t.url].ref++,ep[e][t.url]}},{key:"clear",value:function(e,t){ep[e]&&ep[e][t]&&(ep[e][t].close(),delete ep[e])}}]),n}(),np={},rp=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this.ref=0,this._iid=s,this._channel=i;var u,c,l=Es.of(this._iid),d=l.logger,h=l.sdkState,f=l.dispatcher;this._metadataKey=(u=h.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Jf(p,(function(){return E(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(d.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=Es.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=Bu.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,h=c.token,r.hasNext=l,r.nextToken=h,this._metadata.token=h,d.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),d.debug("poll changelog sync error",e.t1),!(e.t1 instanceof M&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ga)if(e.stateType===da.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=Es.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=Es.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){Es.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){Es.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete np[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return np[t]||(np[t]={}),np[t][n.url]||(np[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),np[t][n.url].ref++,np[t][n.url]}}]),e}(),ap=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.isWebSocketEventComing=u,a.data=l,a}return s(n)}(ue),sp=function(t){i(a,t);var n=f(a);function a(t){var s,i,o,u,c,l,d,h,f,p,v;return r(this,a),(s=n.call(this)).method=de.GET,s.path="".concat(Se(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),s.params=ce({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(i=t.threshold)&&void 0!==i?i:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),s}return s(a)}(Ue),ip=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,d;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return $s(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return $s(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,s}return s(n)}(De),op=function(e,t){return t instanceof Fs?e.findIndex((function(e){return e instanceof Fs&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},up=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},cp=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},lp=s((function e(t){r(this,e),this.source=t})),dp=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(lp),hp=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(lp),fp=s((function e(t){r(this,e),this.source=t})),pp=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(fp),vp=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(fp),_p=6e5,mp={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var gp,yp,kp,Ep=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;Aa((function(){return E(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),bp=function(){function n(a,s){var i=this,o=s.filter,u=s.startingPoint,c=s.limit,l=s.channel,d=s.channelManager;r(this,n),this._messages=[],this._unsentMessages=[],this._iid=a,this._key="mc-".concat(ae()),this._isDisposed=!1,this.filter=null!=o?o:new bl,this._channel=l,this._syncRange=new Pf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u?u:Date.now()+_p,this._limit=c||100,this._channelManager=d,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(n,r,a){var s=n.findIndex((function(e){return e.isIdentical(i.channel)}));s>=0&&(i._replaceChannelOfCollection(n[s]),i.channel._runIfHandleableWithGroupChannel((function(n){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:var s=!1;for(var o in i._messages){if(i._messages[o].createdAt>=n.messageOffsetTimestamp){s=!0;var u=parseInt(o);if(u>0){var c=i._messages.splice(0,u);i._removeMessagesFromView(c.map((function(e){return e.messageId})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var l=Es.of(i._iid).sdkState,d=a;l.userId===d&&i._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=Es.of(i._iid).sdkState,f=a;h.userId===f&&-1!==n._myMutedRemainingTime&&i._startCheckMyMutedTimer(n._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:n.isPublic&&i._clearCheckMyMutedTimer()}Aa((function(){return E(i,void 0,void 0,t().mark((function e(){var n,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._createChannelEventContext(r),Gh(r)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(a,this.channel);case 2:case"end":return e.stop()}}),e,this)})))}))})))},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),Aa((function(){return E(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._createChannelEventContext(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(_i(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var h=Es.of(this._iid),f=h.cacheContext,p=h.dispatcher,v=h.logger;this._channel._updateMessageCollectionLastAccessedAt();var m=this._createChannelUpdateEventCommand(e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);m&&p.dispatch(m),this._shouldStartBackgroundSync()&&(this._backgroundSync=$f.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=tp.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=rp.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Jf(this._key,(function(n){return E(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof ga)switch(n.stateType){case da.CONNECTED:i._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS),Ma((function(){return E(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case da.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),Es.of(this._iid).statLogCollector.put(new fs({type:Oe.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=Es.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_createChannelEventContext",value:function(e){switch(!0){case this.channel.isGroupChannel():return new dp(e);case this.channel.isFeedChannel():return new hp(e);default:throw new M({code:b.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}},{key:"_createMessageEventContext",value:function(e){switch(!0){case this.channel.isGroupChannel():return new pp(e);case this.channel.isFeedChannel():return new vp(e);default:throw new M({code:b.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}},{key:"_createChannelUpdateEventCommand",value:function(e){switch(!0){case this.channel.isGroupChannel():return new jh({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new ap({channels:[this._channel],source:e});default:return null}}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(op(this._messages,l)<0){op(this._unsentMessages,l)<0&&o.push(l);var d=cp(this._messages,l);this._messages.splice(d,0,l)}}else if(l instanceof Fs){op(this._unsentMessages,l)<0&&op(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var h=op(this._messages,l);if(h<0){var f=op(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=cp(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[h]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Fs){var m=op(this._unsentMessages,l);m<0?op(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}_i(r)&&Aa((function(){return E(s,void 0,void 0,t().mark((function e(){var n,a,s,i,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=this._createMessageEventContext(r),o.length>0&&(null===(a=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===a||a.call(n,c,this.channel,o)),u.length>0&&(null===(i=null===(s=this._handler)||void 0===s?void 0:s.onMessagesUpdated)||void 0===i||i.call(s,c,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=up(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&_i(n)&&Aa((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=this._createMessageEventContext(n),s.length>0&&(null===(a=(r=this._handler).onMessagesUpdated)||void 0===a||a.call(r,i,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=up(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&_i(n)&&Aa((function(){return E(r,void 0,void 0,t().mark((function e(){var r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=this._createMessageEventContext(n),null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,i,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=up(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&_i(n)&&Aa((function(){return E(r,void 0,void 0,t().mark((function e(){var r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=this._createMessageEventContext(n),null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,i,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=[],u=y(e);try{for(u.s();!(r=u.n()).done;){var c=r.value;if(c.messageId>0){var l=op(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var d=op(this._unsentMessages,c);if(d>=0){var h=this._unsentMessages.splice(d,1);if(this.hasNext&&h.length>0)o.push(h[0]);else{i.push(c);var f=cp(this._messages,c);this._messages.splice(f,0,c)}}else{var p=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,_(p))&&!this._hasNext)&&s.push(c)}}}else if(c instanceof Fs){var v=op(this._unsentMessages,c);v>=0&&(i.push(c),this._unsentMessages[v]=c)}}}catch(e){u.e(e)}finally{u.f()}return _i(n)&&Aa((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:l=this._createMessageEventContext(n),i.length>0?null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,l,this.channel,i):o.length>0?null===(c=null===(u=this._handler)||void 0===u?void 0:u.onMessagesDeleted)||void 0===c||c.call(u,l,this.channel,[],o):s.length>0&&this._addMessagesToView(s,n);case 2:case"end":return e.stop()}}),e,this)})))})),i}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return _i(n)&&i.length>0&&Aa((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=this._createMessageEventContext(n),null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===a||a.call(r,o,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s,o=n.inclusive,u=void 0===o||o;return E(this,void 0,void 0,t().mark((function n(){var r,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!u){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:r=t.sent;case 5:if(!(a>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(s=t.t0,!(i>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return o=t.t1,t.abrupt("return",[].concat(_(r),_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 22:case"end":return t.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.CollectionEventSource.REQUEST_MESSAGE:u,l=r.reverse,d=void 0!==l&&l,h=r.checkingContinuousMessages,f=void 0!==h&&h;return E(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Ll.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,le(Object.assign(Object.assign(Object.assign({},this.filter),mp),{isInclusive:!0,reverse:d,prevResultSize:s,nextResultSize:o})),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h,f,p,v,m,g,y,k,w,C,x,T=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=15;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,r.next=7,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 7:return u=r.sent,r.next=10,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 10:return c=r.sent,r.next=13,Na((function(){return E(T,void 0,void 0,t().mark((function n(){var r,l,d,h,f,p,v,m,g,y,k,b,w,C,x,T,S,I,N,A,M,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=Es.of(this._iid),d=l.dispatcher,h=l.requestQueue,f=l.cacheContext,p=new sp(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:u,nextStart:i,nextEnd:o,nextCount:c,checkingContinuousMessages:f.localCacheEnabled},this.filter),mp)),n.next=4,h.send(p);case 4:v=n.sent,m=v.as(ip),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,b=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,T=m.nextHasmore,S=m.isContinuousNextMessages,g?Aa((function(){return E(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(I=this.viewTop,N=this.viewBottom,A=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),M=Math.max.apply(Math,[0,N].concat(_(x.map((function(e){return e.createdAt}))))),d.dispatch(new mi({messages:k,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),d.dispatch(new mi({messages:x,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(A,M),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(A,M)),b&&this._prevFill.start(A),T&&this._nextFill.start(M));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 13:r.next=30;break;case 15:return l=Es.of(this._iid),d=l.cacheContext,h=Math.floor(this._limit/2),f=Date.now(),r.prev=18,r.next=21,this._getRemoteMessages(f,{prevLimit:h,nextLimit:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 21:if(p=r.sent,v=p.messages,m=p.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),k=0,w=0,C=0;C=f&&w++;this._hasPrevious=k>=h,this._hasNext=w>=h,(g=this._syncRange).extends.apply(g,_(y)),m&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=30;break;case 27:r.prev=27,r.t0=r.catch(18),r.t0 instanceof M&&r.t0.code===b.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 30:case"end":return r.stop()}}),r,this,[[18,27]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+_p,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){this._channelManager.refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(r,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,r=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:a=t.sent,r=!a.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r=!0;case 12:return t.prev=12,r&&this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a=s._createChannelEventContext(e.CollectionEventSource.EVENT_CHANNEL_UNMUTED);null===(r=null===(n=s._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,s.channel)})),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"initialize",value:function(n){var r=this,a=new Ep;this._messages=[],this._unsentMessages=[],this._syncRange=new Pf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.CollectionEventSource.REFRESH_CHANNEL),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return E(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.CollectionEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(A(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=Es.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),d=0,h=0,f=0;fr._startingPoint&&h++}r._hasPrevious=d>=s,r._hasNext=h>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.CollectionEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(A(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=Es.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new fs({type:Oe.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(this._hasPrevious){n.next=4;break}return n.abrupt("return",[]);case 4:return r=Math.floor(this._limit/2),a=this.viewTop,s=[],n.next=9,Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{prevLimit:r,inclusive:!1});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 9:if(!(s.length=r,s.length>0&&((l=this._syncRange).extends.apply(l,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top)));case 8:case"end":return e.stop()}}),e,this)})))}));case 12:this._addMessagesToView(s,e.CollectionEventSource.REQUEST_MESSAGE),n.next=17;break;case 15:this._hasPrevious=s.length>=r,s.length>0&&this._addMessagesToView(s,e.CollectionEventSource.REQUEST_MESSAGE);case 17:return n.abrupt("return",s);case 18:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._isDisposed){r.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(this._hasNext){r.next=4;break}return r.abrupt("return",[]);case 4:return a=Math.floor(this._limit/2),s=this.viewBottom,i=[],r.next=9,Ma((function(){return E(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(s,{nextLimit:a,inclusive:!1});case 3:e.t1=e.sent,i=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 9:if(!(i.length=a,i.length>0&&((l=this._syncRange).extends.apply(l,_(i.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 8:case"end":return e.stop()}}),e,this)})))}));case 12:this._addMessagesToView(i,e.CollectionEventSource.REQUEST_MESSAGE),r.next=17;break;case 15:this._hasNext=i.length>=a,i.length>0&&this._addMessagesToView(i,e.CollectionEventSource.REQUEST_MESSAGE);case 17:return r.abrupt("return",i);case 18:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return t.next=4,this._channelManager.removeFailedMessageFromCache(e);case 4:(r=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r;if(!this._isDisposed){this._isDisposed=!0;var a=Es.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt();var o=this._createChannelUpdateEventCommand(e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);o&&i.dispatch(o),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}]),n}(),wp=function(e){i(n,e);var t=f(n);function n(e,a){return r(this,n),t.call(this,e,Object.assign(Object.assign({},a),{channelManager:Zf.of(e)}))}return s(n,[{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}}]),n}(bp),Cp={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},xp=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage,!0))&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},Tp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=t.call(this)).method=de.GET,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ue),Sp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new kh(e,t)}))),s}return s(n)}(De);e.MutedMemberFilter=void 0,(gp=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",gp.MUTED="muted",gp.UNMUTED="unmuted",e.MemberListOrder=void 0,(yp=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",yp.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(kp=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",kp.JOINED="joined_only",kp.INVITED="invited_only",kp.INVITED_BY_FRIEND="invited_by_friend",kp.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Ip,Np,Ap=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,d;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(d=s.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&R(e.MutedMemberFilter,this.mutedMemberFilter)&&R(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&R(e.OperatorFilter,this.operatorFilter)&&R(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new Tp(le(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Sp),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(no),Mp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Ue),Op=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new ov(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(De),Up=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a.params=ce({is_distinct:i,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(Ue),Dp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new ov(e,a),s}return s(n)}(De),Lp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=de.DELETE,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ue),Rp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=de.DELETE,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Ue),Pp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Ue),Fp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(De),Hp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=de.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Ue),qp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(De),Gp=Object.assign(Object.assign({},Yi),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),jp=function(e){return Zi(e)&&L("number",e.scheduledAt,!0)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},zp=Object.assign(Object.assign({},Ji),{scheduledAt:void 0}),Vp=function(e){return Xi(e)&&L("number",e.scheduledAt,!0)},Bp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=de.PUT,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ce(le({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Z.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Hs.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return As.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Ue),Qp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new ei(e,a),s}return s(n)}(De),Kp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=de.PUT,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ce(le({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Z.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return As.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Us.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Ue),Wp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=de.DELETE,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Ue),Yp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=de.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Ue),Zp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=de.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Ue),Jp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(De),Xp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Ue),$p=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(De),ev=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=de.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ue),tv=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=de.DELETE,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ue),nv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=$s(e,a.message),s}return s(n)}(Ya),rv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=de.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ce({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return s(n)}(Ue),av=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new nv(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(De),sv=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new rv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(av),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(no);e.CountPreference=void 0,(Ip=e.CountPreference||(e.CountPreference={})).ALL="all",Ip.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ip.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ip.OFF="off",e.HiddenState=void 0,(Np=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Np.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Np.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var iv,ov=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h,f,p,v,m,g,y,k,E,b,w,C,x,T,S;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isChatNotification=!1,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(d=n.is_public)&&void 0!==d&&d,s.isDiscoverable=null!==(h=n.is_discoverable)&&void 0!==h?h:s.isPublic,s.isChatNotification=null!==(f=n.is_chat_notification)&&void 0!==f&&f,s.isAccessCodeRequired=null!==(p=n.is_access_code_required)&&void 0!==p&&p,s.isPushEnabled=null!==(v=n.is_push_enabled)&&void 0!==v&&v,Array.isArray(n.members))&&(S=s.members).push.apply(S,_(n.members.map((function(e){return new kh(s._iid,e)}))));return s.memberCount=null!==(m=n.member_count)&&void 0!==m?m:0,s.joinedMemberCount=null!==(g=n.joined_member_count)&&void 0!==g?g:0,s.hiddenState=R(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(y=n.ts_message_offset)&&void 0!==y?y:0,s.messageSurvivalSeconds=null!==(k=n.message_survival_seconds)&&void 0!==k?k:-1,s.lastMessage=n.last_message?$s(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=R(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=R(e.Role,n.my_role)?n.my_role:e.Role.NONE,R(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=R(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=R(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(E=n.user_last_read)&&void 0!==E?E:0,s.inviter=n.inviter?new is(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(w=n.joined_ts)&&void 0!==w?w:0,s._updateUnreadCount(null!==(C=n.unread_message_count)&&void 0!==C?C:0,null!==(x=n.unread_mention_count)&&void 0!==x?x:0),s.pinnedMessageIds=null!==(T=n.pinned_message_ids)&&void 0!==T?T:[],s.lastPinnedMessage=n.latest_pinned_message?$s(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Fs&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=Es.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=Es.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ns(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wp(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ap(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new sv(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof kh?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Fs&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=Es.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=Es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Fs?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o>=e.createdAt&&s.push(i)}})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Es.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Fs?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=Es.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new Eh(e._iid,{channel_url:e.url,channel_type:e.channelType,user:kh.payloadify(a),ts:null!=s?s:0})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=Es.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Es.of(this._iid),s=a.requestQueue,i=a.dispatcher,o=new Kh({channelUrl:this.url}),t.next=4,s.send(o);case 4:return u=t.sent,c=u.as(Wh),l=c.channel,this._update(l),n&&i.dispatch(new jh({channels:[l],source:e.CollectionEventSource.REQUEST_CHANNEL})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=Es.of(this._iid),a.dispatcher.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=Es.of(this._iid),a.dispatcher.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cp),n),as(xp(a)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new Up(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Dp),d=l.channel,this._update(d),i.dispatch(new jh({channels:[d],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(e.every((function(e){return e instanceof is}))).throw(M.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(F("string",n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new yf({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(kf),l=c.channel,this._update(l),s.dispatch(new jh({channels:[l],source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",n,!0)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new pf({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(vf),(d=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(d),s.dispatch(new jh({channels:[d],source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Es.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new mf({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",n,!0)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Mp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Op),(d=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(d),s.dispatch(new jh({channels:[d],source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new bf({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Li,a=Es.of(this._iid).dispatcher,s=od.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Zf.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new jh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return E(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,d=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Es.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Zf.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})),o.dispatch(new jh({channels:[this],source:l?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}))),l&&Zf.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(d)})),o.dispatch(new mi({messages:[u],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Li,a=Es.of(this._iid).dispatcher,s=od.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var i=Zf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new jh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Li,a=Es.of(this._iid).dispatcher,s=od.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var i=Zf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new jh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new nc,a=Es.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var s=Zf.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new jh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return E(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,d=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Es.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Zf.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})),o.dispatch(new jh({channels:[this],source:l?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}))),l&&Zf.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(d)})),o.dispatch(new mi({messages:[u],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Li,a=Es.of(this._iid).dispatcher,s=od.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var i=Zf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new jh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return E(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Fs&&(s=Es.of(this._iid),s.dispatcher.dispatch(new yi({reqId:n.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cf),n),as(xf(a)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new Tf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,d=l.as(Sf),h=d.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new Rp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Lp({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new Gf({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(jf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Zf.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),s.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new zf({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=Es.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new Nf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=Es.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new Mf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},xl),e),as(function(e){return Gi(e)&&L("number",e.scheduledAt,!0)}(e)).throw(M.invalidParameters);var t=new Li;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},zp),n),as(Vp(a)).throw(M.invalidParameters),s=Es.of(this._iid),i=s.requestQueue,o=new Kp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(fu),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Tl),e),as(function(e){return Pi(e)&&L("number",e.scheduledAt)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(M.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new Li;return Sa(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);Aa((function(){return E(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(i));case 1:case"end":return e.stop()}}),e)})))}))})),q(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},Gp),n),as(jp(a)).throw(M.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Bp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=Es.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Qp),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Wp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=Es.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Yp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=Es.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Xp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as($p),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(R(e.PushTriggerOption,n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Zp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Jp),d=l.pushTriggerOption,this.myPushTriggerOption=d,s.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(R(e.CountPreference,n)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Pp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Fp),d=l.countPreference,this.myCountPreference=d,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new jh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",d);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Es.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new Hp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(qp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt0).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new ev({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("number",e)&&e>0).throw(M.invalidParameters),r=Es.of(this._iid),a=r.requestQueue,s=new tv({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,d,h,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!q(e.file)){t.next=11;break}return r=Es.of(this._iid),a=r.requestQueue,s=new ws({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(Cs),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,d=o.thumbnailSizes,h=void 0===d?e.thumbnailSizes:d,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=h,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return kh.payloadify(e)})),last_message:e.lastMessage?Xs(e.lastMessage):null,inviter:e.inviter?is.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?Xs(e.lastPinnedMessage):null})))}}]),u}(rc),uv={},cv=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this.ref=0,this._iid=i,this._limit=u;var c,l=Es.of(this._iid),d=l.sdkState,h=l.dispatcher,f=l.logger,p=l.cacheContext;this._metadataKey=(c=d.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var v=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(d.userId);this._sync=new Jf(v,(function(){return E(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,v,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),null===(a=this._metadata)||void 0===a?void 0:a.completed){t.next=41;break}if(t.prev=5,(u={includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL}).order!==e.GroupChannelListOrder.LATEST_LAST_MESSAGE){t.next=18;break}return t.prev=8,t.next=11,p.preference.get(Ba(d.appId));case 11:c=t.sent,u.includeChatNotification=Boolean(c),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),u.includeChatNotification=!1;case 18:return l=Zf.of(this._iid),t.next=21,l.getMyGroupChannels(null!==(i=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==i?i:"",u,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);case 21:return h=t.sent,v=h.channels,m=h.token,o.hasNext=v.length>=this._limit&&!!m,o.nextToken=m,this._metadata&&(this._metadata.token=m,(g=this._metadata.range).extends.apply(g,_(v.map((function(e){return e.createdAt})))),this._metadata.completed=!o.hasNext),f.debug("channel background sync progress",o),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(5),f.debug("channel background sync error",t.t1),!(t.t1 instanceof M&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:t.next=43;break;case 41:o.hasNext=!1,o.nextToken="";case 43:return t.abrupt("return",o);case 44:case"end":return t.stop()}}),n,this,[[5,32],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ga)if(e.stateType===da.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Pf({})}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=Es.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new Pf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=Es.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=Es.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){Es.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete uv[this._iid])}}],[{key:"of",value:function(e){return uv[e]||(uv[e]=new n({_iid:e})),uv[e].ref++,uv[e]}},{key:"clear",value:function(e){uv[e]&&(uv[e].close(),delete uv[e])}}]),n}(),lv={},dv=function(){function n(a){var s=this,i=a._iid;r(this,n),this.ref=0,this._iid=i;var o,u=Es.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher,h=u.cacheContext;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var f=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Jf(f,(function(){return E(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,o={includeEmpty:!0},t.prev=6,t.next=9,h.preference.get(Ba(l.appId));case 9:u=t.sent,o.includeChatNotification=Boolean(u),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),o.includeChatNotification=!1;case 16:return d=Zf.of(this._iid),t.next=19,d.getMyGroupChannelChangeLogs(null!==(s=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==s?s:"",o,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return f=t.sent,p=f.hasMore,v=f.token,i.hasNext=p,i.nextToken=v,this._metadata&&(this._metadata.token=v),c.debug("channel changelog sync progress",i),t.next=28,this.saveMetadata();case 28:t.next=37;break;case 30:if(t.prev=30,t.t1=t.catch(4),c.debug("channel changelog sync error",t.t1),!(t.t1 instanceof M&&t.t1.isInvalidTokenError)){t.next=36;break}return t.next=36,this.clearMetadata();case 36:throw t.t1;case 37:return t.abrupt("return",i);case 38:case"end":return t.stop()}}),n,this,[[4,30],[6,13]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ga)if(e.stateType===da.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=Es.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=Es.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){Es.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete lv[this._iid])}}],[{key:"of",value:function(e){return lv[e]||(lv[e]=new n({_iid:e})),lv[e].ref++,lv[e]}},{key:"clear",value:function(e){lv[e]&&(lv[e].close(),delete lv[e])}}]),n}(),hv=function(t,n){var r,a,s,i;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name;default:return null!==(i=null===(s=t.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:t.createdAt}},fv=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},pv=function(e,t,n){if(e.length>0){for(var r=fv(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:vv(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},vv=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a;default:return 0}},_v=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._iid=a,this._key="gcc-".concat(ae()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new wh,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=Es.of(this._iid),d=l.sdkState,h=l.cacheContext,f=l.dispatcher;h.localCacheEnabled&&(this._backgroundSync=cv.of(a),this._backgroundSync.resume()),this._changelogSync=dv.of(a),this._changelogSync.resume(),Zf.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){if(Gh(t)){var n=e.filter((function(e){return i.filter.match(e,d.userId)})),r=e.filter((function(e){return!i.filter.match(e,d.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),Es.of(this._iid).statLogCollector.put(new fs({type:Oe.FEATURE_LOCALCACHE,data:{use_local_cache:h.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof ga&&(e.stateType===da.CONNECTED?i._isGetRemoteChannelsSucceeded||E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===da.LOGOUT&&i.dispose())}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var d=a.value,h=fv(this.channels,d);h>=0&&this.channels.splice(h,1);var f=pv(this.channels,d,this.order).place;if(h<0)f===this.channels.length?!i&&this._hasMore||(o.push(d),this.channels.push(d)):(o.push(d),this.channels.splice(f,0,d));else switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:f!==h&&this._hasMore&&f===this.channels.length?c.push(d):(this.channels.splice(f,0,d),u.push(d));break;default:this.channels.splice(f,0,d),u.push(d)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var p,v=y(c);try{for(v.s();!(p=v.n()).done;){var _=p.value,m=fv(this.channels,_);-1!==m&&this.channels.splice(m,1)}}catch(e){v.e(e)}finally{v.f()}}Gh(r)&&Aa((function(){return E(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new dp(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return Gh(n)&&s.length>0&&Aa((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new dp(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Zf.of(this._iid),r=this.channels.length>0?hv(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:void 0);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Zf.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,le(Object.assign(Object.assign({},this.filter),{order:this.order})),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:r=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(r,e.CollectionEventSource.REQUEST_CHANNEL,!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),n,this,[[2,10]])})))}},{key:"loadMore",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=Es.of(this._iid),a=r.cacheContext,s=r.connectionManager,i=[],!a.localCacheEnabled||s.isConnected&&!this._backgroundSync.completed){n.next=11;break}return n.next=8,Ma((function(){return E(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:i=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:this._hasMore=i.length>=this._limit,n.next=21;break;case 11:return n.prev=11,n.next=14,this._getRemoteChannels();case 14:i=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=21;break;case 18:n.prev=18,n.t0=n.catch(11),this._isGetRemoteChannelsSucceeded=!1;case 21:return this._addChannelsToView(i,e.CollectionEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",i);case 23:return n.abrupt("return",[]);case 24:case"end":return n.stop()}}),n,this,[[11,18]])})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Zf.of(this._iid).unsubscribeChannelEvent(this._key))}}]),n}(),mv=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,E=t.includeMetaData;return(s=n.call(this)).method=de.GET,s.path=ve,s.params=ce(le({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:d,channel_urls:h,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:E})),s}return s(a)}(Ue),gv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new ov(e,t)}))),s.ts="number"==typeof u?u:0,s}return s(n)}(De);e.MembershipFilter=void 0,(iv=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",iv.JOINED="joined";var yv,kv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d,h,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(d=n.customTypesFilter)&&void 0!==d?d:null,s.customTypeStartsWithFilter=null!==(h=n.customTypeStartsWithFilter)&&void 0!==h?h:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&R(e.MembershipFilter,this.membershipFilter)&&R(e.SuperChannelFilter,this.superChannelFilter)&&R(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=Es.of(this._iid),a=r.requestQueue,r.dispatcher,s=new mv(le(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(gv),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(to),Ev=s((function e(){r(this,e),this.onUserMuted=Ke,this.onUserUnmuted=Ke,this.onUserBanned=Ke,this.onUserUnbanned=Ke,this.onChannelChanged=Ke,this.onChannelDeleted=Ke,this.onChannelFrozen=Ke,this.onChannelUnfrozen=Ke,this.onOperatorUpdated=Ke,this.onChannelMemberCountChanged=Ke,this.onMetaDataCreated=Ke,this.onMetaDataUpdated=Ke,this.onMetaDataDeleted=Ke,this.onMetaCounterCreated=Ke,this.onMetaCounterUpdated=Ke,this.onMetaCounterDeleted=Ke,this.onMessageReceived=Ke,this.onMessageUpdated=Ke,this.onMessageDeleted=Ke,this.onMentionReceived=Ke,this.onReactionUpdated=Ke,this.onThreadInfoUpdated=Ke})),bv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=Ke,e.onUserLeft=Ke,e.onUserReceivedInvitation=Ke,e.onUserDeclinedInvitation=Ke,e.onChannelHidden=Ke,e.onUnreadMemberStatusUpdated=Ke,e.onUndeliveredMemberStatusUpdated=Ke,e.onTypingStatusUpdated=Ke,e.onPollUpdated=Ke,e.onPollVoted=Ke,e.onPollDeleted=Ke,e.onPinnedMessageUpdated=Ke,e}return s(n)}(Ev),wv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(bv),Cv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=t.call(this)).method=de.GET,a.path="".concat(Ce),a.params=ce(le({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return s(n)}(Ue),xv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return $s(e,t)})),s}return s(n)}(De),Tv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,d;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(d=n.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(R(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&R(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new Cv(le(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(xv),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(to),Sv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Zf(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _v(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Lf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new kv(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Tv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){as(L("string",e)&&t instanceof wv).throw(M.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){as(L("string",e)).throw(M.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Nh),n),as(L("string",e)&&Ah(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Nh),n),as(L("number",e)&&Ah(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Mh),e),as(Oh(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Sh),e),as(Ih(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Sh),e),as(Ih(r)).throw(M.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},Sh),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:as(F("string",e)).throw(M.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(bs),Iv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return!!e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._channels.get(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],e.forEach((function(e){if(a._channels.has(e.url)){var t=a._channels.get(e.url);Object.assign(t,e),r.push(t)}else a._channels.set(e.url,e),r.push(e)})),t.abrupt("return",r);case 3:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(Ya),Nv={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},Av=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage,!0)||q(e.coverUrlOrImage,!0))&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},Mv=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=de.GET,a.path="".concat(i?ge:me,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ue),Ov=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Wv(e,a),s}return s(n)}(De),Uv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=t.call(this)).method=de.POST,a.path=me,a.params=ce(le({channel_url:s,cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return s(n)}(Ue),Dv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(fa),Lv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new is(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(ff),Rv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(fa),Pv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new is(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(ff),Fv={},Hv=function(n){i(o,n);var a=f(o);function o(n,s){var i;return r(this,o),(i=a.call(this,n,Object.assign(Object.assign({},s),{channelType:e.ChannelType.OPEN}))).subscribeChannelEvent=Ke,i.unsubscribeChannelEvent=Ke,i.refreshChannel=function(){return E(h(i),void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},i._openChannelCache=new Iv(n),i._openChannelHandlers=new Map,i._dispatcher.on((function(e){if(e instanceof Qe)i._handleEvent(e);else if(e instanceof ga&&e.stateType===da.CONNECTED){var t,n=y(i._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),Fv[n]||(Fv[n]=h(i)),i}return s(o,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=rs(e);return new Wv(this._iid,Wv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,d,h,f,p,v,_,m,g,k,b,w,C,x,T,S,I,N,M,O,U,D,L,R,P,F,H,q,G,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,ke,Ee,be,we,Ce,xe,Te,Se,Ie,Ne,Ae,Me,Oe,Ue,De,Le,Re=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?73:"VOTE"===r.t0?81:"SYEV"===r.t0?89:166;break;case 4:if(a=null,"MESG"===n.code?a=n.as($o):"FILE"===n.code?a=n.as(ri):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(Hf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived&&a.onMessageReceived(u,i),o&&a.onMentionReceived&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",166);case 14:if(c=null,"MEDI"===n.code?c=n.as(tu):"FEDI"===n.code?c=n.as(ru):"AEDI"===n.code&&(c=n.as(qf)),!c){r.next=23;break}if(d=(l=c).message,h=l.mentionCountChange,d.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(d.channelUrl,!0);case 21:f=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated&&a.onMessageUpdated(f,d),h>0&&a.onMentionReceived&&a.onMentionReceived(f,d))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",166);case 24:if(p=n.as(su),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",166);case 31:if(k=n.as(Bf),b=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(b,!0);case 35:x=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(x.url)&&a.onReactionUpdated&&a.onReactionUpdated(x,C)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",166);case 38:if(T=n.as(Qf),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",166);case 45:N=n.as(Kf),M=N.openChannelMemberCounts,O=[],U=y(M),r.prev=48,U.s();case 50:if((D=U.n()).done){r.next=59;break}return L=D.value,R=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(R);case 55:(H=r.sent)&&H._updateParticipantCount(P,F)&&O.push(H);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=72;break}return r.next=70,this.upsertChannelsToCache(O);case 70:q=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 72:return r.abrupt("break",166);case 73:if(G=n.as(Wf),j=G.event,z=G.status,V=G.channelUrl,B=G.channelType,!V||B!==e.ChannelType.OPEN){r.next=80;break}return r.next=77,this.getChannel(V,!0);case 77:Q=r.sent,this._dispatcher.dispatch(new Ei({event:j,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),Aa(z===Vs?function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(Q,j)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 80:return r.abrupt("break",166);case 81:if(K=n.as(Nu),W=K.event,Y=K.channelUrl,Z=K.channelType,!Y||Z!==e.ChannelType.OPEN){r.next=88;break}return r.next=85,this.getChannel(Y,!0);case 85:J=r.sent,this._dispatcher.dispatch(new bi({event:W,source:e.CollectionEventSource.EVENT_POLL_VOTED})),Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(J,W)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 88:return r.abrupt("break",166);case 89:if(X=n.as(ff),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===bh.CHANNEL_ENTER?94:r.t2===bh.CHANNEL_EXIT?101:r.t2===bh.CHANNEL_OPERATOR_UPDATE?108:r.t2===bh.USER_CHANNEL_MUTE||r.t2===bh.USER_CHANNEL_UNMUTE?116:r.t2===bh.USER_CHANNEL_BAN||r.t2===bh.USER_CHANNEL_UNBAN?123:r.t2===bh.CHANNEL_FREEZE||r.t2===bh.CHANNEL_UNFREEZE?130:r.t2===bh.CHANNEL_DELETED?138:r.t2===bh.CHANNEL_PROP_CHANGED?145:r.t2===bh.CHANNEL_META_DATA_CHANGED?150:r.t2===bh.CHANNEL_META_COUNTERS_CHANGED?159:165;break;case 94:return r.next=96,this.getChannel($.channelUrl,!0);case 96:return ee=r.sent,te=n.as(Lv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 101:return r.next=103,this.getChannel($.channelUrl,!0);case 103:return se=r.sent,ie=n.as(Pv),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 108:return r.next=110,this.getChannel($.channelUrl,!0);case 110:return le=r.sent,de=n.as(Uf),he=de.operators,le.operators=he,this.upsertChannelsToCache([le]),Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(le,he)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 116:return r.next=118,this.getChannel($.channelUrl,!0);case 118:return fe=r.sent,pe=$.category===bh.USER_CHANNEL_MUTE,ve=n.as(pe?qo:jo),_e=ve.user,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){pe?e.onUserMuted&&e.onUserMuted(fe,_e):e.onUserUnmuted&&e.onUserUnmuted(fe,_e)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 123:return r.next=125,this.getChannel($.channelUrl,!0);case 125:return me=r.sent,ge=$.category===bh.USER_CHANNEL_BAN,ye=n.as(ge?Vo:Qo),ke=ye.user,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ge?e.onUserBanned&&e.onUserBanned(me,ke):e.onUserUnbanned&&e.onUserUnbanned(me,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 130:return r.next=132,this.getChannel($.channelUrl,!0);case 132:return Ee=r.sent,be=n.as(Wo),we=be.freeze,Ee.isFrozen=we,this.upsertChannelsToCache([Ee]),Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen&&e.onChannelFrozen(Ee):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 138:return r.next=140,this.getChannel($.channelUrl,!0);case 140:return Ce=r.sent,r.next=143,this.removeChannelsFromCache([Ce.url]);case 143:return Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ce.url,Ce.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 145:return r.next=147,this.getChannelWithoutCache($.channelUrl,!0);case 147:return xe=r.sent,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 150:return r.next=152,this.getChannel($.channelUrl,!0);case 152:return Te=r.sent,Se=n.as(xo),Ie=Se.created,Ne=Se.updated,Ae=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Ae&&Te._removeFromCachedMetaData(Ae,$.ts),Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ie&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ne),Ae&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Ae)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 159:return r.next=161,this.getChannel($.channelUrl,!0);case 161:return Me=r.sent,Oe=n.as(Ro),Ue=Oe.created,De=Oe.updated,Le=Oe.deleted,Aa((function(){return E(Re,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ue&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Me,Ue),De&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Me,De),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Me,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 165:return r.abrupt("break",166);case 166:r.next=172;break;case 168:if(r.prev=168,r.t3=r.catch(0),!A(r.t3)){r.next=172;break}throw r.t3;case 172:case"end":return r.stop()}}),r,this,[[0,168],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return as(L("string",e)).throw(M.invalidParameters),a=new Mv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(Ov),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",t.sent[0]);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Nv),e),as(Av(r)).throw(M.invalidParameters),a=new Uv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Ov),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Fv[e]}}]),o}(Ff),qv={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Gv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},jv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=de.GET,a.path="".concat(me,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Ue),zv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new Di(e,t)})),s}return s(n)}(De),Vv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new jv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(zv),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(no),Bv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=de.PUT,a.path="".concat(me,"/").concat(encodeURIComponent(s)),a.params=ce(le({cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l})),a}return s(n)}(Ue),Qv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Wv(e,a),s}return s(n)}(De),Kv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=de.DELETE,a.path="".concat(me,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ue),Wv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new is(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return ns(this)}},{key:"isOperator",value:function(e){return e instanceof is?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new Vv(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Hv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Dv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(Lv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),Hv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Rv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(Pv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),Hv.of(this._iid).setExitedToCache(this),Ll.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},qv),e),as(Gv(r)).throw(M.invalidParameters),a=Es.of(this._iid),s=a.requestQueue,i=new Bv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Qv),c=u.channel,this._update(c),l=Hv.of(this._iid),t.next=12,l.upsertChannelsToCache([c]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return E(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},qv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Es.of(this._iid),r=n.requestQueue,a=new Kv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=Hv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return as(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return as(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return ce(le(Object.assign(Object.assign({},rc.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return is.payloadify(e)}))})))}}]),u}(rc),Yv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=Ke,e.onUserExited=Ke,e.onChannelParticipantCountChanged=Ke,e.onPollUpdated=Ke,e.onPollVoted=Ke,e.onPollDeleted=Ke,e}return s(n)}(Ev),Zv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Yv),Jv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=t.call(this)).method=de.GET,a.path=me,a.params=ce({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d}),a}return s(n)}(Ue),Xv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new Wv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(De),$v=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=Es.of(this._iid),r=n.requestQueue,a=new Jv(le(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Xv),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=Hv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw M.queryInProgress;case 21:e.next=24;break;case 23:throw M.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(to),e_=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Hv(e,{sdkState:n,dispatcher:r,requestQueue:i,logger:u,cacheContext:l,sessionManager:s})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new $v(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return E(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},Nv)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(bs);yv=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function l_(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function d_(e){return"string"!=typeof e&&(e=String(e)),e}function h_(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return a_&&(t[Symbol.iterator]=function(){return t}),t}function f_(e){this.map={},e instanceof f_?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p_(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function v_(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function __(e){var t=new FileReader,n=v_(t);return t.readAsArrayBuffer(e),n}function m_(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g_(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s_&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i_&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r_&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o_&&s_&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=m_(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o_&&(ArrayBuffer.prototype.isPrototypeOf(e)||c_(e))?this._bodyArrayBuffer=m_(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r_&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s_&&(this.blob=function(){var e=p_(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=p_(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(s_)return this.blob().then(__);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e=p_(this);if(e)return e;if(this._bodyBlob)return function(e){var t=new FileReader,n=v_(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8";return t.readAsText(e,a),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in n_)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E_(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function b_(e,t){if(!(this instanceof b_))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new f_(t.headers),this.url=t.url||"",this._initBody(e)}k_.prototype.clone=function(){return new k_(this,{body:this._bodyInit})},g_.call(k_.prototype),g_.call(b_.prototype),b_.prototype.clone=function(){return new b_(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f_(this.headers),url:this.url})},b_.error=function(){var e=new b_(null,{status:200,statusText:""});return e.status=0,e.type="error",e};var w_=[301,302,303,307,308];b_.redirect=function(e,t){if(-1===w_.indexOf(t))throw new RangeError("Invalid status code");return new b_(null,{status:t,headers:{location:e}})};var C_=n_.DOMException;try{new C_}catch(hn){(C_=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),C_.prototype.constructor=C_}function x_(e,t){return new Promise((function(r,a){var s=new k_(e,t);if(s.signal&&s.signal.aborted)return a(new C_("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}if(i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new f_,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new b_(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new C_("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&n_.location.href?n_.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(s_?i.responseType="blob":o_&&(i.responseType="arraybuffer")),t&&"object"===n(t.headers)&&!(t.headers instanceof f_||n_.Headers&&t.headers instanceof n_.Headers)){var u=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){u.push(l_(e)),i.setRequestHeader(e,d_(t.headers[e]))})),s.headers.forEach((function(e,t){-1===u.indexOf(t)&&i.setRequestHeader(t,e)}))}else s.headers.forEach((function(e,t){i.setRequestHeader(t,e)}));s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}x_.polyfill=!0,n_.fetch||(n_.fetch=x_,n_.Headers=f_,n_.Request=k_,n_.Response=b_);var T_=Object.freeze({__proto__:null});return e.AdminMessage=js,e.AppleCriticalAlertOptions=Us,e.ApplicationUserListQuery=hc,e.BannedUserListQuery=fo,e.BaseChannel=rc,e.BaseMessage=Ps,e.BlockedUserListQuery=vc,e.CachedChannelInfo=te,e.ConnectionHandler=oc,e.Emoji=ac,e.EmojiCategory=sc,e.EmojiContainer=ic,e.FileMessage=ei,e.FriendListQuery=gc,e.GroupChannel=ov,e.GroupChannelCollection=_v,e.GroupChannelEventContext=dp,e.GroupChannelEventSource=qh,e.GroupChannelFilter=wh,e.GroupChannelHandler=wv,e.GroupChannelListQuery=Lf,e.GroupChannelModule=Sv,e.LocalCacheConfig=ne,e.Member=kh,e.MemberListQuery=Ap,e.MemoryStore=pl,e.MessageCollection=wp,e.MessageCollectionInitHandler=Ep,e.MessageEventContext=pp,e.MessageEventSource=vi,e.MessageFilter=bl,e.MessageMetaArray=As,e.MessageModule=Kl,e.MessageRequestHandler=Li,e.MessageSearchQuery=Vl,e.MultipleFilesMessage=Js,e.MultipleFilesMessageRequestHandler=nc,e.MutedUserListQuery=co,e.NotificationInfo=Va,e.OGImage=Ms,e.OGMetaData=Os,e.OpenChannel=Wv,e.OpenChannelHandler=Zv,e.OpenChannelListQuery=$v,e.OpenChannelModule=e_,e.OperatorListQuery=so,e.Participant=Di,e.ParticipantListQuery=Vv,e.PinnedMessage=nv,e.PinnedMessageListQuery=sv,e.Plugin=zs,e.PreviousMessageListQuery=io,e.PublicGroupChannelListQuery=kv,e.Reaction=Ns,e.ReactionEvent=Is,e.ReadStatus=Eh,e.RestrictedUser=Ui,e.RestrictionInfo=Oi,e.ScheduledMessageListQuery=Tv,e.SendbirdChat=dh,e.SendbirdChatOptions=G,e.SendbirdError=M,e.Sender=Ds,e.SessionHandler=uc,e.ThreadInfo=xs,e.ThreadInfoUpdateEvent=Rl,e.Thumbnail=Hs,e.UIKitConfigInfo=Qa,e.UploadedFileInfo=Zs,e.User=is,e.UserEventHandler=cc,e.UserMessage=Ys,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,s=Object.create(i.prototype),o=new T(r||[]);return a(s,"_invoke",{value:b(e,n,o)}),s}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h={};function f(){}function p(){}function v(){}var _={};c(_,s,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,s)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(a,i,s,o){var u=d(e[a],e,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}})}function b(e,t,n){var r="suspendedStart";return function(a,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw i;return I()}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var o=w(s,n);if(o){if(o===h)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=d(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var a=d(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,h;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function S(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var o=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw i}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var b,w="4.9.8",C=function(){function e(){r(this,e)}return i(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",e[e.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.SESSION_REVOKED=400310]="SESSION_REVOKED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_COMMAND=700700]="INVALID_COMMAND",e[e.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(b||(b={}));var x,T,S,I,N,A=function(e){return!(e instanceof M&&!e.shouldThrowOutside)},M=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.code,s=void 0===i?0:i,o=e.message,u=void 0===o?"":o;return r(this,n),(a=t.call(this,u)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=s,Object.setPrototypeOf(h(a),n.prototype),a}return i(n,[{key:"isInvalidTokenError",get:function(){return this.code===b.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===b.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===b.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===b.SESSION_REVOKED}},{key:"isUserAuthDeactivedError",get:function(){return this.code===b.USER_AUTH_DEACTIVATED}},{key:"isUserAuthDeletedOrNotFoundError",get:function(){return this.code===b.USER_AUTH_DELETED_OR_NOT_FOUND}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:b.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:b.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new n({code:b.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new n({code:b.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new n({code:b.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:b.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:b.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:b.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:b.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:b.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"channelTypeNotSupportedError",get:function(){return new n({code:b.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}},{key:"networkError",get:function(){return new n({code:b.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:b.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:b.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:b.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:b.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:b.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:b.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:b.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:b.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:b.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:b.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:b.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:b.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(d(Error)),O=[b.CONNECTION_REQUIRED,b.NETWORK_ERROR,b.ACK_TIMEOUT,b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.FILE_UPLOAD_CANCEL_FAILED,b.REQUEST_CANCELED,b.INTERNAL_SERVER_ERROR,b.RATE_LIMIT_EXCEEDED,b.UNKNOWN_SERVER_ERROR],U=[b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.CONNECTION_REQUIRED],D=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},R=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?L(e,t):P(e,t):n(t)===e)},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return R(e,t)}))},H=function(e){return!(!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])||void 0!==e)||"number"==typeof e&&13===e.toString().length},q=function(e){return e>0&&U.indexOf(e)>=0},G=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null==e)return!0;var t="object"===n(e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},j=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,d=t.websocketPayloadDecompression,h=void 0===d||d,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=h}return i(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){R("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){R("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){R("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){R("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){R("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),z={encrypt:function(e){return e},decrypt:function(e){return e}},V=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return i(e,[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,i="".concat(e,".metadata.version"),t.next=5,this._store.get(i);case 5:return s=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,s&&!(s.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,i=t.clearOrder,s=void 0===i?N.MESSAGE_COLLECTION_ACCESSED_AT:i,o=t.customClearOrderComparator;r(this,e),this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),o?(this._clearOrder=s,this._customClearOrderComparator=o):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return i(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),ae=function(){function e(){r(this,e)}return i(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0}}]),e}(),ie=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},se=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=ie()}return i(e,[{key:"_register",value:function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)}}]),e}(),oe=function(){function e(){r(this,e),this._container={}}return i(e,[{key:"on",value:function(e,t){return new se({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new se({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=y(n.keys());try{for(i.s();!(r=i.n()).done;){var s=r.value,o=n.get(s);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(s))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),ue=function(){function e(){r(this,e),this._dispatcher=new oe}return i(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),ce=i((function e(){r(this,e)})),le=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},de=function e(t){if(null!=t){if("object"===n(t)){if(Array.isArray(t)){var r=_(t);for(var a in r)r[a]=e(r[a]);return r}for(var i in t)null===t[i]&&delete t[i];return t}return t}};e.ChannelType=void 0,(Q=e.ChannelType||(e.ChannelType={})).BASE="base",Q.GROUP="group",Q.OPEN="open",Q.FEED="feed",e.Role=void 0,(K=e.Role||(e.Role={})).OPERATOR="operator",K.NONE="none",e.MutedState=void 0,(W=e.MutedState||(e.MutedState={})).MUTED="muted",W.UNMUTED="unmuted",e.MessageType=void 0,(Y=e.MessageType||(e.MessageType={})).BASE="base",Y.USER="user",Y.FILE="file",Y.ADMIN="admin",e.MessageTypeFilter=void 0,(Z=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",Z.USER="MESG",Z.FILE="FILE",Z.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(J||(J={})),e.MentionType=void 0,(X=e.MentionType||(e.MentionType={})).USERS="users",X.CHANNEL="channel",e.ReplyType=void 0,($=e.ReplyType||(e.ReplyType={})).ALL="all",$.NONE="none",$.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,(ee=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",ee.SUPPRESS="suppress",e.SendingStatus=void 0,(te=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",te.SCHEDULED="scheduled",te.SUCCEEDED="succeeded",te.FAILED="failed",te.CANCELED="canceled";var he,fe="v3",pe="/".concat(fe,"/users"),ve="/".concat(fe,"/storage/file"),_e="/".concat(fe,"/group_channels"),me="/".concat(fe,"/sdk/group_channels"),ge="/".concat(fe,"/open_channels"),ye="/".concat(fe,"/sdk/open_channels"),ke="/".concat(fe,"/search"),Ee="/".concat(fe,"/report"),be="/".concat(fe,"/emojis"),we="/".concat(fe,"/emoji_categories"),Ce="/".concat(fe,"/polls"),xe="/".concat(fe,"/scheduled_messages"),Te="/".concat(fe,"/sdk/ui_kit/configuration"),Se="/".concat(fe,"/sdk/statistics"),Ie=function(t){switch(t){case e.ChannelType.FEED:case e.ChannelType.GROUP:return _e;case e.ChannelType.OPEN:return ge;default:return null}},Ne=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(Ee,"/group_channels");case e.ChannelType.OPEN:return"".concat(Ee,"/open_channels");default:return null}},Ae=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,i=y(n);try{for(i.s();!(a=i.n()).done;){if(a.value===r)return!0}}catch(e){i.e(e)}finally{i.f()}}}return!1},Me=function(e,t,n){var r,a,i,s,o=Ae(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(a=e.mentionedUserIds)&&void 0!==a?a:[],n),u=Ae(null!==(i=t.mentionType)&&void 0!==i?i:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!o&&u?1:o&&!u?-1:0},Oe=function e(t,r,a){var i,s=r||new FormData;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var u=t[o],c=a?"".concat(a,"[").concat(o,"]"):o;G(u)?s.append(c,u,null!==(i=u.name)&&void 0!==i?i:"filename"):"object"!==n(u)||null===u||Array.isArray(u)||u instanceof Blob?s.append(c,String(u)):s=e(u,s,c)}return s};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(he||(he={}));var Ue,De=function(e){s(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=ie(),e}return i(a,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=le(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=le(this.params);return Object.keys(e).some((function(t){return G(e[t])}))?Oe(e):JSON.stringify(e)}}]),a}(ce),Re=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this))._iid=e,i._payload=a,i}return i(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}(ce),Le=function(e){s(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return i(n)}(ce),Pe=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.expires_in,s=e.reason,o=void 0===s?b.SESSION_KEY_EXPIRED:s;switch(r(this,n),(a=t.call(this)).expiresIn=null!=i?i:0,o){case b.SESSION_KEY_EXPIRED:case b.SESSION_TOKEN_EXPIRED:case b.SESSION_REVOKED:case b.USER_AUTH_DEACTIVATED:case b.USER_AUTH_DELETED_OR_NOT_FOUND:a.error=new M({code:o})}return a}return i(n,[{key:"invalidateSessionToken",get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}]),n}(ce),Fe=function(e){s(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return i(n)}(ce);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Ue||(Ue={}));var He,qe,Ge,je=function(){function e(t){var n=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;r(this,e),this.type=n,this.createdAt=s,this.data=a}return i(e,null,[{key:"payloadify",value:function(e){return le({stat_type:e.type,ts:e.createdAt,data:le(e.data)})}}]),e}(),ze=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ve=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};e.SendbirdProduct=void 0,(He=e.SendbirdProduct||(e.SendbirdProduct={})).CHAT="chat",He.CALLS="calls",He.DESK="desk",He.LIVE="live",He.UIKIT_CHAT="uikit-chat",He.UIKIT_LIVE="uikit-live",e.SendbirdPlatform=void 0,(qe=e.SendbirdPlatform||(e.SendbirdPlatform={})).ANDROID="android",qe.IOS="ios",qe.JS="js",qe.UNREAL="unreal",qe.UNITY="unity",qe.REACT_NATIVE="react-native",qe.FLUTTER="flutter",e.DeviceOsPlatform=void 0,(Ge=e.DeviceOsPlatform||(e.DeviceOsPlatform={})).ANDROID="android",Ge.IOS="ios",Ge.WEB="web",Ge.MOBILE_WEB="mobile_web",Ge.WINDOWS="windows";var Be=i((function e(){r(this,e)}));Be.sendbirdSdkUserAgentWithExtension=function(t){var n=ze()?e.SendbirdPlatform.REACT_NATIVE:e.SendbirdPlatform.JS,r={main_sdk_info:"chat/".concat(n,"/").concat(C.SDK_VERSION),device_os_platform:Ve()?"mobile-web":"web",os_version:C.OS_VERSION};if(t){var a=t.sendbirdExtensions,i=t.deviceOS,s=t.customData,o=void 0===s?{}:s;i.version&&(r.os_version=i.version),i.platform&&(r.device_os_platform=i.platform),a.length>0&&(r.extension_sdk_info=a.map((function(e){var t=e.product,n=e.platform,r=e.version;return"".concat(t,"/").concat(n,"/").concat(r)})).join(",")),Object.keys(r).forEach((function(e){return delete o[e]})),Object.keys(o).length>0&&(r=Object.assign(Object.assign({},r),o))}return Object.entries(r).map((function(e){var t=v(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join("&")},Be.userAgentWithExtension=function(e){var t=ze()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Ve()?"omobile-web":"oweb";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)};var Qe=function(){function e(t,n){var a=this,i=n.auth,s=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Le&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return i(e,[{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,i=n.sendbirdRuntimeEnvironment,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":Be.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Be.sendbirdSdkUserAgentWithExtension(i)});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Fe(new je({type:Ue.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d,h,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,i=![he.GET,he.DELETE].includes(a),s=this._sdkState.api,o="".concat(s.host).concat(r).concat(i?"":e.query),u=i?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:void 0),l=new AbortController,d=l.signal,this._abortControl.set(e.requestId,l),h=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return i_}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return A_}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:d});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h),t.abrupt("return",new Re(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new M(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Pe({reason:v.code})),this._statLogApiResult(e,h,v),v;case 37:throw _=M.requestFailed,this._statLogApiResult(e,h,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,h,t.t0),!(t.t0 instanceof M)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw M.requestCanceled;case 54:throw m=M.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),Ke=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(s=t.call(this))._iid=e,s.code=a,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:u,s}return i(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a={};try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(ce),We=function(){};function Ye(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ze=256,Je=286,Xe=30,$e=15,et=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),tt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),nt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),rt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),at=new Array(576);Ye(at);const it=new Array(60);Ye(it);const st=new Array(512);Ye(st);const ot=new Array(256);Ye(ot);const ut=new Array(29);Ye(ut);const ct=new Array(Xe);function lt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let dt,ht,ft;function pt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ye(ct);const vt=e=>e<256?st[e]:st[256+(e>>>7)],_t=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},mt=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{mt(e,n[2*t],n[2*t+1])},yt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},kt=(e,t,n)=>{const r=new Array(16);let a,i,s=0;for(a=1;a<=$e;a++)s=s+n[a-1]<<1,r[a]=s;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=yt(r[t]++,t))}},Et=e=>{let t;for(t=0;t{e.bi_valid>8?_t(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},wt=(e,t,n,r)=>{const a=2*t,i=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,i,s,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?gt(e,a,t):(i=ot[a],gt(e,i+Ze+1,t),s=et[i],0!==s&&(a-=ut[i],mt(e,a,s)),r--,i=vt(r),gt(e,i,n),s=tt[i],0!==s&&(r-=ct[i],mt(e,r,s)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)Ct(e,n,s);u=i;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ct(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[2*u]=n[2*s]+n[2*o],e.depth[u]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[2*s+1]=n[2*o+1]=u,e.heap[1]=u++,Ct(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,d,h,f,p,v=0;for(h=0;h<=$e;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],h=n[2*n[2*l+1]+1]+1,h>u&&(h=u,v++),n[2*l+1]=h,l>r||(e.bl_count[h]++,f=0,l>=o&&(f=s[l-o]),p=n[2*l],e.opt_len+=p*(h+f),i&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(h=u-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(h=u;0!==h;h--)for(l=e.bl_count[h];0!==l;)d=e.heap[--c],d>r||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),l--)}})(e,t),kt(n,c,e.bl_count)},St=(e,t,n)=>{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=s,s=t[2*(r+1)+1],++o{let r,a,i=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),r=0;r<=n;r++)if(a=s,s=t[2*(r+1)+1],!(++o{mt(e,0+(r?1:0),3),bt(e),_t(e,n),_t(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Mt=(e,t,n,r)=>{let a,i,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(St(e,e.dyn_ltree,e.l_desc.max_code),St(e,e.dyn_dtree,e.d_desc.max_code),Tt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*rt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&-1!==t?At(e,t,n,r):4===e.strategy||i===a?(mt(e,2+(r?1:0),3),xt(e,at,it)):(mt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(mt(e,t-257,5),mt(e,n-1,5),mt(e,r-4,4),a=0;a{Nt||((()=>{let e,t,n,r,a;const i=new Array(16);for(n=0,r=0;r<28;r++)for(ut[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(ot[n]+Ze+1)]++,e.dyn_dtree[2*vt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{mt(e,2,3),gt(e,256,at),(e=>{16===e.bi_valid?(_t(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ut=(e,t,n,r)=>{let a=65535&e|0,i=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{a=a+t[r++]|0,i=i+a|0}while(--s);a%=65521,i%=65521}return a|i<<16|0};const Dt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Rt=(e,t,n,r)=>{const a=Dt,i=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},Lt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Pt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ft,_tr_stored_block:Ht,_tr_flush_block:qt,_tr_tally:Gt,_tr_align:jt}=Ot,{Z_NO_FLUSH:zt,Z_PARTIAL_FLUSH:Vt,Z_FULL_FLUSH:Bt,Z_FINISH:Qt,Z_BLOCK:Kt,Z_OK:Wt,Z_STREAM_END:Yt,Z_STREAM_ERROR:Zt,Z_DATA_ERROR:Jt,Z_BUF_ERROR:Xt,Z_DEFAULT_COMPRESSION:$t,Z_FILTERED:en,Z_HUFFMAN_ONLY:tn,Z_RLE:nn,Z_FIXED:rn,Z_DEFAULT_STRATEGY:an,Z_UNKNOWN:sn,Z_DEFLATED:on}=Pt,un=258,cn=262,ln=42,dn=113,hn=666,fn=(e,t)=>(e.msg=Lt[t],t),pn=e=>2*e-(e>4?9:0),vn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},_n=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let mn=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},yn=(e,t)=>{qt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,gn(e.strm)},kn=(e,t)=>{e.pending_buf[e.pending++]=t},En=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},bn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ut(e.adler,t,a,n):2===e.state.wrap&&(e.adler=Rt(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},wn=(e,t)=>{let n,r,a=e.max_chain_length,i=e.strstart,s=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-cn?e.strstart-(e.w_size-cn):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+un;let f=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+s]===p&&c[n+s-1]===f&&c[n]===c[i]&&c[++n]===c[i+1]){i+=2,n++;do{}while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&is){if(e.match_start=t,s=r,r>=o)break;f=c[i+s-1],p=c[i+s]}}}while((t=d[t&l])>u&&0!=--a);return s<=e.lookahead?s:e.lookahead},Cn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-cn)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),_n(e),r+=t),0===e.strm.avail_in)break;if(n=bn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=mn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=mn(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,gn(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(bn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(bn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,i=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=i||(r||t===Qt)&&t!==zt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,s=t===Qt&&0===e.strm.avail_in&&n===r?1:0,Ht(e,e.block_start,n,s),e.block_start+=n,gn(e.strm)),s?3:1)},Tn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=mn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-cn&&(e.match_length=wn(e,n)),e.match_length>=3)if(r=Gt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=mn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=mn(e,e.ins_h,e.window[e.strstart+1]);else r=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(yn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Qt?(yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(yn(e,!1),0===e.strm.avail_out)?1:2},Sn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=mn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=Gt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=mn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(yn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Gt(e,0,e.window[e.strstart-1]),r&&yn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Gt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Qt?(yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(yn(e,!1),0===e.strm.avail_out)?1:2};function In(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Nn=[new In(0,0,0,0,xn),new In(4,4,8,4,Tn),new In(4,5,16,8,Tn),new In(4,6,32,32,Tn),new In(4,4,16,16,Sn),new In(8,16,32,32,Sn),new In(8,16,128,128,Sn),new In(8,32,128,256,Sn),new In(32,128,258,1024,Sn),new In(32,258,258,4096,Sn)];function An(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=on,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),vn(this.dyn_ltree),vn(this.dyn_dtree),vn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),vn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),vn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Mn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ln&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==dn&&t.status!==hn?1:0},On=e=>{if(Mn(e))return fn(e,Zt);e.total_in=e.total_out=0,e.data_type=sn;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?ln:dn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Ft(t),Wt},Un=e=>{const t=On(e);var n;return t===Wt&&((n=e.state).window_size=2*n.w_size,vn(n.head),n.max_lazy_match=Nn[n.level].max_lazy,n.good_match=Nn[n.level].good_length,n.nice_match=Nn[n.level].nice_length,n.max_chain_length=Nn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Dn=(e,t,n,r,a,i)=>{if(!e)return Zt;let s=1;if(t===$t&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||n!==on||r<8||r>15||t<0||t>9||i<0||i>rn||8===r&&1!==s)return fn(e,Zt);8===r&&(r=9);const o=new An;return e.state=o,o.strm=e,o.status=ln,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<Dn(e,t,on,15,8,an),deflateInit2:Dn,deflateReset:Un,deflateResetKeep:On,deflateSetHeader:(e,t)=>Mn(e)||2!==e.state.wrap?Zt:(e.state.gzhead=t,Wt),deflate:(e,t)=>{if(Mn(e)||t>Kt||t<0)return e?fn(e,Zt):Zt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===hn&&t!==Qt)return fn(e,0===e.avail_out?Xt:Zt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(gn(e),0===e.avail_out)return n.last_flush=-1,Wt}else if(0===e.avail_in&&pn(t)<=pn(r)&&t!==Qt)return fn(e,Xt);if(n.status===hn&&0!==e.avail_in)return fn(e,Xt);if(n.status===ln&&0===n.wrap&&(n.status=dn),n.status===ln){let t=on+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=tn||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,En(n,t),0!==n.strstart&&(En(n,e.adler>>>16),En(n,65535&e.adler)),e.adler=1,n.status=dn,gn(e),0!==n.pending)return n.last_flush=-1,Wt}if(57===n.status)if(e.adler=0,kn(n,31),kn(n,139),kn(n,8),n.gzhead)kn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),kn(n,255&n.gzhead.time),kn(n,n.gzhead.time>>8&255),kn(n,n.gzhead.time>>16&255),kn(n,n.gzhead.time>>24&255),kn(n,9===n.level?2:n.strategy>=tn||n.level<2?4:0),kn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(kn(n,255&n.gzhead.extra.length),kn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Rt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(kn(n,0),kn(n,0),kn(n,0),kn(n,0),kn(n,0),kn(n,9===n.level?2:n.strategy>=tn||n.level<2?4:0),kn(n,3),n.status=dn,gn(e),0!==n.pending)return n.last_flush=-1,Wt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,gn(e),0!==n.pending)return n.last_flush=-1,Wt;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-r,r)),gn(e),0!==n.pending)return n.last_flush=-1,Wt;r=0}t=n.gzindexr&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-r,r)),gn(e),0!==n.pending)return n.last_flush=-1,Wt;r=0}t=n.gzindexr&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(gn(e),0!==n.pending))return n.last_flush=-1,Wt;kn(n,255&e.adler),kn(n,e.adler>>8&255),e.adler=0}if(n.status=dn,gn(e),0!==n.pending)return n.last_flush=-1,Wt}if(0!==e.avail_in||0!==n.lookahead||t!==zt&&n.status!==hn){let r=0===n.level?xn(n,t):n.strategy===tn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Cn(e),0===e.lookahead)){if(t===zt)return 1;break}if(e.match_length=0,n=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(yn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Qt?(yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(yn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===nn?((e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=un){if(Cn(e),e.lookahead<=un&&t===zt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+un;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Gt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(yn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Qt?(yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(yn(e,!1),0===e.strm.avail_out)?1:2})(n,t):Nn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=hn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Wt;if(2===r&&(t===Vt?jt(n):t!==Kt&&(Ht(n,0,0,!1),t===Bt&&(vn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),gn(e),0===e.avail_out))return n.last_flush=-1,Wt}return t!==Qt?Wt:n.wrap<=0?Yt:(2===n.wrap?(kn(n,255&e.adler),kn(n,e.adler>>8&255),kn(n,e.adler>>16&255),kn(n,e.adler>>24&255),kn(n,255&e.total_in),kn(n,e.total_in>>8&255),kn(n,e.total_in>>16&255),kn(n,e.total_in>>24&255)):(En(n,e.adler>>>16),En(n,65535&e.adler)),gn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Wt:Yt)},deflateEnd:e=>{if(Mn(e))return Zt;const t=e.state.status;return e.state=null,t===dn?fn(e,Jt):Wt},deflateSetDictionary:(e,t)=>{let n=t.length;if(Mn(e))return Zt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==ln||r.lookahead)return Zt;if(1===a&&(e.adler=Ut(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(vn(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Cn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=mn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Cn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=o,e.avail_in=i,r.wrap=a,Wt},deflateInfo:"pako deflate (from Nodeca project)"};const Ln=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Pn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Ln(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Hn[254]=Hn[254]=1;var qn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const i=new Array(2*n);for(a=0,r=0;r4)i[a++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?i[a++]=65533:t<65536?i[a++]=t:(t-=65536,i[a++]=55296|t>>10&1023,i[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Fn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Hn[e[n]]>t?n:t}};var Gn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const jn=Object.prototype.toString,{Z_NO_FLUSH:zn,Z_SYNC_FLUSH:Vn,Z_FULL_FLUSH:Bn,Z_FINISH:Qn,Z_OK:Kn,Z_STREAM_END:Wn,Z_DEFAULT_COMPRESSION:Yn,Z_DEFAULT_STRATEGY:Zn,Z_DEFLATED:Jn}=Pt;function Xn(e){this.options=Pn.assign({level:Yn,method:Jn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Zn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gn,this.strm.avail_out=0;let n=Rn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Kn)throw new Error(Lt[n]);if(t.header&&Rn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?qn.string2buf(t.dictionary):"[object ArrayBuffer]"===jn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Rn.deflateSetDictionary(this.strm,e),n!==Kn)throw new Error(Lt[n]);this._dict_set=!0}}function $n(e,t){const n=new Xn(t);if(n.push(e,!0),n.err)throw n.msg||Lt[n.err];return n.result}Xn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Qn:zn,"string"==typeof e?n.input=qn.string2buf(e):"[object ArrayBuffer]"===jn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(i===Vn||i===Bn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Rn.deflate(n,i),a===Wn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Rn.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Kn;if(0!==n.avail_out){if(i>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Xn.prototype.onData=function(e){this.chunks.push(e)},Xn.prototype.onEnd=function(e){e===Kn&&(this.result=Pn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var er={Deflate:Xn,deflate:$n,deflateRaw:function(e,t){return(t=t||{}).raw=!0,$n(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,$n(e,t)},constants:Pt};const tr=16209;var nr=function(e,t){let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,k,E,b,w,C,x;const T=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,i=a-(t-e.avail_out),s=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,d=T.window,h=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,h>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(h&(1<>>=y,f-=y),f<15&&(h+=C[n++]<>>24,h>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(h&(1<o){e.msg="invalid distance too far back",T.mode=tr;break e}if(h>>>=y,f-=y,y=a-i,E>y){if(y=E-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=tr;break e}if(b=0,w=d,0===l){if(b+=u-y,y2;)x[a++]=w[b++],x[a++]=w[b++],x[a++]=w[b++],k-=3;k&&(x[a++]=w[b++],k>1&&(x[a++]=w[b++]))}else{b=a-E;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],k-=3}while(k>2);k&&(x[a++]=x[b++],k>1&&(x[a++]=x[b++]))}break}}break}}while(n>3,n-=k,f-=k<<3,h&=(1<{const u=o.bits;let c,l,d,h,f,p,v=0,_=0,m=0,g=0,y=0,k=0,E=0,b=0,w=0,C=0,x=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=rr;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[i++]=20971520,a[i++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-E,s[_]+1=p?(N=M[s[_]-p],A=x[s[_]-p]):(N=96,A=0),c=1<>E)+l]=I<<24|N<<16|A|0}while(0!==l);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,_++,0==--T[v]){if(v===g)break;v=t[n+s[_]]}if(v>y&&(C&h)!==d){for(0===E&&(E=y),f+=m,k=v-E,b=1<852||2===e&&w>592)return 1;d=C&h,a[d]=y<<24|k<<16|f-i|0}}return 0!==C&&(a[f+C]=v-E<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:cr,Z_BLOCK:lr,Z_TREES:dr,Z_OK:hr,Z_STREAM_END:fr,Z_NEED_DICT:pr,Z_STREAM_ERROR:vr,Z_DATA_ERROR:_r,Z_MEM_ERROR:mr,Z_BUF_ERROR:gr,Z_DEFLATED:yr}=Pt,kr=16180,Er=16190,br=16191,wr=16192,Cr=16194,xr=16199,Tr=16200,Sr=16206,Ir=16209,Nr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ar(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Mr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Or=e=>{if(Mr(e))return vr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=kr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,hr},Ur=e=>{if(Mr(e))return vr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Or(e)},Dr=(e,t)=>{let n;if(Mr(e))return vr;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?vr:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Ur(e))},Rr=(e,t)=>{if(!e)return vr;const n=new Ar;e.state=n,n.strm=e,n.window=null,n.mode=kr;const r=Dr(e,t);return r!==hr&&(e.state=null),r};let Lr,Pr,Fr=!0;const Hr=e=>{if(Fr){Lr=new Int32Array(512),Pr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ur(1,e.lens,0,288,Lr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ur(2,e.lens,0,32,Pr,0,e.work,{bits:5}),Fr=!1}e.lencode=Lr,e.lenbits=9,e.distcode=Pr,e.distbits=5},qr=(e,t,n,r)=>{let a;const i=e.state;return null===i.window&&(i.wsize=1<=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>r&&(a=r),i.window.set(t.subarray(n-r,n-r+a),i.wnext),(r-=a)?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whaveRr(e,15),inflateInit2:Rr,inflate:(e,t)=>{let n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,k,E,b,w,C=0;const x=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Mr(e)||!e.output||!e.input&&0!==e.avail_in)return vr;n=e.state,n.mode===br&&(n.mode=wr),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,d=o,h=u,w=hr;e:for(;;)switch(n.mode){case kr:if(0===n.wrap){n.mode=wr;break}for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=Rt(n.check,x,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Ir;break}if((15&c)!==yr){e.msg="unknown compression method",n.mode=Ir;break}if(c>>>=4,l-=4,b=8+(15&c),0===n.wbits&&(n.wbits=b),b>15||b>n.wbits){e.msg="invalid window size",n.mode=Ir;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Rt(n.check,x,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=Rt(n.check,x,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Rt(n.check,x,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[i++]<>>8&255,n.check=Rt(n.check,x,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(b=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(i,i+f),b)),512&n.flags&&4&n.wrap&&(n.check=Rt(n.check,r,f,i)),o-=f,i+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{b=r[i+f++],n.head&&b&&n.length<65536&&(n.head.name+=String.fromCharCode(b))}while(b&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=br;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[i++]<>>=7&l,l-=7&l,n.mode=Sr;break}for(;l<3;){if(0===o)break e;o--,c+=r[i++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(Hr(n),n.mode=xr,t===dr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Ir}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Ir;break}if(n.length=65535&c,c=0,l=0,n.mode=Cr,t===dr)break e;case Cr:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(i,i+f),s),o-=f,i+=f,u-=f,s+=f,n.length-=f;break}n.mode=br;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[i++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Ir;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=ur(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=Ir;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=Ir;break}b=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,b=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,b=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Ir;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Ir)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Ir;break}if(n.lenbits=9,T={bits:n.lenbits},w=ur(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=Ir;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=ur(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=Ir;break}if(n.mode=xr,t===dr)break e;case xr:n.mode=Tr;case Tr:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=i,e.avail_in=o,n.hold=c,n.bits=l,nr(e,h),s=e.next_out,a=e.output,u=e.avail_out,i=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===br&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=br;break}if(64&m){e.msg="invalid literal/length code",n.mode=Ir;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[i++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[i++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Ir;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Ir;break}n.mode=16204;case 16204:if(0===u)break e;if(f=h-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Ir;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=s-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[s++]=v[p++]}while(--f);0===n.length&&(n.mode=Tr);break;case 16205:if(0===u)break e;a[s++]=n.length,u--,n.mode=Tr;break;case Sr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[i++]<{if(Mr(e))return vr;let t=e.state;return t.window&&(t.window=null),e.state=null,hr},inflateGetHeader:(e,t)=>{if(Mr(e))return vr;const n=e.state;return 0==(2&n.wrap)?vr:(n.head=t,t.done=!1,hr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,i;return Mr(e)?vr:(r=e.state,0!==r.wrap&&r.mode!==Er?vr:r.mode===Er&&(a=1,a=Ut(a,t,n,0),a!==r.check)?_r:(i=qr(e,t,n,n),i?(r.mode=16210,mr):(r.havedict=1,hr)))},inflateInfo:"pako inflate (from Nodeca project)"};var jr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const zr=Object.prototype.toString,{Z_NO_FLUSH:Vr,Z_FINISH:Br,Z_OK:Qr,Z_STREAM_END:Kr,Z_NEED_DICT:Wr,Z_STREAM_ERROR:Yr,Z_DATA_ERROR:Zr,Z_MEM_ERROR:Jr}=Pt;function Xr(e){this.options=Pn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gn,this.strm.avail_out=0;let n=Gr.inflateInit2(this.strm,t.windowBits);if(n!==Qr)throw new Error(Lt[n]);if(this.header=new jr,Gr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=qn.string2buf(t.dictionary):"[object ArrayBuffer]"===zr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Gr.inflateSetDictionary(this.strm,t.dictionary),n!==Qr)))throw new Error(Lt[n])}function $r(e,t){const n=new Xr(t);if(n.push(e),n.err)throw n.msg||Lt[n.err];return n.result}Xr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let i,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Br:Vr,"[object ArrayBuffer]"===zr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),i=Gr.inflate(n,s),i===Wr&&a&&(i=Gr.inflateSetDictionary(n,a),i===Qr?i=Gr.inflate(n,s):i===Zr&&(i=Wr));n.avail_in>0&&i===Kr&&n.state.wrap>0&&0!==e[n.next_in];)Gr.inflateReset(n),i=Gr.inflate(n,s);switch(i){case Yr:case Zr:case Wr:case Jr:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===Kr))if("string"===this.options.to){let e=qn.utf8border(n.output,n.next_out),t=n.next_out-e,a=qn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(i!==Qr||0!==o){if(i===Kr)return i=Gr.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Xr.prototype.onData=function(e){this.chunks.push(e)},Xr.prototype.onEnd=function(e){e===Qr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Pn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ea={Inflate:Xr,inflate:$r,inflateRaw:function(e,t){return(t=t||{}).raw=!0,$r(e,t)},ungzip:$r,constants:Pt};const{Deflate:ta,deflate:na,deflateRaw:ra,gzip:aa}=er,{Inflate:ia,inflate:sa,inflateRaw:oa,ungzip:ua}=ea;var ca,la={Deflate:ta,deflate:na,deflateRaw:ra,gzip:aa,Inflate:ia,inflate:sa,inflateRaw:oa,ungzip:ua,constants:Pt},da=function(e){return E(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=la.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(ca=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",ca.OPEN="OPEN",ca.CLOSED="CLOSED";var ha,fa=function(n){s(o,n);var a=f(o);function o(e,t){var n,i=t.sdkState,s=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=i,n._dispatcher=s,n._logger=u,n}return i(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"ws",get:function(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ke.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Pe(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return E(n,void 0,void 0,t().mark((function n(){var r,a,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return E(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,da(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",M.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=We,t._ws.onmessage=We,t._ws.onerror=We,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()}))}},{key:"send",value:function(e){if(!this._ws)throw M.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(oe),pa=function(e){s(n,e);var t=f(n);function n(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,n),(a=t.call(this)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:ie(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return i(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}(ce),va=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.all,s=e.feed,o=e.custom_types,u=e.ts;return r(this,n),(a=t.call(this)).all=i,a.feed=s,a.customTypes=o,a.ts=u,a}return i(n)}(ce),_a=i((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),ma=function(){function e(t,n){var a=this,i=n.auth,s=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=o,this._logger=u,this.apiClient=new Qe(t,{auth:i,sdkState:s,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new fa(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new va(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new M({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(M.connectionClosed)})),a._ackStateMap.clear()}))}return i(e,[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._sdkState.websocket){t.next=2;break}throw M.connectionRequired;case 2:if(r=new _a,e.ackRequired){i=function(t,n){s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(s._logger.debug("fail websocket request",t),r.reject(t)):(s._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return i(M.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return i(void 0,e)},reject:function(e){return i(e)}}),this.websocketClient.send(e)}catch(e){i(e)}}else try{this.websocketClient.send(e),r.resolve()}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof De)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof pa)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw M.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(ha||(ha={}));var ga,ya=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.stateType;return r(this,n),(a=t.call(this)).stateType=i,a}return i(n)}(ce),ka=function(){function e(n,a){var i=this,s=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,d=void 0!==l&&l;r(this,e),this._currentConnectionStateType=ha.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ma(n,{auth:s,sdkState:o,dispatcher:u,logger:c,useFetchCompat:d}),this._auth=s,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof ya){var n=e.stateType;switch(i._currentConnectionStateType=n,n){case ha.CONNECTED:var r=i._lazyCallQueue;i._lazyCallQueue=[],r.forEach((function(e){return E(i,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,i=e.timeout,clearTimeout(i),t.prev=2,t.next=5,this.send(r);case 5:s=t.sent,a.resolve(s),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case ha.INITIALIZED:case ha.INTERNAL_DISCONNECTED:case ha.EXTERNAL_DISCONNECTED:case ha.LOGOUT:var a=i._lazyCallQueue;i._lazyCallQueue=[],a.forEach((function(e){return E(i,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(M.connectionClosed):r.reject(M.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return i(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===ha.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===ha.CONNECTING||this._currentConnectionStateType===ha.RECONNECTING}},{key:"send",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof pa)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new _a,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return s.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),M.connectionRequired;case 17:case 37:t.next=40;break;case 19:if(!(e instanceof De)){t.next=39;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new _a,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return s.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw i=M.connectionRequired,this._logger.debug("fail api request",i),i;case 39:throw M.invalidCommand;case 40:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.debug("send forced request",e),!(e instanceof pa||e instanceof De)){t.next=7;break}return t.next=4,this.commandRouter.send(e);case 4:return t.abrupt("return",t.sent);case 7:throw M.invalidCommand;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(M.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),Ea="sendbird@devicetokens",ba=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return i(e,null,[{key:"payloadify",value:function(e){return le(de({type:e.type,token:e.token}))}}]),e}(),wa=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(pe,"/").concat(i,"/session_key"),a.method=he.POST,a.params={token:s,expiring_session:!!u},a.requireAuth=!1,a}return i(n)}(De),Ca=function(e){s(n,e);var t=f(n);function n(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?"":o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:s?1:0,req_id:u},ackRequired:!0})}return i(n)}(pa),xa=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.key;return i.key=s,i}return i(n)}(Re),Ta=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o;return r(this,n),(s=t.call(this,e,"LOGI",i)).error=null,s.newKey=null,s.newKey=null!==(o=i.new_key)&&void 0!==o?o:null,s.error=i.error?new M(i.error):null,s}return i(n)}(Ke),Sa=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return i(n)}(ce),Ia=function(e){return E(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},Na=function(){function e(){r(this,e)}return i(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),Aa=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Na;return E(void 0,void 0,void 0,t().mark((function a(){var i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=0,s=null,o=function(e){return s=null!=e?e:new Error("Halted")},u=function(){i=0};case 4:if(!(-1===n||i=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new Ca({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,i=a.as(Ta),s=i.newKey,!(o=i.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=s?s:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new wa({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,Aa((function(e){return E(a,void 0,void 0,t().mark((function n(){var a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,i=a.as(xa),s=i.key,this.auth.sessionKey=s,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==ha.CONNECTED){t.next=26;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=26;break}if(!n){t.next=26;break}return t.next=14,this._receiveNewAuthToken();case 14:if(!(a=t.sent)){t.next=22;break}return this.auth.authToken=a,t.next=19,this._refreshSessionKey(this.auth.authToken,!1);case 19:this.complete(),t.next=25;break;case 22:return t.next=24,this.clear();case 24:this.close();case 25:return t.abrupt("return");case 26:return t.prev=26,t.next=29,this._refreshSessionKeyByApi(e);case 29:this.complete(),t.next=55;break;case 32:if(t.prev=32,t.t1=t.catch(26),!this._isSessionRelatedError(t.t1)){t.next=54;break}if(!n){t.next=51;break}return t.next=38,this._receiveNewAuthToken();case 38:if(!(i=t.sent)){t.next=46;break}return this.auth.authToken=i,t.next=43,this._refreshSessionKeyByApi(this.auth.authToken);case 43:this.complete(),t.next=49;break;case 46:return t.next=48,this.clear();case 48:this.close();case 49:t.next=52;break;case 51:throw t.t1;case 52:t.next=55;break;case 54:throw t.t1;case 55:case"end":return t.stop()}}),r,this,[[1,8],[26,32]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new _a;return Ma((function(){return E(e,void 0,void 0,t().mark((function e(){var r,a,i,s,o=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),this.handler.onSessionTokenRequired?(r=null,a=function(){r&&(clearTimeout(r),r=null)},i=function(e){a(),o._isRefreshingAuthToken&&(o._isRefreshingAuthToken=!1,o.dispatch("refresh-authtoken"),n.resolve(e))},s=function(e){a(),o._isRefreshingAuthToken&&(o._isRefreshingAuthToken=!1,n.reject(e))},r=setTimeout((function(){return s()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(i,s)):n.resolve(null);case 3:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof M&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,i=e.ekey,s=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,Ua.set(this,i),this._deviceTokenCacheEnabled=null===(n=null==s?void 0:s.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(Ea);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(Ea,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),this.close(),Ua.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(oe),Ra=function(){function e(){r(this,e),this.type=ha.NONE,this.name="none"}return i(e,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),La=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=ha.LOGOUT,e.name="logout",e}return i(a,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new ja,r);case 6:Ma((function(){return E(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Ra),Pa=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=ha.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return i(a,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ga({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ha,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new La,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ra),Fa=function(e){s(a,e);var n=f(a);function a(e){var t,i=e.autoReconnect;return r(this,a),(t=n.call(this)).type=ha.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=i,t}return i(a,[{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Ha,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ga({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ha,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Pa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new La,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ra),Ha=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=ha.RECONNECTING,e.name="reconnecting",e._callbacks=[],e}return i(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new _a,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),Ma((function(){return E(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,i=e.sdkState.websocket,s=i.reconnectMaxRetry,o=i.reconnectRetryStrategy,n.next=8,Aa((function(n,r){return E(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===b.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),s,o);case 8:return n.next=10,e.changeState(new qa,r);case 10:Ma((function(){return E(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),A(n.t0)){n.next=23;break}if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===b.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Fa({autoReconnect:!1}),r);case 20:Ma((function(){return E(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new _a,this._halt(M.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ga({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new _a,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new Fa({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new Pa,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new La,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Ra),qa=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=ha.CONNECTED,e.name="connected",e}return i(a,[{key:"onReconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ha,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return E(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Fa({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Pa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new La,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ra),Ga=function(e){s(a,e);var n=f(a);function a(e){var t,i=e.authToken;return r(this,a),(t=n.call(this)).type=ha.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=i,t}return i(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new _a,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Aa((function(n){return E(i,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===b.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new qa,r);case 8:Ma((function(){return E(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),A(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===b.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new ja,r);case 20:Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new _a,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,i=n.autoReconnect,s=void 0!==i&&i;return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Fa({autoReconnect:s}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new La,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Pa,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new La,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new La,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Ra),ja=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=ha.INITIALIZED,e.name="initialized",e}return i(a,[{key:"onConnect",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ga({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Ra),za=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return i(n)}(pa),Va=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,i=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=i}return i(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this;if(!this.sdkState.websocket)throw M.connectionRequired;var n=new za;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}},{key:"refreshTimer",value:function(){var e,t=this;if(!this.sdkState.websocket)throw M.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}]),e}(),Ba=function(){function e(t){var n,a,i,s;r(this,e),this.isEnabled=null!==(n=t.enabled)&&void 0!==n&&n,this.feedChannels=null!==(a=t.feed_channels)&&void 0!==a?a:{},this.templateListToken=null!==(i=t.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(s=t.settings_updated_at)&&void 0!==s?s:0}return i(e,null,[{key:"payloadify",value:function(e){return le(de({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}]),e}(),Qa=function(e){return"sendbird@".concat(e,"/changelog_include_chat_notifications")},Ka=function(){function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}return i(e,null,[{key:"payloadify",value:function(e){return le(de({last_updated_at:e.lastUpdatedAt}))}}]),e}(),Wa=1048576,Ya=function(){function e(){var t,n,a,i,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=o.emoji_hash||"",this.uploadSizeLimit=o.file_upload_size_limit?o.file_upload_size_limit*Wa:Number.MAX_SAFE_INTEGER,this.useReaction=!!o.use_reaction,this.applicationAttributes=null!==(t=o.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=o.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(a=o.multiple_file_send_max_size)&&void 0!==a?a:5,this.allowSdkStatsUpload=null===(i=o.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new Ka(null!==(s=o.uikit_config)&&void 0!==s?s:{}),this.notificationInfo=o.notifications?new Ba(o.notifications):null}return i(e,null,[{key:"payloadify",value:function(e){return le(de({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Wa,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Ka.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?Ba.payloadify(e.notificationInfo):null}))}}]),e}(),Za=function(){function e(t){r(this,e),this._iid="",this._iid=t}return i(e,null,[{key:"payloadify",value:function(e){return{}}}]),e}(),Ja=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.metadata;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(pe,"/").concat(i,"/metadata"),a.params={metadata:s},a}return i(n)}(De),Xa=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).metaData=a,i}return i(n)}(Re),$a=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return i(n)}(De),ei=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).metadata=a,i}return i(n)}(Re),ti=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.metadataKey;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(i,"/metadata/").concat(s),a}return i(n)}(De),ni=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(i,"/metadata"),a}return i(n)}(De),ri=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ai=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ii=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(ga=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",ga.OFFLINE="offline",ga.NON_AVAILABLE="nonavailable";var si,oi=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h,f,p,v,m,g,y;return r(this,u),(i=a.call(this,t)).userId=null!==(o=null!==(s=n.guest_id)&&void 0!==s?s:n.user_id)&&void 0!==o?o:"",i.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",i.plainProfileUrl=null!==(h=null!==(d=n.profile_url)&&void 0!==d?d:n.image)&&void 0!==h?h:"",i.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,i.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},i.connectionStatus=e.UserOnlineState.NON_AVAILABLE,L(e.UserOnlineState,n.is_online)?i.connectionStatus=n.is_online:R("boolean",n.is_online)&&(i.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),i.isActive=null===(v=n.is_active)||void 0===v||v,i.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,i.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,i.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,i.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,i}return i(u,[{key:"profileUrl",get:function(){var e=bi.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return ri(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return R("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(this._isValidMetaData(e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ja({userId:a.userId,metadata:e}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(Xa),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(this._isValidMetaData(e)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new $a({userId:i.userId,metadata:e,upsert:n}),t.next=5,s.send(o);case 5:return u=t.sent,c=u.as(ei),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ti({userId:a.userId,metadataKey:e}),t.next=5,i.send(s);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ni({userId:r.userId}),e.next=4,a.send(i);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}}]),u}(Za),ui=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=i,a}return i(n)}(ce),ci=function(){function e(t,n){var a,i,s,o,u,c,l,d,h,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ya(n),this.user=new oi(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=n.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=n.pong_timeout)&&void 0!==s?s:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(h=null===(d=n.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==h?h:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return i(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=bi.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new ui({userProfile:this}))}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign(Object.assign({},oi.payloadify(e.user)),Ya.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}}]),e}(),li=function(e){s(a,e);var n=f(a);function a(e,t,i){var s,o,u,c;return r(this,a),(s=n.call(this,e,t,i)).error=null,s.userProfile=new ci(e,i),s.deviceTokenLastDeletedAt=null!==(o=i.device_token_last_deleted_at)&&void 0!==o?o:0,s.key=null!==(u=i.key)&&void 0!==u?u:"",s.ekey=null!==(c=i.ekey)&&void 0!==c?c:"",s.error=i.error?new M(i):null,s}return i(a,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=bi.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw M.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a("","LOGI",Object.assign({user_id:"",error:!0},e))}}]),a}(Ke),di=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.request,s=void 0===i||i,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=s,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return i(n)}(ce),hi=function(e){s(a,e);var n=f(a);function a(e,t){var i,s,o=t.sdkState,u=t.cacheContext,c=t.connectionHandlers,l=t.sessionManager,d=t.websocketClient,h=t.dispatcher,f=t.logger,p=t.entryState,v=void 0===p?new ja:p;return r(this,a),(i=n.call(this))._stateUpdatedAt=0,i._connectingAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=o,i.cacheContext=u,i.connectionHandlers=c,i._sessionManager=l,i._websocketClient=d,i._dispatcher=h,i._logger=f,i._currentState=v,(null===(s=i.sdkState.websocket)||void 0===s?void 0:s.pingerDisabled)||(i._pinger=new Va({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:f})),i._websocketClient.on("open",(function(){i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(li))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){i._logiProcessingTimer=setTimeout((function(){i._logiProcessingTimer=void 0,i._unresolvedLogi||i._rejectConnectionRequest(M.networkError)}),500)})),i._dispatcher.on((function(e){e instanceof li&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return i(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new ya({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=void 0,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=void 0,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Pe({reason:r.error.code})),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=this.sdkState,a=r.appId,i=r.appVersion,s=r.userId,o=r.extensions,u=r.sendbirdRuntimeEnvironment,c=this.cacheContext.localCacheEnabled,l=this._sessionManager.auth,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,h=!!(null!==(t=this.sdkState.extensions)&&void 0!==t?t:{}).sb_uikit,f=Be.userAgentWithExtension(o);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(a).concat(i?"&av=".concat(i):"").concat(l.hasSession?"&key=".concat(encodeURIComponent(l.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(n)),"&pmce=").concat(d?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&SB-SDK-User-Agent=").concat(encodeURIComponent(Be.sendbirdSdkUserAgentWithExtension(u)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(c?1:0,"&include_poll_details=1").concat(h?"&uikit_config=1":"")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new di({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new Fe(new je({type:Ue.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,t().mark((function r(){var a,i,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(M.connectionCanceled)),a=this._url(n),i=new _a,this._connectionRequestQueue.push(i),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=void 0,s._rejectConnectionRequest(M.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),n&&(this._sessionManager.auth.authToken=n),this._websocketClient.connect(a)),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(li.asError(M.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}]),a}(oe),fi=function(){function e(t,n){var a=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,d=n.disableWebSocketCloseEventHandling,h=void 0!==d&&d;r(this,e),this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=h,this._context=new hi(t,{sdkState:a,cacheContext:i,connectionHandlers:s,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return i(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}},{key:"isConnected",get:function(){return this._context.currentState.type===ha.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===ha.CONNECTING||e.type===ha.RECONNECTING}},{key:"websocketClient",get:function(){return this._websocketClient}},{key:"connect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),pi=function(e){s(n,e);var t=f(n);function n(e){var a,i,s,o,u,c=e.type,l=e.data,d=e.ts,h=void 0===d?Date.now():d;return r(this,n),(a=t.call(this,{type:c,data:l,ts:h})).date=new Date(h),a.key="".concat((i=a.date,s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0"),"".concat(s).concat(o).concat(u)),"_").concat(c),a}return i(n)}(je),vi=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.deviceId,s=e.statLogs;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(Se),a.params={device_id:i,log_entries:s.map((function(e){return je.payloadify(e)}))},a}return i(n)}(De),_i=function e(t,r){if(null!==t&&null!==r){var a,i=Object.keys(t),s=Object.keys(r),o={},u=y(_(new Set([].concat(i,s))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),d=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===d?o[c]=t[c]:l!==d?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(si||(si={}));var mi,gi=function(e){s(a,e);var n=f(a);function a(e){var t,i=e.cacheContext,s=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,d=void 0===l?1e3:l,h=e.minLimit,f=void 0===h?10:h;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=si.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=ie(),t.cacheContext=i,t.requestQueue=s,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=d,t.minLimit=f,t}return i(a,[{key:"isEnabled",get:function(){return this.enabledState===si.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ue.API_RESULT||e.type===Ue.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ue.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==si.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return je.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof pi){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return i=new vi({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(i);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof M)){e.next=30;break}if(e.t0.code!==b.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=si.DISABLED,e.next=30;break;case 29:e.t0.code===b.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=si.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new je({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,Ia(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Fe){var t=e.statLog;i.put(t)}else if(e instanceof di){var n=e.request,r=e.features,a=e.options;i._collectRequestStat=n,i._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,i._arrangeStat(),i._collectRequestStat||i._collectFeatureLocalCacheStat?i.enabledState=a.ingestion?si.ENABLED:si.COLLECT_ONLY:i.enabledState=si.DISABLED,i.isEnabled?i.queue.length>=i.limit&&i._flush():i.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===si.DISABLED){t.next=7;break}return e instanceof pi?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof pi&&t.key===e.key})),a=v(r,1),(i=a[0])?i.data=_i(i.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}]),a}(oe);e.LogLevel=void 0,(mi=e.LogLevel||(e.LogLevel={}))[mi.NONE=0]="NONE",mi[mi.VERBOSE=1]="VERBOSE",mi[mi.DEBUG=2]="DEBUG",mi[mi.INFO=3]="INFO",mi[mi.WARN=4]="WARN",mi[mi.ERROR=5]="ERROR";var yi,ki=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return i(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&R("number",s)&&(this.key=a,this.userIds=i,this.updatedAt=s);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return i(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return le(de({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}]),t}(),Mi=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return i(e,null,[{key:"payloadify",value:function(e){var t;return le(de({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}]),e}(),Oi=function(){function e(t){r(this,e),this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}return i(e,null,[{key:"payloadify",value:function(e){var t,n;return le(de({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))}}]),e}(),Ui=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new Oi(t["og:image"]))}return i(e,null,[{key:"payloadify",value:function(e){return le(de({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Oi.payloadify(e.defaultImage):null}))}}]),e}(),Di=function(){function e(t){var n,a;r(this,e),this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return i(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return le(de({name:e.name,volume:e.volume}))}}]),e}(),Ri=function(t){s(a,t);var n=f(a);function a(t,i){var s,o;return r(this,a),(s=n.call(this,t,i)).isBlockedByMe=!1,s.role=L(e.Role,i.role)?i.role:e.Role.NONE,s.isBlockedByMe=null!==(o=i.is_blocked_by_me)&&void 0!==o&&o,s}return i(a,null,[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}]),a}(oi);e.ScheduledStatus=void 0,(Si=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Si.SENT="sent",Si.FAILED="failed",Si.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Ii||(Ii={}));var Li,Pi=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Fi=function(t){s(a,t);var n=f(a);function a(t,i){var s,o,u,c,l,d,h,f,p,v,_,m,g,y,k,E,b;r(this,a),(s=n.call(this,t)).channelType=e.ChannelType.BASE,s.parentMessage=null,s.silent=!1,s.isOperatorMessage=!1,s.messageType=e.MessageType.BASE,s.mentionType=null,s.threadInfo=null,s.reactions=[],s.metaArrays=[],s.appleCriticalAlertOptions=null,s.createdAt=0,s.updatedAt=0,s.scheduledInfo=null,s.extendedMessage={},s._isContinuousMessages=!1,s._scheduledStatus=null,s.messageId=null!==(u=null!==(o=i.msg_id)&&void 0!==o?o:i.message_id)&&void 0!==u?u:0,s.channelUrl=i.channel_url,s.channelType=L(e.ChannelType,i.channel_type)?i.channel_type:e.ChannelType.GROUP,i.channel&&(i.channel.channel_url&&(s.channelUrl=i.channel.channel_url),i.channel.channel_type&&(s.channelType=i.channel.channel_type)),s.parentMessageId=null!==(c="string"==typeof i.parent_message_id?parseInt(i.parent_message_id):i.parent_message_id)&&void 0!==c?c:0,s.data=null!==(l=i.data)&&void 0!==l?l:"",s.customType=null!==(d=i.custom_type)&&void 0!==d?d:"",s.mentionType=L(e.MentionType,i.mention_type)?i.mention_type:null,s.mentionedUsers=i.mentioned_users?i.mentioned_users.map((function(e){return new oi(s._iid,e)})):null,s.mentionedUserIds=null!==(h=i.mentioned_user_ids)&&void 0!==h?h:null,s.mentionedUsers&&!s.mentionedUserIds&&(s.mentionedUserIds=s.mentionedUsers.map((function(e){return e.userId}))),s.mentionedMessageTemplate=null!==(f=i.mentioned_message_template)&&void 0!==f?f:"",s.threadInfo=i.thread_info?new Ti(s._iid,i.thread_info):null,s.reactions=i.reactions?i.reactions.map((function(e){return new Ai(e)})):[];var w=null!==(p=i.metaarray)&&void 0!==p?p:{},C=null!==(v=i.metaarray_key_order)&&void 0!==v?v:Object.keys(w).sort((function(e,t){return e.localeCompare(t)}));s.metaArrays=[];for(var x=0;x=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,i;return le(de(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Pi(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return oi.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?Ti.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return Ai.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Mi.payloadify(e)})),og_tag:e.ogMetaData?Ui.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?Di.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}},{key:"_getParentMessageInfoPayload",value:function(e){return le(de({type:Pi(e.messageType),ts:e.createdAt,user:e.sender?Ri.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}}]),a}(Za),Hi=function(t){s(a,t);var n=f(a);function a(t,i){var s,o,u,c,l;if(r(this,a),(s=n.call(this,t,i)).reqId="",s.replyToChannel=!1,s.errorCode=0,s.sender=i.user?new Ri(s._iid,i.user):i.sender_id,s.reqId=null!==(u=null!==(o=i.req_id)&&void 0!==o?o:i.request_id)&&void 0!==u?u:"",s.replyToChannel=null!==(c=i.is_reply_to_channel)&&void 0!==c&&c,i.request_state&&L(e.SendingStatus,i.request_state)&&(s.sendingStatus=i.request_state),!s.sendingStatus)if(s.messageId>0)s.sendingStatus=e.SendingStatus.SUCCEEDED;else if(s.scheduledInfo)switch(i.scheduled_status&&(s._scheduledStatus=i.scheduled_status),i.scheduled_status){case Ii.SENT:case Ii.IN_QUEUE:s.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Ii.PENDING:s.sendingStatus=e.SendingStatus.SCHEDULED;break;case Ii.FAILED:case Ii.REMOVED:s.sendingStatus=e.SendingStatus.FAILED;break;case Ii.CANCELED:s.sendingStatus=e.SendingStatus.CANCELED}else s.sendingStatus=e.SendingStatus.PENDING;return s.errorCode=null!==(l=i.error_code)&&void 0!==l?l:0,s}return i(a,[{key:"isResendable",get:function(){return(this.sendingStatus===e.SendingStatus.FAILED||this.sendingStatus===e.SendingStatus.CANCELED)&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Ri.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}}]),a}(Fi),qi=function(){function e(t){var n,a;r(this,e),this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return i(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return le(de({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}}]),e}(),Gi={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ji=function(t){return R("number",t.prevResultSize)&&R("number",t.nextResultSize)&&R("boolean",t.isInclusive)&&R("boolean",t.reverse)&&R("string",t.messageTypeFilter)&&L(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&R("boolean",t.includeMetaArray)&&R("boolean",t.includeReactions)&&R("boolean",t.includeParentMessageInfo)},zi=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l;if(r(this,u),(i=a.call(this,t,n)).translations={},i.message=null!==(s=n.message)&&void 0!==s?s:"",i.messageType=e.MessageType.ADMIN,i.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var d=n.parent_message_info;i.parentMessage=es(t,le(de(Object.assign(Object.assign({},d),{message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:d.file,url:null===(c=d.file)||void 0===c?void 0:c.url,require_auth:null===(l=d.file)||void 0===l?void 0:l.require_auth}))))}return i}return i(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Gi),n),ii(this.messageId>0&&R("number",e)&&ji(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Fi),Vi=function(){function e(t){var n,a;r(this,e),this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.detail&&R("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return i(e,null,[{key:"payloadify",value:function(e){return le(de({type:e.type,vendor:e.vendor,detail:e.detail}))}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Li||(Li={}));var Bi="removed",Qi=function(e){switch(e){case"open":return Li.OPEN;case"closed":return Li.CLOSED;default:return null}},Ki=function(e){return!e||!!e.text&&R("string",e.text)},Wi=function(e){s(n,e);var t=f(n);function n(e,a){var i,s,o,u,c,l,d,h;return r(this,n),(i=t.call(this,e)).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(d=a.created_at)&&void 0!==d?d:0,i.updatedAt=null!==(h=a.updated_at)&&void 0!==h?h:0,i}return i(n,null,[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}]),n}(Za),Yi=function(e){s(n,e);var t=f(n);function n(e,a){var i,s,o,u,c,l,d,h,f,p,v,_,m,g;return r(this,n),(i=t.call(this,e)).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=Li.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(d=Qi(a.status))&&void 0!==d?d:Li.CLOSED,i.messageId=null!==(h=a.message_id)&&void 0!==h?h:0,i.data=null!==(f=a.data)&&void 0!==f?f:null,i.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,i.options=a.options?a.options.map((function(e){return new Wi(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,i.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,i.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],i}return i(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=Qi(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Wi(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>=i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return ri(this)}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Wi.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}]),n}(Za),Zi=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d;if(r(this,u),(i=a.call(this,t,n)).message="",i.messageParams=null,i.translations={},i.translationTargetLanguages=[],i.messageSurvivalSeconds=-1,i.plugins=[],i._poll=null,i.message=n.message,i.messageType=e.MessageType.USER,i.translations=null!==(s=n.translations)&&void 0!==s?s:{},i.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(i.translations).length&&i.translationTargetLanguages.length>0){var h,f=y(i.translationTargetLanguages);try{for(f.s();!(h=f.n()).done;){var p=h.value;i.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(i.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,i.plugins=n.plugins?n.plugins.map((function(e){return new Vi(e)})):[],i._poll=n.poll?new Yi(i._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;i.parentMessage=es(t,le(de(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(d=v.file)||void 0===d?void 0:d.require_auth}))))}return i}return i(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Gi),n),ii(this.messageId>0&&R("number",e)&&ji(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Vi.payloadify(e)})),poll:e._poll?Yi.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Hi),Ji=function(e){s(n,e);var t=f(n);function n(e,a){var i,s,o,u,c,l;r(this,n),(i=t.call(this,e)).plainUrl="",i.fileName=null,i.mimeType=null,i.fileSize=0,i.thumbnails=[],i._requireAuth=!1,i.plainUrl=null!==(s=a.url)&&void 0!==s?s:"",i.fileName=null!==(o=a.file_name)&&void 0!==o?o:null,i.mimeType=null!==(u=a.file_type)&&void 0!==u?u:null,i.fileSize=null!==(c=a.file_size)&&void 0!==c?c:0,i._requireAuth=null!==(l=a.require_auth)&&void 0!==l&&l;var d=bi.of(i._iid).sessionManager;return i.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new qi(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(i._requireAuth?"?auth=".concat(d.ekey):"")}))})):[],i}return i(n,[{key:"url",get:function(){var e=bi.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return le(de({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}}]),n}(Za),Xi=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d;if(r(this,u),(i=a.call(this,t,n)).messageParams=null,i.fileInfoList=[],i.messageSurvivalSeconds=-1,i.messageType=e.MessageType.FILE,i.fileInfoList=null!==(o=null===(s=n.files)||void 0===s?void 0:s.map((function(e){return new Ji(t,e)})))&&void 0!==o?o:[],i.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var h=n.parent_message_info;i.parentMessage=es(t,le(de(Object.assign(Object.assign({},h),{created_at:h.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:h.file,url:null===(l=h.file)||void 0===l?void 0:l.url,require_auth:null===(d=h.file)||void 0===d?void 0:d.require_auth}))))}return i}return i(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Gi),n),ii(this.messageId>0&&R("number",e)&&ji(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Ji.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Hi),$i=function(t){switch(t.messageType){case e.MessageType.USER:return Zi.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?Xi.payloadify(t):ts.payloadify(t);case e.MessageType.ADMIN:return zi.payloadify(t);default:throw M.unknown}},es=function(e,t){switch(t.type){case"MESG":return new Zi(e,t);case"FILE":return Xi._isMultipleFilesMessagePayload(t)?new Xi(e,t):new ts(e,t);case"ADMM":case"BRDM":return new zi(e,t)}throw M.unknown},ts=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h,f,p,v,_,m,g,y,k;r(this,u),(i=a.call(this,t,n)).messageParams=null,i.plainUrl="",i.requireAuth=!1,i.thumbnails=[],i.messageSurvivalSeconds=-1,i.messageType=e.MessageType.FILE;var E=n.file;i.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:n.url)&&void 0!==o?o:"").split("?auth=")[0],i.name=null!==(l=null!==(c=null==E?void 0:E.name)&&void 0!==c?c:n.name)&&void 0!==l?l:"File",i.size=null!==(h=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==h?h:0,i.data=null!==(p=null!==(f=null==E?void 0:E.data)&&void 0!==f?f:n.custom)&&void 0!==p?p:"",i.type=E?null!==(v=E.type)&&void 0!==v?v:"":null!==(_=n.type)&&void 0!==_?_:"";var b=bi.of(i._iid).sessionManager;if(i.requireAuth=null!==(m=n.require_auth)&&void 0!==m&&m,i.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new qi(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(i.requireAuth?"?auth=".concat(b.ekey):"")}))})):[],i.messageSurvivalSeconds=null!==(g=n.message_survival_seconds)&&void 0!==g?g:-1,n.parent_message_info){var w=n.parent_message_info;i.parentMessage=es(t,le(de(Object.assign(Object.assign({},w),{created_at:w.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:w.file,url:null===(y=w.file)||void 0===y?void 0:y.url,require_auth:null===(k=w.file)||void 0===k?void 0:k.require_auth}))))}return i}return i(u,[{key:"url",get:function(){var e=bi.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Gi),n),ii(this.messageId>0&&R("number",e)&&ji(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){var t;return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Hi),ns=function(t){s(a,t);var n=f(a);function a(t){var i,s,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:le(de({channel_url:t.channelUrl,files:t.files?ss(t.files):null,url:t.url,name:null!==(i=t.fileName)&&void 0!==i?i:"",type:null!==(s=t.mimeType)&&void 0!==s?s:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage}))})}return i(a)}(pa),rs=function(t){s(a,t);var n=f(a);function a(t){var i,s,o;r(this,a),i=n.call(this);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),i.method=he.POST,i.path="".concat(Ie(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=le(de({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?ss(t.files):null,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(s=t.thumbnailSizes)||void 0===s?void 0:s.map((function(e){return qi.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return Mi.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),i}return i(a)}(De),as=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c,l;r(this,n),(s=t.call(this,e,"FILE",i)).message=i.files&&i.files.length>=2?new Xi(e,i):new ts(e,i);var d=bi.of(e).sdkState;return s.isMentioned=Ae(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return i(n)}(Ke),is=function(e){s(n,e);var t=f(n);function n(e,a){var i,s,o,u,c;r(this,n),(i=t.call(this,e,a)).message=a.files&&a.files.length>=2?new Xi(e,a):new ts(e,a);var l=bi.of(e).sdkState;return i.isMentioned=Ae(i.message.mentionType,null!==(u=null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:null===(o=i.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),i.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,i}return i(n)}(Re);function ss(e){return e.map((function(e){var t,n;return le(de({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return qi.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var os;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(os||(os={}));var us=function(){function e(t,n){var a=this,i=n.sdkState,s=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof ya&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return i(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===ha.CONNECTED||this._connectionState===ha.CONNECTING||this._connectionState===ha.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._createSendFileMessageRequestParams(e,n),!this._shouldSendThroughWebSocket){t.next=10;break}return i=new ns(a),t.next=5,this._requestQueue.send(i);case 5:return s=t.sent,o=s.as(as),u=o.message,t.abrupt("return",u);case 10:return c=new rs(Object.assign(Object.assign({},a),{userId:this._sdkState.userId})),t.next=13,this._requestQueue.send(c);case 13:return l=t.sent,d=l.as(is),h=d.message,t.abrupt("return",h);case 16:case"end":return t.stop()}}),r,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this._queueMap.get(e.url))){t.next=58;break}if(a.isResolving){t.next=57;break}a.isResolving=!0,i=[],s=!0,o=y(a.messageQueue),t.prev=7,o.s();case 9:if((u=o.n()).done){t.next=40;break}c=u.value,t.t0=c.state,t.next=t.t0===os.PENDING||t.t0===os.UPLOADING?14:t.t0===os.UPLOADED?17:t.t0===os.FAILED?35:38;break;case 14:return s=!1,i.push(c),t.abrupt("break",38);case 17:if(!s){t.next=33;break}return t.prev=18,c.state=os.SENDING,t.next=22,this._sendFileMessage(e,c);case 22:return l=t.sent,c.deferred.resolve(l),t.next=26,Ia(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),c.deferred.reject(t.t1);case 31:t.next=34;break;case 33:i.push(c);case 34:return t.abrupt("break",38);case 35:return d=null!==(n=c.error)&&void 0!==n?n:M.unknown,c.deferred.reject(d.code===b.REQUEST_CANCELED?M.fileUploadCanceled:d),t.abrupt("break",38);case 38:t.next=9;break;case 40:t.next=45;break;case 42:t.prev=42,t.t2=t.catch(7),o.e(t.t2);case 45:return t.prev=45,o.f(),t.finish(45);case 48:if(h=a.isResolveRequestPending,a.messageQueue=i,a.isResolving=!1,a.isResolveRequestPending=!1,!h){t.next=55;break}return t.next=55,this._resolveMessageQueue(e);case 55:t.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return t.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this._queueMap.get(e.url))){t.next=29;break}if(!(i=a.messageQueue.find((function(e){return e.state===os.PENDING})))){t.next=29;break}if(!i.multipleFileUploadInfo){t.next=18;break}if(s=i.multipleFileUploadInfo,o=s.uploadIndex,u=s.uploadCount,c=s.requestHandler,l=i.params,d=l.fileInfoList[o],!G(d.file)||(null===(n=d._uploadedMetaData)||void 0===n?void 0:n.isUploaded)){t.next=13;break}return t.next=11,this._tryUploadNextItemAndUpdateItemState(e,a,i);case 11:t.next=14;break;case 13:i.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,i,s;return E(this,void 0,void 0,t().mark((function o(){var u,c,l,d,h,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new Ci({file:r.file,channelUrl:e.url,thumbnailSizes:r.thumbnailSizes,requestId:n.requestId}),t.next=3,this._requestQueue.send(u);case 3:c=t.sent,l=c.as(xi),d=l.url,h=l.fileSize,f=void 0===h?r.fileSize:h,p=l.thumbnailSizes,v=void 0===p?r.thumbnailSizes:p,_=l.requireAuth,m=void 0!==_&&_,r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(i=r.mimeType)&&void 0!==i?i:r.file.type,r.fileSize=null!==(s=r.fileSize)&&void 0!==s?s:r.file.size,r.fileUrl=d,r.fileSize=f,r.thumbnailSizes=v,r.requireAuth=m;case 12:case"end":return t.stop()}}),o,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,n,r){var a,i,s;return E(this,void 0,void 0,t().mark((function o(){var u,c,l,d,h,f,p,v,_,m,g,y;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.multipleFileUploadInfo.uploadIndex,c=r.fileInfoList[u],l=new Ci({file:c.file,channelUrl:e.url,thumbnailSizes:c.thumbnailSizes,requestId:n.requestId}),t.next=5,this._requestQueue.send(l);case 5:d=t.sent,h=d.as(xi),f=h.url,p=h.fileSize,v=void 0===p?c.fileSize:p,_=h.thumbnailSizes,m=void 0===_?c.thumbnailSizes:_,g=h.requireAuth,y=void 0!==g&&g,c.fileName=null!==(a=c.fileName)&&void 0!==a?a:c.file.name,c.mimeType=null!==(i=c.mimeType)&&void 0!==i?i:c.file.type,c.fileSize=null!==(s=c.fileSize)&&void 0!==s?s:c.file.size,c.file=void 0,c.fileUrl=f,c.fileSize=v,c.thumbnailSizes=m,c._uploadedMetaData=Object.assign(Object.assign({},c._uploadedMetaData),{requireAuth:y,isUploaded:!0});case 15:case"end":return t.stop()}}),o,this)})))}},{key:"request",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return E(this,void 0,void 0,t().mark((function i(){var s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._queueMap.has(e.url)||(s={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,s)),o=this._queueMap.get(e.url),u=new _a,c={requestId:n,params:r,state:os.PENDING,deferred:u},cs(r)&&(l=r,d=Object.assign({uploadIndex:0,uploadCount:l.fileInfoList.length},a),c.multipleFileUploadInfo=d),o.messageQueue.push(c),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"cancel",value:function(e,t){var n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),i=y(a);try{for(i.s();!(r=i.n()).done;){var s=r.value;if(s)switch(s.state){case os.PENDING:if(s.state=os.FAILED,s.error=M.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){var o=s.multipleFileUploadInfo,u=o.uploadIndex,c=o.requestHandler,l=s.params.fileInfoList[u];null==c||c._triggerOnFileUploaded(s.requestId,u,l,M.fileUploadCanceled)}this._resolveMessageQueue(e);break;case os.UPLOADING:this._requestQueue.cancel(s.requestId)}}}catch(e){i.e(e)}finally{i.f()}}}}]),e}();function cs(e){return"fileInfoList"in e}var ls,ds={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},hs=function(t){return R("number",t.prevResultSize)&&R("number",t.nextResultSize)&&R("boolean",t.isInclusive)&&R("boolean",t.reverse)&&R("string",t.messageTypeFilter)&&L(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L(e.ReplyType,t.replyType)&&R("boolean",t.includeMetaArray)&&R("boolean",t.includeReactions)&&R("boolean",t.includeParentMessageInfo)&&R("boolean",t.includeThreadInfo)&&R("boolean",t.showSubchannelMessagesOnly)},fs={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ps=function(t){return L(e.ReplyType,t.replyType)&&R("boolean",t.includeReactions)&&R("boolean",t.includeMetaArray)&&R("boolean",t.includeParentMessageInfo)&&R("boolean",t.includeThreadInfo)};e.CollectionEventSource=void 0,(ls=e.CollectionEventSource||(e.CollectionEventSource={})).UNKNOWN="UNKNOWN",ls.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",ls.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",ls.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",ls.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",ls.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",ls.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",ls.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",ls.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",ls.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",ls.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",ls.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",ls.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",ls.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",ls.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",ls.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",ls.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",ls.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",ls.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",ls.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",ls.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",ls.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",ls.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",ls.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",ls.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",ls.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",ls.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",ls.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",ls.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",ls.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",ls.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ls.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ls.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",ls.REQUEST_CHANNEL="REQUEST_CHANNEL",ls.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",ls.REFRESH_CHANNEL="REFRESH_CHANNEL",ls.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",ls.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",ls.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",ls.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ls.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ls.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ls.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ls.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ls.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ls.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ls.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ls.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ls.REQUEST_MESSAGE="REQUEST_MESSAGE",ls.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ls.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ls.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ls.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ls.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ls.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ls.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ls.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ls.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ls.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ls.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ls.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ls.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var vs,_s=Object.assign({},e.CollectionEventSource),ms=function(t){return t.startsWith("EVENT_")||t.startsWith("LOCAL_MESSAGE_")||t===e.CollectionEventSource.SYNC_MESSAGE_FILL||t===e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.CollectionEventSource.SYNC_POLL_CHANGELOGS},gs=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.messages,s=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messages=i,a.source=s,a.isWebSocketEventComing=u,a}return i(n)}(ce),ys=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.messageIds,s=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messageIds=i,a.source=s,a.isWebSocketEventComing=u,a}return i(n)}(ce),ks=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.reqId,s=e.source;return r(this,n),(a=t.call(this)).reqId=i,a.source=s,a}return i(n)}(ce),Es=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.polls,s=e.source;return r(this,n),(a=t.call(this)).polls=i,a.source=s,a}return i(n)}(ce),bs=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.event,s=e.source;return r(this,n),(a=t.call(this)).event=i,a.source=s,a}return i(n)}(ce),ws=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.event,s=e.source;return r(this,n),(a=t.call(this)).event=i,a.source=s,a}return i(n)}(ce),Cs=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:d,include_poll_details:!0},a}return i(n)}(De),xs=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).message=a?es(e,Object.assign({},a)):null,i}return i(n)}(Re),Ts=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,d=e.isInclusive,h=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,k=e.includeThreadInfo,E=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,w=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=le(de({is_sdk:!0,prev_limit:c,next_limit:l,include:d,reverse:h,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:v,include_reply_type:_,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:k,include_parent_message_info:E,show_subchannel_message_only:b,include_poll_details:!0,checking_continuous_messages:w})),a}return i(n)}(De),Ss=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).messages=a.messages.map((function(t){return es(e,t)})),i}return i(n)}(Re),Is=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,d=e.includeReactions,h=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:d,include_thread_info:h,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return i(n)}(De),Ns=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return es(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return i(n)}(Re),As=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return i(n)}(De),Ms=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).message=a?es(e,Object.assign({},a)):null,i}return i(n)}(Re);e.RestrictionType=void 0,(vs=e.RestrictionType||(e.RestrictionType={})).MUTED="muted",vs.BANNED="banned";var Os=function(){function t(n){var a,i,s,o;r(this,t),this.restrictionType=null,L(e.RestrictionType,n.restriction_type)&&(this.restrictionType=n.restriction_type),this.description=null!==(a=n.description)&&void 0!==a?a:null,this.endAt=null!==(s=null!==(i=n.end_at)&&void 0!==i?i:n.muted_end_at)&&void 0!==s?s:-1,this.remainingDuration=null!==(o=n.remaining_duration)&&void 0!==o?o:-1}return i(t,null,[{key:"payloadify",value:function(e){return le(de({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}]),t}(),Us=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).restrictionInfo=new Os(a),i}return i(n,null,[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),Os.payloadify(e.restrictionInfo))))}}]),n}(oi),Ds=function(e){s(n,e);var t=f(n);function n(e,a){var i,s;return r(this,n),(i=t.call(this,e,a)).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return i(n)}(oi),Rs=function(){function t(){r(this,t),this._onPending=We,this._onFailed=We,this._onSucceeded=We}return i(t,[{key:"_trigger",value:function(t){switch(null==t?void 0:t.sendingStatus){case e.SendingStatus.PENDING:0===t.errorCode&&this._onPending(t);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(t)}}},{key:"_triggerFailed",value:function(t,n){switch(null==n?void 0:n.sendingStatus){case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),Ls={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},Ps=function(t){return R("string",t.data,!0)&&R("string",t.customType,!0)&&L(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(oi,t.mentionedUsers,!0)&&R("string",t.mentionedMessageTemplate,!0)&&F(Mi,t.metaArrays,!0)&&R("number",t.parentMessageId,!0)&&R("boolean",t.isReplyToChannel)&&L(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&R(Di,t.appleCriticalAlertOptions,!0)&&R("boolean",t.isPinnedMessage,!0)},Fs=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Hs=Object.assign(Object.assign({},Ls),{message:"",translationTargetLanguages:void 0,pollId:void 0});function qs(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:de(Object.assign(Object.assign({},t),{mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(t.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Gs,js=function(e){var t;return le(de({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},zs=function(e){return Ps(e)&&R("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&R("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Gs||(Gs={}));var Vs=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Bs=function(e){return e===Gs.BLOB||e===Gs.FILE},Qs=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Ks=Object.assign(Object.assign({},Ls),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1});function Ws(t){var n,r,a,i;return null!==(n=t.messageParams)&&void 0!==n?n:de(Object.assign(Object.assign({},t),{fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=t.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}))}var Ys,Zs=function(e,t){var n;return e.messageParams?(!e.url&&G(t)&&(e.messageParams.file=t),e.messageParams):le(de({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},Js=function(e){return Ps(e)&&(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return R("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Xs={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},$s=function(t){return R("string",t.data,!0)&&R("string",t.customType,!0)&&L(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(oi,t.mentionedUsers,!0)&&R("string",t.mentionedMessageTemplate,!0)&&F(Mi,t.metaArrays,!0)&&L(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&R(Di,t.appleCriticalAlertOptions,!0)},eo=Object.assign(Object.assign({},Xs),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),to=function(e){return $s(e)&&R("string",e.message,!0)&&F("string",e.translationTargetLanguages,!0)&&R("number",e.pollId,!0)},no=Object.assign({},Xs),ro=function(e){return $s(e)},ao=function(){function e(t,n){var a;r(this,e),this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return i(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return R("number",this.limit)&&this.limit>0}}]),e}(),io=function(t){s(a,t);var n=f(a);function a(e,t,i,s){var o;return r(this,a),(o=n.call(this,e,s)).channelUrl=t,o.channelType=i,o}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&R("string",this.channelUrl)&&L(e.ChannelType,this.channelType)}}]),a}(ao),so=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={token:o,limit:u},a}return i(n)}(De),oo=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).operators=a.operators.map((function(t){return new oi(e,t)})),i.token=a.next,i}return i(n)}(Re),uo=function(e){s(a,e);var n=f(a);function a(e,t,i,s){return r(this,a),n.call(this,e,t,i,s)}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=bi.of(this._iid),a=r.requestQueue,i=new so(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),e.next=9,a.send(i);case 9:return s=e.sent,o=s.as(oo),u=o.operators,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),a}(io),co=function(n){s(u,n);var a=f(u);function u(t,n,i,s){var o,c,l,d,h,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,i,s)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=s.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=s.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(d=s.customTypesFilter)&&void 0!==d?d:null,o.senderUserIdsFilter=null!==(h=s.senderUserIdsFilter)&&void 0!==h?h:null,o.replyType=null!==(f=s.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=s.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=s.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=s.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=s.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=s.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&R("boolean",this.reverse)&&L(e.MessageTypeFilter,this.messageTypeFilter)&&L(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&R("boolean",this.includeMetaArray)&&R("boolean",this.includeReactions)&&R("boolean",this.includeParentMessageInfo)&&R("boolean",this.includeThreadInfo)&&R("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=Hl.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,de({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw M.queryInProgress;case 16:e.next=19;break;case 18:throw M.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(io),lo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=he.GET,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={limit:o,token:u},a}return i(n)}(De),ho=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).mutedUsers=[];var s=a.next,o=a.muted_list;return i.token=s,o&&o.length>0&&(i.mutedUsers=o.map((function(t){return new Us(e,t)}))),i}return i(n)}(Re),fo=function(e){s(a,e);var n=f(a);function a(e,t,i,s){return r(this,a),n.call(this,e,t,i,s)}return i(a,[{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new lo(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(ho),o=s.mutedUsers,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(io),po=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=he.GET,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=le({limit:o,token:u}),a}return i(n)}(De),vo=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Us(e,t.user)}))),i}return i(n)}(Re),_o=function(e){s(a,e);var n=f(a);function a(e,t,i,s){return r(this,a),n.call(this,e,t,i,s)}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new po(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(vo),o=s.bannedUsers,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(io);e.ReportCategory=void 0,(Ys=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",Ys.HARASSING="harassing",Ys.SUSPICIOUS="suspicious",Ys.INAPPROPRIATE="inappropriate";var mo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=he.POST,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return i(n)}(De),go=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return i(n)}(De),yo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=he.GET,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return i(n)}(De),ko=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).isMuted=!1,i.startAt=0,i.endAt=0;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return i(n)}(Re),Eo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=t.call(this)).method=he.GET,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return i(n)}(De),bo=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return i(n)}(Re),wo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=t.call(this)).method=he.POST,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return i(n)}(De),Co=function(e){s(n,e);var t=f(n);function n(e,a){var i,s,o;return r(this,n),(i=t.call(this,e,a)).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return i(n)}(Re),xo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=he.PUT,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return i(n)}(De),To=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=o,i}return i(n)}(Re),So=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),s=t.call(this,e,"SYEV",i),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return i(n)}(Ke),Io=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return i(n)}(De),No=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.ts;return i.ts=s,i}return i(n)}(Re),Ao=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return i(n)}(De),Mo=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.ts;return i.ts=s,i}return i(n)}(Re),Oo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=t.call(this)).method=he.GET,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return i(n)}(De),Uo=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).metaCounter=a,i}return i(n)}(Re),Do=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=he.POST,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return i(n)}(De),Ro=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).metaCounter=a,i}return i(n)}(Re),Lo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,d=void 0===l?"set":l;return(a=t.call(this)).method=he.PUT,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:d},a}return i(n)}(De),Po=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).metaCounter=a,i}return i(n)}(Re),Fo=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),s=t.call(this,e,"SYEV",i),i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return i(n)}(Ke),Ho=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params={},a}return i(n)}(De),qo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={},a}return i(n)}(De),Go=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=he.POST,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return i(n)}(De),jo=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).user=new Us(e,i.data),s}return i(n)}(Ke),zo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return i(n)}(De),Vo=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).user=new Us(e,i.data),s}return i(n)}(Ke),Bo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=he.POST,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=le({user_id:o,seconds:u,description:c}),a}return i(n)}(De),Qo=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).user=new Us(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return i(n)}(Ke),Ko=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return i(n)}(De),Wo=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).user=new Us(e,i.data),s}return i(n)}(Ke),Yo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=t.call(this)).method=he.PUT,a.path="".concat(Ie(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return i(n)}(De),Zo=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).freeze=i.data.freeze,s}return i(n)}(Ke),Jo=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=he.POST,a.path="".concat(Ne(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return i(n)}(De),Xo=function(t){s(a,t);var n=f(a);function a(t){var i;r(this,a);var s=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,d=t.description;return(i=n.call(this)).method=he.POST,i.path="".concat(Ee,"/users/").concat(l),i.params={channel_url:s,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:d},i}return i(a)}(De),$o=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,d=e.description;return(a=t.call(this)).method=he.POST,a.path="".concat(Ne(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:d,offending_user_id:c},a}return i(n)}(De),eu=function(t){s(a,t);var n=f(a);function a(t){r(this,a);var i=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:le(de({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage}))})}return i(a)}(pa),tu=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c,l;r(this,n),(s=t.call(this,e,"MESG",i)).message=new Zi(e,i);var d=bi.of(e).sdkState;return s.isMentioned=Ae(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return i(n)}(Ke),nu=function(t){s(a,t);var n=f(a);function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:le(de({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})}return i(a)}(pa),ru=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c,l,d;r(this,n),(s=t.call(this,e,"MEDI",i)).message=new Zi(e,i);var h=bi.of(e).sdkState;return s.mentionCountChange=Me({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},de({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return i(n)}(Ke),au=function(t){s(a,t);var n=f(a);function a(t){r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:le(de({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,apple_critical_alert_options:t.appleCriticalAlertOptions}))})}return i(a)}(pa),iu=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c,l,d;r(this,n),(s=t.call(this,e,"FEDI",i)).message=new ts(e,i);var h=bi.of(e).sdkState;return s.mentionCountChange=Me({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},de({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return i(n)}(Ke),su=function(e){s(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return i(n)}(De),ou=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"DELM",i)).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s}return i(n)}(Ke),uu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return i(n)}(De),cu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).reactionEvent=new Ni(a),i}return i(n)}(Re),lu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return i(n)}(De),du=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).reactionEvent=new Ni(Object.assign({},a)),i}return i(n)}(Re),hu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return i(n)}(De),fu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).message=new Zi(e,a),i}return i(n)}(Re),pu=function(t){s(a,t);var n=f(a);function a(t){var i,s;r(this,a),i=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return i.method=he.POST,i.path="".concat(Ie(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=le(de({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:J.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return i(a)}(De),vu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).message=new Zi(e,a),i}return i(n)}(Re),_u=function(t){s(a,t);var n=f(a);function a(t){var i,s;r(this,a),i=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return i.method=he.POST,i.path="".concat(Ie(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=de({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:J.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return qi.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return i(a)}(De),mu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).message=new ts(e,a),i}return i(n)}(Re),gu=function(e){return R("string",e.title,!0)&&Ki(e.data)&&R("boolean",e.allowUserSuggestion,!0)&&R("boolean",e.allowMultipleVotes,!0)&&R("number",e.closeAt,!0)},yu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return i(n)}(De),ku=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).poll=new Yi(e,a),i}return i(n)}(Re),Eu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.pollId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return i(n)}(De),bu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.pollId;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/close"),a}return i(n)}(De),wu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).poll=new Yi(e,a),i}return i(n)}(Re),Cu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(Ce,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return i(n)}(De),xu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).poll=new Yi(e,a),i}return i(n)}(Re),Tu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return i(n)}(De),Su=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).poll=new Yi(e,a),i}return i(n)}(Re),Iu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.pollId,s=e.pollOptionId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return i(n)}(De),Nu=function(t){s(a,t);var n=f(a);function a(t){var i=t.reqId,s=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:le({req_id:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return i(a)}(pa),Au=i((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),Mu=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"VOTE",i)).event=new Au(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return i(n)}(Ke),Ou=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=he.POST,a.path=Ce,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return i(n)}(De),Uu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).poll=new Yi(e,a),i}return i(n)}(Re),Du=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return i(n)}(De),Ru=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).poll=new Yi(e,a),i}return i(n)}(Re),Lu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return i(n)}(De),Pu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).pollOption=new Wi(e,a),i}return i(n)}(Re),Fu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=le({change_ts:o,token:u}),a}return i(n)}(De),Hu=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return new Yi(e,t)}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return i(n)}(Re),qu={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Gu=function(e){return R("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Ki(e.data)&&R("boolean",e.allowUserSuggestion,!0)&&R("boolean",e.allowMultipleVotes,!0)&&R("number",e.closeAt,!0);var t},ju={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},zu=function(t){return R("string",t.channelUrl)&&""!==t.channelUrl&&L(e.ChannelType,t.channelType)&&R("number",t.pollId)&&t.pollId>0&&R("number",t.pollOptionId)&&t.pollOptionId>0},Vu={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},Bu=function(t){return R("string",t.channelUrl)&&""!==t.channelUrl&&L(e.ChannelType,t.channelType)&&R("number",t.pollId)},Qu={},Ku=function(){function n(e,t){var a=t.sdkState,i=t.dispatcher,s=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,Qu[e]=this}return i(n,[{key:"buildPollFromSerializedData",value:function(e){var t=ai(e);return new Yi(this._iid,Yi.payloadify(t))}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(Bu(e)).throw(M.invalidParameters),r=new Du(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,i=a.as(Ru),s=i.poll,t.abrupt("return",s);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(Gu(e)).throw(M.invalidParameters),r=new Ou(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,i=a.as(Uu),s=i.poll,t.abrupt("return",s);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(zu(e)).throw(M.invalidParameters),r=new Lu(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,i=a.as(Pu),s=i.pollOption,t.abrupt("return",s);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,t().mark((function e(){var s,o,u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Fu(de({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Hu),c=u.updatedPolls,l=u.deletedPollIds,d=u.hasMore,h=u.nextToken,c.length>0&&this._dispatcher.dispatch(new Es({polls:c,source:i})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:d,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Qu[e]}}]),n}(),Wu="GroupChannel",Yu="Message",Zu=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=he.GET,a.path=Ce,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return i(n)}(De),Ju=function(e){s(n,e);var t=f(n);function n(e,a){var i,s;return r(this,n),(i=t.call(this,e,a)).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new Yi(e,t)})),i.token=a.next,i}return i(n)}(Re),Xu=function(e){s(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return i(a,[{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new Zu(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Ju),o=s.polls,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(io),$u=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return i(n)}(De),ec=function(e){s(n,e);var t=f(n);function n(e,a){var i,s;return r(this,n),(i=t.call(this,e,a)).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new oi(e,t)})),i.token=a.next,i}return i(n)}(Re),tc=function(e){s(a,e);var n=f(a);function a(e,t){var i;return r(this,a),(i=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,i.pollOptionId=t.pollOptionId,i}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&R("number",this.pollId)&&R("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new $u(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(ec),o=s.voters,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(io);var nc,rc=Object.assign(Object.assign({},Ls),{fileInfoList:[]}),ac=function(e){return(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},ic=function(e){s(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=We,e}return i(n,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(o(n.prototype),"onPending",this).call(this,e),this}},{key:"onFailed",value:function(e){return p(o(n.prototype),"onFailed",this).call(this,e),this}},{key:"onSucceeded",value:function(e){return p(o(n.prototype),"onSucceeded",this).call(this,e),this}}]),n}(Rs);!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(nc||(nc={}));var sc,oc=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h;return r(this,u),(i=a.call(this,t))._name="",i._createdAt=0,i.channelType=e.ChannelType.BASE,i.coverUrl="",i.customType="",i.data="",i.isFrozen=!1,i.isEphemeral=!1,i.creator=null,i._messageCollectionLastAccessedAt=0,i._url=n.channel_url,i._name=null!==(s=n.name)&&void 0!==s?s:"",i._createdAt=1e3*n.created_at,i.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",i.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",i.data=null!==(l=n.data)&&void 0!==l?l:"",i.isFrozen=null!==(d=n.freeze)&&void 0!==d&&d,i.isEphemeral=null!==(h=n.is_ephemeral)&&void 0!==h&&h,i.creator=n.created_by?new oi(i._iid,n.created_by):null,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(i._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){i._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),i}return i(u,[{key:"url",get:function(){return this._url}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"createdAt",get:function(){return this._createdAt}},{key:"toJSON",value:function(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}},{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"isFeedChannel",value:function(){return this.channelType===e.ChannelType.FEED}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=le(e);Object.assign(this,t)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_updateCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData?this._cachedMetaData.forEach((function(r,a){var i;r.updatedAt<=t&&n._cachedMetaData.set(a,{value:null!==(i=e[a])&&void 0!==i?i:r.value,isRemoved:!e[a],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new uo(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fo(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _o(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new co(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new mo({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new go({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new yo({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(ko),u=o.isMuted,c=o.startAt,l=o.endAt,d=o.remainingDuration,h=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:d,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new Eo({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(bo),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Eo({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(bo),o=s.metadata,u=s.ts,this._updateCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.requestQueue,i=new wo({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Co),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=bi.of(this._iid),i=a.requestQueue,s=new xo({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,i.send(s);case 4:return o=t.sent,u=o.as(To),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new Io({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(i);case 5:s=t.sent,o=s.as(No),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Ao({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:i=e.sent,s=i.as(Mo),o=s.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new Oo({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Uo),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Oo({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Uo),o=s.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.requestQueue,i=new Do({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Ro),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=bi.of(this._iid),i=a.requestQueue,s=new Lo({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,i.send(s);case 4:return o=t.sent,u=o.as(Po),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.requestQueue,i=new Lo({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Po),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.requestQueue,i=new Lo({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Po),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new Ho({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new qo({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)&&R("number",n,!0)&&R("string",r,!0)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new Go({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,s.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new zo({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)&&R("number",n,!0)&&R("string",r,!0)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new Bo({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,s.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new Ko({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Yo({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Yo({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ds),n),ii(R("number",e)&&hs(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ds),n),ii(R("number",e)&&hs(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},fs),n),ii(R("number",e)&&ps(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},fs),n),ii(R("string",e)&&ps(a)).throw(M.invalidParameters),i=Hl.of(this._iid),t.next=5,i.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,i=bi.of(this._iid).sessionManager;return le(de({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return Mi.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:i.currentUser?Ri.payloadify(i.currentUser):null,req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return oi.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,s=y(t.translationTargetLanguages);try{for(s.s();!(i=s.n()).done;){a[i.value]=""}}catch(e){s.e(e)}finally{s.f()}}var o=le(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new Zi(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a,i,s,o,u,c,l=le(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(a=t.fileName)&&void 0!==a?a:null===(i=t.file)||void 0===i?void 0:i.name,size:null!==(s=t.fileSize)&&void 0!==s?s:null===(o=t.file)||void 0===o?void 0:o.size,type:null!==(u=t.mimeType)&&void 0!==u?u:null===(c=t.file)||void 0===c?void 0:c.type,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),d=new ts(this._iid,l);return d.messageParams=t,d}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=le(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE})),i=new Xi(this._iid,a);return i.messageParams=t,i}},{key:"_validateFailedFileMessageHasFile",value:function(e,t){var n;return Boolean(e.url)||G(t)||G(null===(n=e.messageParams)||void 0===n?void 0:n.file)}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===b.REQUEST_CANCELED||n.code===b.FILE_UPLOAD_CANCEL_FAILED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},Hs),e);return ii(zs(t)).throw(M.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nc.SEND,i=arguments.length>2?arguments[2]:void 0,s=bi.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=null!=i?i:this._generateRequestId(),l=Date.now(),d=new Rs;return Ia(2).then((function(){var i=r._createPendingUserMessage(n,c,l);o.dispatch(new gs({messages:[i],source:a===nc.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",d._trigger(i));case 1:case"end":return e.stop()}}),e)})))}));var s=new eu(Object.assign(Object.assign({},n),{channelUrl:r.url,channelType:r.channelType,reqId:c}));u.send(s).then((function(n){var a=n.as(tu).message;o.dispatch(new gs({messages:[a],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",d._trigger(a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;Ia(2).then((function(){var i=r._createPendingUserMessage(n,c,l),s=bi.of(r._iid).cacheContext.localCacheEnabled&&q(a.code);r._markMessageAsFailed(i,a,s),o.dispatch(new gs({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",d._triggerFailed(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),d}},{key:"_autoResendUserMessage",value:function(e){return ii(e instanceof Zi&&!!e.messageParams).throw(M.invalidParameters),this._sendUserMessage(e.messageParams,nc.SEND,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e instanceof Zi&&!e.scheduledInfo).throw(M.invalidParameters),a=new _a,i=null!==(n=e.messageParams)&&void 0!==n?n:js(e),this._sendUserMessage(i,nc.RESEND,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},eo),n),ii(R("number",e)&&to(a)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new nu(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,s.send(o);case 6:return u=t.sent,c=u.as(ru),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,i,s;return E(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(n instanceof u&&r instanceof Zi&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),ii(!r.poll).throw(M.notSupportedError),c=new _a,l=null!==(a=r.messageParams)&&void 0!==a?a:de(Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(i=r.mentionedUserIds)&&void 0!==i?i:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e instanceof Zi&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new hu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(fu),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=bi.of(this._iid).requestQueue,i=Date.now(),s=this._generateRequestId();Ia(2).then((function(){var a=r._createPendingScheduledUserMessage(e,s,i);Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new pu(Object.assign({reqId:s,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(vu).message;Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;Ia(2).then((function(){var o=r._createPendingScheduledUserMessage(e,s,i);r._markMessageAsFailed(o,a),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Ks),e);return ii(Js(t)).throw(M.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},rc),e),r=bi.of(this._iid);ii(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return Ps(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ac(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(M.invalidParameters);var a=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return ii(!a).throw(M.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nc.SEND,i=arguments.length>2?arguments[2]:void 0,s=bi.of(this._iid).dispatcher,o=Hl.of(this._iid).fileMessageQueue,u=null!=i?i:this._generateRequestId(),c=Date.now(),l=new Rs;return Ia(2).then((function(){var i=r._createPendingFileMessage(n,u,c);s.dispatch(new gs({messages:[i],source:a===nc.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(i));case 1:case"end":return e.stop()}}),e)})))})),o.request(r,u,n).then((function(n){s.dispatch(new gs({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;Ia(2).then((function(){var i=r._createPendingFileMessage(n,u,c),o=bi.of(r._iid).cacheContext.localCacheEnabled&&q(a.code);r._markMessageAsFailed(i,a,o),s.dispatch(new gs({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.CollectionEventSource.REQUEST_RESEND_MESSAGE:a.code===b.FILE_UPLOAD_CANCEL_FAILED?e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Ma((function(){return E(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_autoResendFileMessage",value:function(e){ii(e instanceof ts&&!!e.messageParams).throw(M.invalidParameters);var t=bi.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,nc.SEND,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(n,r,a){var i=this,s=bi.of(this._iid).dispatcher,o=Hl.of(this._iid).fileMessageQueue,u=null!=a?a:this._generateRequestId(),c=Date.now(),l=new ic;return Ia(2).then((function(){var a=i._createPendingMultipleFilesMessage(n,u,c);s.dispatch(new gs({messages:[a],source:r===nc.RESEND?e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a));case 1:case"end":return e.stop()}}),e)})))})),o.request(i,u,n,{requestHandler:l,isCopy:r===nc.COPY}).then((function(n){s.dispatch(new gs({messages:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(A(r))throw r;Ia(2).then((function(){var a=i._createPendingMultipleFilesMessage(n,u,c);i._markMessageAsFailed(a,r),s.dispatch(new gs({messages:[a],source:e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._triggerFailed(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var i=this,s=bi.of(this._iid).requestQueue,o=new _u(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));s.send(o).then((function(e){var r=e.as(mu).message;Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(s){if(A(s))throw s;Ia(2).then((function(){var o=i._createPendingScheduledFileMessage(e,r,a);i._markMessageAsFailed(o,s),Ma((function(){return E(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._triggerFailed(s,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ii(e.every((function(e){return Js(Object.assign(Object.assign({},Ks),e))}))).throw(M.invalidParameters);var t,n=new Rs,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(e)})).onFailed((function(e,t){return n._triggerFailed(e,t)})).onSucceeded((function(e){return n._trigger(e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=this._validateFailedFileMessageHasFile(e,n),ii(e instanceof ts&&a&&!e.scheduledInfo).throw(M.invalidParameters),i=new _a,s=Zs(e,n),this._sendFileMessage(s,nc.RESEND,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"resendMessage",value:function(e,t){var n,r;if(ii(e instanceof Hi&&!e.scheduledInfo&&e.isResendable).throw(M.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:js(e);return this._sendUserMessage(a,nc.RESEND,e.reqId)}if(e.isFileMessage()){var i=this._validateFailedFileMessageHasFile(e,t);ii(i).throw(M.invalidParameters);var s=null!==(r=e.messageParams)&&void 0!==r?r:Zs(e,t);return this._sendFileMessage(s,nc.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw M.channelTypeNotSupportedError}},{key:"updateFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},no),n),ii(R("number",e)&&ro(a)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new au(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,s.send(o);case 6:return u=t.sent,c=u.as(iu),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=Hl.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,i,s;return E(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(n instanceof u&&r instanceof ts&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),c=new _a,l=de(Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(s=r.thumbnails)||void 0===s?void 0:s.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1})),n._sendFileMessage(l).onSucceeded((function(e){return c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 5:case"end":return t.stop()}}),o,this)})))}},{key:"copyMessage",value:function(t,n){ii(t instanceof u&&n instanceof Hi&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(M.invalidParameters);var r=n,a=t;if(r.isUserMessage()){ii(!r.poll).throw(M.notSupportedError);var i=qs(r);return a._sendUserMessage(i)}if(r.isFileMessage()){var s=Ws(r);return a._sendFileMessage(s)}if(n.isMultipleFilesMessage())throw M.channelTypeNotSupportedError}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ii(e instanceof Fi).throw(M.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=bi.of(this._iid),a=r.requestQueue,i=new su({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e instanceof Fi&&e.messageId>0&&R("string",n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new uu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(cu),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e instanceof Fi&&e.messageId>0&&R("string",n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new lu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(du),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,i){return E(this,void 0,void 0,t().mark((function s(){var o,u,c,l,d,h,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=bi.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new nu({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:i}}),t.next=4,c.send(l);case 4:return d=t.sent,h=d.as(ru),f=h.message,u.dispatch(new gs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,i){return E(this,void 0,void 0,t().mark((function s(){var o,u,c,l,d,h,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=bi.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new au({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:i}}),t.next=4,c.send(l);case 4:return d=t.sent,h=d.as(iu),f=h.message,u.dispatch(new gs({messages:[f],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ii(e instanceof Fi&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new Mi({key:e})})),!(e instanceof ts)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ii(e instanceof Fi&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new Mi({key:e})})),!(e instanceof ts)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ii(e instanceof Fi&&e.messageId>0&&n.every((function(e){return e instanceof Mi}))).throw(M.invalidParameters),!(e instanceof ts)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ii(e instanceof Fi&&e.messageId>0&&n.every((function(e){return e instanceof Mi}))).throw(M.invalidParameters),!(e instanceof ts)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(L(e.ReportCategory,n)&&R("string",r)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Jo({channelUrl:this.url,channelType:this.channelType,userId:s.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return E(this,void 0,void 0,t().mark((function i(){var s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(n instanceof oi&&L(e.ReportCategory,r)&&R("string",a)).throw(M.invalidParameters),s=bi.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new Xo({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),i,this)})))}},{key:"reportMessage",value:function(n,r,a){return E(this,void 0,void 0,t().mark((function i(){var s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(n instanceof Hi&&L(e.ReportCategory,r)&&R("string",a)).throw(M.invalidParameters),s=bi.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new $o({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),i,this)})))}},{key:"updatePoll",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("number",e)&&gu(n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new yu(Object.assign({pollId:e},n)),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(ku),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=R("number",e),ii(r).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new Eu({pollId:e}),t.next=6,i.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=R("number",e),ii(r).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new bu({pollId:e}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(wu),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=R("number",e)&&R("string",n)&&""!==n.trim(),ii(a).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new Cu({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,s.send(o);case 6:return u=t.sent,c=u.as(xu),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=R("number",e)&&R("number",n)&&R("string",r)&&""!==r.trim(),ii(i).throw(M.invalidParameters),s=bi.of(this._iid),o=s.requestQueue,u=new Tu({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Su),d=l.poll,t.abrupt("return",d);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=R("number",e)&&R("number",n),ii(a).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new Iu({pollId:e,pollOptionId:n}),t.next=6,s.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=R("number",n)&&F("number",r),ii(i).throw(M.invalidParameters),s=bi.of(this._iid),o=s.requestQueue,u=s.dispatcher,c=new Nu({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,d=l.as(Mu),h=d.event,u.dispatch(new ws({event:h,source:e.CollectionEventSource.EVENT_POLL_VOTED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("number",e)).throw(M.invalidParameters),r=Ku.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e,!0)),r=Ku.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new Xu(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new tc(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?oi.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}}]),u}(Za),uc=i((function e(t){r(this,e),this.key=t.key,this.url=t.url})),cc=i((function e(t){r(this,e),this.id=t.id,this.name=t.name,this.url=t.url,this.emojis=t.emojis?t.emojis.map((function(e){return new uc(e)})):[]})),lc=i((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new cc(e)})):[]})),dc=function(e){s(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return i(n)}(i((function e(){r(this,e),this.onConnected=We,this.onReconnectStarted=We,this.onReconnectSucceeded=We,this.onReconnectFailed=We,this.onDisconnected=We}))),hc=function(e){s(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return i(n)}(i((function e(){r(this,e),this.onSessionExpired=We,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=We,this.onSessionRefreshed=We,this.onSessionClosed=We}))),fc=function(e){s(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return i(n)}(i((function e(){r(this,e),this.onFriendsDiscovered=We,this.onTotalUnreadMessageCountChanged=We,this.onTotalUnreadMessageCountUpdated=We}))),pc=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=he.GET,a.path=pe,a.params=le({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return i(n)}(De),vc=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).users=a.users.map((function(t){return new oi(e,t)})),i.next=a.next,i}return i(n)}(Re),_c=function(e){s(a,e);var n=f(a);function a(e,t){var i,s,o,u;return r(this,a),(i=n.call(this,e,t)).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,i}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&R("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&R("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new pc(de(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(vc),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ao),mc=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(i,"/block"),a.params=le({limit:s,token:o,user_ids:u}),a}return i(n)}(De),gc=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).users=a.users.map((function(t){return new oi(e,t)})),i.next=a.next,i}return i(n)}(Re),yc=function(e){s(a,e);var n=f(a);function a(e,t){var i,s;return r(this,a),(i=n.call(this,e,t)).userIdsFilter=null,i.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null,i}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new mc(de(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token}))),e.next=8,a.send(i);case 8:return s=e.sent,o=s.as(gc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ao),kc=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return i(n)}(De),Ec=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).hasMore=a.has_more,i.users=a.users.map((function(t){return new oi(e,t)})),i.next=a.next,i}return i(n)}(Re),bc=function(e){s(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new kc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(i);case 8:return s=e.sent,o=s.as(Ec),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ao),wc={},Cc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,d=void 0===l?10:l,h=t.blockHashConstant,f=void 0===h?11:h,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),wc[n]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=d,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,wc[n]=this),wc[n]}return i(e,null,[{key:"get",value:function(e){return wc[e]}}]),e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(sc||(sc={}));var xc,Tc=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.code,s=void 0===i?sc.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=s,Object.setPrototypeOf(h(a),n.prototype),a}return i(n,null,[{key:"storeNotDefined",get:function(){return new n({code:sc.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:sc.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:sc.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:sc.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:sc.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:sc.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:sc.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:sc.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:sc.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:sc.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:sc.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:sc.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:sc.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:sc.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:sc.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:sc.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:sc.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:sc.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:sc.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:sc.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:sc.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:sc.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:sc.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:sc.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:sc.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(d(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(xc||(xc={}));var Sc,Ic=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw Tc.circularReferenceFound;var a;if(r.set(t,!0),Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var i in a={},t)a[i]=e(t[i],r);return r.delete(t),a}return t},Nc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Tc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Ac=function(e,t){for(var n=0,r=0;r>>0)%t},Mc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Oc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var i=a;if("object"===n(t[i])){var s=t[i];for(var o in s)switch(o){case"/eq":case"=":if(r[i]!==s[o])return!1;break;case"/neq":case"!=":if(r[i]===s[o])return!1;break;case"/gt":case">":var u=r[i],c=s[o];if(!(Nc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[i],d=s[o];if(!(Nc(l,d)>=0))return!1;break;case"/lt":case"<":var h=r[i],f=s[o];if(!(Nc(h,f)<0))return!1;break;case"/lte":case"<=":var p=r[i],v=s[o];if(!(Nc(p,v)<=0))return!1;break;case"/in":var _=r[i];if(!s[o].includes(_))return!1;break;case"/nin":var m=r[i];if(s[o].includes(m))return!1;break;case"/contain":var g=r[i],y=s[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[i];if(!s[o].test(k))return!1;break;case"/where":var E=r[i];if(!(0,s[o])(E))return!1}}else if("function"==typeof t[i]){if(!t[i](r[i]))return!1}else if(t[i]!==r[i])return!1}}return!0}return t(r)},Uc=function(){},Dc=function(){return Promise.resolve()},Rc=function(e){return e},Lc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Sc||(Sc={}));var Pc,Fc,Hc,qc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Rc:u,l=t.backward,d=void 0===l?Dc:l,h=t.forward,f=void 0===h?Dc:h,p=t.complete,v=void 0===p?Uc:p;r(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=d,this._forward=f,this._iterator=o,this._complete=v}return i(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),Gc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}return i(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"===n(this.condition[s])){var u=o>0?r:t;for(var c in this.condition[s])if(u.includes(c))for(var l=a;l>=0;l--)if(o*Nc(this._indexer.origin[l].columnValues[i],this.condition[s][c])<=0){a=l;break}}else for(var d=a;d>=0;d--)if(o*Nc(this._indexer.origin[d].columnValues[i],this.condition[s])<=0){a=d;break}}return Math.min(a+1,this._indexer.origin.length-1)}var h=0;if("function"!=typeof this.condition)for(var f=function(a){var i=e._indexer.fields[a],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),e.condition[i])if("object"===n(e.condition[i]))Object.keys(e.condition[i]).forEach((function(n){if((s>0?t:r).includes(n))for(var o=h;o=0){h=o;break}}));else for(var o=h;o=0){h=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw Tc.collectionQueryNotValid;case 8:return n.prev=8,i=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return E(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(i.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Kc(e,t)).concat(n,".").concat(r)},Yc=function(){function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=i}return i(e,[{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,i=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return s=t.sent,t.next=11,s.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Wc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,i=a.blobId,s=a.data,o=a.type,t.next=8,this.store.set({key:i,value:{data:s,type:o}});case 8:return t.abrupt("return",i);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Kc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return E(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Pc||(Pc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Fc||(Fc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hc||(Hc={}));var Zc,Jc,Xc=[Fc.PENDING,Fc.VOLATILE],$c={},el=function(){function e(t){var n=t.dbname,a=t.limit,i=void 0===a?256:a;return r(this,e),$c[n]||(this.dbname=n,this._items=[],this._limit=i,$c[n]=this),$c[n]}return i(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Hc.DEFAULT;return E(this,void 0,void 0,t().mark((function a(){var i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(s=t.sent)&&(i={key:n,value:s,state:r===Hc.PERSISTENT?Fc.PERSISTENT:Fc.VOLATILE},this.put(i)),t.next=9;break;case 8:r===Hc.PERSISTENT&&(i.state=Fc.PERSISTENT);case 9:return t.abrupt("return",i);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Hc.PERSISTENT&&(r.state=Fc.PERSISTENT),t!==Hc.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)Xc.includes(this._items[t].state)&&Xc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Fc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],s=y(this._items);try{for(s.s();!(a=s.n()).done;){var o=a.value;o.state===Fc.VOLATILE&&r>0?r--:i.push(o)}}catch(e){s.e(e)}finally{s.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Fc.VOLATILE}))}}],[{key:"get",value:function(e){return $c[e]}}]),e}(),tl=function(){function e(t){var n=t.dbname,a=t.collectionName,i=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Vc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Vc(e,t),"/trans.recordset")}(n,a),this._store=i}return i(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=el.get(this.dbname),i=n.generation,s=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(s.map((function(e){return Object.assign(Object.assign({},e.data),{generation:i})})));case 6:for(u=t.sent,c=0;c0)){e.next=20;break}for(r=[],a={},i=n.length-1;i>=0;i--)s=n[i],o=s.data,a[o.key]||(a[o.key]=!0,r.unshift(s));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(l=el.get(this.dbname),d=0;d1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=i,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Ac)(e,r)}(e,i,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Qc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=el.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return i=this.createBlockId(e,a),t.next=6,r.find(this._store,i);case 6:if(!(s=t.sent)){t.next=12;break}if(o=nl.createFromCacheItem(s),!(null==o?void 0:o.getItemByKey(e))){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Cc.get(this.dbname),i=this.createBlockId(e),s=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=el.get(this.dbname),t.next=6,o.find(this._store,i);case 6:if(u=t.sent,!(null==(c=u?nl.createFromCacheItem(u):new nl({blockId:i,keyName:this.keyName,items:[],limit:s}))?void 0:c.add(n))){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Qc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:el.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),al={},il=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Vc(e,t),"/index.").concat(n)}(a,i,o.join(">"));return al[l]||(this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Pc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Pc.ERROR,this.indexerKey,(function(){return n.abort()}))),al[l]}return i(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,i=[],s=y(this.fields);try{for(s.s();!(t=s.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Tc.indexTypesNotMatch;i.push(e[o])}}catch(e){s.e(e)}finally{s.f()}return i}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Nc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c,l,d,h,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=el.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Hc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Qc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:i=e.sent,s=y(i),e.prev=10,s.s();case 12:if((o=s.n()).done){e.next=22;break}if(!(u=o.value).startsWith(a)){e.next=20;break}return e.next=17,n.find(this._store,u,Hc.NO_CACHE);case 17:if(c=e.sent,l=nl.createFromCacheItem(c)){d=y(l.items);try{for(d.s();!(h=d.n()).done;)f=h.value,this._addItem(f)}catch(e){d.e(e)}finally{d.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),s.e(e.t0);case 27:return e.prev=27,s.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=r.value,this._table=Ic(this._origin);case 35:al[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return el.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete al[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Ic(this._origin)}},{key:"abort",value:function(){this._table=Ic(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in al)delete al[e]}}]),e}(),sl=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ol=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Zc||(Zc={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Jc||(Jc={}));var ul,cl={},ll=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Zc.PROCESSING,this._queue=[],this._activationQueue=[],cl[t]&&!a.forceCreate||(this.nodeId=ol(),this.key=t,sl()&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,r=t.nodeId,a=t.requestId,i=t.key,s=t.op,o=t.data;if(r!==n.nodeId&&i===n.key)switch(s){case Jc.NEWNODE:n._sendSync();break;case Jc.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Jc.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var d=function(){var e=u.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Jc.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)d()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Jc.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Jc.REQUEST_LOCK:n._requestLock(t);break;case Jc.ACQUIRE_LOCK:var h=n._queue.find((function(e){return e.requestId===a}));n._acquire(h);break;case Jc.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Jc.REMOVENODE)}))),cl[t]=this),cl[t]}return i(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Zc.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:ol(),key:this.key,op:e,data:n.data,ts:Date.now()};return sl()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Jc.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Jc.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var i in t._queue)if(t._queue[i].ts>r.ts){t._queue.splice(parseInt(i),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Jc.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Zc.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Jc.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Jc.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Jc.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}]),e}(),dl=function(){function e(t){var n=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=xc.INIT,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(_(u.filter((function(e){return il.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new ll(function(e,t){return"".concat(Vc(e,t),".lock")}(a,i)),this._blobContainer=new Yc({dbname:a,collectionName:i,store:c}),this._transaction=new tl({dbname:a,collectionName:i,store:c})}return i(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===xc.READY}},{key:"init",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d,h,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=Cc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new rl({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),i=_(this.indexes),s=[],o=i.map((function(e){return il.createKey(e)})),u=a?a.indexes.map((function(e){return il.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)d=l.value,o.includes(d)||s.push(il.parseKey(d))}catch(e){c.e(e)}finally{c.f()}return(h=[]).push.apply(h,_(i.map((function(e){var t=new il({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),h.push.apply(h,_(s.map((function(e){return new il({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(h);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Bc(this.dbname,this.name),this._metadata.indexes=i,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=xc.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=xc.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=il.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===il.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Tc.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Bc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((i=a.n()).done){t.next=22;break}return s=i.value,t.next=20,s.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Tc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:i=y(this._indexers),t.prev=14,i.s();case 16:if((s=i.n()).done){t.next=22;break}return o=s.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),i.e(t.t0);case 27:return t.prev=27,i.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:i=y(this._indexers),t.prev=8,i.s();case 10:if((s=i.n()).done){t.next=19;break}if(0===(o=s.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),i.e(t.t0);case 24:return t.prev=24,i.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((i=a.n()).done){t.next=15;break}return s=i.value,t.next=13,s.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",Ic(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Tc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new jc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Tc.collectionNotReady}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Tc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Ic(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Tc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!s._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Tc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,this._requestInsert(Ic(i));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Tc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Tc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Ic(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Tc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!s._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Tc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,this._requestUpsert(Ic(i));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Tc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Tc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Ic(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Tc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,i=void 0===a?{}:a,s=e.index,o=void 0===s?null:s,u=e.backward,c=void 0!==u&&u,l=[],d=new Gc({condition:i,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,d.each((function(e){return E(v,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,Oc(i,a)&&n.set){if("function"!=typeof n.set)for(s in n.set)a[s]=n.set[s];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:h=0,f=l;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"_resetIfEncryptionChanged",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(this._encryptionCheckKey);case 2:if(n=e.sent,r={encrypted:vl.map((function(e){var t;return null===(t=o.encryption)||void 0===t?void 0:t.encrypt(e)}))},!(n&&n.encrypted&&Array.isArray(n.encrypted))){e.next=17;break}e.t0=t().keys(n.encrypted);case 6:if((e.t1=e.t0()).done){e.next=17;break}if(a=e.t1.value,i=JSON.stringify(n.encrypted[a]),s=JSON.stringify(r.encrypted[a]),i===s){e.next=15;break}return pl.warning("Encryption algorithm has changed. Stored data would be cleared."),e.next=14,this.clear();case 14:return e.abrupt("break",17);case 15:e.next=6;break;case 17:return e.next=19,this.set({key:this._encryptionCheckKey,value:r});case 19:case"end":return e.stop()}}),e,this)})))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((i=a.n()).done){e.next=15;break}return s=i.value,e.next=11,this._getRaw(s);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})).filter((function(e){return!r._reservedKeys.includes(e)})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,i=a.data,!((null==(s=a.metadata)?void 0:s.shards)&&s.shards>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(n){return E(u,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(s=t.sent){t.next=7;break}throw Tc.storeBrokenIntegrity;case 7:return t.abrupt("return",s.data);case 10:return t.abrupt("return",i);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[i];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],t.next=3,this._setRaw(r.concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return i=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return s._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,s=t().mark((function e(){var n,a,s,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(s=e.sent)&&(u=s.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((i=a.n()).done){n.next=9;break}return n.delegateYield(s(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),ml={},gl=function(e){s(a,e);var n=f(a);function a(){var e,t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},i),{itemSizeLimit:null!==(t=i.itemSizeLimit)&&void 0!==t?t:4194304}));var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return i(a,[{key:"rawData",get:function(){return ml[this.dbname]},set:function(e){ml[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ml[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(ml[this.dbname]));case 4:throw Tc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ml[this.dbname]){t.next=6;break}return t.next=3,Mc(this.delay);case 3:return t.abrupt("return",ml[this.dbname][e]?Object.assign({key:e},ml[this.dbname][e]):null);case 6:throw Tc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ml[this.dbname]){t.next=7;break}return t.next=3,Mc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)i=a.value,s=i.key,o=i.data,u=i.metadata,ml[this.dbname][s]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Tc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ml[this.dbname]){t.next=7;break}return t.next=3,Mc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)i=a.value,ml[this.dbname][i]&&delete ml[this.dbname][i]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Tc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,ml[this.dbname]||(ml[this.dbname]={}),t.next=4,this._resetIfEncryptionChanged();case 4:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this.observer[e.key])||"function"!=typeof a.set){t.next=5;break}if(!(i=a.set())){t.next=5;break}throw i;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((i=a.n()).done){t.next=12;break}if(s=i.value,!(o=this.observer[s.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),a.e(t.t0);case 17:return t.prev=17,a.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),n,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Mc(this.delay);case 2:ml[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(_l),yl="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ul||(ul={}));var kl,El=function(e){s(a,e);var n=f(a);function a(){var e,t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},i),{itemSizeLimit:null!==(t=i.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=yl,e._state=ul.UNINITIALIZED,e._openJobQueue=[],e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return i(a,[{key:"state",get:function(){return this._state}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=ul.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(yl,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=ul.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=ul.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=ul.UNINITIALIZED,r(e.target.error)}))}else r(Tc.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===ul.UNINITIALIZED||t.t0===ul.OPEN?7:t.t0===ul.OPENING||t.t0===ul.CLOSED?8:9;break;case 7:throw Tc.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){r._openJobQueue.push((function(){return t(r._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return r=t.sent,t.next=5,new Promise((function(t,n){var a=r.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{key:"checkAvailability",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=16;break}if(this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,!this._window||!sl()){e.next=13;break}if(!(sl()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Tc.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(r._indexedDb)try{var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Tc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Tc.storeNotAvailableInPrivateBrowsing)}else t(Tc.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Tc.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,this._openDatabase(e);case 5:return t.next=7,this._resetIfEncryptionChanged();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readwrite");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}]),a}(_l),bl=function(e){s(a,e);var n=f(a);function a(e){var t;r(this,a);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?6291456:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Hi))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Hi&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Cl||(Cl={}));var Sl,Il=function(e){switch(e){case Cl.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Cl.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Nl=Object.assign(Object.assign({},Hs),{scheduledAt:void 0}),Al=Object.assign(Object.assign({},Ls),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ml="UnsentMessage",Ol={},Ul=function(e){s(a,e);var n=f(a);function a(e){var t;return r(this,a),(t=n.call(this,e))._mutex=new ll("unsendmessagecache.lock"),Ol[e]=h(t),t}return i(a,[{key:"_cacheContext",get:function(){return bi.of(this._iid).cacheContext}},{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Ml);if(!t)throw M.databaseError;return t}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw M.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof Zi?(e.messageParams&&(n.messageParams=Fs(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Fs(t)),{scheduledAt:t.scheduledAt})))):e instanceof ts?(e.messageParams&&(n.messageParams=Qs(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Qs(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof Xi&&e.messageParams&&(n.messageParams=function(e){return le({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Hl.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var n,r,a;return E(this,void 0,void 0,t().mark((function i(){var s,o,u,c,l,d,h,f=this;return t().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(s=Hl.of(this._iid),o=this._deserialize(e),!e.messageParams){i.next=32;break}if(!(o instanceof Zi)){i.next=8;break}u=e.messageParams,o.messageParams=s.buildUserMessageCreateParamsFromSerializedData(u,o),i.next=32;break;case 8:if(!(o instanceof ts)){i.next=26;break}if(!(c=e.messageParams).fileKey||"string"!=typeof c.fileKey||!Bs(null!==(n=c.fileType)&&void 0!==n?n:"")){i.next=23;break}return i.next=13,this.collection.getBlob(c.fileKey);case 13:if(i.t1=r=i.sent,i.t0=null!==i.t1,!i.t0){i.next=17;break}i.t0=void 0!==r;case 17:if(!i.t0){i.next=21;break}i.t2=r,i.next=22;break;case 21:i.t2=void 0;case 22:c.file=i.t2;case 23:o.messageParams=s.buildFileMessageCreateParamsFromSerializedData(c,o),i.next=32;break;case 26:if(!(o instanceof Xi)){i.next=32;break}if(!(l=e.messageParams)||!l.fileInfoList){i.next=32;break}return o.messageParams=s.buildMultipleFilesMessageCreateParamsFromSerializedData(l,o),i.next=32,Promise.all(o.messageParams.fileInfoList.map((function(e){return E(f,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Bs(null!==(i=null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)&&void 0!==i?i:"")){t.next=13;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:if(t.t1=s=t.sent,t.t0=null!==t.t1,!t.t0){t.next=7;break}t.t0=void 0!==s;case 7:if(!t.t0){t.next=11;break}t.t2=s,t.next=12;break;case 11:t.t2=void 0;case 12:e.file=t.t2;case 13:case"end":return t.stop()}}),n,this)})))})));case 32:if(!(o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){i.next=54;break}if(!(o instanceof Zi)){i.next=38;break}d=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=s.buildScheduledUserMessageCreateParamsFromSerializedData(d,o),i.next=54;break;case 38:if(!(o instanceof ts)){i.next=54;break}if(!(h=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof h.fileKey||"string"!=typeof h.fileType||!Bs(h.fileType)){i.next=53;break}return i.next=43,this.collection.getBlob(h.fileKey);case 43:if(i.t4=a=i.sent,i.t3=null!==i.t4,!i.t3){i.next=47;break}i.t3=void 0!==a;case 47:if(!i.t3){i.next=51;break}i.t5=a,i.next=52;break;case 51:i.t5=void 0;case 52:h.file=i.t5;case 53:o.scheduledInfo.scheduledMessageParams=s.buildScheduledFileMessageCreateParamsFromSerializedData(h,o);case 54:return i.abrupt("return",o);case 55:case"end":return i.stop()}}),i,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.filter,a=void 0===r?new Tl:r,i=e.order,s=void 0===i?Cl.CHANNEL_LATEST:i,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return E(this,void 0,void 0,t().mark((function e(){var r,i,u,d,h,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return r=Il(s),i={"/where":function(e){return!!(s!==Cl.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&a.match(f._deserialize(e))}},n&&(i.channelUrl=n),o&&(i.sendingStatus=o),u={where:i,index:r,backward:c},e.next=8,this.collection.query(u);case 8:return d=e.sent,e.next=11,d.fetch({});case 11:return h=e.sent,e.abrupt("return",Promise.all(h.map((function(e){return E(f,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Tl;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:Cl.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ts||e instanceof Xi)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return i=a.value,t.next=8,this.collection.remove(i);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ts)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Vs(r.file)){n.next=9;break}return n.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=n.sent,r.fileKey=a,r.fileType=Gs.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(i=e.scheduledInfo.scheduledMessageParams).file||!Vs(i.file)){n.next=17;break}return n.next=14,this.collection.saveBlob(i.file,e.reqId);case 14:s=n.sent,i.fileKey=s,i.fileType=Gs.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof Xi)){n.next=24;break}if(!((o=e.messageParams)&&o.fileInfoList&&Array.isArray(o.fileInfoList))){n.next=24;break}return n.next=24,Promise.all(o.fileInfoList.map((function(n,r){return E(u,void 0,void 0,t().mark((function a(){var i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.file||!Vs(n.file)){t.next=7;break}return t.next=3,this.collection.saveBlob(n.file,this._getFileInfoBlobKey(e.reqId,r));case 3:i=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=i,n._uploadedMetaData.fileType=Gs.BLOB;case 7:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Ol[e]&&!t||(Ol[e]=new a(e)),Ol[e]}}]),a}(Za),Dl={},Rl=function(e){s(a,e);var n=f(a);function a(e){var t;return r(this,a),t=n.call(this,e),Dl[e]=h(t),t}return i(a,[{key:"_sdkState",get:function(){return bi.of(this._iid).sdkState}},{key:"_cacheContext",get:function(){return bi.of(this._iid).cacheContext}},{key:"_unsentMessageCache",get:function(){return Ul.of(this._iid)}},{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ii(!!e).throw(M.databaseError),e.collection(Yu)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Hl.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,i=void 0===a?100:a,s=e.filter,o=void 0===s?new Tl:s,u=e.order,c=void 0===u?Cl.CHANNEL_LATEST:u,l=e.backward,d=void 0!==l&&l,h=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f,v=e.exactMatch,_=void 0!==v&&v,m=e.inclusive,g=void 0===m||m;return E(this,void 0,void 0,t().mark((function e(){var a,s,u,l,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=Il(c),s={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case Cl.CHANNEL_LATEST:if(_&&e.createdAt!==r)return!1;if(d){if(g&&e.createdAtr||!g&&e.createdAt>=r)return!1;break;case Cl.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&o.match(f._deserialize(e))}},index:a,backward:d},e.next=5,this.collection.query(s);case 5:return u=e.sent,e.next=8,u.fetch({limit:null!=i?i:void 0});case 8:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return E(f,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._deserialize(e));case 1:case"end":return t.stop()}}),n,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Tl;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:Cl.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return i=a.value,t.next=8,this.collection.remove("".concat(i));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:Il(Cl.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:Il(Cl.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return i=Il(Cl.CHANNEL_LATEST),s=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:i}),t.next=5,s.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return E(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ts&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Vs(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return i=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return s=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,i&&(r+=JSON.stringify(i).length),s&&(r+=JSON.stringify(s).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Dl[e]&&!t||(Dl[e]=new a(e)),Dl[e]}}]),a}(Za),Ll={},Pl=function(e){s(a,e);var n=f(a);function a(e){var i;return r(this,a),(i=n.call(this,e))._observers=new Map,i._dispatcherContext=i._dispatcher.on((function(e){return E(h(i),void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,y,k,b,w,C=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof gs)){n.next=14;break}if(r=e.messages,a=e.source,i=e.isWebSocketEventComing,s=r.filter((function(e){return e.messageId>0})),o=r.filter((function(e){return 0===e.messageId})),!(s.length>0)){n.next=8;break}return n.next=7,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(s);case 2:return e.next=4,this._unsentMessageCache.remove(s.map((function(e){return e instanceof Hi?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e,this)})))}));case 7:i||this._broadcastUpdateEvent(s,a);case 8:if(!(o.length>0)){n.next=12;break}return n.next=11,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.upsert(o);case 2:case"end":return e.stop()}}),e,this)})))}));case 11:i||this._broadcastUpdateEvent(o,a);case 12:n.next=61;break;case 14:if(!(e instanceof ys)){n.next=21;break}return u=e.messageIds,c=e.source,l=e.isWebSocketEventComing,n.next=18,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.remove(u);case 2:case"end":return e.stop()}}),e,this)})))}));case 18:l||this._broadcastRemoveEvent(u,c),n.next=61;break;case 21:if(!(e instanceof ks)){n.next=28;break}return d=e.reqId,h=e.source,n.next=25,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._unsentMessageCache.remove([d]);case 2:case"end":return e.stop()}}),e,this)})))}));case 25:this._broadcastRemoveUnsentEvent(d,h),n.next=61;break;case 28:if(!(e instanceof Es)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return C._messageCache.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof bs)){n.next=52;break}return m=e.event,g=e.source,n.next=45,this._messageCache.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof ws)){n.next=61;break}return k=e.event,b=e.source,n.next=56,this._messageCache.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,Oa((function(){return E(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._messageCache.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}));case 60:this._broadcastPollVoteEvent(k,b);case 61:case"end":return n.stop()}}),n,this)})))})),i}return i(a,[{key:"_cacheContext",get:function(){return bi.of(this._iid).cacheContext}},{key:"_dispatcher",get:function(){return bi.of(this._iid).dispatcher}},{key:"_messageCache",get:function(){return Rl.of(this._iid)}},{key:"_unsentMessageCache",get:function(){return Ul.of(this._iid)}},{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}],[{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Ll[e]&&!n||(Ll[e]&&(null===(t=Ll[e]._dispatcherContext)||void 0===t||t.close()),Ll[e]=new a(e)),Ll[e]}}]),a}(Za),Fl={},Hl=function(){function n(e,t){var a=t.sdkState,i=t.dispatcher,s=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,Rl.of(e),Ul.of(e),Pl.of(e),this.fileMessageQueue=new us(e,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),Fl[e]=this}return i(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=ai(t);switch(n.messageType){case e.MessageType.USER:return new Zi(this._iid,Zi.payloadify(n));case e.MessageType.FILE:return Xi._isMultipleFilesMessageSerializedData(n)?new Xi(this._iid,Xi.payloadify(n)):new ts(this._iid,ts.payloadify(n));case e.MessageType.ADMIN:return new zi(this._iid,zi.payloadify(n))}throw M.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return le(de({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return le(de({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){return le({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=ai(e);return new Ri(this._iid,Ri.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Cs(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,i=a.as(xs),s=i.message,t.abrupt("return",s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new As(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,i=a.as(Ms),s=i.message,t.abrupt("return",s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new Ts(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ds),i)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(Ss),l=c.messages,this._dispatcher.dispatch(new gs({messages:l,source:s})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new Ts(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ds),i)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(Ss),l=c.messages,this._dispatcher.dispatch(new gs({messages:l,source:s})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return E(this,void 0,void 0,t().mark((function e(){var u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new Ts(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ds),i),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,d=c.as(Ss),h=d.messages,this._dispatcher.dispatch(new gs({messages:h,source:s})),e.abrupt("return",{messages:h,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,t().mark((function s(){var o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new Ts(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},Gi),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(Ss),l=c.messages,(d=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new gs({messages:d,source:i})),t.abrupt("return",{parentMessage:l[0],threadedMessages:d});case 9:case"end":return t.stop()}}),s,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,t().mark((function e(){var o,u,c,l,d,h,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new Is(le(de(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},fs),i)))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(Ns),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,f=c.nextToken,p=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new gs({messages:l,source:s})),p.length>0&&this._dispatcher.dispatch(new ys({messageIds:p,source:s})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:h,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Fl[e]}}]),n}(),ql=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e)).targetMessageId=0;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&R("object",s)&&R("number",o)&&R("string",u)&&R("string",c)&&(i.threadInfo=new Ti(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return i(n)}(Za),Gl={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},jl=function(t){return R("string",t.channelUrl)&&L(e.ChannelType,t.channelType)&&R("number",t.messageId)&&R("boolean",t.includeReactions,!0)&&R("boolean",t.includeMetaArray,!0)&&R("boolean",t.includeParentMessageInfo,!0)&&R("boolean",t.includeThreadInfo,!0)},zl=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,d=e.order,h=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(ke,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:h,message_ts_to:f,sort_field:d,advanced_query:p,target_fields:v,after:_},a}return i(n)}(De),Vl=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).messages=a.results.map((function(t){return es(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return i(n)}(Re);e.MessageSearchOrder=void 0,(Sl=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Sl.TIMESTAMP="ts";var Bl,Ql,Kl,Wl=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h,f,p,v;return r(this,u),(i=a.call(this,t,n)).keyword="",i.reverse=!1,i.exactMatch=!1,i.channelUrl="",i.channelCustomType="",i.messageTimestampFrom=null,i.messageTimestampTo=null,i.order=e.MessageSearchOrder.SCORE,i.advancedQuery=!1,i.targetFields=null,i._nextToken="",i.totalCount=-1,i.keyword=n.keyword,i.reverse=null!==(s=n.reverse)&&void 0!==s&&s,i.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,i.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",i.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",i.messageTimestampFrom=null!==(d=n.messageTimestampFrom)&&void 0!==d?d:null,i.messageTimestampTo=null!==(h=n.messageTimestampTo)&&void 0!==h?h:null,i.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,i.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,i.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,i}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&R("string",this.keyword)&&this.keyword.length>0&&R("boolean",this.reverse)&&R("boolean",this.exactMatch)&&R("string",this.channelUrl)&&R("string",this.channelCustomType)&&(R("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(R("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&L(e.MessageSearchOrder,this.order)&&R("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new zl(de(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Vl),o=s.messages,u=s.hasNext,c=s.nextToken,l=s.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(ao),Yl={channelUrl:"",scheduledMessageId:0},Zl=function(e){return R("string",e.channelUrl)&&""!==e.channelUrl&&R("number",e.scheduledMessageId)&&e.scheduledMessageId>0},Jl=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return i(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:i,requestQueue:s,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Hl(e,{sdkState:n,dispatcher:r,requestQueue:s,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Gl),e),ii(jl(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Yl),e),ii(Zl(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(wi),Xl=i((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),$l=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return i(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:i,requestQueue:s,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ku(e,{sdkState:n,dispatcher:r,sessionManager:i,requestQueue:s,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},qu),e),ii(Gu(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Vu),e),ii(Bu(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},ju),e),ii(zu(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(wi),ed={profileImage:void 0,profileUrl:void 0,nickname:void 0},td=function(e){return G(e.profileImage,!0)&&R("string",e.profileUrl,!0)&&R("string",e.nickname,!0)};e.GroupChannelListOrder=void 0,(Bl=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Bl.CHRONOLOGICAL="chronological",Bl.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Bl.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Ql=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Ql.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ql.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Kl=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Kl.SCHEDULED_AT="scheduled_at";var nd,rd=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},ad=function(t){return{v2:t.commitSchema([{collectionName:Wu,keyName:"url",index:[rd(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),rd(e.GroupChannelListOrder.CHRONOLOGICAL),rd(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Yu,keyName:"messageId",index:[Il(Cl.CHANNEL_LATEST),Il(Cl.NEWEST_CHILD_MESSAGE)]},{collectionName:Ml,keyName:"reqId",index:[Il(Cl.CHANNEL_LATEST),Il(Cl.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]),v3:t.commitSchema([{collectionName:"FeedChannel",keyName:"url",index:[["-lastMessageUpdatedAt","-createdAt","syncIndex"]]}])}},id=function(e,t){return function(n,r){switch(n){case 1:e.clear().then((function(){t.clear().then((function(){ad(e).v2.then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));break;case 2:ad(e).v3.then((function(){return r()})).catch((function(e){return r(e)}));break;default:r()}}},sd=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},od=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.getVisibilityState,s=void 0===i?sd:i,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,d=e.pauseCheckDelay,f=void 0===d?3e4:d;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=s,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(h(a)),a}return i(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(oe),ud=function(){function e(t){var n=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,s&&(this.connectionDelegate=s)}return i(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:he.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),cd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.message;return r(this,n),(a=t.call(this)).message=i,a}return i(n)}(ce),ld={},dd=function(){function n(e,t){var a=this,i=t.localCacheEnabled,s=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,ld[e]=this,this._localCacheEnabled=i,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=s,this._logger=u,this._sdkState=o,this._localCacheEnabled&&s.on((function(e){if(e instanceof ya)switch(e.stateType){case ha.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case ha.INTERNAL_DISCONNECTED:case ha.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return i(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(i=a.n()).done;)0===(s=i.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=e.SendingStatus.FAILED,s.errorCode=b.ACK_TIMEOUT,this._dispatcher.dispatch(new gs({messages:[s],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(i=a.n()).done;)(s=i.value).errorCode&&q(s.errorCode)&&(o=(new Date).getTime(),u=s.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),s.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new gs({messages:[s],source:e.CollectionEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!q(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ul.of(this._iid),(a=new Tl).replyType=e.ReplyType.ALL,t.next=5,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0,filter:a});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new cd({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return ld[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(nd||(nd={}));var hd,fd,pd=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return i(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new oi(e,r),blockee:new oi(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new oi(e,t)})):[]}}}]),e}(),vd=function(e){s(n,e);var t=f(n);function n(e,a){var i,s=a.userId;return r(this,n),(i=t.call(this))._iid=e,i.userId=s,i}return i(n)}(ce),_d=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return i(n)}(ce),md=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"USEV",i)).event=new pd(i),s}return i(n)}(Ke),gd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i)),a.params=le(de({nickname:s,profile_url:o,profile_file:u,preferred_languages:c})),a}return i(n)}(De),yd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).user=new oi(e,Object.assign({},a)),i}return i(n)}(Re),kd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.token;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/apns"),a.params={apns_device_token:s,always_push:!0},a}return i(n)}(De),Ed=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.token;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params={gcm_reg_token:s,always_push:!0},a}return i(n)}(De),bd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.token;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return i(n)}(De),wd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.token;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return i(n)}(De),Cd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/apns"),a}return i(n)}(De),xd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return i(n)}(De),Td=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return i(n)}(De),Sd=function(t){s(a,t);var n=f(a);function a(t,i){var s;return r(this,a),(s=n.call(this,t,i)).pushTokens={type:i.type?e.PushTokenType[i.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:i.device_tokens,hasMore:i.has_more,token:i.token},s}return i(a)}(Re),Id=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return i(n)}(De),Nd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).autoAccept=a.auto_accept,i}return i(n)}(Re),Ad=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return i(n)}(De),Md=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).autoAccept=a.auto_accept,i}return i(n)}(Re),Od=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference"),a}return i(n)}(De),Ud=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return i(n)}(Re),Dd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,d=e.timezone;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:d},a}return i(n)}(De),Rd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return i(n)}(Re),Ld=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference"),a}return i(n)}(De),Pd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return i(n)}(Re),Fd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return i(n)}(De),Hd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return i(n)}(Re),qd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.blockedUserId;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return i(n)}(De),Gd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return i(n)}(De),jd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference"),a}return i(n)}(De),zd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i}return i(n)}(Re),Vd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return i(n)}(De),Bd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i}return i(n)}(Re),Qd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/template"),a}return i(n)}(De),Kd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).name=a.name,i}return i(n)}(Re),Wd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.templateName;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return i(n)}(De),Yd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).name=a.name,i}return i(n)}(Re),Zd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.token;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return i(n)}(De),Jd=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new oi(e,t)})),updatedUsers:a.updated.map((function(t){return new oi(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return i(n)}(Re),Xd=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.discoveries;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return i(n)}(De),$d=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return i(n)}(Re),eh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return i(n)}(De),th=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.userIds;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return i(n)}(De),nh=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).users=a.users.map((function(t){return new oi(e,t)})),i}return i(n)}(Re),rh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.userIds;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return i(n)}(De),ah=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return i(n)}(De),ih=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,i}return i(n)}(Re),sh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return i(n)}(De),oh=function(e){s(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=he.GET,e.path=we,e}return i(n)}(De),uh=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).emojiContainer=new lc(a),i}return i(n)}(Re),ch=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.categoryId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(we,"/").concat(i),a}return i(n)}(De),lh=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).emojiCategory=new cc(a),i}return i(n)}(Re),dh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.key;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(be,"/").concat(i),a}return i(n)}(De),hh=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).emoji=new uc(a),i}return i(n)}(Re),fh=function(e){s(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=he.GET,e.path="".concat(Te),e}return i(n)}(De),ph=function(e){s(n,e);var t=f(n);function n(e,a){var i,s;r(this,n);var o=null!=a?a:{};return(i=t.call(this,e,a)).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(s=null==a?void 0:a.updated_at)&&void 0!==s?s:0,i}return i(n)}(Re),vh=function(){function n(e,a,i){var s=this;r(this,n),this._storeInitialized=!1,this._iid=e,this.options=a;var o=bi.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,d=o.sessionManager,h=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new ud({logger:f,connectionDelegate:{reconnect:function(){var t=bi.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){bi.of(e).connectionManager.disconnect()}}});var _=new dd(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});i.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:d,requestQueue:h,logger:f,onlineDetector:s._onlineDetector}),s[t.name]=t})),this._appStateChangeDetector=new od({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),s.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),s.setBackgroundState()})),l.on((function(n){var r;if(n instanceof ya){if(n.stateType===ha.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof Ke){if("USEV"===n.code){var a=n.as(md).event;if(a.category===nd.FRIEND_DISCOVERED){var i=pd.getDataAsFriendDiscoveredEvent(e,a).friendDiscoveries;Ma((function(){return E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(i)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof va){var o=bi.of(s._iid).subscribedUnreadMessageCount,l=!1,d=n.ts;if("number"==typeof d&&d>o.ts){if(o.all!==n.all&&(l=!0),o.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)o.customTypes[h]!==n.customTypes[h]&&(l=!0),o.customTypes[h]=n.customTypes[h];l=l&&o.ts>0,o.ts=d}l&&Ma((function(){return E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:o.all,feedChannelCount:o.feed,customTypeUnreadCount:o.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(o.all,o.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof ui?(c.preference.set(s._getUserProfileCacheKey(u.userId),ci.payloadify(n.userProfile)),(null===(r=n.userProfile.appInfo.notificationInfo)||void 0===r?void 0:r.isEnabled)&&c.preference.set(Qa(s.appId),{value:!0})):n instanceof Pe&&n.error&&(n.error.isSessionRevokedError||n.error.isUserAuthDeactivedError||n.error.isUserAuthDeletedOrNotFoundError)&&(f.debug("session revoked."),s.disconnect())}))}return i(n,[{key:"appId",get:function(){return bi.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=bi.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=bi.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!bi.of(this._iid).debugMode}},{key:"logLevel",get:function(){return bi.of(this._iid).logger.level},set:function(e){bi.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return bi.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=bi.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return bi.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=bi.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=bi.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=bi.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}},{key:"apnsPushToken",get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}},{key:"_getNestDBVersion",value:function(){return 3}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=bi.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof gl?n.store:null;throw M.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=bi.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"addSendbirdExtensions",value:function(e,t,n){var r=bi.of(this._iid),a=r.logger,i=r.sdkState,s=new RegExp("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");if(0===e.length)return a.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!s.test(e.version)})))return a.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)for(var o=0,u=Object.entries(n);o0&&void 0!==arguments[0]?arguments[0]:{};return new _c(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new bc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Wl(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new Xu(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new tc(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=ai(e);return new oi(this._iid,oi.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},ed),e),ii(td(r)).throw(M.invalidParameters),!this.currentUser){t.next=13;break}return a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new gd(Object.assign({userId:i.userId},r)),t.next=7,s.send(o);case 7:return u=t.sent,c=u.as(yd),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw M.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ii(F("string",e)).throw(M.invalidParameters),!this.currentUser){t.next=12;break}return r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new gd({userId:a.userId,preferredLanguages:e}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(yd),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw M.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ii(R("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=bi.of(this._iid),i=a.sessionManager,s=a.sdkState,o=a.requestQueue,!i.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new Ed({userId:s.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,Oa((function(){return E(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,i.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ii(R("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=bi.of(this._iid),i=a.sessionManager,s=a.sdkState,o=a.requestQueue,u=new wd({userId:s.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,Oa((function(){return E(d,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i.unsetDeviceToken(e.PushTokenType.FCM,n),i.setDeviceTokenDeletedAt(l),t.next=4,i.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=bi.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new xd({userId:i.userId}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,Oa((function(){return E(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ii(R("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=bi.of(this._iid),i=a.sessionManager,s=a.sdkState,o=a.requestQueue,!i.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new kd({userId:s.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,Oa((function(){return E(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,i.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(ii(R("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=bi.of(this._iid),i=a.sessionManager,s=a.sdkState,o=a.requestQueue,u=new bd({userId:s.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,Oa((function(){return E(d,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i.unsetDeviceToken(e.PushTokenType.APNS,n),i.setDeviceTokenDeletedAt(l),t.next=4,i.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=bi.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Cd({userId:i.userId}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,Oa((function(){return E(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Id({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(Nd),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("boolean",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ad({userId:a.userId,willAutoAccept:e}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(Md),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Od({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(Ud),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,t().mark((function o(){var u,c,l,d,h,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("boolean",e)&&R("number",n)&&R("number",r)&&R("number",a)&&R("number",i)&&R("string",s)).throw(M.invalidParameters),u=bi.of(this._iid),c=u.sdkState,l=u.requestQueue,d=new Dd({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:i,timezone:s}),t.next=5,l.send(d);case 5:return h=t.sent,f=h.as(Rd),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Ld({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(Pd),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("boolean",e)&&R("number",n)&&R("number",r)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Fd({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Hd),d=l.snoozePeriod,t.abrupt("return",d);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u,c,l,d,h,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",n)&&L(e.PushTokenType,r)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.sdkState,o=i.requestQueue,u=i.sessionManager,c=new Td({userId:s.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,d=l.as(Sd),h=d.pushTokens,f=y(h.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(h.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",h);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new jd({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,e.abrupt("return",s.as(zd).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(L(e.PushTriggerOption,n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new Vd({userId:i.userId,pushTriggerOption:n}),t.next=5,s.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Bd).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Qd({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,e.abrupt("return",s.as(Kd).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(L(e.PushTemplate,n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new Wd({userId:i.userId,templateName:n}),t.next=5,s.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Yd).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e instanceof oi||R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new qd({userId:a.userId,blockedUserId:e instanceof oi?e.userId:e}),t.next=5,i.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e instanceof oi||R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Gd({userId:a.userId,unblockedUserId:e instanceof oi?e.userId:e}),t.next=5,i.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Zd({userId:a.userId,token:e}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(Jd),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ah({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(ih),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("boolean",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new sh({userId:a.userId,allowFriendDiscovery:e}),t.next=5,i.send(s);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Xd({userId:a.userId,discoveries:e}),t.next=4,i.send(s);case 4:return o=t.sent,u=o.as($d),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new eh({userId:a.userId,discoveryKeys:e}),t.next=5,i.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new th({userId:a.userId,userIds:e}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.as(nh),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",e)).throw(M.invalidParameters),r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new rh({userId:a.userId,userIds:e}),t.next=5,i.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new oh,e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(uh),o=s.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.requestQueue,i=new ch({categoryId:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(lh),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.requestQueue,i=new dh({key:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(hh),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),ii(n.hasExtension("sb_uikit")).throw(M.notSupportedError),r=n.requestQueue,a=new fh,e.next=6,r.send(a);case 6:return i=e.sent,s=i.as(ph),o=s.uikitConfiguration,e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=e.modules,i=void 0===a?[]:a,s=e.options,o=void 0===s?new j:s,u=e.debugMode,c=void 0!==u&&u,l=e.customApiHost,d=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,m=void 0!==v&&v,g=e.localCacheConfig,y=void 0===g?new re:g,k=e.localCacheEncryption,E=e.useAsyncStorageStore,b=void 0===E?null:E,w=e.appStateToggleEnabled,C=void 0===w||w;if(!hd||f){var x="su-".concat(ie()),T=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},S=new gl({encryption:T});c||(S=ze()?b?new bl({AsyncStorage:b,encryption:T}):new gl({encryption:T}):new El({encryption:T})),new bi(x,{appId:t,appVersion:r,options:o,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:S,encryption:T,logLevel:p,localCacheEnabled:m,localCacheConfig:y,debugMode:c,appStateToggleEnabled:C});var I=[new Jl,new $l],N=new n(x,o,[].concat(_(i),I));return hd||(hd=N),N}return hd}},{key:"instance",get:function(){return hd}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(fd=e.MemberState||(e.MemberState={})).NONE="none",fd.JOINED="joined",fd.INVITED="invited",fd.LEFT="left";var _h,mh,gh,yh,kh,Eh,bh,wh,Ch=function(t){s(a,t);var n=f(a);function a(t,i){var s;return r(this,a),(s=n.call(this,t,i)).state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=L(e.MemberState,i.state)?i.state:null,s.role=L(e.Role,i.role)?i.role:null,"boolean"==typeof i.is_muted&&(s.isMuted=i.is_muted),"boolean"==typeof i.is_blocked_by_me&&(s.isBlockedByMe=i.is_blocked_by_me),"boolean"==typeof i.is_blocking_me&&(s.isBlockingMe=i.is_blocking_me),s}return i(a,null,[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}]),a}(Us),xh=function(t){s(a,t);var n=f(a);function a(t,i){var s,o,u;return r(this,a),(s=n.call(this,t)).channelUrl=null!==(o=i.channel_url)&&void 0!==o?o:"",s.channelType=null!==(u=i.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,s.reader=new oi(s._iid,i.user),s.readAt=i.ts,s}return i(a)}(Za);e.PublicChannelFilter=void 0,(_h=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",_h.PUBLIC="public",_h.PRIVATE="private",e.MyMemberStateFilter=void 0,(mh=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",mh.JOINED="joined_only",mh.INVITED="invited_only",mh.INVITED_BY_FRIEND="invited_by_friend",mh.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(gh=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",gh.SUPER="super",gh.NON_SUPER="nonsuper",gh.BROADCAST_ONLY="broadcast_only",gh.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(yh=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",yh.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(kh=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",kh.UNHIDDEN="unhidden_only",kh.HIDDEN="hidden_only",kh.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",kh.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Eh=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Eh.OPERATOR="operator",Eh.NONOPERATOR="nonoperator",e.QueryType=void 0,(bh=e.QueryType||(e.QueryType={})).AND="AND",bh.OR="OR",e.GroupChannelSearchField=void 0,(wh=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",wh.CHANNEL_NAME="channel_name";var Th,Sh=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return i(t,[{key:"_isFriend",value:function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e,n=new t;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var d=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(d)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(h)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!(this.createdAfter&&t.createdAtthis.createdBefore)}}]),t}(),Ih=function(n){s(o,n);var a=f(o);function o(e,t){var n,i=t.sdkState,s=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=i,n._cacheContext=s,n}return i(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return ii(!!e).throw(M.databaseError),e.collection(Wu)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return ep.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(i);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],i=y(n),t.prev=2,i.s();case 4:if((s=i.n()).done){t.next=12;break}return o=s.value,t.next=8,this.get(o);case 8:(null==(u=t.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),i.e(t.t0);case 17:return t.prev=17,i.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(Za);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(Th||(Th={}));var Nh,Ah=function(){function t(e){var n;r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}return i(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),Mh={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},Oh=function(e){return F("string",e.invitedUserIds,!0)&&R("string",e.channelUrl,!0)&&R("string",e.coverUrl,!0)&&(G(e.coverImage)||R("string",e.coverImage,!0))&&R("boolean",e.isDistinct,!0)&&R("boolean",e.isSuper,!0)&&R("boolean",e.isBroadcast,!0)&&R("boolean",e.isExclusive,!0)&&R("boolean",e.isPublic,!0)&&R("boolean",e.isStrict,!0)&&R("boolean",e.isDiscoverable,!0)&&R("boolean",e.isEphemeral,!0)&&R("string",e.accessCode,!0)&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&R("number",e.messageSurvivalSeconds,!0)},Uh={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},Dh=function(e){return F("string",e.customTypes,!0)&&R("boolean",e.includeEmpty)&&R("boolean",e.includeFrozen)&&R("boolean",e.includeChatNotification)},Rh={myMemberStateFilter:e.MyMemberStateFilter.ALL},Lh=function(t){return L(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(Nh=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",Nh.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",Nh.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",Nh.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",Nh.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",Nh.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",Nh.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",Nh.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",Nh.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var Ph,Fh={keys:[]},Hh=function(t){return F(e.UnreadItemKey,t.keys)},qh={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},Gh=function(t){return F("string",t.channelCustomTypesFilter,!0)&&L(e.SuperChannelFilter,t.superChannelFilter)},jh={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},zh=function(t){return R("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&L(e.MessageTypeFilter,t.messageTypeFilter)},Vh=Object.assign({},e.CollectionEventSource),Bh=function(t){return t.startsWith("EVENT_")||t===e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.CollectionEventSource.REFRESH_CHANNEL},Qh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channels,s=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c,d=e.ts;return r(this,n),(a=t.call(this)).channels=i,a.source=s,a.isWebSocketEventComing=u,a.data=l,a.ts=d,a}return i(n)}(ce),Kh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrls,s=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).channelUrls=i,a.source=s,a.isWebSocketEventComing=u,a}return i(n)}(ce),Wh=function(){function e(n){var a=this,i=n.groupChannelCache,s=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return E(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,d,h,f,p,v,_,m,g,k=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof Qh)){n.next=27;break}r=e.channels,a=e.source,u=e.isWebSocketEventComing,c=e.data,l=r.filter((function(e){return e instanceof dv})),d=i.filterOffsetChanged(l),h=y(d),n.prev=5,h.s();case 7:if((f=h.n()).done){n.next=13;break}return p=f.value,n.next=11,s.removeUnderOffset(p.url,p.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,i.upsert(l,e.ts);case 23:v=n.sent,u||this._broadcastUpdateEvent(v,a,c),n.next=39;break;case 27:if(!(e instanceof Kh)){n.next=36;break}return _=e.channelUrls,m=e.source,g=e.isWebSocketEventComing,n.next=31,i.remove(_);case 31:return n.next=33,Oa((function(){return E(k,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(_),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,s.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 33:g||this._broadcastRemoveEvent(_,m),n.next=39;break;case 36:if(!(e instanceof vd)){n.next=39;break}return n.next=39,i.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 39:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return i(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){var i=r.value;i.onUpdate&&i.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Yh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter,c=e.includeChatNotification,l=void 0!==c&&c;r(this,n),a=t.call(this);var d=Object.assign(Object.assign({},Uh),u),h=d.customTypes,f=d.includeEmpty,p=d.includeFrozen;return a.method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=le(de({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s||null,token:o,custom_types:h,show_empty:f,show_frozen:p,include_chat_notification:l})),a}return i(n)}(De),Zh=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new dv(e,Object.assign(t,{ts:a.ts}))})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i.ts=a.ts,i}return i(n)}(Re),Jh=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(s?me:_e,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return i(n)}(De),Xh=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).channel=new dv(e,a),i}return i(n)}(Re),$h={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:e.MyMemberStateFilter.ALL,unreadChannelFilter:e.UnreadChannelFilter.ALL,superChannelFilter:e.SuperChannelFilter.ALL,publicChannelFilter:e.PublicChannelFilter.ALL,hiddenChannelFilter:e.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0},ef=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,d=e.superChannelFilter,h=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,E=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter,A=e.includeChatNotification,M=void 0!==A&&A,O=e.createdAfter,U=e.createdBefore;return(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=le({token:s,limit:o,order:null!=u?u:$h.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:$h.includeEmpty,member_state_filter:null!=l?l:$h.myMemberStateFilter,super_mode:null!=d?d:$h.superChannelFilter,public_mode:null!=h?h:$h.publicChannelFilter,unread_filter:null!=f?f:$h.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:E,metadata_order_key:b,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:T,show_metadata:S,include_chat_notification:M,created_after:O,created_before:U}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return i(n)}(De),tf=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new dv(e,t)}))),i.ts=null!=u?u:0,i}return i(n)}(Re),nf=function(t){s(a,t);var n=f(a);function a(t){var i,s=t.userId,o=t.filter;r(this,a),i=n.call(this);var u=o.myMemberStateFilter;return i.method=he.GET,i.path="".concat(pe,"/").concat(encodeURIComponent(s),"/group_channel_count"),i.params={state:null!=u?u:e.MyMemberStateFilter.ALL},i}return i(a)}(De),rf=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).groupChannelCount=a.group_channel_count,i}return i(n)}(Re),af=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.filter;r(this,n),a=t.call(this);var o=s.keys;return a.method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params=le({item_keys:o}),a}return i(n)}(De),sf=function(t){s(a,t);var n=f(a);function a(t,i){var s;return r(this,a),s=n.call(this,t,i),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(s.groupChannelUnreadMentionCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(s.groupChannelUnreadMessageCount=i[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(s.groupChannelInvitationCount=i[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(s.superGroupChannelUnreadMentionCount=i[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(s.superGroupChannelUnreadMessageCount=i[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(s.superGroupChannelInvitationCount=i[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(s.nonSuperGroupChannelUnreadMentionCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(s.nonSuperGroupChannelUnreadMessageCount=i[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(s.nonSuperGroupChannelInvitationCount=i[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),s}return i(a)}(Re),of=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return i(n)}(De),uf=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).unreadCount=a.unread_count,i}return i(n)}(Re),cf=function(t){s(a,t);var n=f(a);function a(t){var i,s=t.userId,o=t.filter,u=t.includeFeedChannel,c=void 0!==u&&u;r(this,a),i=n.call(this);var l=o.channelCustomTypesFilter,d=o.superChannelFilter;return i.method=he.GET,i.path="".concat(pe,"/").concat(encodeURIComponent(s),"/unread_message_count"),i.params={super_mode:null!=d?d:e.SuperChannelFilter.ALL,custom_types:l,include_feed_channel:c},i}return i(a)}(De),lf=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).unreadCount=a.unread_count,i.unreadFeedCount=a.unread_feed_count,i}return i(n)}(Re),df=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(xe,"/count"),a.params={channel_url:i,status:ff(s)},o&&(a.params.message_type=o),a}return i(n)}(De),hf=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).count=a.count,i}return i(n)}(Re),ff=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Ii.PENDING);break;case e.ScheduledStatus.SENT:n.push(Ii.IN_QUEUE),n.push(Ii.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Ii.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Ii.FAILED)}})),n},pf=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,d=e.isBroadcast,h=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,E=e.customType,b=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=he.POST,a.path=_e,a.params=le({user_ids:[i].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:d,is_exclusive:f,is_public:h,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:E,operator_ids:C,message_survival_seconds:b}),a}return i(n)}(De),vf=function(e){s(n,e);var t=f(n);function n(e,a){var i,s;return r(this,n),(i=t.call(this,e,a)).channel=new dv(e,a),i.isCreated=null===(s=a.is_created)||void 0===s||s,i}return i(n)}(Re),_f=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.channelUrls;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return i(n)}(De),mf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).event=new Ah(i),s}return i(n)}(Ke),gf=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return i(n)}(De),yf=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).channel=new dv(e,a),i}return i(n)}(Re),kf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;r(this,n),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.users,f=void 0===h?null:h;return s.memberCount=c,s.joinedMemberCount=d,s.members=Array.isArray(f)?f.map((function(t){return new Ch(e,t)})):[new Ch(e,i.data)],s}return i(n)}(mf),Ef=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return i(n)}(De),bf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;r(this,n),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l;return s.memberCount=c,s.joinedMemberCount=d,s.member=new Ch(s._iid,i.data),s}return i(n)}(mf),wf=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.userIds;return(a=t.call(this)).method=he.POST,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return i(n)}(De),Cf=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).channel=new dv(e,a),i}return i(n)}(Re),xf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;r(this,n),(s=t.call(this,e,a,i)).inviter=null;var o=i.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,d=void 0===l?0:l,h=o.inviter,f=o.invitees,p=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=d,h&&Object.keys(h).length>0&&(s.inviter=new oi(e,h)),s.invitees=p.map((function(t){return new Ch(e,t)})),s}return i(n)}(mf),Tf=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.userId;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return i(n)}(De),Sf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;r(this,n),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,d=o.invitee;return s.memberCount=null!=u?u:0,s.joinedMemberCount=null!=c?c:0,s.inviter=new oi(e,l),s.invitee=new Ch(e,d),s}return i(n)}(mf),If={hidePreviousMessages:!1,allowAutoUnhide:!0},Nf=function(e){return R("boolean",e.hidePreviousMessages,!0)&&R("boolean",e.allowAutoUnhide,!0)},Af=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:null!=o?o:If.hidePreviousMessages,allow_auto_unhide:null!=u?u:If.allowAutoUnhide},a}return i(n)}(De),Mf=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return i(n)}(Re),Of=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c;return r(this,n),(s=t.call(this,e,"SYEV",i)).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=null!==(o=i.data.allow_auto_unhide)&&void 0!==o?o:null,s.hidePreviousMessages=null!==(u=i.data.hide_previous_messages)&&void 0!==u?u:null),s.messageOffsetTimestamp=null!==(c=i.ts_message_offset)&&void 0!==c?c:null,s}return i(n)}(Ke),Uf=function(e){s(n,e);var t=f(n);function n(e){var a=e.channelUrl,i=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}})}return i(n)}(pa),Df=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).user=new oi(e,i.data),s}return i(n)}(Ke),Rf=function(e){s(n,e);var t=f(n);function n(e){var a=e.channelUrl,i=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}})}return i(n)}(pa),Lf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"SYEV",i)).user=new oi(e,i.data),s}return i(n)}(Ke),Pf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;r(this,n),s=t.call(this,e,a,i);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new oi(s._iid,e)})),s}return i(n)}(mf),Ff=function(e){s(n,e);var t=f(n);function n(e){var a=e.channelUrl,i=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}})}return i(n)}(pa),Hf=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h,f,p,v,_,m,g,y,k,E,b,w,C,x,T,S,I,N;return r(this,u),(i=a.call(this,t,n)).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.includeChatNotification=!1,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.nicknameContainsFilter=null,i.nicknameStartsWithFilter=null,i.nicknameExactMatchFilter=null,i.channelNameContainsFilter="",i.myMemberStateFilter=e.MyMemberStateFilter.ALL,i.unreadChannelFilter=e.UnreadChannelFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.publicChannelFilter=e.PublicChannelFilter.ALL,i.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,i.searchFilter={fields:[],query:null},i.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,i.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,i.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,i.includeChatNotification=null!==(l=n.includeChatNotification)&&void 0!==l&&l,i.channelUrlsFilter=null!==(d=n.channelUrlsFilter)&&void 0!==d?d:null,i.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,i.customTypeStartsWithFilter=null!==(f=n.customTypeStartsWithFilter)&&void 0!==f?f:"",i.nicknameContainsFilter=null!==(p=n.nicknameContainsFilter)&&void 0!==p?p:null,i.nicknameStartsWithFilter=null!==(v=n.nicknameStartsWithFilter)&&void 0!==v?v:null,i.nicknameExactMatchFilter=null!==(_=n.nicknameExactMatchFilter)&&void 0!==_?_:null,i.channelNameContainsFilter=null!==(m=n.channelNameContainsFilter)&&void 0!==m?m:"",i.myMemberStateFilter=null!==(g=n.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,i.unreadChannelFilter=null!==(y=n.unreadChannelFilter)&&void 0!==y?y:e.UnreadChannelFilter.ALL,i.superChannelFilter=null!==(k=n.superChannelFilter)&&void 0!==k?k:e.SuperChannelFilter.ALL,i.publicChannelFilter=null!==(E=n.publicChannelFilter)&&void 0!==E?E:e.PublicChannelFilter.ALL,i.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,i.searchFilter=null!==(w=n.searchFilter)&&void 0!==w?w:{fields:[],query:null},i.userIdsFilter=null!==(C=n.userIdsFilter)&&void 0!==C?C:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null!==(x=n.metadataKey)&&void 0!==x?x:null,i.metadataValues=null!==(T=n.metadataValues)&&void 0!==T?T:null,i.metadataOrderKeyFilter=null!==(S=n.metadataOrderKeyFilter)&&void 0!==S?S:null,i.metadataValueStartsWith=null!==(I=n.metadataValueStartsWith)&&void 0!==I?I:null,i.order=null!==(N=n.order)&&void 0!==N?N:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,n.createdAfter&&(i.createdAfter=n.createdAfter),n.createdBefore&&(i.createdBefore=n.createdBefore),i}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&R("boolean",this.includeEmpty)&&R("boolean",this.includeFrozen)&&R("boolean",this.includeMetaData)&&R("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&R("string",this.customTypeStartsWithFilter)&&R("string",this.nicknameContainsFilter,!0)&&R("string",this.nicknameStartsWithFilter,!0)&&R("string",this.nicknameExactMatchFilter,!0)&&L(e.MyMemberStateFilter,this.myMemberStateFilter)&&L(e.SuperChannelFilter,this.superChannelFilter)&&L(e.PublicChannelFilter,this.publicChannelFilter)&&L(e.UnreadChannelFilter,this.unreadChannelFilter)&&L(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&R("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&R("boolean",this.userIdsFilter.includeMode)&&L(e.QueryType,this.userIdsFilter.queryType)&&L(e.GroupChannelListOrder,this.order)&&R("string",this.metadataOrderKeyFilter,!0)&&R("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&R("string",this.metadataValueStartsWith,!0)&&H(this.createdAfter,!0)&&H(this.createdBefore,!0)}},{key:"serialize",value:function(){return ri(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ep.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,de(Object.assign({},this)),this.limit);case 7:return r=e.sent,a=r.channels,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(ao),qf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o;return r(this,n),(s=t.call(this,e,"SYEV",i)).pinnedMessageIds=[],s.latestPinnedMessage=null,s.ts=0,i.data&&(s.pinnedMessageIds=null!==(o=i.data.pinned_message_ids)&&void 0!==o?o:[],s.latestPinnedMessage=i.data.latest_pinned_message?es(e,Object.assign({},i.data.latest_pinned_message)):null),s.ts=i.ts,s}return i(n)}(Ke),Gf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,i=t.bottom,s=void 0===i?0:i;r(this,e),this.top=a,this.bottom=s}return i(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r4&&void 0!==arguments[4]?arguments[4]:100,s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,t().mark((function o(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:i,filter:a,backward:"next"===r,inclusive:s});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),o,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r,a){return E(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return E(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new Gf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}}]),a}(Za),zf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c,l;r(this,n),(s=t.call(this,e,"ADMM",i)).message=new zi(e,i);var d=bi.of(e).sdkState;return s.isMentioned=Ae(s.message.mentionType,null!==(c=null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],d.userId),s.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l,s}return i(n)}(Ke),Vf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u,c,l,d;r(this,n),(s=t.call(this,e,"AEDI",i)).message=new zi(e,i);var h=bi.of(e).sdkState;return s.mentionCountChange=Me({mentionType:null===(o=i.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=i.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},de({mentionType:s.message.mentionType,mentionedUserIds:null!==(l=s.message.mentionedUserIds)&&void 0!==l?l:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))}),h.userId),s}return i(n)}(Ke),Bf=function(e){s(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return i(n)}(pa),Qf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"READ",i)).readStatus=new xh(e,i),s}return i(n)}(Ke),Kf=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=le({userId:s}),a}return i(n)}(De),Wf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"DLVR",i)).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return i(n)}(Ke),Yf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"MRCT",i)).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new Ni(i),s}return i(n)}(Ke),Zf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"MTHD",i)).event=new ql(e,i),s}return i(n)}(Ke),Jf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"MCNT",i)).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return i(n)}(Ke),Xf=function(e){s(n,e);var t=f(n);function n(e,a,i){var s;return r(this,n),(s=t.call(this,e,"PEDI",i)).event=new Xl(e,i),s.status=Qi(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return i(n)}(Ke),$f={},ep=function(n){s(o,n);var a=f(o);function o(n,i){var s,u;return r(this,o),(s=a.call(this,n,Object.assign(Object.assign({},i),{channelType:e.ChannelType.GROUP})))._leftChannels=new Map,s._disableMack=!1,s._markAsReadAllLastSentAt=0,s._disableMack=null!==(u=i.disableMack)&&void 0!==u&&u,s._groupChannelHandlers=new Map,s._groupChannelCache=new Ih(s._iid,{sdkState:i.sdkState,cacheContext:i.cacheContext}),s._groupChannelBroadcast=new Wh({dispatcher:i.dispatcher,groupChannelCache:s._groupChannelCache,messageCache:Rl.of(s._iid),unsentMessageCache:Ul.of(s._iid)}),setInterval((function(){var t,n=y(s._groupChannelCache.channels);try{var r=function(){var n=t.value;n.invalidateTypingStatus()&&(s._dispatcher.dispatch(new Qh({channels:[n],source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),s._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(n)})))};for(n.s();!(t=n.n()).done;)r()}catch(e){n.e(e)}finally{n.f()}}),1e3),s._dispatcher.on((function(e){e instanceof Ke?s._handleEvent(e):e instanceof cd?E(h(s),void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.message,t.next=3,this.getChannel(r.channelUrl,!0);case 3:a=t.sent,r instanceof Zi?a._autoResendUserMessage(r):r instanceof ts&&a._autoResendFileMessage(r);case 5:case"end":return t.stop()}}),n,this)}))):e instanceof _d&&s.reduceDBSize()})),$f[n]||($f[n]=h(s)),s}return i(o,[{key:"handlers",get:function(){return _(this._groupChannelHandlers.values())}},{key:"buildGroupChannelFromSerializedData",value:function(e){var t=ai(e);return new dv(this._iid,dv.payloadify(t))}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){var t=ai(e);return new Hf(this._iid,t)}},{key:"buildMemberFromSerializedData",value:function(e){var t=ai(e);return new Ch(this._iid,Ch.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"getChannelsFromCache",value:function(e,n,r,a,i){return E(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.fetch({token:e,filter:n,order:r,limit:a,borderlineChannelUrl:i});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._groupChannelCache.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clearChannelsFromCache",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._groupChannelCache.clear();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"reduceDBSize",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Rl.of(this._iid),r=bi.of(this._iid),a=r.cacheContext,i=a.localCacheConfig,s=a.nestdb,a.localCacheEnabled&&s&&s.state==kl.OPENED){e.next=5;break}return e.abrupt("return");case 5:return o=1024*i.maxSize*1024,e.next=8,s.estimateUsage();case 8:if(!((u=e.sent)0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new Qh({channels:[G],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new Qh({channels:[G],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new Qh({channels:[G],source:e.CollectionEventSource.EVENT_CHANNEL_READ})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUnreadMemberStatusUpdated&&a.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return a.abrupt("break",342);case 81:return j=n.as(Wf),z=j.channelUrl,V=j.deliveredStateUpdate,B=void 0===V?{}:V,Q=this._groupChannelCache.isCachedInMemory(z),a.next=85,this.getChannel(z,!0);case 85:if(K=a.sent,Q)for(W in B)K._updateUndeliveredMemberState(W,B[W]);return Object.keys(B).some((function(e){return e!==hn._sdkState.userId}))&&(this._dispatcher.dispatch(new Qh({channels:[K],source:e.CollectionEventSource.EVENT_CHANNEL_DELIVERED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUndeliveredMemberStatusUpdated&&a.onUndeliveredMemberStatusUpdated(K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",342);case 89:if(Y=n.as(Yf),Z=Y.channelUrl,J=Y.channelType,X=Y.event,J!==e.ChannelType.GROUP){a.next=99;break}return a.next=93,this.getChannel(Z,!0);case 93:return $=a.sent,a.next=96,this.getMessageFromCache(X.messageId);case 96:(ee=a.sent)&&(ee.applyReactionEvent(X),this._dispatcher.dispatch(new gs({messages:[ee],source:e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onReactionUpdated&&a.onReactionUpdated($,X)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return a.abrupt("break",342);case 100:if(te=n.as(Zf),(ne=te.event).channelType!==e.ChannelType.GROUP){a.next=110;break}return a.next=104,this.getChannel(ne.channelUrl,!0);case 104:return re=a.sent,a.next=107,this.getMessageFromCache(ne.targetMessageId);case 107:(ae=a.sent)&&(ae.applyThreadInfoUpdateEvent(ne),this._dispatcher.dispatch(new gs({messages:[ae],source:e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onThreadInfoUpdated&&a.onThreadInfoUpdated(re,ne)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return a.abrupt("break",342);case 111:ie=n.as(Jf),se=ie.groupChannelMemberCounts,oe=[],ue=y(se),a.prev=114,ue.s();case 116:if((ce=ue.n()).done){a.next=125;break}return le=ce.value,de=le.channelUrl,he=le.memberCount,fe=le.joinedMemberCount,pe=le.updatedAt,a.next=121,this.getChannelFromCache(de);case 121:(ve=a.sent)&&ve._setLatestMemberCount(he,fe,pe)&&oe.push(ve);case 123:a.next=116;break;case 125:a.next=130;break;case 127:a.prev=127,a.t2=a.catch(114),ue.e(a.t2);case 130:return a.prev=130,ue.f(),a.finish(130);case 133:return oe.length>0&&(this._dispatcher.dispatch(new Qh({channels:oe,source:e.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(oe)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",342);case 135:if(_e=n.as(Xf),me=_e.event,ge=_e.status,ye=_e.channelUrl,ke=_e.channelType,!ye||ke!==e.ChannelType.GROUP){a.next=142;break}return a.next=139,this.getChannel(ye,!0);case 139:Ee=a.sent,this._dispatcher.dispatch(new bs({event:me,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),Ma(ge===Bi?function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(Ee,me.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(Ee,me)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return a.abrupt("break",342);case 143:if(be=n.as(Mu),we=be.event,Ce=be.channelUrl,xe=be.channelType,!Ce||xe!==e.ChannelType.GROUP){a.next=150;break}return a.next=147,this.getChannel(Ce,!0);case 147:Te=a.sent,this._dispatcher.dispatch(new ws({event:we,source:e.CollectionEventSource.EVENT_POLL_VOTED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(Te,we)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return a.abrupt("break",342);case 151:if(Se=n.as(mf),!(Ie=Se.event).isGroupChannelEvent){a.next=330;break}a.t3=Ie.category,a.next=a.t3===Th.CHANNEL_JOIN?156:a.t3===Th.CHANNEL_LEAVE?165:a.t3===Th.CHANNEL_OPERATOR_UPDATE?181:a.t3===Th.CHANNEL_INVITE?192:a.t3===Th.CHANNEL_DECLINE_INVITE?202:a.t3===Th.TYPING_START||a.t3===Th.TYPING_END?210:a.t3===Th.USER_CHANNEL_MUTE||a.t3===Th.USER_CHANNEL_UNMUTE?219:a.t3===Th.USER_CHANNEL_BAN?246:a.t3===Th.USER_CHANNEL_UNBAN?261:a.t3===Th.CHANNEL_FREEZE||a.t3===Th.CHANNEL_UNFREEZE?269:a.t3===Th.CHANNEL_HIDE?277:a.t3===Th.CHANNEL_UNHIDE?287:a.t3===Th.CHANNEL_DELETED?294:a.t3===Th.CHANNEL_PROP_CHANGED?300:a.t3===Th.CHANNEL_META_DATA_CHANGED?306:a.t3===Th.CHANNEL_META_COUNTERS_CHANGED?315:a.t3===Th.PINNED_MESSAGE_CHANGED?324:330;break;case 156:return a.next=158,this.getChannel(Ie.channelUrl,!0);case 158:return Ne=a.sent,Ae=n.as(kf),Me=Ae.memberCount,Oe=Ae.joinedMemberCount,Ue=Ae.members,De=!1,Ue.forEach((function(t){Ne.isExclusive||Ne.isSuper||Ne.isBroadcast?De=De||Ne._setLatestMemberCount(Me,Oe,Ie.ts):(t.state=e.MemberState.JOINED,Ne.addMember(t,Ie.ts),hn._updateJoinedMemberCount(Ne)),t.userId===hn._sdkState.userId&&(Ne.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new Qh({channels:[Ne],source:e.CollectionEventSource.EVENT_CHANNEL_JOINED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Ue);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ne,r)}}catch(e){n.e(e)}finally{n.f()}Ne.isBroadcast&&De&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ne])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 165:if(!(Re=this._leftChannels.get(Ie.channelUrl))){a.next=170;break}a.t4=Re.channel,a.next=173;break;case 170:return a.next=172,this.getChannel(Ie.channelUrl,!0);case 172:a.t4=a.sent;case 173:return Le=a.t4,Pe=n.as(bf),Fe=Pe.memberCount,He=Pe.joinedMemberCount,qe=Pe.member,Ge=!1,je=bi.of(this._iid),ze=je.appInfo,Le.isExclusive||Le.isSuper||Le.isBroadcast?Ge=Le._setLatestMemberCount(Fe,He,Ie.ts):((null==ze?void 0:ze.enabledChannelMemberShipHistory)?((Ve=Le.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=e.MemberState.LEFT),Le.memberCount=Fe):Le.removeMember(qe),this._updateJoinedMemberCount(Le)),qe.userId===this._sdkState.userId?(Le.myMemberState=e.MemberState.NONE,Le.invitedAt=0,Le.joinedAt=0,Le._updateUnreadCount(0,0),Le.isPublic?this._dispatcher.dispatch(new Qh({channels:[Le],source:e.CollectionEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Le),this._dispatcher.dispatch(new Kh({channelUrls:[Le.url],source:e.CollectionEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new Qh({channels:[Le],source:e.CollectionEventSource.EVENT_CHANNEL_LEFT})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(Le,qe),Le.isBroadcast&&Ge&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Le])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 181:return a.next=183,this.getChannel(Ie.channelUrl,!0);case 183:Be=a.sent,Qe=n.as(Pf),Ke=Qe.operators,We=Ke.map((function(e){return e.userId})),Ye=y(Be.members);try{for(Ye.s();!(Ze=Ye.n()).done;)(Je=Ze.value).role=We.includes(Je.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Ye.e(e)}finally{Ye.f()}return Be.myRole=We.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new Qh({channels:[Be],source:e.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Be,Ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 192:return a.next=194,this.getChannel(Ie.channelUrl,!0);case 194:Xe=a.sent,$e=n.as(xf),et=$e.memberCount,tt=$e.joinedMemberCount,nt=$e.inviter,(rt=$e.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),at=y(rt);try{for(at.s();!(it=at.n()).done;)st=it.value,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(et,tt,Ie.ts):Xe.addMember(st,Ie.ts),this._sdkState.userId===st.userId&&(Xe.hiddenState=e.HiddenState.UNHIDDEN,Xe.myMemberState!==e.MemberState.JOINED&&(Xe.myMemberState=e.MemberState.INVITED),Xe.invitedAt=Ie.ts)}catch(e){at.e(e)}finally{at.f()}return this._dispatcher.dispatch(new Qh({channels:[Xe],source:e.CollectionEventSource.EVENT_CHANNEL_INVITED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Xe,nt,rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 202:return a.next=204,this.getChannel(Ie.channelUrl,!0);case 204:return ot=a.sent,ut=n.as(Sf),ct=ut.memberCount,lt=ut.joinedMemberCount,dt=ut.inviter,ht=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ie.ts):ot.removeMember(ht),this._sdkState.userId===ht.userId?(ot.invitedAt=0,ot.myMemberState=e.MemberState.NONE,ot.isPublic?this._dispatcher.dispatch(new Qh({channels:[ot],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Kh({channelUrls:[ot.url],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Qh({channels:[ot],source:e.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,dt,ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 210:return a.next=212,this.getChannel(Ie.channelUrl,!0);case 212:return ft=a.sent,pt=Ie.category===Th.TYPING_START,vt=n.as(pt?Df:Lf),_t=vt.user,ft._updateTypingStatus(_t,pt?Ie.ts:0),this._dispatcher.dispatch(new Qh({channels:[ft],source:e.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 219:return a.next=221,this.getChannel(Ie.channelUrl,!0);case 221:mt=a.sent,gt=Ie.category===Th.USER_CHANNEL_MUTE,yt=n.as(gt?jo:Vo),(kt=yt.user).userId===this._sdkState.userId&&(mt.myMutedState=gt?e.MutedState.MUTED:e.MutedState.UNMUTED,mt._myMutedRemainingTime=kt.restrictionInfo.remainingDuration),Et=y(mt.members),a.prev=226,Et.s();case 228:if((bt=Et.n()).done){a.next=235;break}if((wt=bt.value).userId!==kt.userId){a.next=233;break}return wt.isMuted=gt,a.abrupt("break",235);case 233:a.next=228;break;case 235:a.next=240;break;case 237:a.prev=237,a.t5=a.catch(226),Et.e(a.t5);case 240:return a.prev=240,Et.f(),a.finish(240);case 243:return this._dispatcher.dispatch(new Qh({channels:[mt],source:gt?e.CollectionEventSource.EVENT_CHANNEL_MUTED:e.CollectionEventSource.EVENT_CHANNEL_UNMUTED,data:kt.userId})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){gt?e.onUserMuted&&e.onUserMuted(mt,kt):e.onUserUnmuted&&e.onUserUnmuted(mt,kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 246:if(!(Ct=this._leftChannels.get(Ie.channelUrl))){a.next=251;break}a.t6=Ct.channel,a.next=254;break;case 251:return a.next=253,this.getChannel(Ie.channelUrl,!0);case 253:a.t6=a.sent;case 254:return xt=a.t6,this._markAsLeave(xt),Tt=n.as(Qo),St=Tt.user,St.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Kh({channelUrls:[xt.url],source:e.CollectionEventSource.EVENT_CHANNEL_BANNED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 261:return a.next=263,this.getChannel(Ie.channelUrl,!0);case 263:return It=a.sent,Nt=n.as(Wo),At=Nt.user,At.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Kh({channelUrls:[It.url],source:e.CollectionEventSource.EVENT_CHANNEL_UNBANNED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(It,At)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 269:return a.next=271,this.getChannel(Ie.channelUrl,!0);case 271:return Mt=a.sent,Ot=n.as(Zo),Ut=Ot.freeze,Mt.isFrozen=Ut,this._dispatcher.dispatch(new Qh({channels:[Mt],source:Ut?e.CollectionEventSource.EVENT_CHANNEL_FROZEN:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ut?e.onChannelFrozen&&e.onChannelFrozen(Mt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 277:return a.next=279,this.getChannel(Ie.channelUrl,!0);case 279:return Dt=a.sent,Rt=n.as(Of),Lt=Rt.allowAutoUnhide,Pt=Rt.hidePreviousMessages,Ft=Rt.messageOffsetTimestamp,null!==Lt&&(Dt.hiddenState=Lt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Dt._updateUnreadCount(0,0),null!==Ft&&(Dt.messageOffsetTimestamp=Ft),this._dispatcher.dispatch(new Qh({channels:[Dt],source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 287:return a.next=289,this.getChannel(Ie.channelUrl,!0);case 289:return(Ht=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new Qh({channels:[Ht],source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 294:return a.next=296,this.getChannel(Ie.channelUrl,!0);case 296:return qt=a.sent,this._dispatcher.dispatch(new Kh({channelUrls:[Ie.channelUrl],source:e.CollectionEventSource.EVENT_CHANNEL_DELETED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(qt.url,qt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 300:return a.next=302,this.getChannelWithoutCache(Ie.channelUrl,!0);case 302:return Gt=a.sent,this._dispatcher.dispatch(new Qh({channels:[Gt],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 306:return a.next=308,this.getChannel(Ie.channelUrl,!0);case 308:return jt=a.sent,zt=n.as(So),Vt=zt.created,Bt=zt.updated,Qt=zt.deleted,Vt&&(jt._upsertCachedMetaData(Vt,Ie.ts),this._dispatcher.dispatch(new Qh({channels:[jt],source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED}))),Bt&&(jt._upsertCachedMetaData(Bt,Ie.ts),this._dispatcher.dispatch(new Qh({channels:[jt],source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED}))),Qt&&(jt._removeFromCachedMetaData(Qt,Ie.ts),this._dispatcher.dispatch(new Qh({channels:[jt],source:e.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED}))),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Vt&&e.onMetaDataCreated&&e.onMetaDataCreated(jt,Vt),Bt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Bt),Qt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 315:return a.next=317,this.getChannel(Ie.channelUrl,!0);case 317:return Kt=a.sent,Wt=n.as(Fo),Yt=Wt.created,Zt=Wt.updated,Jt=Wt.deleted,Yt&&this._dispatcher.dispatch(new Qh({channels:[Kt],source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED})),Zt&&this._dispatcher.dispatch(new Qh({channels:[Kt],source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED})),Jt&&this._dispatcher.dispatch(new Qh({channels:[Kt],source:e.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,Yt),Zt&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,Zt),Jt&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",330);case 324:return a.next=326,this.getChannel(Ie.channelUrl,!0);case 326:return Xt=a.sent,$t=n.as(qf),en=$t.pinnedMessageIds,tn=$t.latestPinnedMessage,(nn=$t.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=en,Xt.lastPinnedMessage=tn,Xt._pinnedMessagesUpdatedAt=nn,this._dispatcher.dispatch(new Qh({channels:[Xt],source:e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(Xt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Ma((function(){return E(hn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",330);case 330:return a.abrupt("break",342);case 331:rn=n.as(md),an=rn.event,a.t7=an.category,a.next=a.t7===nd.USER_BLOCK?335:a.t7===nd.USER_UNBLOCK?338:341;break;case 335:return sn=pd.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),a.abrupt("break",341);case 338:return cn=pd.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,dn=cn.blockee,this._groupChannelCache.unblock(ln.userId,dn.userId),a.abrupt("break",341);case 341:return a.abrupt("break",342);case 342:a.next=348;break;case 344:if(a.prev=344,a.t8=a.catch(0),!A(a.t8)){a.next=348;break}throw a.t8;case 348:case"end":return a.stop()}}),a,this,[[0,344],[19,30,33,36],[114,127,130,133],[226,237,240,243]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function a(){var i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",n)).throw(M.invalidParameters),i=new Jh({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:s=t.sent,o=s.as(Xh),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",t.sent[0]);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REFRESH_CHANNEL;return E(this,void 0,void 0,t().mark((function i(){var s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,s=new Jh({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:if(o=t.sent,u=o.as(Xh),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new Kh({channelUrls:[c.url],source:a})),t.next=14;break;case 10:return t.next=12,this.upsertChannelsToCache([c]);case 12:l=t.sent,this._dispatcher.dispatch(new Qh({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==b.NON_AUTHORIZED&&t.t0.code!==b.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Kh({channelUrls:[n],source:a}));case 19:case"end":return t.stop()}}),i,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.CollectionEventSource.REQUEST_CHANNEL;return E(this,void 0,void 0,t().mark((function e(){var s,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.createdAfter&&(r.createdAfter=Math.floor(r.createdAfter/1e3)),r.createdBefore&&(r.createdBefore=Math.floor(r.createdBefore/1e3)),s=new ef(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=5,this._requestQueue.send(s);case 5:return o=e.sent,u=o.as(tf),c=u.channels,l=u.token,this._dispatcher.dispatch(new Qh({channels:c,source:i})),e.abrupt("return",{channels:c,token:l});case 9:case"end":return e.stop()}}),e,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,t().mark((function e(){var i,s,o,u,c,l,d,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=Object.assign(Object.assign({},Uh),r),ii((R("string",n)||R("number",n))&&Dh(i)).throw(M.invalidParameters),s=new Yh(de({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:i})),e.next=5,this._requestQueue.send(s);case 5:return o=e.sent,u=o.as(Zh),c=u.updatedChannels,l=u.deletedChannelUrls,d=u.hasMore,h=u.ts,c.length>0&&this._dispatcher.dispatch(new Qh({channels:c,source:a,ts:h})),l.length>0&&this._dispatcher.dispatch(new Kh({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:d,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Rh),e),ii(Lh(r)).throw(M.invalidParameters),a=new nf({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return i=t.sent,s=i.as(rf),o=s.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d,h,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Fh),e),ii(Hh(r)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new af({userId:i.userId,filter:r}),t.next=6,s.send(o);case 6:return u=t.sent,c=u.as(sf),l=c.groupChannelUnreadMentionCount,d=c.groupChannelUnreadMessageCount,h=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",le({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:d,groupChannelInvitationCount:h,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new of({userId:r.userId}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(uf),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},qh),e),ii(Gh(r)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new cf({userId:i.userId,filter:r}),t.next=6,s.send(o);case 6:return u=t.sent,c=u.as(lf),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},jh),e),ii(zh(r)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new df(r),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(hf),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=bi.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=bi.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=bi.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Mh),e),ii(Oh(r)).throw(M.invalidParameters),r.isPublic||(r.accessCode=void 0),a=new pf(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return i=t.sent,s=i.as(vf),o=s.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),ii(n-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new _f({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=y(a);try{for(i.s();!(s=i.n()).done;)(o=s.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){i.e(e)}finally{i.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),ii(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new _f({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:i=this._groupChannelCache.channels,s=[],o=y(i);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),s.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(s.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(s);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return $f[e]||($f[e]=new o(e,bi.of(e))),$f[e]}},{key:"clear",value:function(e){$f[e]&&delete $f[e]}}]),o}(jf);!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ph||(Ph={}));var tp=function(e){s(a,e);var n=f(a);function a(e,t){var i;return r(this,a),(i=n.call(this))._state=Ph.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=t,i}return i(a,[{key:"isIdle",get:function(){return this._state===Ph.IDLE}},{key:"isRunning",get:function(){return this._state===Ph.RUNNING}},{key:"isDone",get:function(){return this._state===Ph.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(f=d.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(h=u.range).intersect.apply(h,_(f)))?this.extendRange(d):this._metadata={range:new Gf({top:Math.min.apply(Math,_(f)),bottom:Math.max.apply(Math,_(f))}),previousComplete:!1}),c.hasNext=d.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(c.nextToken=this._metadata.range.top,this._metadata.previousComplete=d.length0&&(h=l.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(d=o.range).intersect.apply(d,_(h)))?this.extendRange(l):this._metadata={range:new Gf({top:Math.min.apply(Math,_(h)),bottom:Math.max.apply(Math,_(h))}),previousComplete:!1}),u.hasNext=l.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(u.nextToken=this._metadata.range.bottom),v.debug("message background next sync progress",u),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",u);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ya)if(e.stateType===ha.CONNECTED)i.resume();else i.pause()}))}return i(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Gf({})}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=bi.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(i=t.sent)?i.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),i=bi.of(this._iid),s=i.logger;i.connectionManager.isConnected&&(s.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){bi.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete np[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return np[e]||(np[e]={}),np[e][t.url]||(np[e][t.url]=new n({_iid:e,channel:t})),np[e][t.url].ref++,np[e][t.url]}},{key:"clear",value:function(e,t){np[e]&&np[e][t]&&(np[e][t].close(),delete np[e])}}]),n}(),ap={},ip=function(){function n(a){var i=this,s=a._iid,o=a.channel;r(this,n),this.ref=0,this._iid=s,this._channel=o;var u,c,l=bi.of(this._iid),d=l.logger,h=l.sdkState,f=l.dispatcher;this._metadataKey=(u=h.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(h.userId,this._channel.url);this._sync=new tp(p,(function(){return E(i,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return d.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,i=Hl.of(this._iid),t.next=8,i.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return s=t.sent,o=s.updatedMessages,u=s.deletedMessageIds,c=s.hasMore,l=s.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&this._metadata&&(this._metadata.token=l),d.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),d.debug("message changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ya)if(e.stateType===ha.CONNECTED)i.resume();else i.pause()}))}return i(n,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=bi.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:i=e.sent,this._metadata={token:i?i.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=bi.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=bi.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=bi.of(this._iid),t=e.logger;e.connectionManager,t.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ap[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return ap[e]||(ap[e]={}),ap[e][t.url]||(ap[e][t.url]=new n({_iid:e,channel:t})),ap[e][t.url].ref++,ap[e][t.url]}},{key:"clear",value:function(e,t){ap[e]&&ap[e][t]&&(ap[e][t].close(),delete ap[e])}}]),n}(),sp={},op=function(){function e(n){var a=this,i=n._iid,s=n.channel,o=n.hasPollMessage;r(this,e),this.ref=0,this._iid=i,this._channel=s;var u,c,l=bi.of(this._iid),d=l.logger,h=l.sdkState,f=l.dispatcher;this._metadataKey=(u=h.userId,c=s.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new tp(p,(function(){return E(a,void 0,void 0,t().mark((function e(){var n,r,a,i,s,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(d.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(i=bi.of(this._iid),s=i.firstConnectedAt,this._metadata={token:s}),e.prev=13,u=Ku.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,h=c.token,r.hasNext=l,r.nextToken=h,this._metadata.token=h,d.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),d.debug("poll changelog sync error",e.t1),!(e.t1 instanceof M&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ya)if(e.stateType===ha.CONNECTED)a.resume();else a.pause()}))}return i(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=bi.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=bi.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){bi.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){bi.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete sp[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return sp[t]||(sp[t]={}),sp[t][n.url]||(sp[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),sp[t][n.url].ref++,sp[t][n.url]}}]),e}(),up=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channels,s=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c;return r(this,n),(a=t.call(this)).channels=i,a.source=s,a.isWebSocketEventComing=u,a.data=l,a}return i(n)}(ce),cp=function(t){s(a,t);var n=f(a);function a(t){var i,s,o,u,c,l,d,h,f,p,v;return r(this,a),(i=n.call(this)).method=he.GET,i.path="".concat(Ie(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),i.params=le({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(s=t.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(o=t.customTypes)&&void 0!==o?o:["*"],message_type:null!==(u=t.messageType)&&void 0!==u?u:null,include_reply_type:null!==(c=t.replyType)&&void 0!==c?c:e.ReplyType.NONE,include_reactions:null===(l=t.includeReactions)||void 0===l||l,include_meta_array:null===(d=t.includeMetaArray)||void 0===d||d,include_thread_info:null===(h=t.includeThreadInfo)||void 0===h||h,include_parent_message_info:null===(f=t.includeParentMessageInfo)||void 0===f||f,with_sorted_meta_array:null===(p=t.includeMetaArray)||void 0===p||p,show_subchannel_messages_only:null!==(v=t.showSubchannelMessagesOnly)&&void 0!==v&&v,include_poll_details:!0,checking_continuous_messages:t.checkingContinuousMessages}),i}return i(a)}(De),lp=function(e){s(n,e);var t=f(n);function n(e,a){var i,s,o,u,c,l,d;return r(this,n),(i=t.call(this,e,a)).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return es(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,i.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return es(e,t)})),i.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,i.isContinuousNextMessages=null!==(d=a.is_continuous_next_messages)&&void 0!==d&&d,i}return i(n)}(Re),dp=function(e,t){return t instanceof Hi?e.findIndex((function(e){return e instanceof Hi&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},hp=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},fp=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},pp=i((function e(t){r(this,e),this.source=t})),vp=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return i(n)}(pp),_p=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return i(n)}(pp),mp=i((function e(t){r(this,e),this.source=t})),gp=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return i(n)}(mp),yp=function(e){s(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return i(n)}(mp),kp=6e5,Ep={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var bp,wp,Cp,xp=function(){function e(){r(this,e),this._onCacheResult=We,this._onApiResult=We}return i(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;Ma((function(){return E(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),Tp=function(){function n(a,i){var s=this,o=i.filter,u=i.startingPoint,c=i.limit,l=i.channel,d=i.channelManager;r(this,n),this._messages=[],this._unsentMessages=[],this._iid=a,this._key="mc-".concat(ie()),this._isDisposed=!1,this.filter=null!=o?o:new Tl,this._channel=l,this._syncRange=new Gf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u?u:Date.now()+kp,this._limit=c||100,this._channelManager=d,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:function(n,r,a){var i=n.findIndex((function(e){return e.isIdentical(s.channel)}));i>=0&&(s._replaceChannelOfCollection(n[i]),s.channel._runIfHandleableWithGroupChannel((function(n){switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:var i=!1;for(var o in s._messages){if(s._messages[o].createdAt>=n.messageOffsetTimestamp){i=!0;var u=parseInt(o);if(u>0){var c=s._messages.splice(0,u);s._removeMessagesFromView(c.map((function(e){return e.messageId})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!i&&s._messages.length>0&&s._removeMessagesFromView(s._messages.map((function(e){return e.messageId})),e.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.CollectionEventSource.EVENT_CHANNEL_UNMUTED:var l=bi.of(s._iid).sdkState,d=a;l.userId===d&&s._clearCheckMyMutedTimer();break;case e.CollectionEventSource.EVENT_CHANNEL_MUTED:var h=bi.of(s._iid).sdkState,f=a;h.userId===f&&-1!==n._myMutedRemainingTime&&s._startCheckMyMutedTimer(n._myMutedRemainingTime);break;case e.CollectionEventSource.EVENT_CHANNEL_LEFT:n.isPublic&&s._clearCheckMyMutedTimer()}Ma((function(){return E(s,void 0,void 0,t().mark((function e(){var n,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._createChannelEventContext(r),Bh(r)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(a,this.channel);case 2:case"end":return e.stop()}}),e,this)})))}))})))},onRemove:function(e,n){e.indexOf(s.channel.url)>=0&&(s._clearCheckMyMutedTimer(),Ma((function(){return E(s,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._createChannelEventContext(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],i=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===s._channel.url&&(s.filter.match(u)?a.push(u):i.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(ms(n)){if(a.length>0)switch(n){case e.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case e.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case e.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.CollectionEventSource.EVENT_MESSAGE_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:s._updateMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:s._addMessagesToView(a,n);break;case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:s.hasNext||s._addMessagesToView(a,n);break;case e.CollectionEventSource.SYNC_MESSAGE_FILL:s._addMessagesToView(a,n)}i.length>0&&s._removeMessagesFromView(i,n)}},onRemove:function(e,t){s._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){s._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){s._updatePollsToView(e,t)},onPollUpdate:function(e,t){s._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){s._applyPollVoteEventToView(e,t)}});var h=bi.of(this._iid),f=h.cacheContext,p=h.dispatcher,v=h.logger;this._channel._updateMessageCollectionLastAccessedAt();var m=this._createChannelUpdateEventCommand(e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);m&&p.dispatch(m),this._shouldStartBackgroundSync()&&(this._backgroundSync=rp.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ip.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=op.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new tp(this._key,(function(n){return E(s,void 0,void 0,t().mark((function r(){var a,i,s,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(i=t.sent,s=i.messages,o=i.isContinuousMessages,!(s.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(s.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:s.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(s.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(s.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof ya)switch(n.stateType){case ha.CONNECTED:s._refreshChannel(e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS),Oa((function(){return E(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),s._checkHugeGap();break;case ha.LOGOUT:s.dispose();break;default:s._clearCheckMyMutedTimer(),s._prevFill.stop(),s._nextFill.stop()}})),bi.of(this._iid).statLogCollector.put(new pi({type:Ue.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return i(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"_replaceChannelOfCollection",value:function(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}},{key:"_shouldStartBackgroundSync",value:function(){var e=bi.of(this._iid).cacheContext;return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}},{key:"_createChannelEventContext",value:function(e){switch(!0){case this.channel.isGroupChannel():return new vp(e);case this.channel.isFeedChannel():return new _p(e);default:throw new M({code:b.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}},{key:"_createMessageEventContext",value:function(e){switch(!0){case this.channel.isGroupChannel():return new gp(e);case this.channel.isFeedChannel():return new yp(e);default:throw new M({code:b.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}},{key:"_createChannelUpdateEventCommand",value:function(e){switch(!0){case this.channel.isGroupChannel():return new Qh({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new up({channels:[this._channel],source:e});default:return null}}},{key:"_setBaseMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,i=this,s=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(s);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.CollectionEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(dp(this._messages,l)<0){dp(this._unsentMessages,l)<0&&o.push(l);var d=fp(this._messages,l);this._messages.splice(d,0,l)}}else if(l instanceof Hi){dp(this._unsentMessages,l)<0&&dp(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var h=dp(this._messages,l);if(h<0){var f=dp(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=fp(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[h]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Hi){var m=dp(this._unsentMessages,l);m<0?dp(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}ms(r)&&Ma((function(){return E(i,void 0,void 0,t().mark((function e(){var n,a,i,s,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=this._createMessageEventContext(r),o.length>0&&(null===(a=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===a||a.call(n,c,this.channel,o)),u.length>0&&(null===(s=null===(i=this._handler)||void 0===i?void 0:i.onMessagesUpdated)||void 0===s||s.call(i,c,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,i=[],s=y(e);try{for(s.s();!(r=s.n()).done;){var o=r.value,u=hp(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),i.push(c)}}}catch(e){s.e(e)}finally{s.f()}return i.length>0&&ms(n)&&Ma((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=this._createMessageEventContext(n),i.length>0&&(null===(a=(r=this._handler).onMessagesUpdated)||void 0===a||a.call(r,s,this.channel,i));case 2:case"end":return e.stop()}}),e,this)})))})),i}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=hp(this._messages,e.messageId);if(a>=0){var i=this._messages[a];i&&i.isUserMessage()&&i.poll&&i.poll.applyPollUpdateEvent(e)&&ms(n)&&Ma((function(){return E(r,void 0,void 0,t().mark((function e(){var r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=this._createMessageEventContext(n),null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,s,this.channel,[i]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=hp(this._messages,e.messageId);if(a>=0){var i=this._messages[a];i&&i.isUserMessage()&&i.poll&&i.poll.applyPollVoteEvent(e)&&ms(n)&&Ma((function(){return E(r,void 0,void 0,t().mark((function e(){var r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=this._createMessageEventContext(n),null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,s,this.channel,[i]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,i=[],s=[],o=[],u=y(e);try{for(u.s();!(r=u.n()).done;){var c=r.value;if(c.messageId>0){var l=dp(this._messages,c);if(l>=0)s.push(c),this._messages[l]=c;else{var d=dp(this._unsentMessages,c);if(d>=0){var h=this._unsentMessages.splice(d,1);if(this.hasNext&&h.length>0)o.push(h[0]);else{s.push(c);var f=fp(this._messages,c);this._messages.splice(f,0,c)}}else{var p=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,_(p))&&!this._hasNext)&&i.push(c)}}}else if(c instanceof Hi){var v=dp(this._unsentMessages,c);v>=0&&(s.push(c),this._unsentMessages[v]=c)}}}catch(e){u.e(e)}finally{u.f()}return ms(n)&&Ma((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:l=this._createMessageEventContext(n),s.length>0?null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesUpdated)||void 0===a||a.call(r,l,this.channel,s):o.length>0?null===(c=null===(u=this._handler)||void 0===u?void 0:u.onMessagesDeleted)||void 0===c||c.call(u,l,this.channel,[],o):i.length>0&&this._addMessagesToView(i,n);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,i=[],s=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];i.push(n.messageId),s.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return ms(n)&&s.length>0&&Ma((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=this._createMessageEventContext(n),null===(a=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===a||a.call(r,o,this.channel,i,s);case 2:case"end":return e.stop()}}),e,this)})))})),i}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.inclusive,u=void 0===o||o;return E(this,void 0,void 0,t().mark((function n(){var r,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!u){t.next=5;break}return t.next=4,this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 4:r=t.sent;case 5:if(!(a>0)){t.next=11;break}return t.next=8,this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a,!1);case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=[];case 12:if(i=t.t0,!(s>0)){t.next=19;break}return t.next=16,this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1);case 16:t.t1=t.sent,t.next=20;break;case 19:t.t1=[];case 20:return o=t.t1,t.abrupt("return",[].concat(_(r),_(i),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 22:case"end":return t.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,i=void 0===a?0:a,s=r.nextLimit,o=void 0===s?0:s,u=r.source,c=void 0===u?e.CollectionEventSource.REQUEST_MESSAGE:u,l=r.reverse,d=void 0!==l&&l,h=r.checkingContinuousMessages,f=void 0!==h&&h;return E(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Hl.of(this._iid),!(i>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,de(Object.assign(Object.assign(Object.assign({},this.filter),Ep),{isInclusive:!0,reverse:d,prevResultSize:i,nextResultSize:o})),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h,f,p,v,m,g,y,k,w,C,x,T=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=15;break}return a=this._syncRange.top,i=this.viewTop,s=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,r.next=7,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,a);case 7:return u=r.sent,r.next=10,this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,s,o);case 10:return c=r.sent,r.next=13,Aa((function(){return E(T,void 0,void 0,t().mark((function n(){var r,l,d,h,f,p,v,m,g,y,k,b,w,C,x,T,S,I,N,A,M,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=bi.of(this._iid),d=l.dispatcher,h=l.requestQueue,f=l.cacheContext,p=new cp(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:i,prevEnd:a,prevCount:u,nextStart:s,nextEnd:o,nextCount:c,checkingContinuousMessages:f.localCacheEnabled},this.filter),Ep)),n.next=4,h.send(p);case 4:v=n.sent,m=v.as(lp),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,b=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,T=m.nextHasmore,S=m.isContinuousNextMessages,g?Ma((function(){return E(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null===(n=this._handler)||void 0===n?void 0:n.onHugeGapDetected)&&this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(I=this.viewTop,N=this.viewBottom,A=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),M=Math.max.apply(Math,[0,N].concat(_(x.map((function(e){return e.createdAt}))))),d.dispatch(new gs({messages:k,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),d.dispatch(new gs({messages:x,source:e.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(A,M),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(A,M)),b&&this._prevFill.start(A),T&&this._nextFill.start(M));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 13:r.next=30;break;case 15:return l=bi.of(this._iid),d=l.cacheContext,h=Math.floor(this._limit/2),f=Date.now(),r.prev=18,r.next=21,this._getRemoteMessages(f,{prevLimit:h,nextLimit:h,source:e.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 21:if(p=r.sent,v=p.messages,m=p.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),k=0,w=0,C=0;C=f&&w++;this._hasPrevious=k>=h,this._hasNext=w>=h,(g=this._syncRange).extends.apply(g,_(y)),m&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,e.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=30;break;case 27:r.prev=27,r.t0=r.catch(18),r.t0 instanceof M&&r.t0.code===b.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 30:case"end":return r.stop()}}),r,this,[[18,27]])})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter);case 2:this._unsentMessages=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+kp,this.filter,1);case 2:if(!(e.sent.length>0)){e.next=5;break}return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){this._channelManager.refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(r,void 0,void 0,t().mark((function n(){var r,a,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,r=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:a=t.sent,r=!a.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r=!0;case 12:return t.prev=12,r&&this.channel._runIfHandleableWithGroupChannel((function(t){var n,r;t.myMutedState=e.MutedState.UNMUTED;var a=i._createChannelEventContext(e.CollectionEventSource.EVENT_CHANNEL_UNMUTED);null===(r=null===(n=i._handler)||void 0===n?void 0:n.onChannelUpdated)||void 0===r||r.call(n,a,i.channel)})),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"initialize",value:function(n){var r=this,a=new xp;this._messages=[],this._unsentMessages=[],this._syncRange=new Gf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.CollectionEventSource.REFRESH_CHANNEL),Oa((function(){return E(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var i=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:i,nextLimit:i}).then((function(n){return E(r,void 0,void 0,t().mark((function r(){var i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this._filterUnderOffsetMessage(n),this._addMessagesToView(i,e.CollectionEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,i);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(A(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=bi.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:i,nextLimit:i,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,s=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(s);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),d=0,h=0,f=0;fr._startingPoint&&h++}r._hasPrevious=d>=i,r._hasNext=h>=i,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.CollectionEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(A(e))throw e;a._invokeResponse("remote",e,null)}))}));var s=bi.of(this._iid),o=s.cacheContext;return s.statLogCollector.put(new pi({type:Ue.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(this._hasPrevious){n.next=4;break}return n.abrupt("return",[]);case 4:return r=Math.floor(this._limit/2),a=this.viewTop,i=[],n.next=9,Oa((function(){return E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{prevLimit:r,inclusive:!1});case 3:e.t1=e.sent,i=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 9:if(!(i.length=r,i.length>0&&((l=this._syncRange).extends.apply(l,_(i.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 8:case"end":return e.stop()}}),e,this)})))}));case 12:this._addMessagesToView(i,e.CollectionEventSource.REQUEST_MESSAGE),n.next=17;break;case 15:this._hasPrevious=i.length>=r,i.length>0&&this._addMessagesToView(i,e.CollectionEventSource.REQUEST_MESSAGE);case 17:return n.abrupt("return",i);case 18:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._isDisposed){r.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(this._hasNext){r.next=4;break}return r.abrupt("return",[]);case 4:return a=Math.floor(this._limit/2),i=this.viewBottom,s=[],r.next=9,Oa((function(){return E(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(i,{nextLimit:a,inclusive:!1});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 9:if(!(s.length=a,s.length>0&&((l=this._syncRange).extends.apply(l,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 8:case"end":return e.stop()}}),e,this)})))}));case 12:this._addMessagesToView(s,e.CollectionEventSource.REQUEST_MESSAGE),r.next=17;break;case 15:this._hasNext=s.length>=a,s.length>0&&this._addMessagesToView(s,e.CollectionEventSource.REQUEST_MESSAGE);case 17:return r.abrupt("return",s);case 18:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return t.next=4,this._channelManager.removeFailedMessageFromCache(e);case 4:(r=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(r,1);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=this;if(!this._isDisposed){this._isDisposed=!0;var i=bi.of(this._iid),s=i.cacheContext,o=i.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((function(t){if(t.myMemberState!==e.MemberState.NONE){a._channel._updateMessageCollectionLastAccessedAt();var n=a._createChannelUpdateEventCommand(e.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);n&&o.dispatch(n)}})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}]),n}(),Sp=function(e){s(n,e);var t=f(n);function n(e,a){return r(this,n),t.call(this,e,Object.assign(Object.assign({},a),{channelManager:ep.of(e)}))}return i(n,[{key:"setMessageCollectionHandler",value:function(e){this._setBaseMessageCollectionHandler(e)}}]),n}(Tp),Ip={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},Np=function(e){return R("string",e.coverUrl,!0)&&(G(e.coverImage)||R("string",e.coverImage,!0))&&R("boolean",e.isDistinct,!0)&&R("boolean",e.isPublic,!0)&&R("boolean",e.isDiscoverable,!0)&&R("string",e.accessCode,!0)&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&R("number",e.messageSurvivalSeconds,!0)},Ap=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,d=e.nicknameStartsWithFilter,h=e.operatorFilter;return(a=t.call(this)).method=he.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:d,operator_filter:h,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return i(n)}(De),Mp=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new Ch(e,t)}))),i}return i(n)}(Re);e.MutedMemberFilter=void 0,(bp=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",bp.MUTED="muted",bp.UNMUTED="unmuted",e.MemberListOrder=void 0,(wp=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",wp.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(Cp=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",Cp.JOINED="joined_only",Cp.INVITED="invited_only",Cp.INVITED_BY_FRIEND="invited_by_friend",Cp.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Op,Up,Dp=function(n){s(u,n);var a=f(u);function u(t,n,i){var s,o,c,l,d;return r(this,u),(s=a.call(this,t,n,e.ChannelType.GROUP,i)).mutedMemberFilter=e.MutedMemberFilter.ALL,s.memberStateFilter=e.MemberStateFilter.ALL,s.nicknameStartsWithFilter=null,s.operatorFilter=e.OperatorFilter.ALL,s.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,s.mutedMemberFilter=null!==(o=i.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,s.memberStateFilter=null!==(c=i.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,s.nicknameStartsWithFilter=null!==(l=i.nicknameStartsWithFilter)&&void 0!==l?l:null,s.order=null!==(d=i.order)&&void 0!==d?d:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,s}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L(e.MutedMemberFilter,this.mutedMemberFilter)&&L(e.MemberStateFilter,this.memberStateFilter)&&(R("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&L(e.OperatorFilter,this.operatorFilter)&&L(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new Ap(de(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Mp),o=s.members,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(io),Rp=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return i(n)}(De),Lp=function(t){s(a,t);var n=f(a);function a(t,i){var s;return r(this,a),(s=n.call(this,t,i)).channel=new dv(t,i),s.channel.myMemberState=e.MemberState.JOINED,s}return i(a)}(Re),Pp=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,d=e.accessCode,h=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i)),a.params=le({is_distinct:s,is_public:o,is_discoverable:u,name:h,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:d,operator_ids:v,message_survival_seconds:_}),a}return i(n)}(De),Fp=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).channel=new dv(e,a),i}return i(n)}(Re),Hp=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl;return(a=t.call(this)).method=he.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i)),a}return i(n)}(De),qp=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl;return(a=t.call(this)).method=he.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/hide"),a}return i(n)}(De),Gp=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return i(n)}(De),jp=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).countPreference=a.count_preference,i}return i(n)}(Re),zp=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl;return(a=t.call(this)).method=he.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/reset_user_history"),a}return i(n)}(De),Vp=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.ts_message_offset;return i.messageOffsetTimestamp=s,i}return i(n)}(Re),Bp=Object.assign(Object.assign({},Xs),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Qp=function(e){return $s(e)&&R("number",e.scheduledAt,!0)&&(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return R("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Kp=Object.assign(Object.assign({},eo),{scheduledAt:void 0}),Wp=function(e){return to(e)&&R("number",e.scheduledAt,!0)},Yp=function(t){s(a,t);var n=f(a);function a(t){var i,s;r(this,a),i=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return i.method=he.PUT,i.path="".concat(Ie(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=le(de({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:J.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return qi.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),i}return i(a)}(De),Zp=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).message=new ts(e,a),i}return i(n)}(Re),Jp=function(t){s(a,t);var n=f(a);function a(t){var i,s;r(this,a),i=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return i.method=he.PUT,i.path="".concat(Ie(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),i.params=le(de({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:J.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(s=t.metaArrays)||void 0===s?void 0:s.map((function(e){return Mi.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?Di.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),i}return i(a)}(De),Xp=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=he.DELETE,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return i(n)}(De),$p=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=he.POST,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return i(n)}(De),ev=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=he.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return i(n)}(De),tv=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return i(n)}(Re),nv=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.userId,s=e.channelUrl;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return i(n)}(De),rv=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return i(n)}(Re),av=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=he.POST,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return i(n)}(De),iv=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=he.DELETE,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return i(n)}(De),sv=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e)).message=es(e,a.message),i}return i(n)}(Za),ov=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelType,s=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,d=e.includeParentMessageInfo,h=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=he.GET,a.path="".concat(Ie(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),a.params=le({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:h,include_parent_message_info:d,include_poll_details:f}),a}return i(n)}(De),uv=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),i=t.call(this,e,a);var s=a.pinned_messages,o=a.has_more,u=a.next;return i.pinnedMessages=s.map((function(t){return new sv(e,t)})),i.hasMore=o,i.token=u,i}return i(n)}(Re),cv=function(e){s(a,e);var n=f(a);function a(e,t,i,s){var o;return r(this,a),(o=n.call(this,e,t,i,s)).includeMetaArray=s.includeMetaArray,o.includeReactions=s.includeReactions,o.includeParentMessageInfo=s.includeParentMessageInfo,o.includeThreadInfo=s.includeThreadInfo,o.includePollDetails=s.includePollDetails,o}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&R("boolean",this.includeMetaArray,!0)&&R("boolean",this.includeReactions,!0)&&R("boolean",this.includeParentMessageInfo,!0)&&R("boolean",this.includeThreadInfo,!0)&&R("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new ov(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(uv),o=s.pinnedMessages,u=s.hasMore,c=s.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(io);e.CountPreference=void 0,(Op=e.CountPreference||(e.CountPreference={})).ALL="all",Op.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Op.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Op.OFF="off",e.HiddenState=void 0,(Up=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Up.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Up.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var lv,dv=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h,f,p,v,m,g,y,k,E,b,w,C,x,T,S;(r(this,u),(i=a.call(this,t,n))._unreadMemberStateMap=new Map,i._undeliveredMemberStateMap=new Map,i._typingStatus=new Map,i._lastMemberCountUpdated=0,i._typingStarted=0,i._typingEnded=0,i.isDistinct=!1,i.isSuper=!1,i.isBroadcast=!1,i.isExclusive=!1,i.isPublic=!1,i.isDiscoverable=!0,i.isChatNotification=!1,i.isAccessCodeRequired=!1,i.isPushEnabled=!1,i.unreadMessageCount=0,i.unreadMentionCount=0,i.members=[],i.memberCount=0,i.joinedMemberCount=0,i.hiddenState=e.HiddenState.UNHIDDEN,i.lastMessage=null,i.messageOffsetTimestamp=0,i.messageSurvivalSeconds=-1,i.myMemberState=e.MemberState.NONE,i.myRole=e.Role.NONE,i.myMutedState=e.MutedState.UNMUTED,i.myLastRead=0,i.myCountPreference=e.CountPreference.ALL,i.myPushTriggerOption=e.PushTriggerOption.DEFAULT,i.inviter=null,i.invitedAt=0,i.joinedAt=0,i.pinnedMessageIds=[],i.lastPinnedMessage=null,i._pinnedMessagesUpdatedAt=0,i._myMutedRemainingTime=-1,i.channelType=e.ChannelType.GROUP,i.isDistinct=null!==(s=n.is_distinct)&&void 0!==s&&s,i.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,i.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,i.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,i.isPublic=null!==(d=n.is_public)&&void 0!==d&&d,i.isDiscoverable=null!==(h=n.is_discoverable)&&void 0!==h?h:i.isPublic,i.isChatNotification=null!==(f=n.is_chat_notification)&&void 0!==f&&f,i.isAccessCodeRequired=null!==(p=n.is_access_code_required)&&void 0!==p&&p,i.isPushEnabled=null!==(v=n.is_push_enabled)&&void 0!==v&&v,Array.isArray(n.members))&&(S=i.members).push.apply(S,_(n.members.map((function(e){return new Ch(i._iid,e)}))));return i.memberCount=null!==(m=n.member_count)&&void 0!==m?m:0,i.joinedMemberCount=null!==(g=n.joined_member_count)&&void 0!==g?g:0,i.hiddenState=L(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,i.messageOffsetTimestamp=null!==(y=n.ts_message_offset)&&void 0!==y?y:0,i.messageSurvivalSeconds=null!==(k=n.message_survival_seconds)&&void 0!==k?k:-1,i.lastMessage=n.last_message?es(i._iid,Object.assign({channel_type:i.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){R("number",n.read_receipt[e])&&i._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){R("number",n.delivery_receipt[e])&&i._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),i.myMemberState=L(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,i.myRole=L(e.Role,n.my_role)?n.my_role:e.Role.NONE,L(e.MutedState,n.is_muted)?i.myMutedState=n.is_muted:R("boolean",n.is_muted)?i.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:i.myMutedState=e.MutedState.UNMUTED,i.myCountPreference=L(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,i.myPushTriggerOption=L(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,i.myLastRead=null!==(E=n.user_last_read)&&void 0!==E?E:0,i.inviter=n.inviter?new oi(i._iid,n.inviter):null,i.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,i.joinedAt=null!==(w=n.joined_ts)&&void 0!==w?w:0,i._updateUnreadCount(null!==(C=n.unread_message_count)&&void 0!==C?C:0,null!==(x=n.unread_mention_count)&&void 0!==x?x:0),i.pinnedMessageIds=null!==(T=n.pinned_message_ids)&&void 0!==T?T:[],i.lastPinnedMessage=n.latest_pinned_message?es(i._iid,Object.assign({channel_type:i.channelType},n.latest_pinned_message)):null,i}return i(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Hi&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=bi.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=bi.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ri(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Sp(this._iid,Object.assign(Object.assign({},e),{channel:this}))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Dp(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new cv(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof Ch?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Hi&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=bi.of(this._iid).sdkState,a=t.createdAt,i=0,s=y(this.members);try{for(s.s();!(n=s.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=bi.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Hi?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o>=e.createdAt&&i.push(s)}})),i}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=bi.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Hi?e.sender:null,i=[];return this.members.forEach((function(s){if(n||s.userId!==r.userId&&s.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(s.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=bi.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var i=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new xh(e._iid,{channel_url:e.url,channel_type:e.channelType,user:Ch.payloadify(a),ts:null!=i?i:0})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=bi.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._refresh());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"_refresh",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=bi.of(this._iid),i=a.requestQueue,s=a.dispatcher,o=new Jh({channelUrl:this.url}),t.next=4,i.send(o);case 4:return u=t.sent,c=u.as(Xh),l=c.channel,this._update(l),n&&s.dispatch(new Qh({channels:[l],source:e.CollectionEventSource.REQUEST_CHANNEL})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=bi.of(this._iid),a.dispatcher.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return E(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=bi.of(this._iid),a.dispatcher.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Ip),n),ii(Np(a)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.dispatcher,o=i.requestQueue,u=new Pp(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Fp),d=l.channel,this._update(d),s.dispatch(new Qh({channels:[d],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(e.every((function(e){return e instanceof oi}))).throw(M.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(F("string",n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new wf({channelUrl:this.url,userIds:n}),t.next=5,s.send(o);case 5:return u=t.sent,c=u.as(Cf),l=c.channel,this._update(l),i.dispatch(new Qh({channels:[l],source:e.CollectionEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",n,!0)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new gf({channelUrl:this.url,userId:s.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(yf),(d=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(d),i.dispatch(new Qh({channels:[d],source:e.CollectionEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=bi.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new Ef({channelUrl:this.url,userId:i.userId,shouldRemoveOperatorStatus:n}),t.next=4,s.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",n,!0)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new Rp({channelUrl:this.url,userId:s.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Lp),(d=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(d),i.dispatch(new Qh({channels:[d],source:e.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Tf({channelUrl:this.url,userId:a.userId}),t.next=4,i.send(s);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Rs,a=bi.of(this._iid).dispatcher,i=dd.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),ep.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new Qh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,i=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return E(this,void 0,void 0,t().mark((function a(){var s,o,u,c,l,d=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=bi.of(this._iid),o=s.dispatcher,t.next=3,i.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(ep.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})),o.dispatch(new Qh({channels:[this],source:l?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}))),l&&ep.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(d)})),o.dispatch(new gs({messages:[u],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Rs,a=bi.of(this._iid).dispatcher,i=dd.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var s=ep.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new Qh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Rs,a=bi.of(this._iid).dispatcher,i=dd.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var s=ep.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new Qh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new ic,a=bi.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var i=ep.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new Qh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,i=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return E(this,void 0,void 0,t().mark((function a(){var s,o,u,c,l,d=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=bi.of(this._iid),o=s.dispatcher,t.next=3,i.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(ep.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})),o.dispatch(new Qh({channels:[this],source:l?e.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.CollectionEventSource.EVENT_MESSAGE_UPDATED}))),l&&ep.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(d)})),o.dispatch(new gs({messages:[u],source:e.CollectionEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Rs,a=bi.of(this._iid).dispatcher,i=dd.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var s=ep.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new Qh({channels:[n],source:e.CollectionEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return E(this,void 0,void 0,t().mark((function r(){var i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Hi&&(i=bi.of(this._iid),i.dispatcher.dispatch(new ks({reqId:n.reqId,source:e.CollectionEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},If),n),ii(Nf(a)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.dispatcher,o=i.sdkState,u=i.requestQueue,c=new Af(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,d=l.as(Mf),h=d.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),s.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=new qp({channelUrl:this.url}),t.next=4,i.send(s);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Hp({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.sdkState,i=r.dispatcher,s=r.requestQueue,o=new Bf({channelUrl:this.url}),t.next=4,s.send(o);case 4:u=t.sent,c=u.as(Qf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),ep.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),i.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Kf({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(i);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=bi.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(i=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=i,this._typingEnded=0,s=new Uf({channelUrl:this.url,time:this._typingStarted}),r.send(s));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=bi.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(i=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=i,s=new Rf({channelUrl:this.url,time:this._typingStarted}),r.send(s));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Nl),e),ii(function(e){return zs(e)&&R("number",e.scheduledAt,!0)}(e)).throw(M.invalidParameters);var t=new Rs;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Kp),n),ii(Wp(a)).throw(M.invalidParameters),i=bi.of(this._iid),s=i.requestQueue,o=new Jp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,s.send(o);case 6:return u=t.sent,c=u.as(vu),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Al),e),ii(function(e){return Ps(e)&&R("number",e.scheduledAt)&&(G(e.file)||R("string",e.fileUrl))&&R("string",e.fileName,!0)&&R("string",e.mimeType,!0)&&R("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return R("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(M.invalidParameters);var r=Date.now(),a=this._generateRequestId(),i=new Rs;return Ia(2).then((function(){var s=n._createPendingScheduledFileMessage(e,a,r);Ma((function(){return E(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",i._trigger(s));case 1:case"end":return e.stop()}}),e)})))}))})),G(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,i,a,r)})):this._createScheduledFileMessage(e,i,a,r),i}},{key:"updateScheduledFileMessage",value:function(e,n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},Bp),n),ii(Qp(a)).throw(M.invalidParameters),!G(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return i=new Yp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),s=bi.of(this._iid),o=s.requestQueue,t.next=9,o.send(i);case 9:return u=t.sent,c=u.as(Zp),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Xp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=bi.of(this._iid),i=a.requestQueue,t.next=4,i.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new $p({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=bi.of(this._iid),i=a.requestQueue,t.next=4,i.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new nv({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(i);case 4:return s=e.sent,o=s.as(rv),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(L(e.PushTriggerOption,n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new ev({userId:s.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(tv),d=l.pushTriggerOption,this.myPushTriggerOption=d,i.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(L(e.CountPreference,n)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new Gp({channelUrl:this.url,userId:s.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(jp),d=l.countPreference,this.myCountPreference=d,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),i.dispatch(new Qh({channels:[this],source:e.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",d);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=bi.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=new zp({channelUrl:this.url}),t.next=4,i.send(s);case 4:return o=t.sent,u=o.as(Vp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt0).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new av({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("number",e)&&e>0).throw(M.invalidParameters),r=bi.of(this._iid),a=r.requestQueue,i=new iv({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,d,h,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!G(e.file)){t.next=11;break}return r=bi.of(this._iid),a=r.requestQueue,i=new Ci({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(i);case 5:s=t.sent,o=s.as(xi),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,d=o.thumbnailSizes,h=void 0===d?e.thumbnailSizes:d,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=h,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"resendMessage",value:function(e,t){var n,r=this;if(ii(e instanceof Hi&&!e.scheduledInfo&&e.isResendable).throw(M.invalidParameters),e.isUserMessage()){var a=null!==(n=e.messageParams)&&void 0!==n?n:js(e),i=new Rs;return this._sendUserMessage(a,nc.RESEND,e.reqId).onPending((function(e){i._trigger(e)})).onFailed((function(e,t){i._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),i._trigger(e)})),i}if(e.isFileMessage()){var s=this._validateFailedFileMessageHasFile(e,t);ii(s).throw(M.invalidParameters);var o=Zs(e,t),u=new Rs;return this._sendFileMessage(o,nc.RESEND,e.reqId).onPending((function(e){u._trigger(e)})).onFailed((function(e,t){u._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),u._trigger(e)})),u}if(e.isMultipleFilesMessage()){var c=e.messageParams,l=new ic;return this._sendMultipleFilesMessage(c,nc.RESEND,e.reqId).onPending((function(e){l._trigger(e)})).onFailed((function(e,t){l._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(r,e),l._trigger(e)})).onFileUploaded((function(e,t,n,r){l._triggerOnFileUploaded(e,t,n,r)})),l}}},{key:"copyMessage",value:function(t,n){var r=this;if(ii(t instanceof oc&&n instanceof Hi&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(M.invalidParameters),n.isUserMessage()){ii(!n.poll).throw(M.notSupportedError);var a=qs(n),i=new Rs;return t._sendUserMessage(a).onPending((function(e){i._trigger(e)})).onFailed((function(e,t){i._triggerFailed(e,t)})).onSucceeded((function(e){t.isGroupChannel()&&r._tryUpdateLastMessageAndCallEvents(t,e),i._trigger(e)})),i}if(n.isFileMessage()){var s=Ws(n),o=new Rs;return t._sendFileMessage(s).onPending((function(e){o._trigger(e)})).onFailed((function(e,t){o._triggerFailed(e,t)})).onSucceeded((function(e){t.isGroupChannel()&&r._tryUpdateLastMessageAndCallEvents(t,e),o._trigger(e)})),o}if(n.isMultipleFilesMessage()){if(t.isGroupChannel()){var u=function(t){var n,r,a;return null!==(n=t.messageParams)&&void 0!==n?n:de(Object.assign(Object.assign({},t),{isReplyToChannel:!1,mentionedUserIds:null!==(r=t.mentionedUserIds)&&void 0!==r?r:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:t.fileInfoList.map((function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))}(n),c=new ic;return t._sendMultipleFilesMessage(u,nc.COPY).onPending((function(e){c._trigger(e)})).onFailed((function(e,t){c._triggerFailed(e,t)})).onSucceeded((function(e){r._tryUpdateLastMessageAndCallEvents(t,e),c._trigger(e)})).onFileUploaded((function(e,t,n,r){c._triggerOnFileUploaded(e,t,n,r)})),c}throw M.channelTypeNotSupportedError}}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return Ch.payloadify(e)})),last_message:e.lastMessage?$i(e.lastMessage):null,inviter:e.inviter?oi.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?$i(e.lastPinnedMessage):null})))}}]),u}(oc),hv={},fv=function(){function n(a){var i=this,s=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this.ref=0,this._iid=s,this._limit=u;var c,l=bi.of(this._iid),d=l.sdkState,h=l.dispatcher,f=l.logger,p=l.cacheContext;this._metadataKey=(c=d.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var v=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(d.userId);this._sync=new tp(v,(function(){return E(i,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l,h,v,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),null===(a=this._metadata)||void 0===a?void 0:a.completed){t.next=41;break}if(t.prev=5,(u={includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL}).order!==e.GroupChannelListOrder.LATEST_LAST_MESSAGE){t.next=18;break}return t.prev=8,t.next=11,p.preference.get(Qa(d.appId));case 11:c=t.sent,u.includeChatNotification=Boolean(c),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),u.includeChatNotification=!1;case 18:return l=ep.of(this._iid),t.next=21,l.getMyGroupChannels(null!==(s=null===(i=this._metadata)||void 0===i?void 0:i.token)&&void 0!==s?s:"",u,this._limit,e.CollectionEventSource.SYNC_CHANNEL_BACKGROUND);case 21:return h=t.sent,v=h.channels,m=h.token,o.hasNext=v.length>=this._limit&&!!m,o.nextToken=m,this._metadata&&(this._metadata.token=m,(g=this._metadata.range).extends.apply(g,_(v.map((function(e){return e.createdAt})))),this._metadata.completed=!o.hasNext),f.debug("channel background sync progress",o),t.next=30,this.saveMetadata();case 30:t.next=39;break;case 32:if(t.prev=32,t.t1=t.catch(5),f.debug("channel background sync error",t.t1),!(t.t1 instanceof M&&t.t1.isInvalidTokenError)){t.next=38;break}return t.next=38,this.clearMetaData();case 38:throw t.t1;case 39:t.next=43;break;case 41:o.hasNext=!1,o.nextToken="";case 43:return t.abrupt("return",o);case 44:case"end":return t.stop()}}),n,this,[[5,32],[8,15]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ya)if(e.stateType===ha.CONNECTED)i.resume();else i.pause()}))}return i(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Gf({})}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=bi.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new Gf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=bi.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=bi.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){bi.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete hv[this._iid])}}],[{key:"of",value:function(e){return hv[e]||(hv[e]=new n({_iid:e})),hv[e].ref++,hv[e]}},{key:"clear",value:function(e){hv[e]&&(hv[e].close(),delete hv[e])}}]),n}(),pv={},vv=function(){function n(a){var i=this,s=a._iid;r(this,n),this.ref=0,this._iid=s;var o,u=bi.of(this._iid),c=u.logger,l=u.sdkState,d=u.dispatcher,h=u.cacheContext;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var f=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new tp(f,(function(){return E(i,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,o={includeEmpty:!0},t.prev=6,t.next=9,h.preference.get(Qa(l.appId));case 9:u=t.sent,o.includeChatNotification=Boolean(u),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(6),o.includeChatNotification=!1;case 16:return d=ep.of(this._iid),t.next=19,d.getMyGroupChannelChangeLogs(null!==(i=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==i?i:"",o,e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS);case 19:return f=t.sent,p=f.hasMore,v=f.token,s.hasNext=p,s.nextToken=v,this._metadata&&(this._metadata.token=v),c.debug("channel changelog sync progress",s),t.next=28,this.saveMetadata();case 28:t.next=37;break;case 30:if(t.prev=30,t.t1=t.catch(4),c.debug("channel changelog sync error",t.t1),!(t.t1 instanceof M&&t.t1.isInvalidTokenError)){t.next=36;break}return t.next=36,this.clearMetadata();case 36:throw t.t1;case 37:return t.abrupt("return",s);case 38:case"end":return t.stop()}}),n,this,[[4,30],[6,13]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ya)if(e.stateType===ha.CONNECTED)i.resume();else i.pause()}))}return i(n,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=bi.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:i=e.sent,this._metadata={token:i?i.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=bi.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){bi.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete pv[this._iid])}}],[{key:"of",value:function(e){return pv[e]||(pv[e]=new n({_iid:e})),pv[e].ref++,pv[e]}},{key:"clear",value:function(e){pv[e]&&(pv[e].close(),delete pv[e])}}]),n}(),_v=function(t,n){var r,a,i,s;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name;default:return null!==(s=null===(i=t.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==s?s:t.createdAt}},mv=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},gv=function(e,t,n){if(e.length>0){for(var r=mv(e,t),a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,oldPosition:r};a=s+1,s=Math.floor((a+i)/2)}}return{place:yv(e[s],t,n)>=0?s:s+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},yv=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a;default:return 0}},kv=function(){function n(a,i){var s=this,o=i.filter,u=i.order,c=i.limit;r(this,n),this.channels=[],this._iid=a,this._key="gcc-".concat(ie()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new Sh,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=bi.of(this._iid),d=l.sdkState,h=l.cacheContext,f=l.dispatcher;h.localCacheEnabled&&(this._backgroundSync=fv.of(a),this._backgroundSync.resume()),this._changelogSync=vv.of(a),this._changelogSync.resume(),ep.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){if(Bh(t)){var n=e.filter((function(e){return s.filter.match(e,d.userId)})),r=e.filter((function(e){return!s.filter.match(e,d.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),r.length>0&&s._removeChannelsFromView(r,t)}},onRemove:function(e,t){s._removeChannelsFromView(e,t)}}),bi.of(this._iid).statLogCollector.put(new pi({type:Ue.FEATURE_LOCALCACHE,data:{use_local_cache:h.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof ya&&(e.stateType===ha.CONNECTED?s._isGetRemoteChannelsSucceeded||E(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===ha.LOGOUT&&s.dispose())}))}return i(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,i=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var d=a.value,h=mv(this.channels,d);h>=0&&this.channels.splice(h,1);var f=gv(this.channels,d,this.order).place;if(h<0)f===this.channels.length?!s&&this._hasMore||(o.push(d),this.channels.push(d)):(o.push(d),this.channels.splice(f,0,d));else switch(r){case e.CollectionEventSource.EVENT_CHANNEL_UPDATED:case e.CollectionEventSource.EVENT_MESSAGE_RECEIVED:case e.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS:case e.CollectionEventSource.EVENT_MESSAGE_SENT:f!==h&&this._hasMore&&f===this.channels.length?c.push(d):(this.channels.splice(f,0,d),u.push(d));break;default:this.channels.splice(f,0,d),u.push(d)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var p,v=y(c);try{for(v.s();!(p=v.n()).done;){var _=p.value,m=mv(this.channels,_);-1!==m&&this.channels.splice(m,1)}}catch(e){v.e(e)}finally{v.f()}}Bh(r)&&Ma((function(){return E(i,void 0,void 0,t().mark((function e(){var n,a,i,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new vp(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(s,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(s,u),c.length>0&&(null===(i=this._handler)||void 0===i?void 0:i.onChannelsDeleted)&&this._handler.onChannelsDeleted(s,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,i=[],s=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(a.channels[t].url),a.channels.splice(t,1))};for(s.s();!(r=s.n()).done;)o()}catch(e){s.e(e)}finally{s.f()}return Bh(n)&&i.length>0&&Ma((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new vp(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,i);case 2:case"end":return e.stop()}}),e,this)})))})),i}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ep.of(this._iid),r=this.channels.length>0?_v(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:void 0);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ep.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,de(Object.assign(Object.assign({},this.filter),{order:this.order})),this._limit);case 3:return r=e.sent,a=r.channels,i=r.token,this._token=i,this._hasMore=!!i,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:r=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(r,e.CollectionEventSource.REQUEST_CHANNEL,!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),n,this,[[2,10]])})))}},{key:"loadMore",value:function(){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=bi.of(this._iid),a=r.cacheContext,i=r.connectionManager,s=[],!a.localCacheEnabled||i.isConnected&&!this._backgroundSync.completed){n.next=11;break}return n.next=8,Oa((function(){return E(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:this._hasMore=s.length>=this._limit,n.next=21;break;case 11:return n.prev=11,n.next=14,this._getRemoteChannels();case 14:s=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=21;break;case 18:n.prev=18,n.t0=n.catch(11),this._isGetRemoteChannelsSucceeded=!1;case 21:return this._addChannelsToView(s,e.CollectionEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 23:return n.abrupt("return",[]);case 24:case"end":return n.stop()}}),n,this,[[11,18]])})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),ep.of(this._iid).unsubscribeChannelEvent(this._key))}}]),n}(),Ev=function(t){s(a,t);var n=f(a);function a(t){var i;r(this,a);var s=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,d=t.channelNameContainsFilter,h=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,E=t.includeMetaData;return(i=n.call(this)).method=he.GET,i.path=_e,i.params=le(de({token:s,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:d,channel_urls:h,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:E})),i}return i(a)}(De),bv=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new dv(e,t)}))),i.ts="number"==typeof u?u:0,i}return i(n)}(Re);e.MembershipFilter=void 0,(lv=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",lv.JOINED="joined";var wv,Cv=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d,h,f,p,v,_,m,g,y,k;return r(this,u),(i=a.call(this,t,n)).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.channelNameContainsFilter=null,i.membershipFilter=e.MembershipFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,i.includeEmpty=null!==(s=n.includeEmpty)&&void 0!==s&&s,i.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,i.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,i.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,i.customTypesFilter=null!==(d=n.customTypesFilter)&&void 0!==d?d:null,i.customTypeStartsWithFilter=null!==(h=n.customTypeStartsWithFilter)&&void 0!==h?h:null,i.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,i.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,i.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,i.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,i.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,i.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,i.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,i.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,i}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&R("boolean",this.includeEmpty)&&R("boolean",this.includeFrozen)&&R("boolean",this.includeMetaData)&&R("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&R("string",this.customTypeStartsWithFilter,!0)&&L(e.MembershipFilter,this.membershipFilter)&&L(e.SuperChannelFilter,this.superChannelFilter)&&L(e.PublicGroupChannelListOrder,this.order)&&R("string",this.metadataOrderKeyFilter,!0)&&R("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&R("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=bi.of(this._iid),a=r.requestQueue,r.dispatcher,i=new Ev(de(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,a.send(i);case 9:return s=e.sent,o=s.as(bv),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(ao),xv=i((function e(){r(this,e),this.onUserMuted=We,this.onUserUnmuted=We,this.onUserBanned=We,this.onUserUnbanned=We,this.onChannelChanged=We,this.onChannelDeleted=We,this.onChannelFrozen=We,this.onChannelUnfrozen=We,this.onOperatorUpdated=We,this.onChannelMemberCountChanged=We,this.onMetaDataCreated=We,this.onMetaDataUpdated=We,this.onMetaDataDeleted=We,this.onMetaCounterCreated=We,this.onMetaCounterUpdated=We,this.onMetaCounterDeleted=We,this.onMessageReceived=We,this.onMessageUpdated=We,this.onMessageDeleted=We,this.onMentionReceived=We,this.onReactionUpdated=We,this.onThreadInfoUpdated=We})),Tv=function(e){s(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=We,e.onUserLeft=We,e.onUserReceivedInvitation=We,e.onUserDeclinedInvitation=We,e.onChannelHidden=We,e.onUnreadMemberStatusUpdated=We,e.onUndeliveredMemberStatusUpdated=We,e.onTypingStatusUpdated=We,e.onPollUpdated=We,e.onPollVoted=We,e.onPollDeleted=We,e.onPinnedMessageUpdated=We,e}return i(n)}(xv),Sv=function(e){s(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return i(n)}(Tv),Iv=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,d=e.scheduledStatus;return(a=t.call(this)).method=he.GET,a.path="".concat(xe),a.params=le(de({token:i,limit:s,reverse:u,channel_url:c,order:o,message_type:l,status:d})),a}return i(n)}(De),Nv=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return es(e,t)})),i}return i(n)}(Re),Av=function(n){s(u,n);var a=f(u);function u(t,n){var i,s,o,c,l,d;return r(this,u),(i=a.call(this,t,n)).channelUrl=null,i.order=null,i.reverse=!1,i.scheduledStatus=null,i.messageTypeFilter=e.MessageTypeFilter.ALL,i.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:null,i.order=null!==(o=n.order)&&void 0!==o?o:null,i.reverse=null!==(c=n.reverse)&&void 0!==c&&c,i.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,i.messageTypeFilter=null!==(d=n.messageTypeFilter)&&void 0!==d?d:e.MessageTypeFilter.ALL,i}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&R("string",this.channelUrl,!0)&&(L(e.ScheduledMessageListOrder,this.order)||null===this.order)&&R("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&L(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new Iv(de(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Nv),o=s.scheduledMessages,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(ao),Mv=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return i(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:i,requestQueue:s,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new ep(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:i,requestQueue:s,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new kv(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Hf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Cv(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Av(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ii(R("string",e)&&t instanceof Sv).throw(M.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ii(R("string",e)).throw(M.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Uh),n),ii(R("string",e)&&Dh(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Uh),n),ii(R("number",e)&&Dh(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Rh),e),ii(Lh(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Mh),e),ii(Oh(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Mh),e),ii(Oh(r)).throw(M.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},Mh),{invitedUserIds:e,isDistinct:n,name:r,data:i,customType:s}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ii(F("string",e)).throw(M.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(wi),Ov=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return i(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return!!e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._channels.get(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],e.forEach((function(e){if(a._channels.has(e.url)){var t=a._channels.get(e.url);Object.assign(t,e),r.push(t)}else a._channels.set(e.url,e),r.push(e)})),t.abrupt("return",r);case 3:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(Za),Uv={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},Dv=function(e){return F("string",e.operatorUserIds,!0)&&(R("string",e.coverUrlOrImage,!0)||G(e.coverUrlOrImage,!0))&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)&&(R("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&R("boolean",e.isEphemeral,!0)},Rv=function(e){s(n,e);var t=f(n);function n(e){var a,i=e.channelUrl,s=e.isInternalCall;return r(this,n),(a=t.call(this)).method=he.GET,a.path="".concat(s?ye:ge,"/").concat(encodeURIComponent(i)),a}return i(n)}(De),Lv=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).channel=new Xv(e,a),i}return i(n)}(Re),Pv=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,d=e.isEphemeral;return(a=t.call(this)).method=he.POST,a.path=ge,a.params=le(de({channel_url:i,cover_url:R("string",s)?s:null,cover_file:G(s)?s:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:d})),a}return i(n)}(De),Fv=function(e){s(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return i(n)}(pa),Hv=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u;return r(this,n),s=t.call(this,e,"SYEV",i),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new oi(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return i(n)}(mf),qv=function(e){s(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return i(n)}(pa),Gv=function(e){s(n,e);var t=f(n);function n(e,a,i){var s,o,u;return r(this,n),s=t.call(this,e,"EXIT",i),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new oi(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return i(n)}(mf),jv={},zv=function(n){s(o,n);var a=f(o);function o(n,i){var s;return r(this,o),(s=a.call(this,n,Object.assign(Object.assign({},i),{channelType:e.ChannelType.OPEN}))).subscribeChannelEvent=We,s.unsubscribeChannelEvent=We,s.refreshChannel=function(){return E(h(s),void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})))},s._openChannelCache=new Ov(n),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){if(e instanceof Ke)s._handleEvent(e);else if(e instanceof ya&&e.stateType===ha.CONNECTED){var t,n=y(s._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),jv[n]||(jv[n]=h(s)),s}return i(o,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=ai(e);return new Xv(this._iid,Xv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var n;return E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return i=a.value,t.next=7,this._openChannelCache.remove(i);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o,u,c,l,d,h,f,p,v,_,m,g,k,b,w,C,x,T,S,I,N,M,O,U,D,R,L,P,F,H,q,G,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,de,he,fe,pe,ve,_e,me,ge,ye,ke,Ee,be,we,Ce,xe,Te,Se,Ie,Ne,Ae,Me,Oe,Ue,De,Re,Le=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?73:"VOTE"===r.t0?81:"SYEV"===r.t0?89:166;break;case 4:if(a=null,"MESG"===n.code?a=n.as(tu):"FILE"===n.code?a=n.as(as):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(zf)),!a){r.next=13;break}if(s=(i=a).message,o=i.isMentioned,s.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(s.channelUrl,!0);case 11:u=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived&&a.onMessageReceived(u,s),o&&a.onMentionReceived&&a.onMentionReceived(u,s))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",166);case 14:if(c=null,"MEDI"===n.code?c=n.as(ru):"FEDI"===n.code?c=n.as(iu):"AEDI"===n.code&&(c=n.as(Vf)),!c){r.next=23;break}if(d=(l=c).message,h=l.mentionCountChange,d.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(d.channelUrl,!0);case 21:f=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated&&a.onMessageUpdated(f,d),h>0&&a.onMentionReceived&&a.onMentionReceived(f,d))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",166);case 24:if(p=n.as(ou),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",166);case 31:if(k=n.as(Yf),b=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(b,!0);case 35:x=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(x.url)&&a.onReactionUpdated&&a.onReactionUpdated(x,C)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",166);case 38:if(T=n.as(Zf),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",166);case 45:N=n.as(Jf),M=N.openChannelMemberCounts,O=[],U=y(M),r.prev=48,U.s();case 50:if((D=U.n()).done){r.next=59;break}return R=D.value,L=R.channelUrl,P=R.participantCount,F=R.updatedAt,r.next=55,this.getChannelFromCache(L);case 55:(H=r.sent)&&H._updateParticipantCount(P,F)&&O.push(H);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=72;break}return r.next=70,this.upsertChannelsToCache(O);case 70:q=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 72:return r.abrupt("break",166);case 73:if(G=n.as(Xf),j=G.event,z=G.status,V=G.channelUrl,B=G.channelType,!V||B!==e.ChannelType.OPEN){r.next=80;break}return r.next=77,this.getChannel(V,!0);case 77:Q=r.sent,this._dispatcher.dispatch(new bs({event:j,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),Ma(z===Bi?function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(Q,j)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 80:return r.abrupt("break",166);case 81:if(K=n.as(Mu),W=K.event,Y=K.channelUrl,Z=K.channelType,!Y||Z!==e.ChannelType.OPEN){r.next=88;break}return r.next=85,this.getChannel(Y,!0);case 85:J=r.sent,this._dispatcher.dispatch(new ws({event:W,source:e.CollectionEventSource.EVENT_POLL_VOTED})),Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(J,W)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 88:return r.abrupt("break",166);case 89:if(X=n.as(mf),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===Th.CHANNEL_ENTER?94:r.t2===Th.CHANNEL_EXIT?101:r.t2===Th.CHANNEL_OPERATOR_UPDATE?108:r.t2===Th.USER_CHANNEL_MUTE||r.t2===Th.USER_CHANNEL_UNMUTE?116:r.t2===Th.USER_CHANNEL_BAN||r.t2===Th.USER_CHANNEL_UNBAN?123:r.t2===Th.CHANNEL_FREEZE||r.t2===Th.CHANNEL_UNFREEZE?130:r.t2===Th.CHANNEL_DELETED?138:r.t2===Th.CHANNEL_PROP_CHANGED?145:r.t2===Th.CHANNEL_META_DATA_CHANGED?150:r.t2===Th.CHANNEL_META_COUNTERS_CHANGED?159:165;break;case 94:return r.next=96,this.getChannel($.channelUrl,!0);case 96:return ee=r.sent,te=n.as(Hv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 101:return r.next=103,this.getChannel($.channelUrl,!0);case 103:return ie=r.sent,se=n.as(Gv),oe=se.participantCount,ue=se.user,ce=ie._updateParticipantCount(oe,$.ts),Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ie,ue),ce&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ie)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 108:return r.next=110,this.getChannel($.channelUrl,!0);case 110:return le=r.sent,de=n.as(Pf),he=de.operators,le.operators=he,this.upsertChannelsToCache([le]),Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(le,he)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 116:return r.next=118,this.getChannel($.channelUrl,!0);case 118:return fe=r.sent,pe=$.category===Th.USER_CHANNEL_MUTE,ve=n.as(pe?jo:Vo),_e=ve.user,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){pe?e.onUserMuted&&e.onUserMuted(fe,_e):e.onUserUnmuted&&e.onUserUnmuted(fe,_e)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 123:return r.next=125,this.getChannel($.channelUrl,!0);case 125:return me=r.sent,ge=$.category===Th.USER_CHANNEL_BAN,ye=n.as(ge?Qo:Wo),ke=ye.user,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ge?e.onUserBanned&&e.onUserBanned(me,ke):e.onUserUnbanned&&e.onUserUnbanned(me,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 130:return r.next=132,this.getChannel($.channelUrl,!0);case 132:return Ee=r.sent,be=n.as(Zo),we=be.freeze,Ee.isFrozen=we,this.upsertChannelsToCache([Ee]),Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen&&e.onChannelFrozen(Ee):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 138:return r.next=140,this.getChannel($.channelUrl,!0);case 140:return Ce=r.sent,r.next=143,this.removeChannelsFromCache([Ce.url]);case 143:return Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ce.url,Ce.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 145:return r.next=147,this.getChannelWithoutCache($.channelUrl,!0);case 147:return xe=r.sent,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 150:return r.next=152,this.getChannel($.channelUrl,!0);case 152:return Te=r.sent,Se=n.as(So),Ie=Se.created,Ne=Se.updated,Ae=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Ae&&Te._removeFromCachedMetaData(Ae,$.ts),Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ie&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ne),Ae&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Ae)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 159:return r.next=161,this.getChannel($.channelUrl,!0);case 161:return Me=r.sent,Oe=n.as(Fo),Ue=Oe.created,De=Oe.updated,Re=Oe.deleted,Ma((function(){return E(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ue&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Me,Ue),De&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Me,De),Re&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Me,Re)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 165:return r.abrupt("break",166);case 166:r.next=172;break;case 168:if(r.prev=168,r.t3=r.catch(0),!A(r.t3)){r.next=172;break}throw r.t3;case 172:case"end":return r.stop()}}),r,this,[[0,168],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,t().mark((function r(){var a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ii(R("string",e)).throw(M.invalidParameters),a=new Rv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return i=t.sent,s=i.as(Lv),o=s.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",t.sent[0]);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Uv),e),ii(Dv(r)).throw(M.invalidParameters),a=new Pv(r),t.next=5,this._requestQueue.send(a);case 5:return i=t.sent,s=i.as(Lv),o=s.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return jv[e]}}]),o}(jf),Vv={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Bv=function(e){return F("string",e.operatorUserIds,!0)&&(R("string",e.coverUrlOrImage)||G(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&R("string",e.name,!0)&&R("string",e.data,!0)&&R("string",e.customType,!0)},Qv=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.token,o=e.limit;return(a=t.call(this)).method=he.GET,a.path="".concat(ge,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return i(n)}(De),Kv=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new Ds(e,t)})),i}return i(n)}(Re),Wv=function(n){s(u,n);var a=f(u);function u(t,n,i){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,i)}return i(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new Qv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Kv),o=s.participants,u=s.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(io),Yv=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=he.PUT,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a.params=le(de({cover_url:R("string",s)?s:null,cover_file:G(s)?s:null,name:o,data:u,custom_type:c,operators:l})),a}return i(n)}(De),Zv=function(e){s(n,e);var t=f(n);function n(e,a){var i;return r(this,n),(i=t.call(this,e,a)).channel=new Xv(e,a),i}return i(n)}(Re),Jv=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.channelUrl;return(a=t.call(this)).method=he.DELETE,a.path="".concat(ge,"/").concat(encodeURIComponent(i)),a}return i(n)}(De),Xv=function(n){s(u,n);var a=f(u);function u(t,n){var i,s;return r(this,u),(i=a.call(this,t,n))._lastParticipantCountUpdated=0,i.participantCount=0,i.operators=[],i.channelType=e.ChannelType.OPEN,i.participantCount=null!==(s=n.participant_count)&&void 0!==s?s:0,i.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new oi(t,e)})):[],i}return i(u,[{key:"serialize",value:function(){return ri(this)}},{key:"isOperator",value:function(e){return e instanceof oi?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new Wv(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=zv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Fv({channelUrl:this.url}),e.next=4,r.send(a);case 4:i=e.sent,s=i.as(Hv),o=s.participantCount,u=s.ts,this._updateParticipantCount(o,u),zv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new qv({channelUrl:this.url}),e.next=4,r.send(a);case 4:i=e.sent,s=i.as(Gv),o=s.participantCount,u=s.ts,this._updateParticipantCount(o,u),zv.of(this._iid).setExitedToCache(this),Hl.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){var r,a,i,s,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Vv),e),ii(Bv(r)).throw(M.invalidParameters),a=bi.of(this._iid),i=a.requestQueue,s=new Yv(Object.assign({channelUrl:this.url},r)),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(Zv),c=u.channel,this._update(c),l=zv.of(this._iid),t.next=12,l.upsertChannelsToCache([c]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,i){return E(this,void 0,void 0,t().mark((function s(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},Vv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:i}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),s,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bi.of(this._iid),r=n.requestQueue,a=new Jv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=zv.of(this._iid),e.next=7,i.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return ii(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return ii(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return le(de(Object.assign(Object.assign({},oc.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return oi.payloadify(e)}))})))}}]),u}(oc),$v=function(e){s(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=We,e.onUserExited=We,e.onChannelParticipantCountChanged=We,e.onPollUpdated=We,e.onPollVoted=We,e.onPollDeleted=We,e}return i(n)}(xv),e_=function(e){s(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return i(n)}($v),t_=function(e){s(n,e);var t=f(n);function n(e){var a;r(this,n);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,d=e.includeMetaData;return(a=t.call(this)).method=he.GET,a.path=ge,a.params=le({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:d}),a}return i(n)}(De),n_=function(e){s(n,e);var t=f(n);function n(e,a){var i;r(this,n),(i=t.call(this,e,a)).channels=[];var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new Xv(e,t)}))),i.ts="number"==typeof u?u:null,i}return i(n)}(Re),r_=function(e){s(a,e);var n=f(a);function a(e,t){var i,s,o,u,c,l;return r(this,a),(i=n.call(this,e,t)).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,i}return i(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&R("boolean",this.includeFrozen)&&R("boolean",this.includeMetaData)&&R("string",this.nameKeyword,!0)&&R("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,i,s,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=bi.of(this._iid),r=n.requestQueue,a=new t_(de(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(n_),o=s.channels,u=s.token,this._token=u,this._hasNext=!!u,c=zv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw M.queryInProgress;case 21:e.next=24;break;case 23:throw M.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(ao),a_=function(e){s(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return i(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:i,requestQueue:s,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new zv(e,{sdkState:n,dispatcher:r,requestQueue:s,logger:u,cacheContext:l,sessionManager:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r_(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,i){return E(this,void 0,void 0,t().mark((function s(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},Uv)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=i,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),s,this)})))}}]),a}(wi);wv=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function p_(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function v_(e){return"string"!=typeof e&&(e=String(e)),e}function __(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return u_&&(t[Symbol.iterator]=function(){return t}),t}function m_(e){this.map={},e instanceof m_?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function g_(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function y_(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function k_(e){var t=new FileReader,n=y_(t);return t.readAsArrayBuffer(e),n}function E_(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b_(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:c_&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:l_&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:o_&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():d_&&c_&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=E_(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):d_&&(ArrayBuffer.prototype.isPrototypeOf(e)||f_(e))?this._bodyArrayBuffer=E_(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o_&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c_&&(this.blob=function(){var e=g_(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=g_(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(c_)return this.blob().then(k_);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e=g_(this);if(e)return e;if(this._bodyBlob)return function(e){var t=new FileReader,n=y_(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8";return t.readAsText(e,a),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in s_)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function x_(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function T_(e,t){if(!(this instanceof T_))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new m_(t.headers),this.url=t.url||"",this._initBody(e)}C_.prototype.clone=function(){return new C_(this,{body:this._bodyInit})},b_.call(C_.prototype),b_.call(T_.prototype),T_.prototype.clone=function(){return new T_(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new m_(this.headers),url:this.url})},T_.error=function(){var e=new T_(null,{status:200,statusText:""});return e.status=0,e.type="error",e};var S_=[301,302,303,307,308];T_.redirect=function(e,t){if(-1===S_.indexOf(t))throw new RangeError("Invalid status code");return new T_(null,{status:t,headers:{location:e}})};var I_=s_.DOMException;try{new I_}catch(fn){(I_=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),I_.prototype.constructor=I_}function N_(e,t){return new Promise((function(r,a){var i=new C_(e,t);if(i.signal&&i.signal.aborted)return a(new I_("Aborted","AbortError"));var s=new XMLHttpRequest;function o(){s.abort()}if(s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new m_,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();try{t.append(r,a)}catch(e){console.warn("Response "+e.message)}}})),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var a="response"in s?s.response:s.responseText;setTimeout((function(){r(new T_(a,n))}),0)},s.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},s.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},s.onabort=function(){setTimeout((function(){a(new I_("Aborted","AbortError"))}),0)},s.open(i.method,function(e){try{return""===e&&s_.location.href?s_.location.href:e}catch(t){return e}}(i.url),!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&(c_?s.responseType="blob":d_&&(s.responseType="arraybuffer")),t&&"object"===n(t.headers)&&!(t.headers instanceof m_||s_.Headers&&t.headers instanceof s_.Headers)){var u=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){u.push(p_(e)),s.setRequestHeader(e,v_(t.headers[e]))})),i.headers.forEach((function(e,t){-1===u.indexOf(t)&&s.setRequestHeader(t,e)}))}else i.headers.forEach((function(e,t){s.setRequestHeader(t,e)}));i.signal&&(i.signal.addEventListener("abort",o),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",o)}),s.send(void 0===i._bodyInit?null:i._bodyInit)}))}N_.polyfill=!0,s_.fetch||(s_.fetch=N_,s_.Headers=m_,s_.Request=C_,s_.Response=T_);var A_=Object.freeze({__proto__:null});return e.AdminMessage=zi,e.AppleCriticalAlertOptions=Di,e.ApplicationUserListQuery=_c,e.BannedUserListQuery=_o,e.BaseChannel=oc,e.BaseMessage=Fi,e.BlockedUserListQuery=yc,e.CachedChannelInfo=ne,e.ConnectionHandler=dc,e.Emoji=uc,e.EmojiCategory=cc,e.EmojiContainer=lc,e.FileMessage=ts,e.FriendListQuery=bc,e.GroupChannel=dv,e.GroupChannelCollection=kv,e.GroupChannelEventContext=vp,e.GroupChannelEventSource=Vh,e.GroupChannelFilter=Sh,e.GroupChannelHandler=Sv,e.GroupChannelListQuery=Hf,e.GroupChannelModule=Mv,e.LocalCacheConfig=re,e.Member=Ch,e.MemberListQuery=Dp,e.MemoryStore=gl,e.MessageCollection=Sp,e.MessageCollectionInitHandler=xp,e.MessageEventContext=gp,e.MessageEventSource=_s,e.MessageFilter=Tl,e.MessageMetaArray=Mi,e.MessageModule=Jl,e.MessageRequestHandler=Rs,e.MessageSearchQuery=Wl,e.MultipleFilesMessage=Xi,e.MultipleFilesMessageRequestHandler=ic,e.MutedUserListQuery=fo,e.NotificationInfo=Ba,e.OGImage=Oi,e.OGMetaData=Ui,e.OpenChannel=Xv,e.OpenChannelHandler=e_,e.OpenChannelListQuery=r_,e.OpenChannelModule=a_,e.OperatorListQuery=uo,e.Participant=Ds,e.ParticipantListQuery=Wv,e.PinnedMessage=sv,e.PinnedMessageListQuery=cv,e.Plugin=Vi,e.PreviousMessageListQuery=co,e.PublicGroupChannelListQuery=Cv,e.Reaction=Ai,e.ReactionEvent=Ni,e.ReadStatus=xh,e.RestrictedUser=Us,e.RestrictionInfo=Os,e.ScheduledMessageListQuery=Av,e.SendbirdChat=vh,e.SendbirdChatOptions=j,e.SendbirdError=M,e.Sender=Ri,e.SessionHandler=hc,e.ThreadInfo=Ti,e.ThreadInfoUpdateEvent=ql,e.Thumbnail=qi,e.UIKitConfigInfo=Ka,e.UploadedFileInfo=Ji,e.User=oi,e.UserEventHandler=fc,e.UserMessage=Zi,Object.defineProperty(e,"__esModule",{value:!0}),e}({});