From e6fca5b41a70e2256c243bf8287ae80579726415 Mon Sep 17 00:00:00 2001 From: Liam Cho Date: Tue, 17 May 2022 17:02:32 +0900 Subject: [PATCH] v4.0.0-beta.10 --- CHANGES_FROM_V3.md | 37 +- __bundle-083b498b.js | 1 - __bundle-96ae73c1.js => __bundle-2ae23ac6.js | 2 +- __bundle-368767fc.js | 15 - __bundle-45e61fc8.js | 15 + __bundle-72d7e125.js | 1 - __bundle-876572c8.js | 1 + __bundle-fd9b6bb9.js | 1 + groupChannel.js | 2 +- index.d.ts | 1 - lib/__definition.d.ts | 848 +++++++++---------- message.d.ts | 2 - message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- sendbird.js | 2 +- 16 files changed, 463 insertions(+), 471 deletions(-) delete mode 100644 __bundle-083b498b.js rename __bundle-96ae73c1.js => __bundle-2ae23ac6.js (89%) delete mode 100644 __bundle-368767fc.js create mode 100644 __bundle-45e61fc8.js delete mode 100644 __bundle-72d7e125.js create mode 100644 __bundle-876572c8.js create mode 100644 __bundle-fd9b6bb9.js diff --git a/CHANGES_FROM_V3.md b/CHANGES_FROM_V3.md index bfc2e67..fe6721a 100644 --- a/CHANGES_FROM_V3.md +++ b/CHANGES_FROM_V3.md @@ -40,6 +40,25 @@ import { GroupChannel } from '@sendbird/groupChannel'; ## New features - Added `onConnected()`, `onDisconnected()` to `ConnectionHandler`. +- Added `translationTargetLanguages` in `UserMessage`. +- Added `translationTargetLanguages` in `UserMessageUpdateParamsProperties`. +- Scheduled message support: + - Added `scheduledInfo` in `BaseMessage`. + - Added `ScheduledStatus`. + - Added `SCHEDULED` in `SendingStatus`. + - Added `ScheduledMessageRetrievalParams`. + - Added `ScheduledFileMessageCreateParams`. + - Added `ScheduledFileMessageUpdateParams`. + - Added `ScheduledUserMessageCreateParams`. + - Added `ScheduledUserMessageUpdateParams`. + - Added `TotalScheduledMessageCountParams`. + - Added `ScheduledMessageListOrder`. + - Added `ScheduledMessageListQuery`. + - Added `ScheduledMessageListQueryParams`. + - Added `getScheduledMessage()` in `MessageModule`, . + - Added `createScheduledMessageListQuery() in `GroupChannelModule`. + - Added `getTotalScheduledMessageCount() in `SendbirdChat`. + - Added `createScheduledUserMessage()`, `updateScheduledUserMessage()`, `createScheduledFileMessage()`, `updateScheduledFileMessage()`, `cancelScheduledMessage()`, `sendScheduledMessageNow() in `GroupChannel`. ## Changes @@ -301,12 +320,7 @@ SendBird.getInstance() sb.getApplicationId() sb.getConnectionState() sb.getLastConnectedAt() -channel.isGroupChannel() -channel.isOpenChannel() channel.getCachedMetaData() -message.isUserMessage() -message.isFileMessage() -message.isAdminMessage() message.isResendable() // v4 @@ -314,12 +328,7 @@ SendbirdChat.instance sb.appId sb.connectionState sb.lastConnectedAt -channel.isGroupChannel -channel.isOpenChannel channel.cachedMetaData -message.isUserMessage -message.isFileMessage -message.isAdminMessage message.isResendable ``` @@ -343,10 +352,14 @@ message.isResendable |`channelHandler.onDeliveryReceiptUpdated()`|`groupChannelHandler.onUndeliveredMemberStatusUpdated()`| |`groupChannel.cachedReadReceiptStatus`|`groupChannel.cachedUnreadMemberState`| |`groupChannel.cachedDeliveryReceiptStatus`|`groupChannel.cachedUndeliveredMemberState`| -|`message.sendingStatus`|`message.requestState`| +|`message.requestedMentionUserIds`|`message.mentionedUserIds`| + > \* But stilling meaning the token for Android. ## Removes -- Removed `channel.getMessagesByID()`. \ No newline at end of file +- Removed `channel.getMessagesByID()`. +- Removed `ScheduledUserMessageParams`. +- Removed `ScheduledUserMessage`. +- Removed `groupChannel.registerScheduledUserMessage()`. \ No newline at end of file diff --git a/__bundle-083b498b.js b/__bundle-083b498b.js deleted file mode 100644 index 3047c35..0000000 --- a/__bundle-083b498b.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,R as n,g as r,j as s,L as i,U as a,I as o,Q as u,q as c,o as l,d as h,e as d,p as f,M as _,T as p,X as m,Y as v,Z as g,$ as E,a0 as y,a1 as N,a2 as C,a3 as b,a4 as A,S,b as M,a as T,i as I,a5 as U,a6 as w,a7 as L,a8 as D,a9 as R,W as O,A as P,f as x,h as F,k,aa as H,ab as V,ac as G,ad as q,B,ae as K,af as z,ag as j,ah as Q,ai as Y,aj as J,z as W,ak as X,F as Z,al as $,x as ee,J as te,am as ne,E as re,V as se,an as ie,ao as ae,ap as oe,aq as ue,ar as ce,as as le,at as he,au as de,av as fe,aw as _e,ax as pe,ay as me,az as ve,aA as ge,aB as Ee,aC as ye,aD as Ne,aE as Ce,aF as be}from"./__bundle-368767fc.js";import{b as Ae,C as Se,U as Me,e as Te,F as Ie,f as Ue,g as we,h as Le,i as De,j as Re,k as Oe,l as Pe,T as xe,m as Fe,D as ke,n as He,o as Ve,p as Ge,q as qe,A as Be,a as Ke}from"./__bundle-72d7e125.js";var ze,je,Qe,Ye,Je;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(ze||(ze={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(je||(je={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(Qe||(Qe={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(Ye||(Ye={})),function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited"}(Je||(Je={}));var We,Xe,Ze,$e=function(i){function a(e,r){var s=i.call(this,e,r)||this;return s.state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=t(Je,r.state)?r.state:null,s.role=t(n,r.role)?r.role:null,r.hasOwnProperty("is_muted")&&(s.isMuted=r.is_muted),r.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=r.is_blocked_by_me),r.hasOwnProperty("is_blocking_me")&&(s.isBlockingMe=r.is_blocking_me),s}return e(a,i),a.payloadify=function(e){return e?r(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})):null},a}(Ae),et=function(t){function n(e,n){var r,s,o=this;return(o=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",o.channelType=null!==(s=n.channel_type)&&void 0!==s?s:i.GROUP,o.reader=new a(o._iid,n.user),o.readAt=n.ts,o}return e(n,t),n}(o);!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"}(We||(We={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Xe||(Xe={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(Ze||(Ze={}));var tt,nt,rt,st,it,at,ot,ut,ct=function(e){switch(e){case We.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case We.CHRONOLOGICAL:return["-createdAt","syncIndex"];case We.CHANNEL_NAME_ALPHABETICAL:return["name"]}};!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(tt||(tt={})),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"}(nt||(nt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(rt||(rt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(st||(st={})),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"}(at||(at={})),function(e){e.AND="AND",e.OR="OR"}(ot||(ot={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(ut||(ut={}));var lt,ht=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter="",this.channelNameContainsFilter="",this.memberStateFilter=nt.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=rt.ALL,this.publicChannelFilter=tt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=st.ALL,this.hiddenChannelFilter=it.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!!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=ot.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t=new e;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},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 ut.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case ut.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,c=i.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(c){case ot.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case ot.OR:if(a.every((function(e){return!l.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!u(a,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.every((function(e){return!e.nickname.toLowerCase().includes(h)})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.memberStateFilter)switch(this.memberStateFilter){case nt.JOINED:if("joined"!==e.myMemberState)return!1;break;case nt.INVITED:if("invited"!==e.myMemberState)return!1;break;case nt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case nt.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===st.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case tt.PUBLIC:if(!e.isPublic)return!1;break;case tt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case rt.SUPER:if(!e.isSuper)return!1;break;case rt.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),dt=100,ft="GroupChannel",_t="url",pt="Message",mt="messageId",vt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("GroupChannel"):null},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 Mn.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return c([],l(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=r.sent())return n=this._deserialize(t),this._channels.set(e,n),[2,n];r.label=2;case 2:return[2,null];case 3:return[2,this._channels.get(e)]}}))}))},n.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?100:n,s=e.backward,i=void 0!==s&&s,a=e.filter,o=void 0===a?new ht:a,u=e.order,c=void 0===u?We.LATEST_LAST_MESSAGE:u;return h(this,void 0,void 0,(function(){var e,n,s,a,u=this;return d(this,(function(l){switch(l.label){case 0:return this.localCacheEnabled?(e=ct(c),n={where:function(e){if(t)switch(c){case We.CHANNEL_NAME_ALPHABETICAL:if(!i&&e.name.localeCompare(t)<0||i&&e.name.localeCompare(t)>0)return!1;break;case We.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:d.sent(),d.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return h(this,void 0,void 0,(function(){return d(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 h(this,void 0,void 0,(function(){return d(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=c([],l(this._channels.keys()),!1)),h(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return d(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=f(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=l.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),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}(o),gt=function(){function e(){this.messageTypeFilter=_.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=v.NONE}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e){switch(this.messageTypeFilter){case _.USER:if(e.messageType!==p.USER)return!1;break;case _.FILE:if(e.messageType!==p.FILE)return!1;break;case _.ADMIN:if(e.messageType!==p.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 v.NONE:if(e.parentMessageId>0)return!1;break;case v.ONLY_REPLY_TO_CHANNEL:if(e instanceof m&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest"}(lt||(lt={}));var Et,yt=function(e){if(e===lt.CHANNEL_LATEST)return["channelUrl","-createdAt","-messageId"]},Nt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},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){var t=s(s({},e.serialize()),{messageId:"".concat(e.messageId)});if(e instanceof g&&e.messageParams){var n=e.messageParams;t.messageParams=s({},n)}else if(e instanceof E&&e.messageParams){n=e.messageParams;t.messageParams=s({},n)}return t},n.prototype._deserialize=function(e){return e=s(s({},e),{messageId:parseInt(e.messageId)}),y.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t;return d(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,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,s=void 0===r?100:r,i=e.backward,a=void 0!==i&&i,o=e.filter,u=void 0===o?new gt:o,c=e.order,l=void 0===c?lt.CHANNEL_LATEST:c;return h(this,void 0,void 0,(function(){var e,r,i,o=this;return d(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=yt(l),r={where:{channelUrl:t,"/where":function(e){if(n&&l===lt.CHANNEL_LATEST)if(!a&&e.createdAt>n||a&&e.createdAt0)throw S.invalidParameters;var r=s({},e.serialize());return e instanceof g?r.messageParams=null===(t=e.messageParams)||void 0===t?void 0:t.serialize():e instanceof E&&(r.messageParams=null===(n=e.messageParams)||void 0===n?void 0:n.serialize()),r},n.prototype._deserialize=function(e){return e?(e=s(s({},e),{messageId:parseInt(e.messageId)}),y.of(this._iid).buildMessageFromSerializedData(e)):null},n.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t;return d(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,null]}}))}))},n.prototype.fetch=function(e){var t=e.filter,n=void 0===t?new gt:t,r=e.order,s=void 0===r?lt.CHANNEL_LATEST:r,i=e.channelUrl,a=void 0===i?null:i,o=e.sendingStatus,u=void 0===o?null:o,c=e.backward,l=void 0!==c&&c;return h(this,void 0,void 0,(function(){var e,t,r,i,o=this;return d(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=yt(s),t={"/where":function(e){return n.match(o._deserialize(e))}},a&&(t.channelUrl=a),u&&(t.sendingStatus=u),r={where:t,index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({})];case 2:return i=c.sent(),[2,Promise.all(i.map((function(e){return h(o,void 0,void 0,(function(){var t,n,r,s;return d(this,(function(i){switch(i.label){case 0:return t=this._deserialize(e),(n=e.messageParams)?(r=y.of(this._iid),t instanceof g?(t.messageParams=r.buildUserMessageCreateParamsFromSerializedData(n,t),[3,4]):[3,1]):[3,4];case 1:return t instanceof E?n.file&&"string"==typeof n.file&&A(n.fileType)?(s=n,[4,this.collection.getBlob(n.file)]):[3,3]:[3,4];case 2:s.file=i.sent(),i.label=3;case 3:t.messageParams=r.buildFileMessageCreateParamsFromSerializedData(n,t),i.label=4;case 4:return[2,t]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.upsert=function(e){return h(this,void 0,void 0,(function(){var t,n=this;return d(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.remove=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a;return d(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=f(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 s=o.sent(),i={error:s},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))},n.prototype.removeChannel=function(e){return h(this,void 0,void 0,(function(){return d(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 h(this,void 0,void 0,(function(){return d(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.saveBlobs=function(e){return h(this,void 0,void 0,(function(){var t=this;return d(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return h(t,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return e instanceof E&&e.messageParams&&((t=e.messageParams).file&&b(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.file=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(o);!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Et||(Et={}));var St,Mt=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,r=n.blocker,s=n.blockee;return{blocker:new a(e,r),blockee:new a(e,s)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new a(e,t)})):[]}},e}(),Tt=function(){this.invitedUserIds=[],this.channelUrl=null,this.coverUrl=null,this.coverImage=null,this.isDistinct=null,this.isSuper=null,this.isBroadcast=null,this.isExclusive=null,this.isPublic=null,this.isDiscoverable=null,this.isStrict=null,this.isEphemeral=null,this.accessCode=null,this.name=null,this.data=null,this.customType=null,this.operatorUserIds=null,this.messageSurvivalSeconds=null},It=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return M("string",this.invitedUserIds)&&T("string",this.channelUrl,!0)&&T("string",this.coverUrl,!0)&&(I(this.coverImage)||T("string",this.coverImage)||null===this.coverImage)&&T("boolean",this.isDistinct,!0)&&T("boolean",this.isSuper,!0)&&T("boolean",this.isBroadcast,!0)&&T("boolean",this.isExclusive,!0)&&T("boolean",this.isPublic,!0)&&T("boolean",this.isStrict,!0)&&T("boolean",this.isDiscoverable,!0)&&T("boolean",this.isEphemeral,!0)&&T("string",this.accessCode,!0)&&T("string",this.name,!0)&&T("string",this.data,!0)&&T("string",this.customType,!0)&&M("string",this.operatorUserIds,!0)&&T("number",this.messageSurvivalSeconds,!0)},n.prototype.addUserIds=function(e){if(M("string",e))for(var t=e.filter((function(e){return T("string",e)})),n=0;n0})),i=r.filter((function(e){return 0===e.messageId})),s.length>0?[4,t.upsert(s)]:[3,3]):[3,6];case 1:return c.sent(),[4,n.remove(s.map((function(e){return e instanceof m?e.reqId:null})).filter((function(e){return null!==e})))];case 2:c.sent(),this._broadcastUpdateEvent(s,u),c.label=3;case 3:return i.length>0?[4,n.upsert(i)]:[3,5];case 4:c.sent(),this._broadcastUpdateEvent(i,u),c.label=5;case 5:return[3,10];case 6:return e instanceof D?(a=e.messageIds,u=e.source,[4,t.remove(a)]):[3,8];case 7:return c.sent(),this._broadcastRemoveEvent(a,u),[3,10];case 8:return e instanceof L?(o=e.reqId,u=e.source,[4,n.remove([o])]):[3,10];case 9:c.sent(),this._broadcastRemoveUnsentEvent(o,u),c.label=10;case 10:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=f(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=f(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var s=f(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.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}(),Ht=function(t){function n(e,n,r){var s=t.call(this,e,"USEV",r)||this;return s.event=new Mt(r),s}return e(n,t),n}(O),Vt=function(t){function n(e){var n=e.userId,s=e.ts,i=e.token,a=e.filter,o=void 0===a?new wt:a,u=t.call(this)||this,c=o.customTypes,l=o.includeEmpty,h=o.includeFrozen;return u.method=P.GET,u.path="".concat(x,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s,token:i,custom_types:c,show_empty:l,show_frozen:h}),u}return e(n,t),n}(F),Gt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new Pr(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(k),qt=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=P.GET,s.path="".concat(r?H:V,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(F),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new Pr(e,n),r}return e(n,t),n}(k),Kt=function(t){function n(e){var n=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.memberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,f=e.nicknameContainsFilter,_=e.channelNameContainsFilter,p=e.channelUrlsFilter,m=e.customTypesFilter,v=e.customTypeStartsWithFilter,g=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,y=e.metadataKey,N=e.metadataValues,C=e.metadataValueStartsWith,b=e.includeFrozen,A=e.includeMetaData,S=e.searchFilter,M=e.userIdsFilter;return(n=t.call(this)||this).method=P.GET,n.path="".concat(x,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:c,super_mode:l,public_mode:h,unread_filter:d,members_nickname_contains:f,name_contains:_,channel_urls:p,custom_types:m,custom_type_startswith:v,hidden_mode:g,metadata_order_key:E,metadata_key:y,metadata_values:N,metadata_value_startswith:C,show_frozen:b,show_metadata:A}),S&&S.query&&S.fields&&(n.params.search_query=S.query,n.params.search_fields=S.fields),M&&M.userIds&&M.userIds.length>0&&(M.includeMode?(n.params.members_include_in=M.userIds,n.params.query_type=M.queryType.toUpperCase()):n.params.members_exactly_in=M.userIds),n}return e(n,t),n}(F),zt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new Pr(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(k),jt=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.memberStateFilter;return s.method=P.GET,s.path="".concat(x,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:nt.ALL},s}return e(n,t),n}(F),Qt=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}(k),Yt=function(t){function n(e){var n=this,r=e.userId,s=e.channelUrl,i=e.coverUrl,a=e.coverImage,o=e.isDistinct,u=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,_=e.isDiscoverable,p=e.isStrict,m=e.isEphemeral,v=e.accessCode,g=e.name,E=e.data,y=e.customType,N=e.messageSurvivalSeconds,C=e.invitedUserIds,b=e.operatorUserIds;return(n=t.call(this)||this).method=P.POST,n.path=V,n.params={user_ids:c([r],l(C),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:i,cover_file:a,is_distinct:o,is_super:u,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:_,strict:p,is_ephemeral:m,access_code:v,name:g,data:E,custom_type:y,operator_ids:b,message_survival_seconds:N},n}return e(n,t),n}(F),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Pr(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(k),Wt=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=P.PUT,s.path="".concat(x,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(F);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var Xt=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(F),Zt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Pr(e,n),r}return e(n,t),n}(k),$t=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,l=i.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 $e(e,t)})):[new $e(e,r.data)],s}return e(n,t),n}(Se),en=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s},n}return e(n,t),n}(F);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var tn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new $e(s._iid,r.data),s}return e(n,t),n}(Se),nn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=P.POST,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(F),rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Pr(e,n),r}return e(n,t),n}(k),sn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,f=i.invitees,_=void 0===f?[]:f;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitees=_.map((function(t){return new $e(e,t)})),s}return e(n,t),n}(Se),an=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(F),on=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Pr(e,n),r.channel.myMemberState=Je.NONE,r}return e(n,t),n}(k),un=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,f=i.invitee,_=void 0===f?null:f;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitee=_?new $e(e,_):null,s}return e(n,t),n}(Se),cn=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}(G),ln=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new et(e,r),s}return e(n,t),n}(O),hn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=P.PUT,i.path="".concat(V,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(F);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var dn,fn=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}(O),_n=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.hidePreviousMessages,a=e.allowAutoUnhide;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(F),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(k),mn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(O),vn=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}(G),gn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(O),En=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}(G),yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(O),Nn=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}(G),Cn=function(n){function r(e,t){var r,s,i,a,o,u,c,l,h,d,f,_,p,m,v,g,E,y,N,C,b=this;return(b=n.call(this,e,t)||this).includeEmpty=!1,b.includeFrozen=!0,b.includeMetaData=!0,b.channelUrlsFilter=null,b.customTypesFilter=null,b.customTypeStartsWithFilter=null,b.nicknameContainsFilter="",b.channelNameContainsFilter="",b.memberStateFilter=nt.ALL,b.unreadChannelFilter=st.ALL,b.superChannelFilter=rt.ALL,b.publicChannelFilter=tt.ALL,b.hiddenChannelFilter=it.UNHIDDEN,b.searchFilter={fields:[],query:null},b.userIdsFilter={userIds:[],includeMode:!0,queryType:ot.AND},b.metadataKey=null,b.metadataValues=null,b.metadataOrderKeyFilter=null,b.metadataValueStartsWith=null,b.order=We.LATEST_LAST_MESSAGE,b.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,b.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,b.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,b.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,b.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,b.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:"",b.nicknameContainsFilter=null!==(c=t.nicknameContainsFilter)&&void 0!==c?c:"",b.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:"",b.memberStateFilter=null!==(h=t.memberStateFilter)&&void 0!==h?h:nt.ALL,b.unreadChannelFilter=null!==(d=t.unreadChannelFilter)&&void 0!==d?d:st.ALL,b.superChannelFilter=null!==(f=t.superChannelFilter)&&void 0!==f?f:rt.ALL,b.publicChannelFilter=null!==(_=t.publicChannelFilter)&&void 0!==_?_:tt.ALL,b.hiddenChannelFilter=null!==(p=t.hiddenChannelFilter)&&void 0!==p?p:it.UNHIDDEN,b.searchFilter=null!==(m=t.searchFilter)&&void 0!==m?m:{fields:[],query:null},b.userIdsFilter=null!==(v=t.userIdsFilter)&&void 0!==v?v:{userIds:[],includeMode:!0,queryType:ot.AND},b.metadataKey=null!==(g=t.metadataKey)&&void 0!==g?g:null,b.metadataValues=null!==(E=t.metadataValues)&&void 0!==E?E:null,b.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,b.metadataValueStartsWith=null!==(N=t.metadataValueStartsWith)&&void 0!==N?N:null,b.order=null!==(C=t.order)&&void 0!==C?C:We.LATEST_LAST_MESSAGE,b}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&T("boolean",this.includeEmpty)&&T("boolean",this.includeFrozen)&&T("boolean",this.includeMetaData)&&T("string",this.channelNameContainsFilter)&&M("string",this.channelUrlsFilter,!0)&&M("string",this.customTypesFilter,!0)&&T("string",this.customTypeStartsWithFilter)&&T("string",this.nicknameContainsFilter)&&t(nt,this.memberStateFilter)&&t(rt,this.superChannelFilter)&&t(tt,this.publicChannelFilter)&&t(st,this.unreadChannelFilter)&&t(it,this.hiddenChannelFilter)&&M(ut,this.searchFilter.fields)&&T("string",this.searchFilter.query,!0)&&M("string",this.userIdsFilter.userIds)&&T("boolean",this.userIdsFilter.includeMode)&&t(ot,this.userIdsFilter.queryType)&&t(We,this.order)&&T("string",this.metadataOrderKeyFilter,!0)&&T("string",this.metadataKey,!0)&&M("string",this.metadataValues,!0)&&T("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return q(this)},r.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Mn.of(this._iid).getMyGroupChannels(this._token,this,this.limit)]):[3,2]:[3,5];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasNext=!!n,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw S.queryInProgress;case 4:return[3,6];case 5:throw S.invalidParameters;case 6:return[2]}}))}))},r}(B),bn=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}else e.sendingStatus===Q.PENDING&&j(e.errorCode)&&this._isNotInQueue(e)&&(this._autoResendQueue.push(e),this._isProcessingAutoResend||this._processNextAutoResend())},e.prototype._fetchAllCachedPendingMessages=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.fetch({sendingStatus:Q.PENDING,backward:!0})];case 1:return[2,e.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 h(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(r){switch(r.label){case 0:if(!this._localCacheEnabled||"foreground"!==this._sdkState.appState)return[3,6];r.label=1;case 1:return r.trys.push([1,5,,6]),this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._logger.debug("processing auto-resend for message request id: ",e.reqId),[4,Mn.of(this._iid).getChannel(e.channelUrl,!0)]):[3,3];case 2:return t=r.sent(),e instanceof g?t._autoResendUserMessage(e):e instanceof E&&t._autoResendFileMessage(e),[3,4];case 3:this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1,r.label=4;case 4:return[3,6];case 5:return n=r.sent(),this._logger.warn("process auto-resend error: ",n),this._isProcessingAutoResend=!1,[3,6];case 6:return[2]}}))}))},e}(),Sn={},Mn=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,s=t.dispatcher,i=t.sessionManager,a=t.requestQueue,o=t.logger,u=this;this._leftChannels=new Map,this._markAsReadAllLastSentAt=0,this.autoResendManager=null,this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=a,this._dispatcher=s,this._logger=o,this._groupChannelHandlers=new Map,this._groupChannelCache=new vt(this._iid,{sdkState:n,cacheContext:r}),this._messageCache=new Nt(this._iid,{sdkState:n,cacheContext:r}),this._unsentMessageCache=new At(this._iid,{sdkState:n,cacheContext:r}),this._groupChannelBroadcast=new Ft({groupChannelCache:this._groupChannelCache,messageCache:this._messageCache,unsentMessageCache:this._unsentMessageCache,dispatcher:s}),this._messageBroadcast=new kt({messageCache:this._messageCache,unsentMessageCache:this._unsentMessageCache,dispatcher:s,logger:o}),this.autoResendManager=new An(e,{localCacheEnabled:r.localCacheEnabled,messageCache:this._messageCache,unsentMessageCache:this._unsentMessageCache,dispatcher:s,sdkState:n,logger:o}),setInterval((function(){var e,t,n=function(e){e.invalidateTypingStatus()&&(u._dispatcher.dispatch(new Ot({channels:[e],source:St.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),u._groupChannelHandlers.forEach((function(t){t.onTypingStatusUpdated(e)})))};try{for(var r=f(u._groupChannelCache.channels),s=r.next();!s.done;s=r.next()){n(s.value)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}}),1e3),this._dispatcher.on((function(e){e instanceof O&&u._handleEvent(e)})),Sn[e]=this}return e.of=function(e){return Sn[e]},Object.defineProperty(e.prototype,"handlers",{get:function(){return c([],l(this._groupChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),e.prototype.buildGroupChannelFromSerializedData=function(e){var t=W(e);return new Pr(this._iid,Pr.payloadify(t))},e.prototype.buildGroupChannelListQueryFromSerializedData=function(e){var t=W(e);return new Cn(this._iid,t)},e.prototype.buildMemberFromSerializedData=function(e){var t=W(e);return new $e(this._iid,$e.payloadify(t))},e.prototype.getChannelFromCache=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._groupChannelCache.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getChannelsFromCache=function(e,t,n){return h(this,void 0,void 0,(function(){return d(this,(function(r){switch(r.label){case 0:return[4,this._groupChannelCache.fetch({token:e,filter:t,order:n})];case 1:return[2,r.sent()]}}))}))},e.prototype._handleEvent=function(e){return h(this,void 0,void 0,(function(){var t,r,s,a,o,u,c,l,_,p,v,g,E,y,N,C,b,A,S,M,T,I,U,L,O,P,x,F,k,H,V,G,q,B,K,z,j,Q,J,W,ee,te,ne,re,se,ie,ae,oe,ue,ce,le,he,de,fe,_e,pe,me,ve,ge,Ee,ye,Ne,Ce,be,Ae,Ke,ze,je,Qe,Ye,We,Xe,Ze,$e,et,tt,nt,rt,st,it,at,ot,ut,ct,lt,ht,dt,ft,_t,pt,mt,vt,gt,yt,Nt,Ct,bt,At,Tt,It,Ut,wt,Lt,Dt,Rt,xt,Ft,kt,Vt,Gt,qt,Bt,Kt,zt,jt,Qt,Yt,Jt,Wt,Xt,Zt,en=this;return d(this,(function(nn){switch(nn.label){case 0:switch(nn.trys.push([0,72,,73]),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"DLVR":return[3,13];case"MRCT":return[3,15];case"MTHD":return[3,19];case"MCNT":return[3,23];case"SYEV":return[3,32];case"USEV":return[3,70]}return[3,71];case 1:return c=null,"MESG"===e.code?c=e.as(qe):"FILE"===e.code?c=e.as($):"ADMM"!==e.code&&"BRDM"!=e.code||(c=e.as(Be)),c?(t=c.message,r=c.isMentioned,s=c.forceUpdateLastMessage,t.channelType!==i.GROUP?[3,3]:(w((function(){return h(en,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new Nn(t),this._requestQueue.send(e),[2]}))}))})),I=this._groupChannelCache.isCachedInMemory(t.channelUrl),v=t instanceof m&&t.sender.userId===this._sdkState.userId,[4,this.getChannel(t.channelUrl,!0)])):[3,3];case 2:if((a=nn.sent()).hiddenState=Lr.UNHIDDEN,t instanceof m){try{for(o=f(a.members),u=o.next();!u.done;u=o.next())if((st=u.value).userId===t.sender.userId){st.nickname=t.sender.nickname,st.plainProfileUrl=t.sender.plainProfileUrl,st.metaData=t.sender.metaData,st.isBlockedByMe=t.sender.isBlockedByMe;break}}catch(e){Bt={error:e}}finally{try{u&&!u.done&&(Kt=o.return)&&Kt.call(o)}finally{if(Bt)throw Bt.error}}v&&(E=this._sessionManager.currentUser)&&(E.nickname=t.sender.nickname,E.plainProfileUrl=t.sender.plainProfileUrl,E.metaData=t.sender.metaData)}t.silent&&!v||(a.isEphemeral||I)&&((!a.lastMessage||a.lastMessage.createdAt0||A.unreadMentionCount>0)&&(A._updateUnreadCount(0,0),this._dispatcher.dispatch(new Ot({channels:[A],source:St.EVENT_CHANNEL_READ})),Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==A.unreadMessageCount&&0!==A.unreadMentionCount||(this._dispatcher.dispatch(new Ot({channels:[A],source:St.EVENT_CHANNEL_READ})),Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new Ot({channels:[A],source:St.EVENT_CHANNEL_READ})),Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),nn.label=12;case 12:return[3,71];case 13:return S=e.as(fn),j=S.channelUrl,M=S.deliveredStateUpdate,T=void 0===M?{}:M,I=this._groupChannelCache.isCachedInMemory(j),[4,this.getChannel(j,!0)];case 14:if(U=nn.sent(),I)for(L in T)U._updateUndeliveredMemberState(L,T[L]);return this._dispatcher.dispatch(new Ot({channels:[U],source:St.EVENT_CHANNEL_DELIVERED})),Object.keys(T).some((function(e){return e!==en._sdkState.userId}))&&Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,71];case 15:return O=e.as(Fe),j=O.channelUrl,P=O.channelType,x=O.event,P!==i.GROUP?[3,18]:[4,this.getChannel(j,!0)];case 16:return F=nn.sent(),[4,this.getMessageFromCache(x.messageId)];case 17:(V=nn.sent())&&(V.applyReactionEvent(x),this._dispatcher.dispatch(new R({messages:[V],source:Y.EVENT_MESSAGE_REACTION_UPDATED}))),Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(F,x)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),nn.label=18;case 18:return[3,71];case 19:return(k=e.as(xe).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(k.channelUrl,!0)];case 20:return H=nn.sent(),[4,this.getMessageFromCache(k.targetMessageId)];case 21:(V=nn.sent())&&(V.applyThreadInfoUpdateEvent(k),this._dispatcher.dispatch(new R({messages:[V],source:Y.EVENT_MESSAGE_THREADINFO_UPDATED}))),Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(H,k)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),nn.label=22;case 22:return[3,71];case 23:G=e.as(Pe).groupChannelMemberCounts,q=[],nn.label=24;case 24:nn.trys.push([24,29,30,31]),B=f(G),K=B.next(),nn.label=25;case 25:return K.done?[3,28]:(z=K.value,j=z.channelUrl,ze=z.memberCount,je=z.joinedMemberCount,Q=z.updatedAt,[4,this.getChannelFromCache(j)]);case 26:(J=nn.sent())&&J._setLatestMemberCount(ze,je,Q)&&q.push(J),nn.label=27;case 27:return K=B.next(),[3,25];case 28:return[3,31];case 29:return W=nn.sent(),zt={error:W},[3,31];case 30:try{K&&!K.done&&(jt=B.return)&&jt.call(B)}finally{if(zt)throw zt.error}return[7];case 31:return q.length>0&&(this._dispatcher.dispatch(new Ot({channels:q,source:St.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Z((function(){return h(en,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(q)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,71];case 32:if(!(ee=e.as(Se).event).isGroupChannelEvent)return[3,69];switch(ee.category){case Le.CHANNEL_JOIN:return[3,33];case Le.CHANNEL_LEAVE:return[3,35];case Le.CHANNEL_OPERATOR_UPDATE:return[3,39];case Le.CHANNEL_INVITE:return[3,41];case Le.CHANNEL_DECLINE_INVITE:return[3,43];case Le.TYPING_START:case Le.TYPING_END:return[3,45];case Le.USER_CHANNEL_MUTE:case Le.USER_CHANNEL_UNMUTE:return[3,47];case Le.USER_CHANNEL_BAN:return[3,49];case Le.USER_CHANNEL_UNBAN:return[3,53];case Le.CHANNEL_FREEZE:case Le.CHANNEL_UNFREEZE:return[3,55];case Le.CHANNEL_HIDE:return[3,57];case Le.CHANNEL_UNHIDE:return[3,59];case Le.CHANNEL_DELETED:return[3,61];case Le.CHANNEL_PROP_CHANGED:return[3,63];case Le.CHANNEL_META_DATA_CHANGED:return[3,65];case Le.CHANNEL_META_COUNTERS_CHANGED:return[3,67]}return[3,69];case 33:return[4,this.getChannel(ee.channelUrl,!0)];case 34:return te=nn.sent(),ne=e.as($t),re=ne.memberCount,se=ne.joinedMemberCount,ie=ne.members,ae=!1,ie.forEach((function(e){te.isExclusive||te.isSuper||te.isBroadcast?ae=ae||te._setLatestMemberCount(re,se,ee.ts):(e.state=Je.JOINED,te.addMember(e,ee.ts),en._updateJoinedMemberCount(te)),e.userId===en._sdkState.userId&&(te.myMemberState=Je.JOINED)})),this._dispatcher.dispatch(new Ot({channels:[te],source:St.EVENT_CHANNEL_JOINED})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=f(ie),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(te,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}te.isBroadcast&&ae&&e.onChannelMemberCountChanged([te])})),[2]}))}))})),[3,69];case 35:return(it=this._leftChannels.get(ee.channelUrl))?(ue=it.channel,[3,38]):[3,36];case 36:return[4,this.getChannel(ee.channelUrl,!0)];case 37:ue=nn.sent(),nn.label=38;case 38:return oe=ue,ce=e.as(tn),ze=ce.memberCount,je=ce.joinedMemberCount,le=ce.member,he=!1,oe.isExclusive||oe.isSuper||oe.isBroadcast?he=oe._setLatestMemberCount(ze,je,ee.ts):(oe.removeMember(le),this._updateJoinedMemberCount(oe)),le.userId===this._sdkState.userId?oe.isPublic?(oe.myMemberState=Je.NONE,oe.invitedAt=0,oe.joinedAt=0,oe._updateUnreadCount(0,0),this._dispatcher.dispatch(new Ot({channels:[oe],source:St.EVENT_CHANNEL_LEFT}))):(this._markAsLeave(oe),this._dispatcher.dispatch(new Pt({channelUrls:[oe.url],source:St.EVENT_CHANNEL_LEFT}))):this._dispatcher.dispatch(new Ot({channels:[oe],source:St.EVENT_CHANNEL_LEFT})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(oe,le),oe.isBroadcast&&he&&e.onChannelMemberCountChanged([oe])})),[2]}))}))})),[3,69];case 39:return[4,this.getChannel(ee.channelUrl,!0)];case 40:de=nn.sent(),fe=e.as(Oe).operators,_e=fe.map((function(e){return e.userId}));try{for(pe=f(de.members),me=pe.next();!me.done;me=pe.next())(st=me.value).role=_e.includes(st.userId)?n.OPERATOR:n.NONE}catch(e){Qt={error:e}}finally{try{me&&!me.done&&(Yt=pe.return)&&Yt.call(pe)}finally{if(Qt)throw Qt.error}}return de.myRole=_e.includes(this._sdkState.userId)?n.OPERATOR:n.NONE,this._dispatcher.dispatch(new Ot({channels:[de],source:St.EVENT_CHANNEL_OPERATOR_UPDATED})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(de,fe)})),[2]}))}))})),[3,69];case 41:return[4,this.getChannel(ee.channelUrl,!0)];case 42:ve=nn.sent(),ge=e.as(sn),ze=ge.memberCount,je=ge.joinedMemberCount,Ee=ge.inviter,(ye=ge.invitees).forEach((function(e){return e.state=Je.INVITED}));try{for(Ne=f(ye),Ce=Ne.next();!Ce.done;Ce=Ne.next())be=Ce.value,ve.isExclusive||ve.isSuper||ve.isBroadcast?ve._setLatestMemberCount(ze,je,ee.ts):ve.addMember(be,ee.ts),this._sdkState.userId===be.userId&&(ve.hiddenState=Lr.UNHIDDEN,ve.myMemberState!==Je.JOINED&&(ve.myMemberState=Je.INVITED),ve.invitedAt=ee.ts)}catch(e){Jt={error:e}}finally{try{Ce&&!Ce.done&&(Wt=Ne.return)&&Wt.call(Ne)}finally{if(Jt)throw Jt.error}}return this._dispatcher.dispatch(new Ot({channels:[ve],source:St.EVENT_CHANNEL_INVITED})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(ve,Ee,ye)})),[2]}))}))})),[3,69];case 43:return[4,this.getChannel(ee.channelUrl,!0)];case 44:return Ae=nn.sent(),Ke=e.as(un),ze=Ke.memberCount,je=Ke.joinedMemberCount,Qe=Ke.inviter,Ye=Ke.invitee,Ae.isExclusive||Ae.isSuper||Ae.isBroadcast?Ae._setLatestMemberCount(ze,je,ee.ts):Ae.removeMember(Ye),this._sdkState.userId===Ye.userId?(Ae.invitedAt=0,Ae.myMemberState=Je.NONE,Ae.isPublic?this._dispatcher.dispatch(new Ot({channels:[Ae],source:St.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Pt({channelUrls:[Ae.url],source:St.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Ot({channels:[Ae],source:St.EVENT_CHANNEL_DECLINED_INVITE})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Ae,Qe,Ye)})),[2]}))}))})),[3,69];case 45:return[4,this.getChannel(ee.channelUrl,!0)];case 46:return We=nn.sent(),Xe=ee.category===Le.TYPING_START,Ze=e.as(Xe?gn:yn).user,We._updateTypingStatus(Ze,Xe?ee.ts:0),this._dispatcher.dispatch(new Ot({channels:[We],source:St.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(We)})),[2]}))}))})),[3,69];case 47:return[4,this.getChannel(ee.channelUrl,!0)];case 48:$e=nn.sent(),et=ee.category===Le.USER_CHANNEL_MUTE,(tt=e.as(et?De:Re).user).userId===this._sdkState.userId&&($e.myMutedState=et?wr.MUTED:wr.UNMUTED);try{for(nt=f($e.members),rt=nt.next();!rt.done;rt=nt.next())if((st=rt.value).userId===tt.userId){st.isMuted=et;break}}catch(e){Xt={error:e}}finally{try{rt&&!rt.done&&(Zt=nt.return)&&Zt.call(nt)}finally{if(Xt)throw Xt.error}}return this._dispatcher.dispatch(new Ot({channels:[$e],source:et?St.EVENT_CHANNEL_MUTED:St.EVENT_CHANNEL_UNMUTED})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){et?e.onUserMuted($e,tt):e.onUserUnmuted($e,tt)})),[2]}))}))})),[3,69];case 49:return(it=this._leftChannels.get(ee.channelUrl))?(ot=it.channel,[3,52]):[3,50];case 50:return[4,this.getChannel(ee.channelUrl,!0)];case 51:ot=nn.sent(),nn.label=52;case 52:return at=ot,this._markAsLeave(at),ut=e.as(we).user,Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(at,ut)})),[2]}))}))})),[3,69];case 53:return[4,this.getChannel(ee.channelUrl,!0)];case 54:return ct=nn.sent(),lt=e.as(Ue).user,Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(ct,lt)})),[2]}))}))})),[3,69];case 55:return[4,this.getChannel(ee.channelUrl,!0)];case 56:return ht=nn.sent(),dt=e.as(Ie).freeze,ht.isFrozen=dt,this._dispatcher.dispatch(new Ot({channels:[ht],source:dt?St.EVENT_CHANNEL_FROZEN:St.EVENT_CHANNEL_UNFROZEN})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){dt?e.onChannelFrozen(ht):e.onChannelUnfrozen(ht)})),[2]}))}))})),[3,69];case 57:return[4,this.getChannel(ee.channelUrl,!0)];case 58:return ft=nn.sent(),_t=e.as(mn),pt=_t.allowAutoUnhide,mt=_t.hidePreviousMessages,vt=_t.messageOffsetTimestamp,null!==pt&&(ft.hiddenState=pt?Lr.HIDDEN_ALLOW_AUTO_UNHIDE:Lr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==mt&&mt&&ft._updateUnreadCount(0,0),null!==vt&&(ft.messageOffsetTimestamp=vt),this._dispatcher.dispatch(new Ot({channels:[ft],source:St.EVENT_CHANNEL_HIDDEN})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(ft)})),[2]}))}))})),[3,69];case 59:return[4,this.getChannel(ee.channelUrl,!0)];case 60:return(gt=nn.sent()).hiddenState=Lr.UNHIDDEN,this._dispatcher.dispatch(new Ot({channels:[gt],source:St.EVENT_CHANNEL_UNHIDDEN})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(gt)})),[2]}))}))})),[3,69];case 61:return[4,this.getChannel(ee.channelUrl,!0)];case 62:return yt=nn.sent(),this._dispatcher.dispatch(new Pt({channelUrls:[ee.channelUrl],source:St.EVENT_CHANNEL_DELETED})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(yt.url,yt.channelType)})),[2]}))}))})),[3,69];case 63:return[4,this.getChannelWithoutCache(ee.channelUrl,!0)];case 64:return Nt=nn.sent(),this._dispatcher.dispatch(new Ot({channels:[Nt],source:St.EVENT_CHANNEL_UPDATED})),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Nt)})),[2]}))}))})),[3,69];case 65:return[4,this.getChannel(ee.channelUrl,!0)];case 66:return Ct=nn.sent(),bt=e.as(Te),At=bt.created,Tt=bt.updated,It=bt.deleted,At&&Ct._upsertCachedMetaData(At,ee.ts),Tt&&Ct._upsertCachedMetaData(Tt,ee.ts),It&&Ct._removeFromCachedMetaData(It,ee.ts),Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){At&&e.onMetaDataCreated(Ct,At),Tt&&e.onMetaDataUpdated(Ct,Tt),It&&e.onMetaDataDeleted(Ct,It)})),[2]}))}))})),[3,69];case 67:return[4,this.getChannel(ee.channelUrl,!0)];case 68:return Ut=nn.sent(),wt=e.as(Me),Lt=wt.created,Dt=wt.updated,Rt=wt.deleted,Z((function(){return h(en,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Lt&&e.onMetaCounterCreated(Ut,Lt),Dt&&e.onMetaCounterUpdated(Ut,Dt),Rt&&e.onMetaCounterDeleted(Ut,Rt)})),[2]}))}))})),[3,69];case 69:return[3,71];case 70:switch((xt=e.as(Ht).event).category){case Et.USER_BLOCK:Ft=Mt.getDataAsUserBlockEvent(this._iid,xt),Vt=Ft.blocker,Gt=Ft.blockee,this._groupChannelCache.block(Vt.userId,Gt.userId);break;case Et.USER_UNBLOCK:kt=Mt.getDataAsUserBlockEvent(this._iid,xt),Vt=kt.blocker,Gt=kt.blockee,this._groupChannelCache.unblock(Vt.userId,Gt.userId)}return[3,71];case 71:return[3,73];case 72:if(qt=nn.sent(),X(qt))throw qt;return[3,73];case 73:return[2]}}))}))},e.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)},e.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},e.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},e.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},e.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},e.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},e.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},e.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Je.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),h(this,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:ee(T("string",e)).throw(S.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()]}}))}))},e.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),h(this,void 0,void 0,(function(){var n,r,s,i,a;return d(this,(function(o){switch(o.label){case 0:return ee(T("string",e)).throw(S.invalidParameters),n=new qt({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(Bt).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case Ur.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case Ur.UNREAD_MENTION_COUNT_ONLY:i=0;break;case Ur.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this._groupChannelCache.upsert([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=St.REQUEST_CHANNEL),h(this,void 0,void 0,(function(){var i,a,o,u,c;return d(this,(function(l){switch(l.label){case 0:return i=new Kt(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(zt),u=o.channels,c=o.token,this._dispatcher.dispatch(new Ot({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s){return void 0===s&&(s=100),h(this,void 0,void 0,(function(){return d(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getAllFailedMessagesFromCache=function(e,t){return h(this,void 0,void 0,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},e.prototype.getCachedMessageCountBetween=function(e,t,n,r){return h(this,void 0,void 0,(function(){return d(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new bn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=St.REQUEST_CHANNEL_CHANGELOGS),h(this,void 0,void 0,(function(){var s,i,a,o,u;return d(this,(function(c){switch(c.label){case 0:return ee(T("string",e)&&t instanceof wt&&t.validate()).throw(S.invalidParameters),s=new Vt(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:t})),[4,this._requestQueue.send(s)];case 1:return i=c.sent(),a=i.as(Gt),o=a.updatedChannels,u=a.deletedChannelUrls,o.length>0&&this._dispatcher.dispatch(new Ot({channels:o,source:n})),u.length>0&&this._dispatcher.dispatch(new Pt({channelUrls:u,source:n})),[2,a]}}))}))},e.prototype.getGroupChannelCount=function(e){return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return ee(e instanceof Dt&&e.validate()).throw(S.invalidParameters),t=new jt({userId:this._sdkState.userId,filter:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Qt).groupChannelCount]}}))}))},e.prototype.createChannel=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return d(this,(function(i){switch(i.label){case 0:return ee(e instanceof It&&e.validate()).throw(S.invalidParameters),e.isPublic||(e.accessCode=null),t=new Yt(s({userId:this._sdkState.userId},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),r=n.as(Jt).channel,[4,this._groupChannelCache.upsert([r])];case 2:return i.sent(),[2,r]}}))}))},e.prototype.markAsReadAll=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return e=Date.now(),ee(e-this._markAsReadAllLastSentAt>=1e3).throw(S.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Wt({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=f(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this._groupChannelCache.upsert(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return d(this,(function(l){switch(l.label){case 0:return t=Date.now(),ee(M("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(S.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Wt({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=f(r),a=i.next();!a.done;a=i.next())o=a.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{a&&!a.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this._groupChannelCache.upsert(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return h(this,void 0,void 0,(function(){return d(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]}}))}))},e}(),Tn=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},In=new Map,Un=new Map,wn=new Map,Ln=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,s=void 0===r?2:r,i=t.backOffDelay,a=void 0===i?0:i,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=s,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],Tn()?(In[this._holdersKey]||(In[this._holdersKey]=[]),Un[this._resolversKey]||(Un[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return h(o,void 0,void 0,(function(){var t,n;return d(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(o._resolversKey,JSON.stringify(n)),o._localAcquiredKeys.forEach((function(e){return o.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(Tn())return this.numLocks-In[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return Tn()?Un[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(Tn())return wn[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){Tn()?wn[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return h(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,ne(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),Tn()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),h(this,void 0,void 0,(function(){var t,n=this;return d(this,(function(r){return Tn()?[2,new Promise((function(t){for(var r={key:te(),resolver:function(e){return t(e)},priority:e},s=Un[n._resolversKey],i=-1,a=0;as[a].priority){i=a;break}i>=0?Un[n._resolversKey].splice(i,0,r):Un[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var s=te(),i={key:s,priority:e},a={key:s,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,i),n._localResolversData.splice(o,0,a)):(t.push(i),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(Tn()){if((t=In[this._holdersKey].indexOf(e))>=0)return In[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=c([],l(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(s),!0}}return!1},e.prototype._tryResolve=function(){if(Tn()){if(In[this._holdersKey].length=100,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,u.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 3:return a.sent(),[3,5];case 4:t.hasNext=!1,a.label=5;case 5:return[2,t]}}))}))})),this._nextSync=new Rn(c,(function(e){return h(r,void 0,void 0,(function(){var t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return a.sent(),u.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),[4,y.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(i=null===(s=this._metadata.range)||void 0===s?void 0:s.bottom)&&void 0!==i?i:e,{prevResultSize:0,nextResultSize:100,replyType:v.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},Y.SYNC_MESSAGE_BACKGROUND)];case 2:return n=a.sent(),this.extendRange(n),t.hasNext=n.length>=100,t.nextToken=this._metadata.range.bottom,u.debug("message background next sync progress",t),[4,this.saveMetadata()];case 3:return a.sent(),[2,t]}}))}))}))}return e.of=function(t,n){if(xn[t]||(xn[t]={}),!xn[t][n.url]){var r=xn[t][n.url]=new e({_iid:t,channel:n});se.of(t).dispatcher.on((function(e){if(e instanceof K)if(e.stateType===z.CONNECTED)r.resume();else r.pause()}))}return xn[t][n.url]},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},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,c([],l(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,c([],l(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return h(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,se.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new bn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._metadata?[4,se.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.resume=function(){var e,t,n,r;se.of(this._iid).logger.debug("message background sync resume()"),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:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},e.prototype.pause=function(){se.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e}(),kn={},Hn=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=se.of(this._iid).sdkState;this._metadataKey=(s=a.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var o=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(a.userId,this._channel.url);this._sync=new Rn(o,(function(){return h(r,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){switch(i.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,8]),[4,y.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:v.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includePollDetails:!0},Y.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=i.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return i.sent(),[2,e];case 5:return(s=i.sent())instanceof S&&s.isInvalidTokenError?[4,this.cleatMetadata()]:[3,7];case 6:i.sent(),i.label=7;case 7:return[3,8];case 8:return[2]}}))}))}))}return e.of=function(t,n){if(kn[t]||(kn[t]={}),!kn[t][n.url]){var r=kn[t][n.url]=new e({_iid:t,channel:n});se.of(t).dispatcher.on((function(e){if(e instanceof K)if(e.stateType===z.CONNECTED)r.resume();else r.pause()}))}return kn[t][n.url]},e.prototype.loadMetadata=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=se.of(this._iid),t=e.cacheContext,n=e.connectedAt,[4,t.store.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._metadata?[4,se.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.cleatMetadata=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){return se.of(this._iid).cacheContext.store.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),Vn=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=P.GET,c.path="".concat(ie(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),c.params=r({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!==(n=e.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(i=e.messageType)&&void 0!==i?i:null,include_reactions:null===(a=e.includeReactions)||void 0===a||a,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u}),c}return e(n,t),n}(F),Gn=function(t){function n(e,n){var r,s,i,a,o=this;return(o=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return ae(e,t)})),o.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,o.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return ae(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(k),qn=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Bn=function(e,t,n){if(e.length>0){var r=qn(e,t);if(r<0){for(var s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};s=a+1,a=Math.floor((s+i)/2)}}return{place:Kn(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},Kn=function(e,t,n){switch(n){case We.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 We.CHRONOLOGICAL:return t.createdAt-e.createdAt;case We.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},zn=function(e,t){if(t instanceof m)return e.findIndex((function(e){return e instanceof m&&t.isIdentical(e)}));e.findIndex((function(e){return e.isIdentical(t)}))},jn=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(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api",e.API_ONLY="api_only"}(Dn||(Dn={}));var Qn,Yn,Jn=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Z((function(){return h(r,void 0,void 0,(function(){return d(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}(),Wn=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._iid=e,this._key="mc-".concat(te()),this.filter=null!=r?r:new gt,this._channel=n,this._syncRange=new bn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||100;var o=Mn.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=qn(e,a._channel);if(o>=0)switch(Z((function(){return h(a,void 0,void 0,(function(){var n;return d(this,(function(r){return n=new On(t),this._channel=e[o],this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case St.EVENT_CHANNEL_UPDATED:var u=!1;for(var c in a._messages){if((g=a._messages[c]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var l=parseInt(c);if(l>0){var _=a._messages.splice(0,l);a._removeMessagesFromView(_.map((function(e){return e.messageId})),Y.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),Y.EVENT_MESSAGE_OFFSET_UPDATED);break;case St.EVENT_CHANNEL_READ:var p=[];try{for(var m=f(a._messages),v=m.next();!v.done;v=m.next()){var g=v.value;if((N=a._readReceiptMap.get(g.messageId))>0)N!==a._channel.getUnreadMemberCount(g)&&p.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}p.length>0&&a._updateMessagesToView(p,Y.EVENT_MESSAGE_READ);break;case St.EVENT_CHANNEL_DELIVERED:p=[];try{for(var E=f(a._messages),y=E.next();!y.done;y=E.next()){var N;g=y.value;if((N=a._deliveryReceiptMap.get(g.messageId))>0)N!==a._channel.getUndeliveredMemberCount(g)&&p.push(g)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(i=E.return)&&i.call(E)}finally{if(s)throw s.error}}p.length>0&&a._updateMessagesToView(p,Y.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&Z((function(){return h(a,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new On(t),this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=f(e),u=o.next();!u.done;u=o.next()){var c=u.value;c.channelUrl===a._channel.url&&(a.filter.match(c)?s.push(c):i.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(oe(t)){if(s.length>0)switch(t){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:a._updateMessagesToView(s,t);break;case Y.EVENT_MESSAGE_SENT_PENDING:case Y.EVENT_MESSAGE_RECEIVED:case Y.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)}}),Fn.of(this._iid,this._channel).resume(),Hn.of(this._iid,this._channel).resume(),this._prevFill=new Rn(this._key,(function(e){return h(a,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:Y.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this._syncRange.top>n,nextToken:this._syncRange.top}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._nextFill=new Rn(this._key,(function(e){return h(a,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{nextLimit:this._limit,source:Y.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.max.apply(Math,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this._syncRange.bottom=t._channel.messageOffsetTimestamp}))},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=f(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(l.messageId>0){if((p=zn(this._messages,l))<0){var _=jn(this._messages,l);a.push(l),this._messages.splice(_,0,l)}else o.push(l),this._messages[p]=l;this._readReceiptMap.set(l.messageId,this._channel.getUnreadMemberCount(l)),this._deliveryReceiptMap.set(l.messageId,this._channel.getUndeliveredMemberCount(l))}else{var p;if(l instanceof m)(p=zn(this._unsentMessages,l))<0?zn(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[p]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}oe(t)&&Z((function(){return h(s,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new Pn(t),a.length>0&&this._handler.onMessagesAdded(e,this.channel,a),o.length>0&&this._handler.onMessagesUpdated(e,this.channel,o),[2]}))}))}))},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=f(e),o=a.next();!o.done;o=a.next()){var u,c=o.value;if(c.messageId>0)if((u=zn(this._messages,c))>=0)i.push(c),this._messages[u]=c;else{var l=zn(this._unsentMessages,c);if(l>=0){i.push(c),this._unsentMessages.splice(l,1);var _=jn(this._messages,c);this._messages.splice(_,0,c)}}else if(c instanceof m)(u=zn(this._unsentMessages,c))>=0&&(i.push(c),this._unsentMessages[u]=c)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return oe(t)&&Z((function(){return h(s,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new Pn(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(i.push(o._messages[t].messageId),o._messages.splice(t,1))},o=this;try{for(var u=f(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return oe(t)&&i.length>0&&Z((function(){return h(s,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new Pn(t),i.length>0&&this._handler.onMessagesDeleted(e,this.channel,i),[2]}))}))})),i},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,i=void 0===s?0:s;return h(this,void 0,void 0,(function(){var t,n,s,a,o,u,h;return d(this,(function(d){switch(d.label){case 0:return t=Mn.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return s=d.sent(),[3,3];case 2:s=[],d.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return o=d.sent(),[3,6];case 5:o=[],d.label=6;case 6:if(a=o,n.length>0&&a.length)for(h in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[h].messageId)){a.splice(parseInt(h),1);break}return[2,c(c([],l(n),!1),l(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?Y.REQUEST_MESSAGE:o;return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(i){switch(i.label){case 0:return t=y.of(this._iid),r>0||a>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=[],i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,f,_,p=this;return d(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(e=this.viewTop,t=this._syncRange.top,n=this._syncRange.bottom,r=Number.MAX_SAFE_INTEGER,[4,(i=Mn.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return a=m.sent(),[4,i.getCachedMessageCountBetween(this._channel.url,this.filter,n,r)];case 2:return o=m.sent(),[4,ue((function(){return h(p,void 0,void 0,(function(){var i,u,f,_,p,m,v,g,E,y,N,C,b,A,S,M,T,I=this;return d(this,(function(U){switch(U.label){case 0:return i=se.of(this._iid),u=i.dispatcher,f=i.requestQueue,_=new Vn(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:a,nextStart:n,nextEnd:r,nextCount:o},this.filter)),[4,f.send(_)];case 1:return p=U.sent(),m=p.as(Gn),v=m.isHugeGap,g=m.prevMessages,E=void 0===g?[]:g,y=m.prevHasMore,N=m.nextMessages,C=void 0===N?[]:N,b=m.nextHasmore,v?Z((function(){return h(I,void 0,void 0,(function(){return d(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=y,this._hasNext=b,A=this.viewTop,S=this.viewBottom,M=Math.min.apply(Math,c([Number.MAX_SAFE_INTEGER],l(E.map((function(e){return e.createdAt}))),!1)),T=Math.max.apply(Math,c([0],l(C.map((function(e){return e.createdAt}))),!1)),u.dispatch(new R({messages:E,source:Y.SYNC_MESSAGE_FILL})),u.dispatch(new R({messages:C,source:Y.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,T),AT&&this._nextFill.start(T)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return u=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:u,nextLimit:u,source:Y.SYNC_MESSAGE_FILL})];case 5:(f=m.sent()).length>0&&((_=this._syncRange).extends.apply(_,c([],l(f.map((function(e){return e.createdAt}))),!1)),f.length0&&((s=t._syncRange).extends.apply(s,c([],l(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,Y.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(X(e))throw e;n._invokeResponse("remote",e,null)}))}));break;case Dn.API_ONLY:this._getRemoteMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){var s,i=t._filterUnderOffsetMessage(e);i.length0&&((s=t._syncRange).extends.apply(s,c([],l(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,Y.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(X(e))throw e;n._invokeResponse("remote",e,null)}))}return n},e.prototype.loadPrevious=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s=this;return d(this,(function(i){switch(i.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,w((function(){return h(s,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return i.sent(),n=Fn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,w((function(){return h(s,void 0,void 0,(function(){var r,s;return d(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,c([],l(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,Y.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,Y.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s=this;return d(this,(function(i){switch(i.label){case 0:return e=this.viewBottom,t=[],[4,w((function(){return h(s,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{nextLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),n=Fn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,w((function(){return h(s,void 0,void 0,(function(){var r,s;return d(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{nextLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasNext=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,c([],l(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,Y.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,Y.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t]}}))}))},e.prototype.removeFailedMessage=function(e){return h(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return[4,Mn.of(this._iid).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=Mn.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},e}(),Xn=function(){this.coverUrl=null,this.coverImage=null,this.isDistinct=null,this.isPublic=null,this.isDiscoverable=null,this.accessCode=null,this.name=null,this.data=null,this.customType=null,this.operatorUserIds=null,this.messageSurvivalSeconds=null},Zn=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return T("string",this.coverUrl,!0)&&(I(this.coverImage)||T("string",this.coverImage)||null===this.coverImage)&&T("boolean",this.isDistinct,!0)&&T("boolean",this.isPublic,!0)&&T("boolean",this.isDiscoverable,!0)&&T("string",this.accessCode,!0)&&T("string",this.name,!0)&&T("string",this.data,!0)&&T("string",this.customType,!0)&&M("string",this.operatorUserIds,!0)&&T("number",this.messageSurvivalSeconds,!0)},n}(Xn),$n=function(){this.hidePreviousMessages=!1,this.allowAutoUnhide=!0},er=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return T("boolean",this.hidePreviousMessages)&&T("boolean",this.allowAutoUnhide)},n}($n),tr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=P.GET,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,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}(F),nr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.members=[];var s=n.next,i=n.members;return r.token=s,i&&i.length>0&&(r.members=i.map((function(t){return new $e(e,t)}))),r}return e(n,t),n}(k);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Qn||(Qn={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Yn||(Yn={}));var rr=function(n){function r(e,t,r){var s,a,o,u,c=this;return(c=n.call(this,e,t,i.GROUP,r)||this).mutedMemberFilter=Qn.ALL,c.memberStateFilter=nt.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=at.ALL,c.order=Yn.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Qn.ALL,c.memberStateFilter=null!==(a=r.memberStateFilter)&&void 0!==a?a:nt.ALL,c.nicknameStartsWithFilter=null!==(o=r.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=r.order)&&void 0!==u?u:Yn.MEMBER_NICKNAME_ALPHABETICAL,c}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&t(Qn,this.mutedMemberFilter)&&t(nt,this.memberStateFilter)&&(T("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&t(at,this.operatorFilter)&&t(Yn,this.order)},r.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,a;return d(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=se.of(this._iid).requestQueue,t=new tr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(nr),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw S.queryInProgress;case 4:return[3,6];case 5:throw S.invalidParameters;case 6:return[2]}}))}))},r}(ce),sr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(F),ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Pr(e,n),r.channel.myMemberState=Je.JOINED,r}return e(n,t),n}(k),ar=function(t){function n(e){var n=this,r=e.channelUrl,s=e.isDistinct,i=e.isPublic,a=e.isDiscoverable,o=e.coverUrl,u=e.coverImage,c=e.accessCode,l=e.name,h=e.data,d=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r)),n.params={is_distinct:s,is_public:i,is_discoverable:a,name:l,data:h,custom_type:d,cover_url:o,cover_file:u,access_code:c,operator_ids:f,message_survival_seconds:_},n}return e(n,t),n}(F),or=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Pr(e,n),r}return e(n,t),n}(k),ur=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=P.DELETE,n.path="".concat(V,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(F);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var cr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=P.DELETE,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(F);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var lr=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=P.GET,r.path="".concat(x,"/").concat(encodeURIComponent(n),"/push_preference"),r}return e(n,t),n}(F),hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(k),dr=function(t){function n(e){var n=e.userId,r=e.pushTriggerOption,s=t.call(this)||this;return s.method=P.PUT,s.path="".concat(x,"/").concat(encodeURIComponent(n),"/push_preference"),s.params={push_trigger_option:r},s}return e(n,t),n}(F),fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(k),_r=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=P.PUT,i.path="".concat(x,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(F),pr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=Ur[n.count_preference],r}return e(n,t),n}(k),mr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=P.PUT,n.path="".concat(V,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(F),vr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(k),gr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return new C(this).validate()&&T("number",this.scheduledAt)},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e}return e(n,t),n}(le)),Er=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl;return n.method=P.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages"),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(F),yr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new g(e,n),r}return e(n,t),n}(k),Nr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),Object.defineProperty(n.prototype,"fileUrl",{get:function(){return T("string",this.file)?this.file:null},set:function(e){T("string",e)&&(this.file=e)},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return new _e(this).validate()&&T("number",this.scheduledAt)&&(I(this.file)||T("string",this.fileUrl))&&T("string",this.fileName,!0)&&T("string",this.mimeType,!0)&&T("number",this.fileSize,!0)&&(null===this.thumbnailSizes||this.thumbnailSizes.every((function(e){return T("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e.file=null,e.fileName=null,e.mimeType=null,e.fileSize=null,e.thumbnailSizes=null,e._requireAuth=!1,e}return e(n,t),n}(pe)),Cr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl;return n.method=P.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages"),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return me.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(F),br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new E(e,n),r}return e(n,t),n}(k),Ar=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),Object.defineProperty(n.prototype,"fileUrl",{get:function(){return T("string",this.file)?this.file:null},set:function(e){T("string",e)&&(this.file=e)},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return new _e(this).validate()&&(T("number",this.scheduledAt)||null===this.scheduledAt)&&(I(this.file)||T("string",this.fileUrl))&&(T("string",this.fileName)||null===this.fileName)&&(T("string",this.mimeType)||null===this.mimeType)&&(T("number",this.fileSize)||null===this.fileSize)&&(null===this.thumbnailSizes||this.thumbnailSizes.every((function(e){return T("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e.file=null,e.fileName=null,e.mimeType=null,e.fileSize=null,e.thumbnailSizes=null,e._requireAuth=!1,e}return e(n,t),n}(ve)),Sr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return new ge(this).validate()&&(T("number",this.scheduledAt)||null===this.scheduledAt)},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e}return e(n,t),n}(Ee)),Mr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=P.PUT,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return me.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(F),Tr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new E(e,n),r}return e(n,t),n}(k),Ir=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=P.PUT,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(F);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new g(e,n),r}e(n,t)}(k);var Ur,wr,Lr,Dr,Rr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=P.DELETE,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(F),Or=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=P.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(F);!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"}(Ur||(Ur={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(wr||(wr={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Lr||(Lr={})),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"}(Dr||(Dr={}));var Pr=function(o){function u(e,r){var u,h,d,f,_,p,m,v,g,E,y,N,C,b,A,S,M,I,U=this;return(U=o.call(this,e,r)||this)._unreadMemberStateMap=new Map,U._undeliveredMemberStateMap=new Map,U._typingStatus=new Map,U._lastMemberCountUpdated=0,U._typingStarted=0,U._typingEnded=0,U.isDistinct=!1,U.isSuper=!1,U.isBroadcast=!1,U.isExclusive=!1,U.isPublic=!1,U.isDiscoverable=!0,U.isAccessCodeRequired=!1,U.isPushEnabled=!1,U.unreadMessageCount=0,U.unreadMentionCount=0,U.members=[],U.memberCount=0,U.joinedMemberCount=0,U.hiddenState=Lr.UNHIDDEN,U.lastMessage=null,U.messageOffsetTimestamp=0,U.messageSurvivalSeconds=-1,U.myMemberState=Je.NONE,U.myRole=n.NONE,U.myMutedState=wr.UNMUTED,U.myLastRead=0,U.myCountPreference=Ur.ALL,U.myPushTriggerOption=je.DEFAULT,U.inviter=null,U.invitedAt=0,U.joinedAt=0,U.channelType=i.GROUP,U.isDistinct=null!==(h=r.is_distinct)&&void 0!==h&&h,U.isSuper=null!==(d=r.is_super)&&void 0!==d&&d,U.isBroadcast=null!==(f=r.is_broadcast)&&void 0!==f&&f,U.isExclusive=null!==(_=r.is_exclusive)&&void 0!==_&&_,U.isPublic=null!==(p=r.is_public)&&void 0!==p&&p,U.isDiscoverable=null!==(m=r.is_discoverable)&&void 0!==m?m:U.isPublic,U.isAccessCodeRequired=null!==(v=r.is_access_code_required)&&void 0!==v&&v,U.isPushEnabled=null!==(g=r.is_push_enabled)&&void 0!==g&&g,Array.isArray(r.members)&&(u=U.members).push.apply(u,c([],l(r.members.map((function(e){return new $e(U._iid,e)}))),!1)),U.memberCount=null!==(E=r.member_count)&&void 0!==E?E:0,U.joinedMemberCount=null!==(y=r.joined_member_count)&&void 0!==y?y:0,U.hiddenState=t(Lr,r.hidden_state)?r.hidden_state:Lr.UNHIDDEN,U.messageOffsetTimestamp=null!==(N=r.ts_message_offset)&&void 0!==N?N:0,U.messageSurvivalSeconds=null!==(C=r.message_survival_seconds)&&void 0!==C?C:-1,U.lastMessage=r.last_message?ae(U._iid,s({channel_type:U.channelType},r.last_message)):null,r.read_receipt&&Object.keys(r.read_receipt).forEach((function(e){T("number",r.read_receipt[e])&&U._updateUnreadMemberState(e,r.read_receipt[e])})),r.delivery_receipt&&Object.keys(r.delivery_receipt).forEach((function(e){T("number",r.delivery_receipt[e])&&U._updateUndeliveredMemberState(e,r.delivery_receipt[e])})),U.myMemberState=t(Je,r.member_state)?r.member_state:Je.NONE,U.myRole=t(n,r.my_role)?r.my_role:n.NONE,t(wr,r.is_muted)?U.myMutedState=r.is_muted:T("boolean",r.is_muted)?U.myMutedState=r.is_muted?wr.MUTED:wr.UNMUTED:U.myMutedState=wr.UNMUTED,U.myCountPreference=t(Ur,r.count_preference)?r.count_preference:Ur.ALL,U.myPushTriggerOption=t(je,r.push_trigger_option)?r.push_trigger_option:je.ALL,U.myLastRead=null!==(b=r.user_last_read)&&void 0!==b?b:0,U.inviter=r.inviter?new a(U._iid,r.inviter):null,U.invitedAt=null!==(A=r.invited_at)&&void 0!==A?A:0,U.joinedAt=null!==(S=r.joined_ts)&&void 0!==S?S:0,U._updateUnreadCount(null!==(M=r.unread_message_count)&&void 0!==M?M:0,null!==(I=r.unread_mention_count)&&void 0!==I?I:0),U}return e(u,o),Object.defineProperty(u.prototype,"isHidden",{get:function(){return this.hiddenState!==Lr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=l(s.value,2),a=i[0],o=i[1];n[a]=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(u.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=l(s.value,2),a=i[0],o=i[1];n[a]=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}),u.payloadify=function(e){return e?r(s(s({},o.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 $e.payloadify(e)})),last_message:ye(e.lastMessage),inviter:e.inviter?a.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},u.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===Ur.ALL||this.myCountPreference===Ur.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=se.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===Ur.ALL||this.myCountPreference===Ur.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},u.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},u.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},u.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},u.prototype.isReadMessage=function(e){var t=se.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},u.prototype.serialize=function(){var e=this;return q(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},u.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Wn(this._iid,s({channel:this},e))},u.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new rr(this._iid,this.url,e)},u.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===Je.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)}},u.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},u.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof m&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=se.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=f(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Je.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&s.push(i))})),s},u.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=se.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=[];return this.members.forEach((function(i){(t||i.userId!==r.userId&&i.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(i.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},u.prototype.refresh=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return e=se.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new qt({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(Bt).channel,n.dispatch(new Ot({channels:[i],source:St.REQUEST_CHANNEL})),[2,i]}}))}))},u.prototype.freeze=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,o.prototype.freeze.call(this)];case 1:return e.sent(),se.of(this._iid).dispatcher.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},u.prototype.unfreeze=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,o.prototype.unfreeze.call(this)];case 1:return e.sent(),se.of(this._iid).dispatcher.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},u.prototype.updateChannel=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,a,o;return d(this,(function(u){switch(u.label){case 0:return ee(e instanceof Zn&&e.validate()).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new ar(s({channelUrl:this.url},e)),[4,r.send(i)];case 1:return a=u.sent(),o=a.as(or).channel,n.dispatch(new Ot({channels:[o],source:St.EVENT_CHANNEL_UPDATED})),[2,o]}}))}))},u.prototype.invite=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){return ee(e.every((function(e){return e instanceof a}))).throw(S.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},u.prototype.inviteWithUserIds=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a;return d(this,(function(o){switch(o.label){case 0:return ee(M("string",e)).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new nn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(rn).channel,n.dispatch(new Ot({channels:[a],source:St.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},u.prototype.join=function(e){return void 0===e&&(e=null),h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return ee(T("string",e)||null===e).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Xt({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Zt).channel).myMemberState=Je.JOINED,n.dispatch(new Ot({channels:[o],source:St.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},u.prototype.leave=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new en({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},u.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return ee(T("string",e)||null===e).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new sr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(ir).channel).myMemberState=Je.JOINED,n.dispatch(new Ot({channels:[o],source:St.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,o]}}))}))},u.prototype.declineInvitation=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new an({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),(i=s.as(on).channel).myMemberState=Je.NONE,[2,i]}}))}))},u.prototype.sendUserMessage=function(e){var t=this,n=new Ne,r=se.of(this._iid).dispatcher;return o.prototype.sendUserMessage.call(this,e).onPending((function(e){Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){r&&Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r);n._trigger(e,r)})).onSucceeded((function(e){var s=Mn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Ot({channels:[t],source:St.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendUserMessage=function(e){var t=this,n=new Ne,r=se.of(this._iid).dispatcher;return o.prototype._autoResendUserMessage.call(this,e).onPending((function(e){Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r),n._trigger(e,r)})).onSucceeded((function(e){var s=Mn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Ot({channels:[t],source:St.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.sendFileMessage=function(e){var t=this,n=new Ne,r=se.of(this._iid).dispatcher;return o.prototype.sendFileMessage.call(this,e).onPending((function(e){Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){r&&Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r);n._trigger(e,r)})).onSucceeded((function(e){var s=Mn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Ot({channels:[t],source:St.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendFileMessage=function(e){var t=this,n=new Ne,r=se.of(this._iid).dispatcher;return o.prototype._autoResendFileMessage.call(this,e).onPending((function(e){Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){Mn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r),n._trigger(e,r)})).onSucceeded((function(e){var s=Mn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Ot({channels:[t],source:St.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.deleteMessage=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,o.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&se.of(this._iid).dispatcher.dispatch(new L({reqId:e.reqId,source:Y.EVENT_MESSAGE_DELETED})),[2]}}))}))},u.prototype.hide=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return d(this,(function(c){switch(c.label){case 0:return ee(e instanceof er&&e.validate()).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.sdkState,i=t.requestQueue,a=new _n(s({channelUrl:this.url,userId:r.userId},e)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(pn).messageOffsetTimestamp,this.hiddenState=e.allowAutoUnhide?Lr.HIDDEN_ALLOW_AUTO_UNHIDE:Lr.HIDDEN_PREVENT_AUTO_UNHIDE,e.hidePreviousMessages&&this._updateUnreadCount(0,0),u&&(this.messageOffsetTimestamp=u),n.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},u.prototype.unhide=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return e=se.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new cr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=Lr.UNHIDDEN,t.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},u.prototype.delete=function(){return h(this,void 0,void 0,(function(){var e,t;return d(this,(function(n){switch(n.label){case 0:return e=se.of(this._iid).requestQueue,t=new ur({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.markAsRead=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return d(this,(function(u){switch(u.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new cn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(ln).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Mn.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_READ})),[2]}}))}))},u.prototype.markAsDelivered=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new hn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},u.prototype.startTyping=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){return e=se.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new vn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},u.prototype.endTyping=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){return e=se.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new En({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},u.prototype.createScheduledUserMessage=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return d(this,(function(i){switch(i.label){case 0:return ee(e instanceof gr&&e.validate()).throw(S.invalidParameters),t=se.of(this._iid).requestQueue,n=new Er(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e)),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(yr).message]}}))}))},u.prototype.updateScheduledUserMessage=function(e,t){return h(this,void 0,void 0,(function(){var n,r,i;return d(this,(function(a){switch(a.label){case 0:return ee(t instanceof Sr&&t.validate()).throw(S.invalidParameters),n=se.of(this._iid).requestQueue,r=new Ir(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t)),[4,n.send(r)];case 1:return i=a.sent(),[2,i.as(yr).message]}}))}))},u.prototype.createScheduledFileMessage=function(e){return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return ee(e instanceof Nr&&e.validate()).throw(S.invalidParameters),I(e.file)?[4,this._uploadFileAndUpdateParams(e)]:[3,2];case 1:r.sent(),r.label=2;case 2:return t=new Cr(s(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e._requireAuth})),[4,se.of(this._iid).requestQueue.send(t)];case 3:return n=r.sent(),[2,n.as(br).message]}}))}))},u.prototype.updateScheduledFileMessage=function(e,t){return h(this,void 0,void 0,(function(){var n,r;return d(this,(function(i){switch(i.label){case 0:return ee(t instanceof Ar&&t.validate()).throw(S.invalidParameters),I(t.file)?[4,this._uploadFileAndUpdateParams(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return n=new Mr(s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t),{fileUrl:t.fileUrl,requireAuth:t._requireAuth})),[4,se.of(this._iid).requestQueue.send(n)];case 3:return r=i.sent(),[2,r.as(Tr).message]}}))}))},u.prototype.cancelScheduledFileMessage=function(e){return h(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return t=new Rr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,se.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.sendScheduledMessageNow=function(e){return h(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return t=new Or({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,se.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.getMyPushTriggerOption=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){switch(i.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new lr({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(hr).pushTriggerOption]}}))}))},u.prototype.setMyPushTriggerOption=function(e){return h(this,void 0,void 0,(function(){var n,r,s,i,a;return d(this,(function(o){switch(o.label){case 0:return ee(t(je,e)).throw(S.invalidParameters),n=se.of(this._iid),r=n.sdkState,s=n.requestQueue,i=new dr({userId:r.userId,pushTriggerOption:e}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(fr).pushTriggerOption]}}))}))},u.prototype.setMyCountPreference=function(e){return h(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return d(this,(function(c){switch(c.label){case 0:return ee(t(Ur,e)).throw(S.invalidParameters),n=se.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new _r({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(pr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_CREATED})),[2,u]}}))}))},u.prototype.resetMyHistory=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return e=se.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new mr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(vr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new Ot({channels:[this],source:St.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},u.prototype._uploadFileAndUpdateParams=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return d(this,(function(d){switch(d.label){case 0:return I(e.file)?(t=se.of(this._iid).requestQueue,n=new be({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(Ce),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=c,e._requireAuth=h,d.label=2;case 2:return[2]}}))}))},u}(Ke);export{$e as $,tt as A,Pr as B,Xe as C,xt as D,Ot as E,Ze as F,We as G,Cn as H,Dt as I,It as J,Ur as K,Ut as L,lt as M,ft as N,Tt as O,Qe as P,Lt as Q,er as R,rt as S,bn as T,Dr as U,$n as V,ut as W,Zn as X,Xn as Y,it as Z,Lr as _,_t as a,Yn as a0,rr as a1,Je as a2,nt as a3,Wn as a4,Jn as a5,Dn as a6,Pn as a7,gt as a8,wr as a9,at as aa,ot as ab,et as ac,st as ad,pt as b,mt as c,yt as d,Ct as e,bt as f,ct as g,Ht as h,Et as i,Mt as j,ze as k,hr as l,lr as m,fr as n,je as o,dr as p,Ye as q,Rn as r,Mn as s,St as t,wt as u,Bn as v,Rt as w,ht as x,dt as y,On as z}; diff --git a/__bundle-96ae73c1.js b/__bundle-2ae23ac6.js similarity index 89% rename from __bundle-96ae73c1.js rename to __bundle-2ae23ac6.js index 48b6282..c1a815f 100644 --- a/__bundle-96ae73c1.js +++ b/__bundle-2ae23ac6.js @@ -1 +1 @@ -import{n as e}from"./__bundle-368767fc.js";var n=function(){this.onUserMuted=e,this.onUserUnmuted=e,this.onUserBanned=e,this.onUserUnbanned=e,this.onChannelChanged=e,this.onChannelDeleted=e,this.onChannelFrozen=e,this.onChannelUnfrozen=e,this.onOperatorUpdated=e,this.onChannelMemberCountChanged=e,this.onMetaDataCreated=e,this.onMetaDataUpdated=e,this.onMetaDataDeleted=e,this.onMetaCounterCreated=e,this.onMetaCounterUpdated=e,this.onMetaCounterDeleted=e,this.onMessageReceived=e,this.onMessageUpdated=e,this.onMessageDeleted=e,this.onMentionReceived=e,this.onReactionUpdated=e,this.onThreadInfoUpdated=e};export{n as B}; +import{n as e}from"./__bundle-45e61fc8.js";var n=function(){this.onUserMuted=e,this.onUserUnmuted=e,this.onUserBanned=e,this.onUserUnbanned=e,this.onChannelChanged=e,this.onChannelDeleted=e,this.onChannelFrozen=e,this.onChannelUnfrozen=e,this.onOperatorUpdated=e,this.onChannelMemberCountChanged=e,this.onMetaDataCreated=e,this.onMetaDataUpdated=e,this.onMetaDataDeleted=e,this.onMetaCounterCreated=e,this.onMetaCounterUpdated=e,this.onMetaCounterDeleted=e,this.onMessageReceived=e,this.onMessageUpdated=e,this.onMessageDeleted=e,this.onMentionReceived=e,this.onReactionUpdated=e,this.onThreadInfoUpdated=e};export{n as B}; diff --git a/__bundle-368767fc.js b/__bundle-368767fc.js deleted file mode 100644 index 4001939..0000000 --- a/__bundle-368767fc.js +++ /dev/null @@ -1,15 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -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!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[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,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&_.indexOf(e)>=0},T=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=y("object",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=o([],a(e),!1).sort(),r=o([],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){y("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),b={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},N={encrypt:function(e){return e},decrypt:function(e){return e}},O=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,a=void 0===s||s;this.nestdb=null,this.store=i,this.encryption=null!=n?n:N,this.localCacheEnabled=a},A=function(){function e(){this.sessionKey=null,this.authToken=null}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=null,this.sessionKey=null},e}(),C=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=C()}return e.prototype._register=function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].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(){for(var e in this._container)this._container[e].delete(this.key)},e}(),R=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 a=[];try{for(var o=s(i.keys()),u=o.next();!u.done;u=o.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&a.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.forEach((function(e){return i.delete(e)}))}},e}(),D=function(){function e(){this._dispatcher=new R}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}(),M=function(){},k=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(h||(h={}));var L,U=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=C(),t}return t(n,e),n.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(e):""},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=k(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(e.stringifyParams(t[n])))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=k(this.params);if(Object.keys(t).some((function(e){return T(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i;if(t[r]instanceof Blob){var s=t[r];n.append(r,s,null!==(i=s.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(t[r]))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(M),P=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}(M),q=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(M),F=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(M),x=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof F&&a.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",n=e.sb_uikit?"u".concat(e.sb_uikit):"";return"JS/c".concat(l.SDK_VERSION,"/").concat(t,"/").concat(n)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,s=r.appVersion,a=n(n({},e.headers),{SendBird:"JS,".concat(l.OS_VERSION,",").concat(l.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});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.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,d,f,_,g,y;return i(this,(function(i){switch(i.label){case 0:t=e.path,n=e.method,r=![h.GET,h.DELETE].includes(n),s=this._sdkState.api,a="".concat(s.host).concat(t).concat(r?"":e.query),o=r?e.payload:null,u=this._createHeader(e,o instanceof FormData?o:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch(a,{method:n,body:o,headers:u,signal:l})];case 2:return[4,(d=i.sent()).json()];case 3:if(f=i.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),[2,new P(this._iid,f)];throw f?((_=new p(f)).isSessionKeyExpiredError&&this._dispatcher.dispatch(new q),_):p.requestFailed;case 4:throw(g=i.sent())instanceof p?(this._logger.debug("fail api request",g),g):"AbortError"===g.name?p.requestCanceled:(y=p.networkError,this._logger.debug("fail api request",y),y);case 5: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}(),G=function(e){function n(t,n,r,i){void 0===i&&(i="");var s,a=this;return(a=e.call(this)||this)._iid=t,a.code=n,a.payload=r,a.requestId=r?null!==(s=r.req_id)&&void 0!==s?s:i:"",a}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i=null;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}(M),j=function(e){function n(t){var n,r=t.code,i=t.ackRequired,s=t.payload,a=void 0===s?null:s,o=this;return(o=e.call(this)||this).code=r,o.payload=a,o.requestId=null!==(n=o.payload.req_id)&&void 0!==n?n:C(),o.ackRequired=i,o.payload.req_id=o.requestId,o}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(M),Q=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(j),z=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;this._pingTimer=null,this._pingTimeoutTimer=null,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,n=new Q;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(null)}),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=null),this.pingDelegate.error(null)}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)},e.prototype.refreshTimer=function(){var e,t=this;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=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)},e}(),K=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(L||(L={}));var V,B=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,a=e.call(this)||this;return a._pinger=null,a.lastActive=0,a._iid=t,a._sdkState=r,a._dispatcher=i,a._logger=s,a._sdkState.websocket.pingerDisabled||(a._pinger=new z({pingDelegate:{send:function(e){return a.send(e)},error:function(e){return a.error(e)}},sdkState:a._sdkState,logger:s})),a}return t(n,e),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return L.CONNECTING;case 1:return L.OPEN}return L.CLOSED},enumerable:!1,configurable:!0}),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){e.data.split("\n").forEach((function(e){if(e&&y("string",e)){var n=G.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.pong():"EXPR"===n.code?n.payload&&n.payload.expires_in>0&&t._dispatcher.dispatch(new q):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t._pinger&&t._pinger.stop(),t.dispatch("error",p.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=K,this._ws.onmessage=K,this._ws.onerror=K,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},n.prototype.send=function(e){if(!this._ws)throw p.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},n}(R),H=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return t(n,e),n}(M),W=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},X=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new x(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new B(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new H(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 p({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(p.connectionClosed)})),a._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var t,n,r,s=this;return i(this,(function(i){if(t=new W,e.ackRequired){n=null,r=function(r,i){void 0===r&&(r=null),void 0===i&&(i=null),s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(s._logger.debug("fail websocket request",r),t.reject(r)):(s._logger.debug("receive websocket ack",e.requestId),t.resolve(i)))};try{n=setTimeout((function(){return r(p.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof U?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof j?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw p.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.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(V||(V={}));var Y,J,Z,$,ee,te,ne,re,ie,se=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(M),ae=function(){function e(e,t){var n=t.auth,s=t.sdkState,a=t.dispatcher,o=t.logger,u=this;this._currentConnectionStateType=V.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new X(e,{auth:n,sdkState:s,dispatcher:a,logger:o}),this._auth=n,this._logger=o,this._dispatcher=a,this._dispatcher.on((function(e){if(e instanceof se){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case V.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n,r,s,a;return i(this,(function(i){switch(i.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(t)];case 2:return s=i.sent(),n.resolve(s),[3,4];case 3:return a=i.sent(),n.reject(a),[3,4];case 4:return[2]}}))}))}));break;case V.INITIALIZED:case V.DISCONNECTED:case V.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(p.connectionClosed):t.reject(p.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===V.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===V.CONNECTING||this._currentConnectionStateType===V.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return e instanceof j?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 W,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"),p.connectionRequired;case 3:return[3,7];case 4:return e instanceof U?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,7];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new W,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=p.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._logger.debug("send websocket request (forced)",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},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(p.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}(),oe=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,a=e.call(this)||this;return a.path="/users/".concat(n,"/session_key"),a.method=h.POST,a.params={token:r,expiring_session:!!s},a.requireAuth=!1,a}return t(n,e),n}(U),ue=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return t(n,e),n}(j),ce=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}(P),le=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new p(r.error):null,i}return t(n,e),n}(G),he=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(M),de=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},pe=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),fe=function(e,t,n){return void 0===n&&(n=new pe),r(void 0,void 0,void 0,(function(){var r,s,a,o,u,c;return i(this,(function(i){switch(i.label){case 0:r=0,s=null,a=function(e){return void 0===e&&(e=null),s=null!=e?e:new Error("Halted")},o=function(){r=0},i.label=1;case 1:if(!(-1===t||r0?Math.min(n*Math.pow(i,e-1),r):10}},t.appInfo=this.appInfo,t.sessionManager.currentUser=this.user;var n=this.reconnectInterval,r=this.reconnectMaxInterval,i=this.reconnectIntervalMultiple;t.connectedAt=this.connectedAt,t.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,t.concurrentCallLimit=this.concurrentCallLimit,t.backOffDelay=this.backOffDelay},r}(G),it=function(e){function n(t,n){var r=n.sdkState,i=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,o=n.dispatcher,u=n.logger,c=n.entryState,l=void 0===c?new be:c,h=e.call(this)||this;return h._currentState=null,h._loginTimer=null,h._connectionRequestQueue=[],h._iid=t,h.sdkState=r,h.connectionHandlers=i,h._sessionManager=s,h._websocketClient=a,h._dispatcher=o,h._logger=u,h._currentState=l,h._websocketClient.on("message",(function(e){if("LOGI"===e.code){h._loginTimer&&(clearTimeout(h._loginTimer),h._loginTimer=null);var t=e.as(rt);t.error?(t.error.isSessionKeyExpiredError&&h._dispatcher.dispatch(new q),h._connectionRequestQueue.forEach((function(e){return e.reject(t.error)}))):(t.applyTo(h._iid),h._connectionRequestQueue.forEach((function(e){return e.resolve()}))),h._connectionRequestQueue=[]}})).on("close",(function(){h._connectionRequestQueue.forEach((function(e){return e.reject(p.networkError)})),h._connectionRequestQueue=[]})),h}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new se({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},n.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=this._sessionManager.auth;return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(l.OS_VERSION),"&sv=").concat(encodeURIComponent(l.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(s.hasSession?"&key=".concat(encodeURIComponent(s.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat("FIXME","&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=1")},n.prototype.connect=function(e){return void 0===e&&(e=""),r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){return t=this._url(e),n=new W,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(rt.asError(p.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(rt.asError(p.connectionRenew))},n.prototype.disconnect=function(){this._websocketClient.disconnect()},n.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},n}(R),st=function(){function e(e,t){var n=t.sdkState,r=t.connectionHandlers,i=t.sessionManager,s=t.websocketClient,a=t.dispatcher,o=t.logger,u=t.disableAutoReconnect,c=void 0!==u&&u,l=this;this._context=null,this._logger=o,this._context=new it(e,{sdkState:n,connectionHandlers:r,sessionManager:i,websocketClient:s,dispatcher:a,logger:o}),c||s.on("close",(function(){"foreground"===n.appState&&(l._logger.debug("try reconnect by websocket connection closed"),l.reconnect())}))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===V.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===V.CONNECTING||e.type===V.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context)];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),r(this,void 0,void 0,(function(){return i(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.logout=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}();!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"}(tt||(tt={}));var at,ot=function(){function e(){this.level=tt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&y("number",c)&&(this.key=i,this.userIds=u,this.updatedAt=c);var l={};try{for(var h=s(this.userIds),d=h.next();!d.done;d=h.next()){l[d.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?k({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},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 at.ADD:t<0&&this.userIds.push(e.userId);break;case at.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),mt=function(){function e(e){this.key=e.key,this.value=E("string",e.value)?o([],a(e.value),!1):[]}return e.payloadify=function(e){var t;return e?k({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Et=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.hasOwnProperty("secure_url")&&(this.secureUrl=e.secure_url),e.hasOwnProperty("type")&&(this.type=e.type),e.hasOwnProperty("width")&&(this.width=e.width),e.hasOwnProperty("height")&&(this.height=e.height),e.hasOwnProperty("alt")&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return e?k({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}):null},e}(),vt=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e.hasOwnProperty("og:title")&&(this.title=e["og:title"]),e.hasOwnProperty("og:url")&&(this.url=e["og:url"]),e.hasOwnProperty("og:description")&&(this.description=e["og:description"]),e.hasOwnProperty("og:image")&&(this.defaultImage=new Et(e["og:image"]))}return e.payloadify=function(e){return e?k({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Et.payloadify(e.defaultImage):null}):null},e}(),Tt=function(){function e(e){var t,n;this.name=null,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.payloadify=function(e){return e?k({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ft||(ft={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(_t||(_t={}));var It,St=function(e){switch(e){case Z.BASE:return"";case Z.USER:return"MESG";case Z.FILE:return"FILE";case Z.ADMIN:return"ADMM"}},bt=function(e){function r(t,n){var r,i,s,a,o,u,c,l,h,d,p,f,_,g=this;(g=e.call(this,t)||this).channelUrl=null,g.channelType=Y.BASE,g.messageId=0,g.parentMessageId=null,g.silent=!1,g.isOperatorMessage=!1,g.messageType=Z.BASE,g.data=null,g.customType=null,g.mentionType=null,g.mentionedUsers=[],g.mentionedMessageTemplate=null,g.threadInfo=null,g.reactions=[],g.metaArrays=[],g.ogMetaData=null,g.appleCriticalAlertOptions=null,g.createdAt=0,g.updatedAt=0,g.scheduledInfo=null,g._scheduledStatus=null,g.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,g.channelUrl=n.channel_url,g.channelType=m(Y,n.channel_type)?n.channel_type:Y.GROUP,n.channel&&(n.channel.channel_url&&(g.channelUrl=n.channel.channel_url),n.channel.channel_type&&(g.channelType=n.channel.channel_type)),g.parentMessageId=null!==(s=n.parent_message_id)&&void 0!==s?s:0,g.data=null!==(a=n.data)&&void 0!==a?a:"",g.customType=null!==(o=n.custom_type)&&void 0!==o?o:"",g.mentionType=m(te,n.mention_type)?n.mention_type:null,g.mentionedUsers=n.mentioned_users?n.mentioned_users.map((function(e){return new nt(g._iid,e)})):[],g.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",g.threadInfo=n.thread_info?new pt(g._iid,n.thread_info):null,g.reactions=n.reactions?n.reactions.map((function(e){return new yt(e)})):[];for(var y=null!==(c=n.metaarray)&&void 0!==c?c:{},E=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(y).sort((function(e,t){return e.localeCompare(t)})),v=0;v0?ie.SUCCEEDED:ie.FAILED,n.request_state&&m(ie,n.request_state)&&(o.sendingStatus=n.request_state),n.scheduled_status)switch(n.scheduled_status){case _t.SENT:case _t.IN_QUEUE:o.sendingStatus=ie.SUCCEEDED;break;case _t.PENDING:o.sendingStatus=ie.SCHEDULED;break;case _t.FAILED:case _t.REMOVED:o.sendingStatus=ie.FAILED;break;case _t.CANCELED:o.sendingStatus=ie.CANCELED}return o.requestedMentionUserIds=null!==(s=n.requested_mention_user_ids)&&void 0!==s?s:[],o.errorCode=null!==(a=n.error_code)&&void 0!==a?a:0,o}return t(r,e),r.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{user:Nt.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,requested_mention_user_ids:t.requestedMentionUserIds,error_code:t.errorCode})):null},Object.defineProperty(r.prototype,"isResendable",{get:function(){return this.sendingStatus===ie.FAILED&&((e=this.errorCode)>0&&f.indexOf(e)>=0);var e},enumerable:!1,configurable:!0}),r.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},r}(bt),At=function(){function e(e){var t,n;this.url=null,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 e?k({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),Ct=function(){this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageTypeFilter=$.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.includeReactions=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1},wt=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("number",this.prevResultSize)&&y("number",this.nextResultSize)&&y("boolean",this.isInclusive)&&y("boolean",this.reverse)&&y("string",this.messageTypeFilter)&&m($,this.messageTypeFilter)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)},n}(Ct),Rt=function(e){function s(t,r){var i,s,a,o,u,c,l,h,d,p,f,_,g,y=this;(y=e.call(this,t,r)||this).messageParams=null,y.plainUrl="",y.requireAuth=!1,y.name=null,y.size=0,y.type=null,y.thumbnails=[],y.messageSurvivalSeconds=-1,y.messageType=Z.FILE;var m=null!==(i=r.file)&&void 0!==i?i:{};return y.plainUrl=(null!==(a=null!==(s=m.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],y.name=null!==(u=null!==(o=m.name)&&void 0!==o?o:r.name)&&void 0!==u?u:"File",y.size=null!==(l=null!==(c=m.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,y.data=null!==(d=null!==(h=m.data)&&void 0!==h?h:r.custom)&&void 0!==d?d:"",Object.keys(m).length>0?y.type=null!==(p=m.type)&&void 0!==p?p:"":y.type=null!==(f=r.type)&&void 0!==f?f:"",y.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,y.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new At(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(y.requireAuth?"?auth=".concat(Ae(y._iid)):"")}))})):[],y.messageSurvivalSeconds=null!==(g=r.message_survival_seconds)&&void 0!==g?g:-1,y}return t(s,e),s.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:t.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:t.messageSurvivalSeconds})):null},Object.defineProperty(s.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(Ae(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return et(this.messageId>0&&y("number",e)&&t instanceof wt&&t.validate()).throw(p.invalidParameters),[4,dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,n.sent()]}}))}))},s}(Ot),Dt=function(e){function n(t){var n,r,i;return e.call(this,{code:"FILE",ackRequired:!0,payload:k({channel_url:t.channelUrl,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i: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:t.mentionType===te.USERS?t.mentionedUserIds:[],push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==re.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,is_reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId})})||this}return t(n,e),n}(j),Mt=function(e){function n(t){var n=e.call(this)||this;return n.method=h.POST,n.path="".concat(je(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),n.params=k({message_type:Z.FILE,user_id:t.userId,url:t.file,mention_type:t.mentionType,mentioned_user_ids:t.mentionedUserIds,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return At.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:t.metaArrays.map((function(e){return mt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Tt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId}),n}return t(n,e),n}(U),kt=function(e){function n(t,n,r){var i,s=this;(s=e.call(this,t,"FILE",r)||this).message=new Rt(t,r);var a=ct.of(t).sdkState;return s.isMentioned=ze(s.message.mentionType,s.message.mentionedUsers.map((function(e){return e.userId})),a.userId),s.forceUpdateLastMessage=null!==(i=r.force_update_last_message)&&void 0!==i&&i,s}return t(n,e),n}(G),Lt=function(e){function n(t,n){var r,i=this;(i=e.call(this,t,n)||this).message=new Rt(t,n);var s=ct.of(t).sdkState;return i.isMentioned=ze(i.message.mentionType,i.message.mentionedUsers.map((function(e){return e.userId})),s.userId),i.forceUpdateLastMessage=null!==(r=n.force_update_last_message)&&void 0!==r&&r,i}return t(n,e),n}(P);!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"}(It||(It={}));var Ut,Pt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.cacheContext,a=this;this._queueMap=new Map,this._isConnected=!1,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=s,this._dispatcher=r,this._dispatcher.on((function(e){if(e instanceof se)if(e.stateType===V.CONNECTED)a._isConnected=!0;else a._isConnected=!1}))}return e.prototype._sendFileMessage=function(e,t){return r(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return this._isConnected?(r=new Dt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.file,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return s=i.sent(),[2,s.as(kt).message];case 2:if(this._cacheContext.localCacheEnabled)throw p.connectionClosed;return r=new Mt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.file,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(Lt).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,l,h,d,f,_,g;return i(this,(function(i){switch(i.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,i.label=1;case 1:i.trys.push([1,15,16,17]),a=s(t.messageQueue),o=a.next(),i.label=2;case 2:if(o.done)return[3,14];switch(c=o.value,c.state){case It.PENDING:case It.UPLOADING:return[3,3];case It.UPLOADED:return[3,4];case It.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(c),[3,13];case 4:if(!r)return[3,10];i.label=5;case 5:return i.trys.push([5,8,,9]),c.state=It.SENDING,[4,this._sendFileMessage(e,c)];case 6:return l=i.sent(),c.deferred.resolve(l),[4,de(100)];case 7:return i.sent(),[3,9];case 8:return h=i.sent(),c.deferred.reject(h),[3,9];case 9:return[3,11];case 10:n.push(c),i.label=11;case 11:return[3,13];case 12:return c.deferred.reject(c.error.code===u.REQUEST_CANCELED?p.fileUploadCanceled:c.error),[3,13];case 13:return o=a.next(),[3,2];case 14:return[3,17];case 15:return d=i.sent(),_={error:d},[3,17];case 16:try{o&&!o.done&&(g=a.return)&&g.call(a)}finally{if(_)throw _.error}return[7];case 17:return f=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:i.sent(),i.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,i.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,h,d,p,f,_;return i(this,(function(i){switch(i.label){case 0:if(t=this._queueMap.get(e.url),!(n=t.messageQueue.find((function(e){return e.state===It.PENDING}))))return[3,9];if(!T(n.params.file))return[3,7];if(!(t.uploadQueue.length<6))return[3,6];n.state=It.UPLOADING,t.uploadQueue.push(n),i.label=1;case 1:return i.trys.push([1,3,4,6]),r=new ht({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 2:return s=i.sent(),a=s.as(dt),o=a.url,u=a.fileSize,c=void 0===u?n.params.fileSize:u,l=a.thumbnailSizes,h=void 0===l?n.params.thumbnailSizes:l,d=a.requireAuth,p=void 0!==d&&d,n.params.fileUrl=o,n.params.fileSize=c,n.params.thumbnailSizes=h,n.params._requireAuth=p,n.requireAuth=p,n.state=It.UPLOADED,[3,6];case 3:return f=i.sent(),n.state=It.FAILED,n.error=f,[3,6];case 4:return(_=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(_,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 5:return i.sent(),[7];case 6:return[3,9];case 7:return n.params.thumbnailSizes=[],n.state=It.UPLOADED,[4,this._resolveMessageQueue(e)];case 8:i.sent(),i.label=9;case 9:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,a,o;return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=new W,T(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(o=n.fileSize)&&void 0!==o?o:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:It.PENDING,deferred:r,requireAuth:n._requireAuth}),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var u=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:o([],a(i.messageQueue),!1);try{for(var c=s(u),l=c.next();!l.done;l=c.next()){var h=l.value;if(h)switch(h.state){case It.PENDING:h.state=It.FAILED,h.error=p.requestCanceled,this._resolveMessageQueue(e);break;case It.UPLOADING:this._requestQueue.cancel(h.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),qt=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&y("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?k({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),Ft=function(e){function a(t,n){var r,i,a,o,u,c=this;if((c=e.call(this,t,n)||this).message="",c.messageParams=null,c.translations={},c.translationTargetLanguages=[],c.messageSurvivalSeconds=-1,c.plugins=[],c.message=n.message,c.messageType=Z.USER,c.translations=null!==(a=n.translations)&&void 0!==a?a:{},c.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],c.translations==={}&&c.translationTargetLanguages.length>0)try{for(var l=s(c.translationTargetLanguages),h=l.next();!h.done;h=l.next()){var d=h.value;c.translations[d]=""}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return c.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,c.plugins=n.plugins?n.plugins.map((function(e){return new qt(e)})):[],c}return t(a,e),a.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,plugins:t.plugins.map((function(e){return qt.payloadify(e)}))})):null},a.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return et(this.messageId>0&&y("number",e)&&t instanceof wt&&t.validate()).throw(p.invalidParameters),[4,dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,n.sent()]}}))}))},a}(Ot),xt=function(e){function s(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).message=null,s.translations={},s.message=null!==(r=n.message)&&void 0!==r?r:"",s.messageType=Z.ADMIN,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s}return t(s,e),s.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations})):null},s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return et(this.messageId>0&&y("number",e)&&t instanceof wt&&t.validate()).throw(p.invalidParameters),[4,dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,n.sent()]}}))}))},s}(bt);!function(e){e.UNKNOWN="UNKNOWN",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_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",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.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"}(Ut||(Ut={}));var Gt,jt=function(e){return e.startsWith("EVENT_")||e===Ut.SYNC_MESSAGE_FILL||e===Ut.SYNC_MESSAGE_CHANGELOGS},Qt=function(e){function n(t){var n=t.messages,r=t.source,i=e.call(this)||this;return i.messages=n,i.source=r,i}return t(n,e),n}(M),zt=function(e){function n(t){var n=t.messageIds,r=t.source,i=e.call(this)||this;return i.messageIds=n,i.source=r,i}return t(n,e),n}(M),Kt=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}(M),Vt=function(e){if(e)switch(e.messageType){case Z.USER:return Ft.payloadify(e);case Z.FILE:return Rt.payloadify(e);case Z.ADMIN:return xt.payloadify(e)}return null},Bt=function(e,t){switch(t.type){case"MESG":return new Ft(e,t);case"FILE":return new Rt(e,t);case"ADMM":case"BRDM":return new xt(e,t)}return null},Ht=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,a=t.includeReactions,o=t.includeThreadInfo,u=t.includeParentMessageInfo,c=t.includePollDetails,l=e.call(this)||this;return l.method=h.GET,l.path="".concat(je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),l.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:a,include_thread_info:o,include_parent_message_info:u,include_poll_details:c},l}return t(n,e),n}(U),Wt=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Bt(t,n({},r)):null,i}return t(r,e),r}(P),Xt=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,a=t.token,o=void 0===a?null:a,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,d=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,m=t.includeReactions,E=t.parentMessageId,v=t.includeThreadInfo,T=t.includeParentMessageInfo,I=t.showSubchannelMessagesOnly,S=t.includePollDetails,b=e.call(this)||this;return b.method=h.GET,b.path="".concat(je(n),"/").concat(encodeURIComponent(r),"/messages"),b.params=k({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:d,message_ts:s,message_id:o,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:g,with_sorted_meta_array:y,include_reactions:m,parent_message_id:E,include_thread_info:v,include_parent_message_info:T,show_subchannel_message_only:I,include_poll_details:S}),b}return t(n,e),n}(U),Yt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return Bt(t,e)})),r}return t(n,e),n}(P),Jt=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,a=t.replyType,o=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,d=t.includePollDetails,p=e.call(this)||this;return p.method=h.GET,p.path="".concat(je(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),p.params={change_ts:i,token:s,with_sorted_meta_array:o,include_reactions:u,include_thread_info:c,include_reply_type:a,include_parent_message_info:l,include_poll_details:d},p}return t(n,e),n}(U),Zt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Bt(t,e)})),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 t(n,e),n}(P),$t=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=h.GET,i.path="".concat(De,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(U),en=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Bt(t,n({},r)):null,i}return t(r,e),r}(P),tn=function(){this.data=null,this.customType=null,this.mentionType=te.USERS,this.mentionedUserIds=[],this.mentionedMessageTemplate=null,this.metaArrays=[],this.parentMessageId=0,this.isReplyToChannel=!1,this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this._mentionedUsers=[]},nn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"mentionedUsers",{get:function(){return this._mentionedUsers},set:function(e){this.mentionedUserIds=e.map((function(e){return e.userId})),this._mentionedUsers=e},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return y("string",this.data,!0)&&y("string",this.customType,!0)&&m(te,this.mentionType)&&E("string",this.mentionedUserIds)&&Array.isArray(this._mentionedUsers)&&this._mentionedUsers.every((function(e){return e instanceof nt}))&&(y("string",this.mentionedMessageTemplate)||null===this.mentionedMessageTemplate)&&Array.isArray(this.metaArrays)&&this.metaArrays.every((function(e){return e instanceof mt}))&&y("number",this.parentMessageId,!0)&&y("boolean",this.isReplyToChannel)&&(null===this.pushNotificationDeliveryOption||m(re,this.pushNotificationDeliveryOption))&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof Tt)},n}(tn),rn=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=null,t.translationTargetLanguages=null,t}return t(n,e),n}(tn),sn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n._fromFailedUserMessage=function(e){return new n(k({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUserIds:e.requestedMentionUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},n.prototype.serialize=function(){return{isReplyToChannel:this.isReplyToChannel,pushNotificationDeliveryOption:this.pushNotificationDeliveryOption}},n.prototype.validate=function(){return new nn(this).validate()&&y("string",this.message)&&E("string",this.translationTargetLanguages,!0)},n}(rn);!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Gt||(Gt={}));var an,on=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},un=function(e){return e===Gt.BLOB||e===Gt.FILE},cn=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.file=null,t.fileName=null,t.fileSize=null,t.mimeType=null,t.thumbnailSizes=null,t._fileType=null,t._requireAuth=!1,t}return t(n,e),n}(tn),ln=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"fileUrl",{get:function(){return y("string",this.file)?this.file:null},set:function(e){y("string",e)&&(this.file=e)},enumerable:!1,configurable:!0}),n.prototype._updateFileType=function(){var e,t;t=this.file,"undefined"!=typeof window&&"File"in window&&"undefined"!=typeof File&&t instanceof File?this._fileType=Gt.FILE:on(this.file)?this._fileType=Gt.BLOB:"object"==typeof(e=this.file)&&"string"==typeof e.name&&"string"==typeof e.uri&&"string"==typeof e.type?this._fileType=Gt.BLOB_LIKE_OBJECT:"string"==typeof this.file&&(this._fileType=Gt.URL)},n._fromFailedFileMessage=function(e,t){return new n({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUserIds:e.requestedMentionUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})},n.prototype.serialize=function(){return{isReplyToChannel:this.isReplyToChannel,pushNotificationDeliveryOption:this.pushNotificationDeliveryOption,file:this.file,_fileType:this._fileType}},n.prototype.validate=function(){return new nn(this).validate()&&(T(this.file)||y("string",this.fileUrl))&&(y("string",this.fileName)||null===this.fileName)&&(y("string",this.mimeType)||null===this.mimeType)&&(y("number",this.fileSize)||null===this.fileSize)&&(null===this.thumbnailSizes||this.thumbnailSizes.every((function(e){return y("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},n}(cn),hn={},dn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=s,this.fileMessageQueue=new Pt(e,{sdkState:n,dispatcher:r,requestQueue:i,cacheContext:s}),hn[e]=this}return e.of=function(e){return hn[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=$e(e);switch(t.messageType){case Z.USER:return new Ft(this._iid,Ft.payloadify(t));case Z.FILE:return new Rt(this._iid,Rt.payloadify(t));case Z.ADMIN:return new xt(this._iid,xt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return new sn(k({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.requestedMentionUserIds,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,_mentionedUsers:t.mentionedUsers,message:t.message,translationTargetLanguages:Object.keys(t.translations)}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return new ln(k({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.requestedMentionUserIds,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,_mentionedUsers:t.mentionedUsers,file:e.file,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_fileType:e._fileType,_requireAuth:t.requireAuth}))},e.prototype.buildSenderFromSerializedData=function(e){var t=$e(e);return new Nt(this._iid,Nt.payloadify(t))},e.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new Ht(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Wt).message]}}))}))},e.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new $t(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(en).message]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,s,a,o){return void 0===o&&(o=Ut.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new Xt(n({channelType:t,channelUrl:e,timestamp:s},a)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Yt).messages,this._dispatcher.dispatch(new Qt({messages:c,source:o})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,s,a){return void 0===a&&(a=Ut.REQUEST_THREADED_MESSAGE),r(this,void 0,void 0,(function(){var r,o,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new Xt(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},s),{replyType:ne.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(r)];case 1:return o=i.sent(),u=o.as(Yt).messages,c=u.slice(1),this._dispatcher.dispatch(new Qt({messages:c,source:a})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,s,a,o){return void 0===o&&(o=Ut.REQUEST_MESSAGE_CHANGELOGS),r(this,void 0,void 0,(function(){var r,u,c,l,h,d,p,f;return i(this,(function(i){switch(i.label){case 0:return r=new Jt(k(n({channelType:t,channelUrl:e,timestamp:"number"==typeof s?s:null,token:"string"==typeof s?s:null},a))),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Zt),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,p=c.nextToken,f=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new Qt({messages:l,source:o})),f.length>0&&this._dispatcher.dispatch(new zt({messageIds:f,source:o})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:d,token:p}]}}))}))},e}(),pn=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case ie.PENDING:this._onPending(t);break;case ie.FAILED:case ie.CANCELED:this._onFailed(e,t.isResendable?t:null);break;case ie.SUCCEEDED:this._onSucceeded(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}(),fn=function(e){function n(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.root_message_id,a=n.channel_url,o=n.channel_type;return i&&y("object",i)&&y("number",s)&&y("string",a)&&y("string",o)&&(r.threadInfo=new pt(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return t(n,e),n}(Ce),_n=function(){this.channelUrl=null,this.channelType=null,this.messageId=0,this.includeReactions=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.includePollDetails=!1},gn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("string",this.channelUrl)&&y("string",this.channelType)&&m(Y,this.channelType)&&y("number",this.messageId)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.includePollDetails)},n}(_n),yn=function(){this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageTypeFilter=$.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=ne.NONE,this.includeReactions=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1},mn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("number",this.prevResultSize)&&y("number",this.nextResultSize)&&y("boolean",this.isInclusive)&&y("boolean",this.reverse)&&y("string",this.messageTypeFilter)&&m($,this.messageTypeFilter)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&m(ne,this.replyType)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n}(yn),En=function(){this.replyType=ne.NONE,this.includeReactions=!1,this.includeThreadInfo=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1,this.includePollDetails=!1},vn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return m(ne,this.replyType)&&y("boolean",this.includeReactions,!0)&&y("boolean",this.includeMetaArray,!0)&&y("boolean",this.includeParentMessageInfo,!0)&&y("boolean",this.includeThreadInfo,!0)&&y("boolean",this.includePollDetails,!0)},n}(En),Tn=function(){this.data=null,this.customType=null,this.mentionType=te.USERS,this.mentionedUserIds=[],this.mentionedMessageTemplate=null,this.metaArrays=[],this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null},In=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return(y("string",this.data)||null===this.data)&&(y("string",this.customType)||null===this.customType)&&m(te,this.mentionType)&&E("string",this.mentionedUserIds)&&(y("string",this.mentionedMessageTemplate)||null===this.mentionedMessageTemplate)&&this.metaArrays.every((function(e){return e instanceof mt}))&&(null===this.pushNotificationDeliveryOption||m(re,this.pushNotificationDeliveryOption))&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof Tt)},n}(Tn),Sn=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=null,t.translationTargetLanguages=null,t}return t(n,e),n}(Tn),bn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return new In(this).validate()&&y("string",this.message,!0)&&E("string",this.translationTargetLanguages,!0)},n}(Sn),Nn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Tn),On=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return new In(this).validate()},n}(Nn),An=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.year=null,t.month=null,t.day=null,t.hour=null,t.min=null,t.timezone=null,t}return t(n,e),n}(rn),Cn=function(e){function n(t){var n=e.call(this)||this;if(n._scheduledDateTimeString=null,t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"scheduledDateTimeString",{get:function(){var e;return null!==(e=this._scheduledDateTimeString)&&void 0!==e?e:"".concat(this.year.toString(),"-").concat(("0"+this.month.toString()).substr(-2),"-").concat(("0"+this.day.toString()).substr(-2)," ").concat(("0"+this.hour.toString()).substr(-2),":").concat(("0"+this.min.toString()).substr(-2))},set:function(e){e&&y("string",e)&&(this._scheduledDateTimeString=e)},enumerable:!1,configurable:!0}),n.prototype.setSchedule=function(e){var t,n,r;this.year=e.year,this.month=e.month,this.day=e.day,this.hour=null!==(t=e.hour)&&void 0!==t?t:null,this.min=null!==(n=e.min)&&void 0!==n?n:null,this.timezone=null!==(r=e.timezone)&&void 0!==r?r:null,this._scheduledDateTimeString=null},n.prototype.validate=function(){return new sn(this).validate()&&y("number",this.year)&&y("number",this.month)&&y("number",this.day)&&y("number",this.hour,!0)&&y("number",this.min,!0)&&y("string",this.timezone,!0)},n}(An),wn=function(){function e(e,t){var n;this._iid=null,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 y("number",this.limit)&&this.limit>0},e}(),Rn=function(e){function n(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,a=t.exactMatch,o=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,d=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=h.GET,_.path="".concat(Ue,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:a,channel_url:o,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:d,target_fields:p,after:f},_}return t(n,e),n}(U),Dn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Bt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r}return t(n,e),n}(P);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(an||(an={}));var Mn=function(e){function s(t,n){var r,i,s,a,o,u,c,l,h,d=this;return(d=e.call(this,t,n)||this).keyword="",d.reverse=!1,d.exactMatch=!1,d.channelUrl="",d.channelCustomType="",d.messageTimestampFrom=null,d.messageTimestampTo=null,d.order=an.SCORE,d.advancedQuery=!1,d.targetFields=null,d._nextToken="",d.keyword=n.keyword,d.reverse=null!==(r=n.reverse)&&void 0!==r&&r,d.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,d.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",d.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:"",d.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,d.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,d.order=null!==(c=n.order)&&void 0!==c?c:an.SCORE,d.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,d.targetFields=null!==(h=n.targetFields)&&void 0!==h?h:null,d}return t(s,e),s.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.keyword)&&this.keyword.length>0&&y("boolean",this.reverse)&&y("boolean",this.exactMatch)&&y("string",this.channelUrl)&&y("string",this.channelCustomType)&&(y("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(y("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(an,this.order)&&y("boolean",this.advancedQuery)&&E("string",this.targetFields,!0)},s.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,r,s,a,o,u;return i(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=ct.of(this._iid).requestQueue,t=new Rn(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=i.sent(),s=r.as(Dn),a=s.messages,o=s.hasNext,u=s.nextToken,this._nextToken=u,this._hasNext=o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},s}(wn),kn=function(e){function n(t,n,r,i){var s=e.call(this,t,i)||this;return s.channelUrl=n,s.channelType=r,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.channelUrl)&&m(Y,this.channelType)},n}(wn),Ln=function(e){function n(t,n,r,i){var s,a,o,u,c,l,h,d,p,f,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=$.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ne.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(s=i.reverse)&&void 0!==s&&s,_.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:$.ALL,_.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,_.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,_.replyType=null!==(c=i.replyType)&&void 0!==c?c:ne.NONE,_.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,_.includeReactions=null!==(h=i.includeReactions)&&void 0!==h&&h,_.includeParentMessageInfo=null!==(d=i.includeParentMessageInfo)&&void 0!==d&&d,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(f=i.showSubchannelMessagesOnly)&&void 0!==f&&f,_}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("boolean",this.reverse)&&m($,this.messageTypeFilter)&&m(ne,this.replyType)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,dn.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{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,o([Number.MAX_SAFE_INTEGER],a(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 p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},n}(kn),Un=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("string",this.channelUrl)&&y("number",this.scheduledMessageId)},n}((function(){this.channelUrl=null,this.scheduledMessageId=0})),Pn=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(n,e),n.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,cacheContext:u}),this._manager=new dn(t,{sdkState:r,dispatcher:i,requestQueue:a,cacheContext:u})},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 r(this,void 0,void 0,(function(){return i(this,(function(t){return et(e instanceof gn&&e.validate()).throw(p.invalidParameters),[2,this._manager.getMessage(e)]}))}))},n.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return et(e instanceof Un&&e.validate()).throw(p.invalidParameters),[2,this._manager.getScheduledMessage(e)]}))}))},n}(lt);export{Rt as $,h as A,wn as B,L as C,N as D,R as E,_e as F,H as G,S as H,Ce as I,C as J,Pn as K,Y as L,$ as M,tt as N,Je as O,qt as P,I as Q,J as R,p as S,Z as T,nt as U,ct as V,G as W,Ot as X,ne as Y,Ft as Z,t as _,y as a,cn as a$,dn as a0,ln as a1,sn as a2,on as a3,un as a4,M as a5,ge as a6,Kt as a7,zt as a8,Qt as a9,bn as aA,Sn as aB,Vt as aC,pn as aD,dt as aE,ht as aF,te as aG,re as aH,ze as aI,xt as aJ,Ke as aK,gt as aL,fn as aM,Qe as aN,g as aO,Ln as aP,Nt as aQ,Be as aR,Ve as aS,mn as aT,vn as aU,W as aV,On as aW,bt as aX,lt as aY,Le as aZ,ke as a_,Me as aa,De as ab,j as ac,Ze as ad,se as ae,V as af,v as ag,ie as ah,Ut as ai,u as aj,d as ak,kt as al,de as am,je as an,Bt as ao,jt as ap,fe as aq,kn as ar,rn as as,ee as at,mt as au,Tt as av,nn as aw,tn as ax,At as ay,Tn as az,E as b,Nn as b0,En as b1,yn as b2,gn as b3,_n as b4,an as b5,Et as b6,vt as b7,yt as b8,at as b9,Cn as ba,An as bb,pt as bc,wt as bd,Ct as be,m as c,r as d,i as e,we as f,k as g,U as h,T as i,n as j,P as k,Fe as l,qe as m,K as n,a as o,s as p,o as q,b as r,ft as s,xe as t,_t as u,c as v,Ae as w,et as x,Mn as y,$e as z}; diff --git a/__bundle-45e61fc8.js b/__bundle-45e61fc8.js new file mode 100644 index 0000000..51f1722 --- /dev/null +++ b/__bundle-45e61fc8.js @@ -0,0 +1,15 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +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!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[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,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&_.indexOf(e)>=0},T=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=y("object",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=o([],a(e),!1).sort(),r=o([],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){y("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),b={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},N={encrypt:function(e){return e},decrypt:function(e){return e}},O=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,a=void 0===s||s;this.nestdb=null,this.store=i,this.encryption=null!=n?n:N,this.localCacheEnabled=a},A=function(){function e(){this.sessionKey=null,this.authToken=null}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=null,this.sessionKey=null},e}(),C=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=C()}return e.prototype._register=function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].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(){for(var e in this._container)this._container[e].delete(this.key)},e}(),R=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 a=[];try{for(var o=s(i.keys()),u=o.next();!u.done;u=o.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&a.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.forEach((function(e){return i.delete(e)}))}},e}(),D=function(){function e(){this._dispatcher=new R}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}(),M=function(){},k=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(d||(d={}));var U,L=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=C(),t}return t(n,e),n.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(e):""},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=k(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(e.stringifyParams(t[n])))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=k(this.params);if(Object.keys(t).some((function(e){return T(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i;if(t[r]instanceof Blob){var s=t[r];n.append(r,s,null!==(i=s.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(t[r]))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(M),P=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}(M),q=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(M),F=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(M),x=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof F&&a.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",n=e.sb_uikit?"u".concat(e.sb_uikit):"";return"JS/c".concat(l.SDK_VERSION,"/").concat(t,"/").concat(n)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,s=r.appVersion,a=n(n({},e.headers),{SendBird:"JS,".concat(l.OS_VERSION,",").concat(l.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});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.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,h,f,_,g,y;return i(this,(function(i){switch(i.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),s=this._sdkState.api,a="".concat(s.host).concat(t).concat(r?"":e.query),o=r?e.payload:null,u=this._createHeader(e,o instanceof FormData?o:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch(a,{method:n,body:o,headers:u,signal:l})];case 2:return[4,(h=i.sent()).json()];case 3:if(f=i.sent(),h.ok||h.redirected)return this._logger.debug("receive api response",e.requestId),[2,new P(this._iid,f)];throw f?((_=new p(f)).isSessionKeyExpiredError&&this._dispatcher.dispatch(new q),_):p.requestFailed;case 4:throw(g=i.sent())instanceof p?(this._logger.debug("fail api request",g),g):"AbortError"===g.name?p.requestCanceled:(y=p.networkError,this._logger.debug("fail api request",y),y);case 5: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}(),G=function(e){function n(t,n,r,i){void 0===i&&(i="");var s,a=this;return(a=e.call(this)||this)._iid=t,a.code=n,a.payload=r,a.requestId=r?null!==(s=r.req_id)&&void 0!==s?s:i:"",a}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i=null;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}(M),Q=function(e){function n(t){var n,r=t.code,i=t.ackRequired,s=t.payload,a=void 0===s?null:s,o=this;return(o=e.call(this)||this).code=r,o.payload=a,o.requestId=null!==(n=o.payload.req_id)&&void 0!==n?n:C(),o.ackRequired=i,o.payload.req_id=o.requestId,o}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(M),j=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Q),z=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;this._pingTimer=null,this._pingTimeoutTimer=null,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,n=new j;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(null)}),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=null),this.pingDelegate.error(null)}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)},e.prototype.refreshTimer=function(){var e,t=this;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=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)},e}(),K=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(U||(U={}));var V,B=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,a=e.call(this)||this;return a._pinger=null,a.lastActive=0,a._iid=t,a._sdkState=r,a._dispatcher=i,a._logger=s,a._sdkState.websocket.pingerDisabled||(a._pinger=new z({pingDelegate:{send:function(e){return a.send(e)},error:function(e){return a.error(e)}},sdkState:a._sdkState,logger:s})),a}return t(n,e),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return U.CONNECTING;case 1:return U.OPEN}return U.CLOSED},enumerable:!1,configurable:!0}),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){e.data.split("\n").forEach((function(e){if(e&&y("string",e)){var n=G.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.pong():"EXPR"===n.code?n.payload&&n.payload.expires_in>0&&t._dispatcher.dispatch(new q):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t._pinger&&t._pinger.stop(),t.dispatch("error",p.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=K,this._ws.onmessage=K,this._ws.onerror=K,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},n.prototype.send=function(e){if(!this._ws)throw p.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},n}(R),H=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return t(n,e),n}(M),W=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},X=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new x(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new B(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new H(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 p({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(p.connectionClosed)})),a._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var t,n,r,s=this;return i(this,(function(i){if(t=new W,e.ackRequired){n=null,r=function(r,i){void 0===r&&(r=null),void 0===i&&(i=null),s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(s._logger.debug("fail websocket request",r),t.reject(r)):(s._logger.debug("receive websocket ack",e.requestId),t.resolve(i)))};try{n=setTimeout((function(){return r(p.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof L?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Q?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw p.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.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(V||(V={}));var Y,J,Z,$,ee,te,ne,re,ie,se=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(M),ae=function(){function e(e,t){var n=t.auth,s=t.sdkState,a=t.dispatcher,o=t.logger,u=this;this._currentConnectionStateType=V.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new X(e,{auth:n,sdkState:s,dispatcher:a,logger:o}),this._auth=n,this._logger=o,this._dispatcher=a,this._dispatcher.on((function(e){if(e instanceof se){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case V.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n,r,s,a;return i(this,(function(i){switch(i.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(t)];case 2:return s=i.sent(),n.resolve(s),[3,4];case 3:return a=i.sent(),n.reject(a),[3,4];case 4:return[2]}}))}))}));break;case V.INITIALIZED:case V.DISCONNECTED:case V.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(p.connectionClosed):t.reject(p.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===V.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===V.CONNECTING||this._currentConnectionStateType===V.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return e instanceof Q?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 W,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"),p.connectionRequired;case 3:return[3,7];case 4:return e instanceof L?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,7];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new W,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=p.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._logger.debug("send websocket request (forced)",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},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(p.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}(),oe=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,a=e.call(this)||this;return a.path="/users/".concat(n,"/session_key"),a.method=d.POST,a.params={token:r,expiring_session:!!s},a.requireAuth=!1,a}return t(n,e),n}(L),ue=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return t(n,e),n}(Q),ce=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}(P),le=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new p(r.error):null,i}return t(n,e),n}(G),de=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(M),he=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},pe=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),fe=function(e,t,n){return void 0===n&&(n=new pe),r(void 0,void 0,void 0,(function(){var r,s,a,o,u,c;return i(this,(function(i){switch(i.label){case 0:r=0,s=null,a=function(e){return void 0===e&&(e=null),s=null!=e?e:new Error("Halted")},o=function(){r=0},i.label=1;case 1:if(!(-1===t||r0?Math.min(n*Math.pow(i,e-1),r):10}},t.appInfo=this.appInfo,t.sessionManager.currentUser=this.user;var n=this.reconnectInterval,r=this.reconnectMaxInterval,i=this.reconnectIntervalMultiple;t.connectedAt=this.connectedAt,t.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,t.concurrentCallLimit=this.concurrentCallLimit,t.backOffDelay=this.backOffDelay},r}(G),it=function(e){function n(t,n){var r=n.sdkState,i=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,o=n.dispatcher,u=n.logger,c=n.entryState,l=void 0===c?new be:c,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.connectionHandlers=i,d._sessionManager=s,d._websocketClient=a,d._dispatcher=o,d._logger=u,d._currentState=l,d._websocketClient.on("message",(function(e){if("LOGI"===e.code){d._loginTimer&&(clearTimeout(d._loginTimer),d._loginTimer=null);var t=e.as(rt);t.error?(t.error.isSessionKeyExpiredError&&d._dispatcher.dispatch(new q),d._connectionRequestQueue.forEach((function(e){return e.reject(t.error)}))):(t.applyTo(d._iid),d._connectionRequestQueue.forEach((function(e){return e.resolve()}))),d._connectionRequestQueue=[]}})).on("close",(function(){d._connectionRequestQueue.forEach((function(e){return e.reject(p.networkError)})),d._connectionRequestQueue=[]})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new se({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},n.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=this._sessionManager.auth;return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(l.OS_VERSION),"&sv=").concat(encodeURIComponent(l.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(s.hasSession?"&key=".concat(encodeURIComponent(s.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat("FIXME","&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=1")},n.prototype.connect=function(e){return void 0===e&&(e=""),r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){return t=this._url(e),n=new W,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(rt.asError(p.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(rt.asError(p.connectionRenew))},n.prototype.disconnect=function(){this._websocketClient.disconnect()},n.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},n}(R),st=function(){function e(e,t){var n=t.sdkState,r=t.connectionHandlers,i=t.sessionManager,s=t.websocketClient,a=t.dispatcher,o=t.logger,u=t.disableAutoReconnect,c=void 0!==u&&u,l=this;this._context=null,this._logger=o,this._context=new it(e,{sdkState:n,connectionHandlers:r,sessionManager:i,websocketClient:s,dispatcher:a,logger:o}),c||s.on("close",(function(){"foreground"===n.appState&&(l._logger.debug("try reconnect by websocket connection closed"),l.reconnect())}))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===V.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===V.CONNECTING||e.type===V.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context)];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),r(this,void 0,void 0,(function(){return i(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.logout=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}();!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"}(tt||(tt={}));var at,ot=function(){function e(){this.level=tt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&y("number",c)&&(this.key=i,this.userIds=u,this.updatedAt=c);var l={};try{for(var d=s(this.userIds),h=d.next();!h.done;h=d.next()){l[h.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?k({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},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 at.ADD:t<0&&this.userIds.push(e.userId);break;case at.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),mt=function(){function e(e){this.key=e.key,this.value=E("string",e.value)?o([],a(e.value),!1):[]}return e.payloadify=function(e){var t;return e?k({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Et=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.hasOwnProperty("secure_url")&&(this.secureUrl=e.secure_url),e.hasOwnProperty("type")&&(this.type=e.type),e.hasOwnProperty("width")&&(this.width=e.width),e.hasOwnProperty("height")&&(this.height=e.height),e.hasOwnProperty("alt")&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return e?k({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}):null},e}(),vt=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e.hasOwnProperty("og:title")&&(this.title=e["og:title"]),e.hasOwnProperty("og:url")&&(this.url=e["og:url"]),e.hasOwnProperty("og:description")&&(this.description=e["og:description"]),e.hasOwnProperty("og:image")&&(this.defaultImage=new Et(e["og:image"]))}return e.payloadify=function(e){return e?k({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Et.payloadify(e.defaultImage):null}):null},e}(),Tt=function(){function e(e){var t,n;this.name=null,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.payloadify=function(e){return e?k({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ft||(ft={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(_t||(_t={}));var It,St=function(e){switch(e){case Z.BASE:return"";case Z.USER:return"MESG";case Z.FILE:return"FILE";case Z.ADMIN:return"ADMM"}},bt=function(e){function r(t,n){var r,i,s,a,o,u,c,l,d,h,p,f,_,g=this;(g=e.call(this,t)||this).channelUrl=null,g.channelType=Y.BASE,g.messageId=0,g.parentMessageId=null,g.silent=!1,g.isOperatorMessage=!1,g.messageType=Z.BASE,g.data=null,g.customType=null,g.mentionType=null,g.mentionedUsers=[],g.mentionedUserIds=[],g.mentionedMessageTemplate=null,g.threadInfo=null,g.reactions=[],g.metaArrays=[],g.ogMetaData=null,g.appleCriticalAlertOptions=null,g.createdAt=0,g.updatedAt=0,g.scheduledInfo=null,g._scheduledStatus=null,g.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,g.channelUrl=n.channel_url,g.channelType=m(Y,n.channel_type)?n.channel_type:Y.GROUP,n.channel&&(n.channel.channel_url&&(g.channelUrl=n.channel.channel_url),n.channel.channel_type&&(g.channelType=n.channel.channel_type)),g.parentMessageId=null!==(s=n.parent_message_id)&&void 0!==s?s:0,g.data=null!==(a=n.data)&&void 0!==a?a:"",g.customType=null!==(o=n.custom_type)&&void 0!==o?o:"",g.mentionType=m(te,n.mention_type)?n.mention_type:null;var y=n.mentioned_users;g.mentionedUsers=y?y.map((function(e){return new nt(g._iid,e)})):[];var E=n.mentioned_user_ids;g.mentionedUserIds=E&&E.length>0?E:g.mentionedUsers.map((function(e){return e.userId})),g.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",g.threadInfo=n.thread_info?new pt(g._iid,n.thread_info):null,g.reactions=n.reactions?n.reactions.map((function(e){return new yt(e)})):[];for(var v=null!==(c=n.metaarray)&&void 0!==c?c:{},T=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(v).sort((function(e,t){return e.localeCompare(t)})),I=0;I0?ie.SUCCEEDED:ie.FAILED,n.request_state&&m(ie,n.request_state)&&(a.sendingStatus=n.request_state),n.scheduled_status)switch(n.scheduled_status){case _t.SENT:case _t.IN_QUEUE:a.sendingStatus=ie.SUCCEEDED;break;case _t.PENDING:a.sendingStatus=ie.SCHEDULED;break;case _t.FAILED:case _t.REMOVED:a.sendingStatus=ie.FAILED;break;case _t.CANCELED:a.sendingStatus=ie.CANCELED}return a.errorCode=null!==(s=n.error_code)&&void 0!==s?s:0,a}return t(r,e),r.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{user:Nt.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode})):null},Object.defineProperty(r.prototype,"isResendable",{get:function(){return this.sendingStatus===ie.FAILED&&((e=this.errorCode)>0&&f.indexOf(e)>=0);var e},enumerable:!1,configurable:!0}),r.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},r}(bt),At=function(){function e(e){var t,n;this.url=null,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 e?k({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),Ct=function(){this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageTypeFilter=$.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.includeReactions=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1},wt=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("number",this.prevResultSize)&&y("number",this.nextResultSize)&&y("boolean",this.isInclusive)&&y("boolean",this.reverse)&&y("string",this.messageTypeFilter)&&m($,this.messageTypeFilter)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)},n}(Ct),Rt=function(e){function s(t,r){var i,s,a,o,u,c,l,d,h,p,f,_,g,y=this;(y=e.call(this,t,r)||this).messageParams=null,y.plainUrl="",y.requireAuth=!1,y.name=null,y.size=0,y.type=null,y.thumbnails=[],y.messageSurvivalSeconds=-1,y.messageType=Z.FILE;var m=null!==(i=r.file)&&void 0!==i?i:{};return y.plainUrl=(null!==(a=null!==(s=m.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],y.name=null!==(u=null!==(o=m.name)&&void 0!==o?o:r.name)&&void 0!==u?u:"File",y.size=null!==(l=null!==(c=m.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,y.data=null!==(h=null!==(d=m.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",Object.keys(m).length>0?y.type=null!==(p=m.type)&&void 0!==p?p:"":y.type=null!==(f=r.type)&&void 0!==f?f:"",y.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,y.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new At(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(y.requireAuth?"?auth=".concat(Ae(y._iid)):"")}))})):[],y.messageSurvivalSeconds=null!==(g=r.message_survival_seconds)&&void 0!==g?g:-1,y}return t(s,e),s.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:t.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:t.messageSurvivalSeconds})):null},Object.defineProperty(s.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(Ae(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return et(this.messageId>0&&y("number",e)&&t instanceof wt&&t.validate()).throw(p.invalidParameters),[4,hn.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,n.sent()]}}))}))},s}(Ot),Dt=function(e){function n(t){var n,r,i;return e.call(this,{code:"FILE",ackRequired:!0,payload:k({channel_url:t.channelUrl,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i: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:t.mentionType===te.USERS?t.mentionedUserIds:[],push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==re.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,is_reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId})})||this}return t(n,e),n}(Q),Mt=function(e){function n(t){var n=e.call(this)||this;return n.method=d.POST,n.path="".concat(Qe(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),n.params=k({message_type:Z.FILE,user_id:t.userId,url:t.file,mention_type:t.mentionType,mentioned_user_ids:t.mentionedUserIds,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return At.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:t.metaArrays.map((function(e){return mt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Tt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId}),n}return t(n,e),n}(L),kt=function(e){function n(t,n,r){var i,s=this;(s=e.call(this,t,"FILE",r)||this).message=new Rt(t,r);var a=ct.of(t).sdkState;return s.isMentioned=ze(s.message.mentionType,s.message.mentionedUsers.map((function(e){return e.userId})),a.userId),s.forceUpdateLastMessage=null!==(i=r.force_update_last_message)&&void 0!==i&&i,s}return t(n,e),n}(G),Ut=function(e){function n(t,n){var r,i=this;(i=e.call(this,t,n)||this).message=new Rt(t,n);var s=ct.of(t).sdkState;return i.isMentioned=ze(i.message.mentionType,i.message.mentionedUsers.map((function(e){return e.userId})),s.userId),i.forceUpdateLastMessage=null!==(r=n.force_update_last_message)&&void 0!==r&&r,i}return t(n,e),n}(P);!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"}(It||(It={}));var Lt,Pt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.cacheContext,a=this;this._queueMap=new Map,this._isConnected=!1,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=s,this._dispatcher=r,this._dispatcher.on((function(e){if(e instanceof se)if(e.stateType===V.CONNECTED)a._isConnected=!0;else a._isConnected=!1}))}return e.prototype._sendFileMessage=function(e,t){return r(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return this._isConnected?(r=new Dt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.file,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return s=i.sent(),[2,s.as(kt).message];case 2:if(this._cacheContext.localCacheEnabled)throw p.connectionClosed;return r=new Mt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.file,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(Ut).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,i.label=1;case 1:i.trys.push([1,15,16,17]),a=s(t.messageQueue),o=a.next(),i.label=2;case 2:if(o.done)return[3,14];switch(c=o.value,c.state){case It.PENDING:case It.UPLOADING:return[3,3];case It.UPLOADED:return[3,4];case It.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(c),[3,13];case 4:if(!r)return[3,10];i.label=5;case 5:return i.trys.push([5,8,,9]),c.state=It.SENDING,[4,this._sendFileMessage(e,c)];case 6:return l=i.sent(),c.deferred.resolve(l),[4,he(100)];case 7:return i.sent(),[3,9];case 8:return d=i.sent(),c.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(c),i.label=11;case 11:return[3,13];case 12:return c.deferred.reject(c.error.code===u.REQUEST_CANCELED?p.fileUploadCanceled:c.error),[3,13];case 13:return o=a.next(),[3,2];case 14:return[3,17];case 15:return h=i.sent(),_={error:h},[3,17];case 16:try{o&&!o.done&&(g=a.return)&&g.call(a)}finally{if(_)throw _.error}return[7];case 17:return f=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:i.sent(),i.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,i.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,d,h,p,f,_;return i(this,(function(i){switch(i.label){case 0:if(t=this._queueMap.get(e.url),!(n=t.messageQueue.find((function(e){return e.state===It.PENDING}))))return[3,9];if(!T(n.params.file))return[3,7];if(!(t.uploadQueue.length<6))return[3,6];n.state=It.UPLOADING,t.uploadQueue.push(n),i.label=1;case 1:return i.trys.push([1,3,4,6]),r=new dt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 2:return s=i.sent(),a=s.as(ht),o=a.url,u=a.fileSize,c=void 0===u?n.params.fileSize:u,l=a.thumbnailSizes,d=void 0===l?n.params.thumbnailSizes:l,h=a.requireAuth,p=void 0!==h&&h,n.params.fileUrl=o,n.params.fileSize=c,n.params.thumbnailSizes=d,n.params._requireAuth=p,n.requireAuth=p,n.state=It.UPLOADED,[3,6];case 3:return f=i.sent(),n.state=It.FAILED,n.error=f,[3,6];case 4:return(_=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(_,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 5:return i.sent(),[7];case 6:return[3,9];case 7:return n.params.thumbnailSizes=[],n.state=It.UPLOADED,[4,this._resolveMessageQueue(e)];case 8:i.sent(),i.label=9;case 9:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,a,o;return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=new W,T(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(o=n.fileSize)&&void 0!==o?o:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:It.PENDING,deferred:r,requireAuth:n._requireAuth}),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var u=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:o([],a(i.messageQueue),!1);try{for(var c=s(u),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case It.PENDING:d.state=It.FAILED,d.error=p.requestCanceled,this._resolveMessageQueue(e);break;case It.UPLOADING:this._requestQueue.cancel(d.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),qt=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&y("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?k({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),Ft=function(e){function a(t,n){var r,i,a,o,u,c=this;if((c=e.call(this,t,n)||this).message="",c.messageParams=null,c.translations={},c.translationTargetLanguages=[],c.messageSurvivalSeconds=-1,c.plugins=[],c.message=n.message,c.messageType=Z.USER,c.translations=null!==(a=n.translations)&&void 0!==a?a:{},c.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],c.translations==={}&&c.translationTargetLanguages.length>0)try{for(var l=s(c.translationTargetLanguages),d=l.next();!d.done;d=l.next()){var h=d.value;c.translations[h]=""}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return c.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,c.plugins=n.plugins?n.plugins.map((function(e){return new qt(e)})):[],c}return t(a,e),a.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,plugins:t.plugins.map((function(e){return qt.payloadify(e)}))})):null},a.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return et(this.messageId>0&&y("number",e)&&t instanceof wt&&t.validate()).throw(p.invalidParameters),[4,hn.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,n.sent()]}}))}))},a}(Ot),xt=function(e){function s(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).message=null,s.translations={},s.message=null!==(r=n.message)&&void 0!==r?r:"",s.messageType=Z.ADMIN,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s}return t(s,e),s.payloadify=function(t){return t?k(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations})):null},s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return et(this.messageId>0&&y("number",e)&&t instanceof wt&&t.validate()).throw(p.invalidParameters),[4,hn.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,n.sent()]}}))}))},s}(bt),Gt=function(){this.data=null,this.customType=null,this.mentionType=te.USERS,this.mentionedUserIds=[],this.mentionedMessageTemplate=null,this.metaArrays=[],this.parentMessageId=0,this.isReplyToChannel=!1,this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this._mentionedUsers=[]},Qt=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("string",this.data,!0)&&y("string",this.customType,!0)&&m(te,this.mentionType)&&E("string",this.mentionedUserIds)&&Array.isArray(this._mentionedUsers)&&this._mentionedUsers.every((function(e){return e instanceof nt}))&&(y("string",this.mentionedMessageTemplate)||null===this.mentionedMessageTemplate)&&Array.isArray(this.metaArrays)&&this.metaArrays.every((function(e){return e instanceof mt}))&&y("number",this.parentMessageId,!0)&&y("boolean",this.isReplyToChannel)&&(null===this.pushNotificationDeliveryOption||m(re,this.pushNotificationDeliveryOption))&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof Tt)},n}(Gt),jt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=null,t.translationTargetLanguages=null,t}return t(n,e),n}(Gt),zt=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"mentionedUsers",{get:function(){return this._mentionedUsers},set:function(e){this.mentionedUserIds=e.map((function(e){return e.userId})),this._mentionedUsers=e},enumerable:!1,configurable:!0}),n._fromFailedUserMessage=function(e){return new n(k({data:e.data,customType:e.customType,mentionType:e.mentionType,_mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds.length>0?e.mentionedUserIds:e.mentionedUsers.map((function(e){return e.userId})),mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},n.prototype.serialize=function(){return{isReplyToChannel:this.isReplyToChannel,pushNotificationDeliveryOption:this.pushNotificationDeliveryOption}},n.prototype.validate=function(){return new Qt(this).validate()&&y("string",this.message)&&E("string",this.translationTargetLanguages,!0)},n}(jt);!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Lt||(Lt={}));var Kt,Vt=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Bt=function(e){return e===Lt.BLOB||e===Lt.FILE},Ht=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.file=null,t.fileName=null,t.fileSize=null,t.mimeType=null,t.thumbnailSizes=null,t._fileType=null,t._requireAuth=!1,t}return t(n,e),n}(Gt),Wt=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"fileUrl",{get:function(){return y("string",this.file)?this.file:null},set:function(e){y("string",e)&&(this.file=e)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"mentionedUsers",{get:function(){return this._mentionedUsers},set:function(e){this.mentionedUserIds=e.map((function(e){return e.userId})),this._mentionedUsers=e},enumerable:!1,configurable:!0}),n.prototype._updateFileType=function(){var e,t;t=this.file,"undefined"!=typeof window&&"File"in window&&"undefined"!=typeof File&&t instanceof File?this._fileType=Lt.FILE:Vt(this.file)?this._fileType=Lt.BLOB:"object"==typeof(e=this.file)&&"string"==typeof e.name&&"string"==typeof e.uri&&"string"==typeof e.type?this._fileType=Lt.BLOB_LIKE_OBJECT:"string"==typeof this.file&&(this._fileType=Lt.URL)},n._fromFailedFileMessage=function(e,t){return new n(k({data:e.data,customType:e.customType,mentionType:e.mentionType,_mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds.length>0?e.mentionedUserIds:e.mentionedUsers.map((function(e){return e.userId})),metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},n.prototype.serialize=function(){return{isReplyToChannel:this.isReplyToChannel,pushNotificationDeliveryOption:this.pushNotificationDeliveryOption,file:this.file,_fileType:this._fileType}},n.prototype.validate=function(){return new Qt(this).validate()&&(T(this.file)||y("string",this.fileUrl))&&(y("string",this.fileName)||null===this.fileName)&&(y("string",this.mimeType)||null===this.mimeType)&&(y("number",this.fileSize)||null===this.fileSize)&&(null===this.thumbnailSizes||this.thumbnailSizes.every((function(e){return y("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},n}(Ht);!function(e){e.UNKNOWN="UNKNOWN",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_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",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.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"}(Kt||(Kt={}));var Xt,Yt=function(e){return e.startsWith("EVENT_")||e===Kt.SYNC_MESSAGE_FILL||e===Kt.SYNC_MESSAGE_CHANGELOGS},Jt=function(e){function n(t){var n=t.messages,r=t.source,i=e.call(this)||this;return i.messages=n,i.source=r,i}return t(n,e),n}(M),Zt=function(e){function n(t){var n=t.messageIds,r=t.source,i=e.call(this)||this;return i.messageIds=n,i.source=r,i}return t(n,e),n}(M),$t=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}(M),en=function(e){if(e)switch(e.messageType){case Z.USER:return Ft.payloadify(e);case Z.FILE:return Rt.payloadify(e);case Z.ADMIN:return xt.payloadify(e)}return null},tn=function(e,t){switch(t.type){case"MESG":return new Ft(e,t);case"FILE":return new Rt(e,t);case"ADMM":case"BRDM":return new xt(e,t)}return null},nn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,a=t.includeReactions,o=t.includeThreadInfo,u=t.includeParentMessageInfo,c=t.includePollDetails,l=e.call(this)||this;return l.method=d.GET,l.path="".concat(Qe(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),l.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:a,include_thread_info:o,include_parent_message_info:u,include_poll_details:c},l}return t(n,e),n}(L),rn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?tn(t,n({},r)):null,i}return t(r,e),r}(P),sn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,a=t.token,o=void 0===a?null:a,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,m=t.includeReactions,E=t.parentMessageId,v=t.includeThreadInfo,T=t.includeParentMessageInfo,I=t.showSubchannelMessagesOnly,S=t.includePollDetails,b=e.call(this)||this;return b.method=d.GET,b.path="".concat(Qe(n),"/").concat(encodeURIComponent(r),"/messages"),b.params=k({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,message_ts:s,message_id:o,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:g,with_sorted_meta_array:y,include_reactions:m,parent_message_id:E,include_thread_info:v,include_parent_message_info:T,show_subchannel_message_only:I,include_poll_details:S}),b}return t(n,e),n}(L),an=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return tn(t,e)})),r}return t(n,e),n}(P),on=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,a=t.replyType,o=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,h=t.includePollDetails,p=e.call(this)||this;return p.method=d.GET,p.path="".concat(Qe(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),p.params={change_ts:i,token:s,with_sorted_meta_array:o,include_reactions:u,include_thread_info:c,include_reply_type:a,include_parent_message_info:l,include_poll_details:h},p}return t(n,e),n}(L),un=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return tn(t,e)})),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 t(n,e),n}(P),cn=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(De,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(L),ln=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?tn(t,n({},r)):null,i}return t(r,e),r}(P),dn={},hn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=s,this.fileMessageQueue=new Pt(e,{sdkState:n,dispatcher:r,requestQueue:i,cacheContext:s}),dn[e]=this}return e.of=function(e){return dn[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=$e(e);switch(t.messageType){case Z.USER:return new Ft(this._iid,Ft.payloadify(t));case Z.FILE:return new Rt(this._iid,Rt.payloadify(t));case Z.ADMIN:return new xt(this._iid,xt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return new zt(k({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,_mentionedUsers:t.mentionedUsers,message:t.message,translationTargetLanguages:Object.keys(t.translations)}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return new Wt(k({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,_mentionedUsers:t.mentionedUsers,file:e.file,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_fileType:e._fileType,_requireAuth:t.requireAuth}))},e.prototype.buildSenderFromSerializedData=function(e){var t=$e(e);return new Nt(this._iid,Nt.payloadify(t))},e.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new nn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(rn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new cn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(ln).message]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,s,a,o){return void 0===o&&(o=Kt.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new sn(n({channelType:t,channelUrl:e,timestamp:s},a)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(an).messages,this._dispatcher.dispatch(new Jt({messages:c,source:o})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,s,a){return void 0===a&&(a=Kt.REQUEST_THREADED_MESSAGE),r(this,void 0,void 0,(function(){var r,o,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new sn(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},s),{replyType:ne.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(r)];case 1:return o=i.sent(),u=o.as(an).messages,c=u.slice(1),this._dispatcher.dispatch(new Jt({messages:c,source:a})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,s,a,o){return void 0===o&&(o=Kt.REQUEST_MESSAGE_CHANGELOGS),r(this,void 0,void 0,(function(){var r,u,c,l,d,h,p,f;return i(this,(function(i){switch(i.label){case 0:return r=new on(k(n({channelType:t,channelUrl:e,timestamp:"number"==typeof s?s:null,token:"string"==typeof s?s:null},a))),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(un),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,p=c.nextToken,f=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new Jt({messages:l,source:o})),f.length>0&&this._dispatcher.dispatch(new Zt({messageIds:f,source:o})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),pn=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case ie.PENDING:this._onPending(t);break;case ie.FAILED:case ie.CANCELED:this._onFailed(e,t.isResendable?t:null);break;case ie.SUCCEEDED:this._onSucceeded(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}(),fn=function(e){function n(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.root_message_id,a=n.channel_url,o=n.channel_type;return i&&y("object",i)&&y("number",s)&&y("string",a)&&y("string",o)&&(r.threadInfo=new pt(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return t(n,e),n}(Ce),_n=function(){this.channelUrl=null,this.channelType=null,this.messageId=0,this.includeReactions=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.includePollDetails=!1},gn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("string",this.channelUrl)&&y("string",this.channelType)&&m(Y,this.channelType)&&y("number",this.messageId)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.includePollDetails)},n}(_n),yn=function(){this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageTypeFilter=$.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=ne.NONE,this.includeReactions=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1},mn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("number",this.prevResultSize)&&y("number",this.nextResultSize)&&y("boolean",this.isInclusive)&&y("boolean",this.reverse)&&y("string",this.messageTypeFilter)&&m($,this.messageTypeFilter)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&m(ne,this.replyType)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n}(yn),En=function(){this.replyType=ne.NONE,this.includeReactions=!1,this.includeThreadInfo=!1,this.includeMetaArray=!1,this.includeParentMessageInfo=!1,this.includePollDetails=!1},vn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return m(ne,this.replyType)&&y("boolean",this.includeReactions,!0)&&y("boolean",this.includeMetaArray,!0)&&y("boolean",this.includeParentMessageInfo,!0)&&y("boolean",this.includeThreadInfo,!0)&&y("boolean",this.includePollDetails,!0)},n}(En),Tn=function(){this.data=null,this.customType=null,this.mentionType=te.USERS,this.mentionedUserIds=[],this.mentionedMessageTemplate=null,this.metaArrays=[],this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this._mentionedUsers=[]},In=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return(y("string",this.data)||null===this.data)&&(y("string",this.customType)||null===this.customType)&&m(te,this.mentionType)&&E("string",this.mentionedUserIds)&&Array.isArray(this._mentionedUsers)&&this._mentionedUsers.every((function(e){return e instanceof nt}))&&(y("string",this.mentionedMessageTemplate)||null===this.mentionedMessageTemplate)&&this.metaArrays.every((function(e){return e instanceof mt}))&&(null===this.pushNotificationDeliveryOption||m(re,this.pushNotificationDeliveryOption))&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof Tt)},n}(Tn),Sn=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=null,t.translationTargetLanguages=null,t}return t(n,e),n}(Tn),bn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"mentionedUsers",{get:function(){return this._mentionedUsers},set:function(e){this.mentionedUserIds=e.map((function(e){return e.userId})),this._mentionedUsers=e},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return new In(this).validate()&&y("string",this.message,!0)&&E("string",this.translationTargetLanguages,!0)},n}(Sn),Nn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Tn),On=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),Object.defineProperty(n.prototype,"mentionedUsers",{get:function(){return this._mentionedUsers},set:function(e){this.mentionedUserIds=e.map((function(e){return e.userId})),this._mentionedUsers=e},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return new In(this).validate()},n}(Nn),An=function(){function e(e,t){var n;this._iid=null,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 y("number",this.limit)&&this.limit>0},e}(),Cn=function(e){function n(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,a=t.exactMatch,o=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(Le,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:a,channel_url:o,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:h,target_fields:p,after:f},_}return t(n,e),n}(L),wn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return tn(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r}return t(n,e),n}(P);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Xt||(Xt={}));var Rn=function(e){function s(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Xt.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",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:Xt.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return t(s,e),s.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.keyword)&&this.keyword.length>0&&y("boolean",this.reverse)&&y("boolean",this.exactMatch)&&y("string",this.channelUrl)&&y("string",this.channelCustomType)&&(y("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(y("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(Xt,this.order)&&y("boolean",this.advancedQuery)&&E("string",this.targetFields,!0)},s.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,r,s,a,o,u;return i(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=ct.of(this._iid).requestQueue,t=new Cn(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=i.sent(),s=r.as(wn),a=s.messages,o=s.hasNext,u=s.nextToken,this._nextToken=u,this._hasNext=o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},s}(An),Dn=function(e){function n(t,n,r,i){var s=e.call(this,t,i)||this;return s.channelUrl=n,s.channelType=r,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.channelUrl)&&m(Y,this.channelType)},n}(An),Mn=function(e){function n(t,n,r,i){var s,a,o,u,c,l,d,h,p,f,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=$.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ne.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(s=i.reverse)&&void 0!==s&&s,_.messageTypeFilter=null!==(a=i.messageTypeFilter)&&void 0!==a?a:$.ALL,_.customTypesFilter=null!==(o=i.customTypesFilter)&&void 0!==o?o:null,_.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,_.replyType=null!==(c=i.replyType)&&void 0!==c?c:ne.NONE,_.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,_.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,_.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(f=i.showSubchannelMessagesOnly)&&void 0!==f&&f,_}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("boolean",this.reverse)&&m($,this.messageTypeFilter)&&m(ne,this.replyType)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,hn.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{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,o([Number.MAX_SAFE_INTEGER],a(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 p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},n}(Dn),kn=function(e){function n(t){var n=e.call(this)||this;if(t)for(var r in t)n.hasOwnProperty(r)&&(n[r]=t[r]);return n}return t(n,e),n.prototype.validate=function(){return y("string",this.channelUrl)&&y("number",this.scheduledMessageId)},n}((function(){this.channelUrl=null,this.scheduledMessageId=0})),Un=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(n,e),n.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,cacheContext:u}),this._manager=new hn(t,{sdkState:r,dispatcher:i,requestQueue:a,cacheContext:u})},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 r(this,void 0,void 0,(function(){return i(this,(function(t){return et(e instanceof gn&&e.validate()).throw(p.invalidParameters),[2,this._manager.getMessage(e)]}))}))},n.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return et(e instanceof kn&&e.validate()).throw(p.invalidParameters),[2,this._manager.getScheduledMessage(e)]}))}))},n}(lt);export{Rt as $,d as A,An as B,U as C,N as D,R as E,_e as F,H as G,S as H,Ce as I,C as J,Un as K,Y as L,$ as M,tt as N,Je as O,qt as P,I as Q,J as R,p as S,Z as T,nt as U,ct as V,G as W,Ot as X,ne as Y,Ft as Z,t as _,y as a,ke as a$,hn as a0,Wt as a1,zt as a2,Vt as a3,Bt as a4,se as a5,V as a6,v as a7,ie as a8,Jt as a9,Tn as aA,bn as aB,Sn as aC,en as aD,pn as aE,ht as aF,dt as aG,te as aH,re as aI,ze as aJ,xt as aK,Ke as aL,gt as aM,fn as aN,je as aO,g as aP,Mn as aQ,Nt as aR,Be as aS,Ve as aT,mn as aU,vn as aV,W as aW,On as aX,bt as aY,lt as aZ,Ue as a_,Kt as aa,u as ab,M as ac,ge as ad,$t as ae,Zt as af,Me as ag,De as ah,Q as ai,Ze as aj,h as ak,kt as al,he as am,Qe as an,tn as ao,Yt as ap,fe as aq,Dn as ar,jt as as,ee as at,mt as au,Tt as av,Qt as aw,Gt as ax,At as ay,In as az,E as b,Ht as b0,Nn as b1,En as b2,yn as b3,gn as b4,_n as b5,Xt as b6,Et as b7,vt as b8,yt as b9,at as ba,pt as bb,wt as bc,Ct as bd,m as c,r as d,i as e,we as f,k as g,L as h,T as i,n as j,P as k,Fe as l,qe as m,K as n,a as o,s as p,o as q,b as r,ft as s,xe as t,_t as u,c as v,Ae as w,et as x,Rn as y,$e as z}; diff --git a/__bundle-72d7e125.js b/__bundle-72d7e125.js deleted file mode 100644 index fe0cdab..0000000 --- a/__bundle-72d7e125.js +++ /dev/null @@ -1 +0,0 @@ -import{c as e,g as t,_ as n,j as r,U as a,L as i,W as s,A as o,an as u,h as c,k as l,aG as h,aH as d,ac as p,Z as f,V as m,aI as v,aJ as _,aK as y,$ as g,aL as E,aM as T,d as U,e as I,ar as w,S as N,aN as C,J as M,aO as A,aP as P,au as b,av as S,aQ as D,ah as L,p as R,T as q,ag as k,aj as H,x as F,am as O,a9 as Q,ai as G,F as V,ak as z,a1 as x,a0 as j,a as W,a2 as Y,aD as B,I as K,b as Z,aR as J,aS as X,q as $,o as ee,aT as te,aU as ne,aV as re,aA as ae,aW as ie,X as se,aX as oe}from"./__bundle-368767fc.js";var ue;!function(e){e.MUTED="muted",e.BANNED="banned"}(ue||(ue={}));var ce,le=function(){function n(t){var n,r,a;this.restrictionType=null,this.description=null,this.endAt=-1,e(ue,t.restriction_type)&&(this.restrictionType=t.restriction_type),this.description=null!==(n=t.description)&&void 0!==n?n:null,this.endAt=null!==(a=null!==(r=t.end_at)&&void 0!==r?r:t.muted_end_at)&&void 0!==a?a:-1}return n.payloadify=function(e){return e?t({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},n}(),he=function(e){function a(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new le(n),r}return n(a,e),a.payloadify=function(n){return n?t(r(r({},e.payloadify.call(this,n)),le.payloadify(n.restrictionInfo))):null},a}(a);!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"}(ce||(ce={}));var de=function(){function e(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(e.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===i.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===i.OPEN},enumerable:!1,configurable:!0}),e}(),pe=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.event=new de(r),a}return n(t,e),t}(s),fe=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data.operators,o=void 0===s?[]:s;return i.operators=o.map((function(e){return new a(i._iid,e)})),i}return n(t,e),t}(pe),me=function(e){function t(t,n,r){var a=e.call(this,t,"MCNT",r)||this;return a.groupChannelMemberCounts=r.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),a.openChannelMemberCounts=r.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),a}return n(t,e),t}(s),ve=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId,s=t.seconds,c=t.description;return(n=e.call(this)||this).method=o.POST,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:i,seconds:s,description:c},n}return n(t,e),t}(c);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(l);var _e=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new he(t,r.data),a}return n(t,e),t}(s),ye=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(i)),n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var ge=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new he(t,r.data),a}return n(t,e),t}(s),Ee=function(e){function r(n){var r=this,a=n.channelUrl,i=n.channelType,s=n.userId,c=n.seconds,l=n.description;return(r=e.call(this)||this).method=o.POST,r.path="".concat(u(i),"/").concat(encodeURIComponent(a),"/ban"),r.params=t({user_id:s,seconds:c,description:l}),r}return n(r,e),r}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Te=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.memberCount=null,a.joinedMemberCount=null,a.user=new he(t,r.data),r.data.member_count&&(a.memberCount=r.data.member_count),r.data.joined_member_count&&(a.joinedMemberCount=r.data.joined_member_count),a}return n(t,e),t}(s),Ue=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(i)),n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Ie=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new he(t,r.data),a}return n(t,e),t}(s),we=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.freezing;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:i},n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Ne=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.freeze=r.data.freeze,a}return n(t,e),t}(s),Ce=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:i,include_ts:!0,upsert:null!=s&&s},n}return n(t,e),t}(c),Me=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.metadata,i=n.ts;return r.metadata=a,r.ts=null!=i?i:null,r}return n(t,e),t}(l),Ae=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.created=null,a.updated=null,a.deleted=null,r.data&&(a.created=r.data.created,a.updated=r.data.updated,a.deleted=r.data.deleted),a}return n(t,e),t}(s),Pe=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metaCounter,s=t.upsert,c=void 0!==s&&s,l=t.mode,h=void 0===l?"set":l;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:i,upsert:c,mode:h},n}return n(t,e),t}(c),be=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(l),Se=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.created=null,a.updated=null,a.deleted=null,r.data&&(a.created=r.data.created,a.updated=r.data.updated,a.deleted=r.data.deleted),a}return n(t,e),t}(s),De=function(e){function r(n){return e.call(this,{code:"MESG",ackRequired:!0,payload:t({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:n.mentionType===h.USERS?n.mentionedUserIds:[],mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==d.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,is_reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId})})||this}return n(r,e),r}(p),Le=function(e){function t(t,n,r){var a,i=this;(i=e.call(this,t,"MESG",r)||this).message=new f(t,r);var s=m.of(t).sdkState;return i.isMentioned=v(i.message.mentionType,i.message.mentionedUsers.map((function(e){return e.userId})),s.userId),i.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,i}return n(t,e),t}(s),Re=function(e){function t(t,n,r){var a,i=this;(i=e.call(this,t,"ADMM",r)||this).message=new _(t,r);var s=m.of(t).sdkState;return i.isMentioned=v(i.message.mentionType,i.message.mentionedUsers.map((function(e){return e.userId})),s.userId),i.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,i}return n(t,e),t}(s),qe=function(e){function r(n){return e.call(this,{code:"MEDI",ackRequired:!0,payload:t({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:n.mentionType===h.USERS?n.mentionedUserIds:[],mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return n(r,e),r}(p),ke=function(e){function t(t,n,r){var a,i,s,o,u=this;(u=e.call(this,t,"MEDI",r)||this).message=new f(t,r);var c=m.of(t).sdkState;return u.mentionCountChange=y({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:u.message.mentionType,mentionedUserIds:u.message.mentionedUsers.map((function(e){return e.userId}))},c.userId),u}return n(t,e),t}(s),He=function(e){function r(n){return e.call(this,{code:"FEDI",ackRequired:!0,payload:t({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:n.mentionType===h.USERS?n.mentionedUserIds:[],apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return n(r,e),r}(p),Fe=function(e){function t(t,n,r){var a,i,s,o,u=this;(u=e.call(this,t,"FEDI",r)||this).message=new g(t,r);var c=m.of(t).sdkState;return u.mentionCountChange=y({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:u.message.mentionType,mentionedUserIds:u.message.mentionedUsers.map((function(e){return e.userId}))},c.userId),u}return n(t,e),t}(s),Oe=function(e){function t(t,n,r){var a,i,s,o,u=this;(u=e.call(this,t,"AEDI",r)||this).message=new _(t,r);var c=m.of(t).sdkState;return u.mentionCountChange=y({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:u.message.mentionType,mentionedUserIds:u.message.mentionedUsers.map((function(e){return e.userId}))},c.userId),u}return n(t,e),t}(s),Qe=function(e){function t(t){var n=e.call(this)||this;return n.method=o.DELETE,n.path="".concat(u(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Ge,Ve=function(e){function t(t,n,r){var a=e.call(this,t,"DELM",r)||this;return a.channelUrl=r.channel_url,a.channelType=r.channel_type,a.messageId=Number(r.msg_id),a}return n(t,e),t}(s),ze=function(e){function t(t,n,r){var a=e.call(this,t,"MRCT",r)||this;return a.channelUrl=r.channel_url,a.channelType=r.channel_type,a.event=new E(r),a}return n(t,e),t}(s),xe=function(e){function t(t,n,r){var a=e.call(this,t,"MTHD",r)||this;return a.event=new T(t,r),a}return n(t,e),t}(s),je=function(e){function t(t){var n=t.channelUrl,r=t.channelType,a=t.token,i=t.limit,s=e.call(this)||this;return s.method=o.GET,s.path="".concat(u(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:a,limit:i},s}return n(t,e),t}(c),We=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new a(t,e)})),r.token=n.next,r}return n(t,e),t}(l),Ye=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,a,i,s,o;return I(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=m.of(this._iid).requestQueue,n=new je(r(r({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=u.sent(),i=a.as(We),s=i.operators,o=i.token,this._token=o,this._hasNext=!!o,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]}}))}))},t}(w),Be=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.limit,s=t.token;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:i,token:s},n}return n(t,e),t}(c),Ke=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.mutedUsers=[];var a=n.next,i=n.muted_list;return r.token=a,i&&i.length>0&&(r.mutedUsers=i.map((function(e){return new he(t,e)}))),r}return n(t,e),t}(l),Ze=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return n(t,e),t.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,a,i,s;return I(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=m.of(this._iid).requestQueue,t=new Be(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(Ke),i=a.mutedUsers,s=a.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]}}))}))},t}(w),Je=function(e){function r(n){var r=this,a=n.channelUrl,i=n.channelType,s=n.limit,c=n.token;return(r=e.call(this)||this).method=o.GET,r.path="".concat(u(i),"/").concat(encodeURIComponent(a),"/ban"),r.params=t({limit:s,token:c}),r}return n(r,e),r}(c),Xe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var a=n.next,i=n.banned_list;return r.token=a,i&&i.length>0&&(r.bannedUsers=i.map((function(e){return new he(t,e.user)}))),r}return n(t,e),t}(l),$e=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,a,i,s;return I(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=m.of(this._iid).requestQueue,t=new Je(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(Xe),i=a.bannedUsers,s=a.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]}}))}))},t}(w);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Ge||(Ge={}));var et=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.operatorUserIds;return(n=e.call(this)||this).method=o.POST,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:i},n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var tt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.operatorUserIds;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:i},n}return n(t,e),t}(c);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(l);var nt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute/").concat(i),n}return n(t,e),t}(c),rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=null,r.endAt=null,r.remainingDuration=null,r.description=null;var a=n.is_muted,i=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=a,r.startAt=i,r.endAt=s,r.remainingDuration=o,r.description=u,r}return n(t,e),t}(l),at=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.keys;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:i,include_ts:!0},n}return n(t,e),t}(c),it=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.metadata,i=n.ts;return r.metadata=a,r.ts=null!=i?i:null,r}return n(t,e),t}(l),st=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.key;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata/").concat(i),n.params={include_ts:!0},n}return n(t,e),t}(c),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.ts;return r.ts=null!=a?a:null,r}return n(t,e),t}(l),ut=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return n(t,e),t}(c),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.ts;return r.ts=null!=a?a:null,r}return n(t,e),t}(l),lt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.keys;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/ban"),n.params={keys:i},n}return n(t,e),t}(c),ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(l),dt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metaCounter;return(n=e.call(this)||this).method=o.POST,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:i},n}return n(t,e),t}(c),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(l),ft=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.key;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter/").concat(i),n.params=null,n}return n(t,e),t}(c);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(l);var mt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var vt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.category,s=t.userId,u=t.description;return(n=e.call(this)||this).method=o.POST,n.path="".concat(C(a),"/").concat(encodeURIComponent(r)),n.params={report_category:i,reporting_user_id:s,report_description:u},n}return n(t,e),t}(c),_t=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,s=t.category,u=t.userId,c=t.offendingUserId,l=t.description;return(n=e.call(this)||this).method=o.POST,n.path="/report/users/".concat(c),n.params={channel_url:r,channel_type:a===i.OPEN?"open_channels":"group_channels",report_category:s,reporting_user_id:u,report_description:l},n}return n(t,e),t}(c),yt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.category,s=t.userId,u=t.offendingUserId,c=t.messageId,l=t.description;return(n=e.call(this)||this).method=o.POST,n.path="".concat(C(a),"/").concat(encodeURIComponent(r),"/messages/").concat(c),n.params={report_category:i,reporting_user_id:s,report_description:l,offending_user_id:u},n}return n(t,e),t}(c),gt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.reactionKey,s=e.call(this)||this;return s.method=o.POST,s.path="".concat(u(n),"/").concat(encodeURIComponent(r),"/messages/").concat(a,"/reactions"),s.params={reaction:i},s}return n(t,e),t}(c),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new E(n),r}return n(t,e),t}(l),Tt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.reactionKey,s=e.call(this)||this;return s.method=o.DELETE,s.path="".concat(u(n),"/").concat(encodeURIComponent(r),"/messages/").concat(a,"/reactions"),s.params={reaction:i},s}return n(t,e),t}(c),Ut=function(e){function t(t,n){var a=e.call(this,t,n)||this;return a.reactionEvent=new E(r({},n)),a}return n(t,e),t}(l),It=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.translationTargetLanguages,s=e.call(this)||this;return s.method=o.POST,s.path="".concat(u(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(a),"/translation"),s.params={target_langs:i},s}return n(t,e),t}(c),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new f(t,n),r}return n(t,e),t}(l),Nt=function(s){function o(e,t){var n,r,o,u,c=this;return(c=s.call(this,e)||this).url="",c.channelType=i.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c.url=t.channel_url,c.name=null!==(n=t.name)&&void 0!==n?n:"",c.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",c.customType=null!==(o=t.custom_type)&&void 0!==o?o:"",c.data=null!==(u=t.data)&&void 0!==u?u:"",c.isFrozen=!!W("boolean",t.freeze)&&t.freeze,c.isEphemeral=!!W("boolean",t.is_ephemeral)&&t.is_ephemeral,c.creator=t.created_by?new a(c._iid,t.created_by):null,c.createdAt=1e3*t.created_at,c._cachedMetaData=new Map,t.metadata&&t.ts&&Object.keys(t.metadata).forEach((function(e){c._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})})),c}return n(o,s),o.payloadify=function(e){return t(r(r({},s.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:a.payloadify(e.creator),created_at:e.createdAt/1e3}))},Object.defineProperty(o.prototype,"isGroupChannel",{get:function(){return this.channelType===i.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"isOpenChannel",{get:function(){return this.channelType===i.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),o.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},o.prototype._removeFromCachedMetaData=function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&Z("string",t)).throw(N.invalidParameters),n=m.of(this._iid).requestQueue,r=new It({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return a=i.sent(),[2,a.as(wt).message]}}))}))},o.prototype.sendFileMessage=function(e){return F(e instanceof x).throw(N.invalidParameters),this._sendFileMessage(e)},o.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=Date.now()),void 0===n&&(n=null);var a=m.of(this._iid).dispatcher,i=j.of(this._iid).fileMessageQueue,s=n,o=new B;return s||(s=this._generateRequestId(),O(2).then((function(){var n=r._createPendingFileMessage(e,s,t);a.dispatch(new Q({messages:[n],source:G.EVENT_MESSAGE_SENT_PENDING})),V((function(){return U(r,void 0,void 0,(function(){return I(this,(function(e){return[2,o._trigger(null,n)]}))}))}))})).catch((function(e){throw e}))),i.request(this,s,e).then((function(e){a.dispatch(new Q({messages:[e],source:G.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return U(r,void 0,void 0,(function(){return I(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(n){if(z(n))throw n;O(2).then((function(){var i=r._createPendingFileMessage(e,s,t);r._markMessageAsFailed(i,n),a.dispatch(new Q({messages:[i],source:i.sendingStatus===L.PENDING?G.REQUEST_RESEND_MESSAGE:G.EVENT_MESSAGE_SENT_FAILED})),V((function(){return U(r,void 0,void 0,(function(){return I(this,(function(e){return[2,o._trigger(n,i)]}))}))}))})).catch((function(e){throw e}))})),o},o.prototype._autoResendFileMessage=function(e){F(e instanceof g).throw(N.invalidParameters);var t=m.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.createdAt,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},o.prototype.sendFileMessages=function(e){var t,n;F(e.every((function(e){return e instanceof x}))).throw(N.invalidParameters);var r=new B;try{for(var a=R(e),i=a.next();!i.done;i=a.next()){var s=i.value;this.sendFileMessage(s).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r},o.prototype.resendFileMessage=function(e,t){var n;return U(this,void 0,void 0,(function(){var r,a;return I(this,(function(i){return F(e instanceof g&&t instanceof Blob).throw(N.invalidParameters),r=new re,a=null!==(n=e.messageParams)&&void 0!==n?n:x._fromFailedFileMessage(e,t),this._sendFileMessage(a).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},o.prototype.updateFileMessage=function(e,t){return U(this,void 0,void 0,(function(){var n,a,i,s,o,u;return I(this,(function(c){switch(c.label){case 0:return F(W("number",e)&&t instanceof ie).throw(N.invalidParameters),n=m.of(this._iid),a=n.dispatcher,i=n.requestQueue,s=new He(r({channelType:this.channelType,channelUrl:this.url,messageId:e},t)),[4,i.send(s)];case 1:return o=c.sent(),u=o.as(Fe).message,a.dispatch(new Q({messages:[u],source:G.EVENT_MESSAGE_UPDATED})),[2,u]}}))}))},o.prototype.cancelUploadingFileMessage=function(e){return U(this,void 0,void 0,(function(){return I(this,(function(t){return F(W("string",e)).throw(N.invalidParameters),j.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},o.prototype.copyFileMessage=function(e,t){return U(this,void 0,void 0,(function(){var n,a;return I(this,(function(i){return F(e instanceof o&&t instanceof g&&e.url===t.channelUrl).throw(N.invalidParameters),n=new re,a=new x(r(r({},t),{file:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:t.mentionedUsers.map((function(e){return e.userId})),pushNotificationDeliveryOption:d.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_requireAuth:t.requireAuth})),e._sendFileMessage(a).onSucceeded((function(e){return n.resolve(e)})).onFailed((function(e){return n.reject(e)})),[2,n.promise]}))}))},o.prototype.deleteMessage=function(e){return U(this,void 0,void 0,(function(){var t,n;return I(this,(function(r){switch(r.label){case 0:return F(e instanceof se).throw(N.invalidParameters),e.messageId>0?(t=m.of(this._iid).requestQueue,n=new Qe({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]}}))}))},o.prototype.addReaction=function(e,t){return U(this,void 0,void 0,(function(){var n,r,a;return I(this,(function(i){switch(i.label){case 0:return F(e instanceof oe&&e.messageId>0&&W("string",t)).throw(N.invalidParameters),n=m.of(this._iid).requestQueue,r=new gt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return a=i.sent(),[2,a.as(Et).reactionEvent]}}))}))},o.prototype.deleteReaction=function(e,t){return U(this,void 0,void 0,(function(){var n,r,a;return I(this,(function(i){switch(i.label){case 0:return F(e instanceof oe&&e.messageId>0&&W("string",t)).throw(N.invalidParameters),n=m.of(this._iid).requestQueue,r=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return a=i.sent(),[2,a.as(Ut).reactionEvent]}}))}))},o.prototype._updateMessageMetaArray=function(e,t,n,r){return U(this,void 0,void 0,(function(){var a,i,s,o,u,c;return I(this,(function(l){switch(l.label){case 0:return a=m.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new qe({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{metaArrays:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(ke).message,i.dispatch(new Q({messages:[c],source:G.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},o.prototype.createMessageMetaArrayKeys=function(e,t){return U(this,void 0,void 0,(function(){var n;return I(this,(function(r){return F(e instanceof se&&e.messageId>0&&Z("string",t)).throw(N.invalidParameters),n=t.map((function(e){return new b({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},o.prototype.deleteMessageMetaArrayKeys=function(e,t){return U(this,void 0,void 0,(function(){var n;return I(this,(function(r){return F(e instanceof se&&e.messageId>0&&Z("string",t)).throw(N.invalidParameters),n=t.map((function(e){return new b({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},o.prototype.addMessageMetaArrayValues=function(e,t){return U(this,void 0,void 0,(function(){return I(this,(function(n){return F(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof b}))).throw(N.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},o.prototype.removeMessageMetaArrayValues=function(e,t){return U(this,void 0,void 0,(function(){return I(this,(function(n){return F(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof b}))).throw(N.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},o.prototype.report=function(t,n){return U(this,void 0,void 0,(function(){var r,a,i,s;return I(this,(function(o){switch(o.label){case 0:return F(e(Ge,t)&&W("string",n)).throw(N.invalidParameters),r=m.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new vt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:t,description:n}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},o.prototype.reportUser=function(t,n,r){return U(this,void 0,void 0,(function(){var i,s,o,u;return I(this,(function(c){switch(c.label){case 0:return F(t instanceof a&&e(Ge,n)&&W("string",r)).throw(N.invalidParameters),i=m.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new _t({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},o.prototype.reportMessage=function(t,n,r){return U(this,void 0,void 0,(function(){var a,i,s,o;return I(this,(function(u){switch(u.label){case 0:return F(t instanceof se&&e(Ge,n)&&W("string",r)).throw(N.invalidParameters),a=m.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new yt({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},o}(K);export{Re as A,$e as B,pe as C,Ve as D,Ne as F,Ze as M,Ye as O,Ge as R,xe as T,Se as U,Nt as a,he as b,le as c,ue as d,Ae as e,Ie as f,Te as g,ce as h,_e as i,ge as j,fe as k,me as l,ze as m,ke as n,Fe as o,Oe as p,Le as q}; diff --git a/__bundle-876572c8.js b/__bundle-876572c8.js new file mode 100644 index 0000000..7973e1e --- /dev/null +++ b/__bundle-876572c8.js @@ -0,0 +1 @@ +import{c as e,g as t,_ as n,j as r,U as a,L as i,W as s,A as o,an as u,h as c,k as l,aH as h,aI as d,ai as p,Z as f,V as m,aJ as v,aK as _,aL as y,$ as g,aM as E,aN as T,d as U,e as I,ar as w,S as N,aO as C,J as M,aP as A,aQ as P,au as S,av as b,aR as D,a8 as L,p as R,T as k,a7 as q,ab as H,x as F,am as O,a9 as Q,aa as G,F as V,ak as z,a1 as x,a0 as j,a as Y,a2 as B,aE as W,I as K,b as Z,aS as J,aT as X,q as $,o as ee,aU as te,aV as ne,aW as re,aB as ae,aX as ie,X as se,aY as oe}from"./__bundle-45e61fc8.js";var ue;!function(e){e.MUTED="muted",e.BANNED="banned"}(ue||(ue={}));var ce,le=function(){function n(t){var n,r,a;this.restrictionType=null,this.description=null,this.endAt=-1,e(ue,t.restriction_type)&&(this.restrictionType=t.restriction_type),this.description=null!==(n=t.description)&&void 0!==n?n:null,this.endAt=null!==(a=null!==(r=t.end_at)&&void 0!==r?r:t.muted_end_at)&&void 0!==a?a:-1}return n.payloadify=function(e){return e?t({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},n}(),he=function(e){function a(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new le(n),r}return n(a,e),a.payloadify=function(n){return n?t(r(r({},e.payloadify.call(this,n)),le.payloadify(n.restrictionInfo))):null},a}(a);!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"}(ce||(ce={}));var de=function(){function e(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(e.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===i.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===i.OPEN},enumerable:!1,configurable:!0}),e}(),pe=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.event=new de(r),a}return n(t,e),t}(s),fe=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data.operators,o=void 0===s?[]:s;return i.operators=o.map((function(e){return new a(i._iid,e)})),i}return n(t,e),t}(pe),me=function(e){function t(t,n,r){var a=e.call(this,t,"MCNT",r)||this;return a.groupChannelMemberCounts=r.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),a.openChannelMemberCounts=r.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),a}return n(t,e),t}(s),ve=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId,s=t.seconds,c=t.description;return(n=e.call(this)||this).method=o.POST,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:i,seconds:s,description:c},n}return n(t,e),t}(c);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(l);var _e=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new he(t,r.data),a}return n(t,e),t}(s),ye=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(i)),n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var ge=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new he(t,r.data),a}return n(t,e),t}(s),Ee=function(e){function r(n){var r=this,a=n.channelUrl,i=n.channelType,s=n.userId,c=n.seconds,l=n.description;return(r=e.call(this)||this).method=o.POST,r.path="".concat(u(i),"/").concat(encodeURIComponent(a),"/ban"),r.params=t({user_id:s,seconds:c,description:l}),r}return n(r,e),r}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Te=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.memberCount=null,a.joinedMemberCount=null,a.user=new he(t,r.data),r.data.member_count&&(a.memberCount=r.data.member_count),r.data.joined_member_count&&(a.joinedMemberCount=r.data.joined_member_count),a}return n(t,e),t}(s),Ue=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(i)),n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Ie=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new he(t,r.data),a}return n(t,e),t}(s),we=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.freezing;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:i},n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Ne=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.freeze=r.data.freeze,a}return n(t,e),t}(s),Ce=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:i,include_ts:!0,upsert:null!=s&&s},n}return n(t,e),t}(c),Me=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.metadata,i=n.ts;return r.metadata=a,r.ts=null!=i?i:null,r}return n(t,e),t}(l),Ae=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.created=null,a.updated=null,a.deleted=null,r.data&&(a.created=r.data.created,a.updated=r.data.updated,a.deleted=r.data.deleted),a}return n(t,e),t}(s),Pe=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metaCounter,s=t.upsert,c=void 0!==s&&s,l=t.mode,h=void 0===l?"set":l;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:i,upsert:c,mode:h},n}return n(t,e),t}(c),Se=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(l),be=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.created=null,a.updated=null,a.deleted=null,r.data&&(a.created=r.data.created,a.updated=r.data.updated,a.deleted=r.data.deleted),a}return n(t,e),t}(s),De=function(e){function r(n){return e.call(this,{code:"MESG",ackRequired:!0,payload:t({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:n.mentionType===h.USERS?n.mentionedUserIds:[],mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==d.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,is_reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId})})||this}return n(r,e),r}(p),Le=function(e){function t(t,n,r){var a,i=this;(i=e.call(this,t,"MESG",r)||this).message=new f(t,r);var s=m.of(t).sdkState;return i.isMentioned=v(i.message.mentionType,i.message.mentionedUsers.map((function(e){return e.userId})),s.userId),i.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,i}return n(t,e),t}(s),Re=function(e){function t(t,n,r){var a,i=this;(i=e.call(this,t,"ADMM",r)||this).message=new _(t,r);var s=m.of(t).sdkState;return i.isMentioned=v(i.message.mentionType,i.message.mentionedUsers.map((function(e){return e.userId})),s.userId),i.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,i}return n(t,e),t}(s),ke=function(e){function r(n){return e.call(this,{code:"MEDI",ackRequired:!0,payload:t({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:n.mentionType===h.USERS?n.mentionedUserIds:[],mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return n(r,e),r}(p),qe=function(e){function t(t,n,r){var a,i,s,o,u=this;(u=e.call(this,t,"MEDI",r)||this).message=new f(t,r);var c=m.of(t).sdkState;return u.mentionCountChange=y({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:u.message.mentionType,mentionedUserIds:u.message.mentionedUsers.map((function(e){return e.userId}))},c.userId),u}return n(t,e),t}(s),He=function(e){function r(n){return e.call(this,{code:"FEDI",ackRequired:!0,payload:t({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:n.mentionType===h.USERS?n.mentionedUserIds:[],apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return n(r,e),r}(p),Fe=function(e){function t(t,n,r){var a,i,s,o,u=this;(u=e.call(this,t,"FEDI",r)||this).message=new g(t,r);var c=m.of(t).sdkState;return u.mentionCountChange=y({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:u.message.mentionType,mentionedUserIds:u.message.mentionedUsers.map((function(e){return e.userId}))},c.userId),u}return n(t,e),t}(s),Oe=function(e){function t(t,n,r){var a,i,s,o,u=this;(u=e.call(this,t,"AEDI",r)||this).message=new _(t,r);var c=m.of(t).sdkState;return u.mentionCountChange=y({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:u.message.mentionType,mentionedUserIds:u.message.mentionedUsers.map((function(e){return e.userId}))},c.userId),u}return n(t,e),t}(s),Qe=function(e){function t(t){var n=e.call(this)||this;return n.method=o.DELETE,n.path="".concat(u(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var Ge,Ve=function(e){function t(t,n,r){var a=e.call(this,t,"DELM",r)||this;return a.channelUrl=r.channel_url,a.channelType=r.channel_type,a.messageId=Number(r.msg_id),a}return n(t,e),t}(s),ze=function(e){function t(t,n,r){var a=e.call(this,t,"MRCT",r)||this;return a.channelUrl=r.channel_url,a.channelType=r.channel_type,a.event=new E(r),a}return n(t,e),t}(s),xe=function(e){function t(t,n,r){var a=e.call(this,t,"MTHD",r)||this;return a.event=new T(t,r),a}return n(t,e),t}(s),je=function(e){function t(t){var n=t.channelUrl,r=t.channelType,a=t.token,i=t.limit,s=e.call(this)||this;return s.method=o.GET,s.path="".concat(u(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:a,limit:i},s}return n(t,e),t}(c),Ye=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new a(t,e)})),r.token=n.next,r}return n(t,e),t}(l),Be=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,a,i,s,o;return I(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=m.of(this._iid).requestQueue,n=new je(r(r({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=u.sent(),i=a.as(Ye),s=i.operators,o=i.token,this._token=o,this._hasNext=!!o,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]}}))}))},t}(w),We=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.limit,s=t.token;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:i,token:s},n}return n(t,e),t}(c),Ke=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.mutedUsers=[];var a=n.next,i=n.muted_list;return r.token=a,i&&i.length>0&&(r.mutedUsers=i.map((function(e){return new he(t,e)}))),r}return n(t,e),t}(l),Ze=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return n(t,e),t.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,a,i,s;return I(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=m.of(this._iid).requestQueue,t=new We(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(Ke),i=a.mutedUsers,s=a.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]}}))}))},t}(w),Je=function(e){function r(n){var r=this,a=n.channelUrl,i=n.channelType,s=n.limit,c=n.token;return(r=e.call(this)||this).method=o.GET,r.path="".concat(u(i),"/").concat(encodeURIComponent(a),"/ban"),r.params=t({limit:s,token:c}),r}return n(r,e),r}(c),Xe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var a=n.next,i=n.banned_list;return r.token=a,i&&i.length>0&&(r.bannedUsers=i.map((function(e){return new he(t,e.user)}))),r}return n(t,e),t}(l),$e=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,a,i,s;return I(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=m.of(this._iid).requestQueue,t=new Je(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(Xe),i=a.bannedUsers,s=a.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]}}))}))},t}(w);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Ge||(Ge={}));var et=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.operatorUserIds;return(n=e.call(this)||this).method=o.POST,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:i},n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var tt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.operatorUserIds;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:i},n}return n(t,e),t}(c);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(l);var nt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/mute/").concat(i),n}return n(t,e),t}(c),rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=null,r.endAt=null,r.remainingDuration=null,r.description=null;var a=n.is_muted,i=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=a,r.startAt=i,r.endAt=s,r.remainingDuration=o,r.description=u,r}return n(t,e),t}(l),at=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.keys;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:i,include_ts:!0},n}return n(t,e),t}(c),it=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.metadata,i=n.ts;return r.metadata=a,r.ts=null!=i?i:null,r}return n(t,e),t}(l),st=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.key;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata/").concat(i),n.params={include_ts:!0},n}return n(t,e),t}(c),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.ts;return r.ts=null!=a?a:null,r}return n(t,e),t}(l),ut=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType;return(n=e.call(this)||this).method=o.PUT,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return n(t,e),t}(c),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.ts;return r.ts=null!=a?a:null,r}return n(t,e),t}(l),lt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.keys;return(n=e.call(this)||this).method=o.GET,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/ban"),n.params={keys:i},n}return n(t,e),t}(c),ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(l),dt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metaCounter;return(n=e.call(this)||this).method=o.POST,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:i},n}return n(t,e),t}(c),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(l),ft=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.key;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter/").concat(i),n.params=null,n}return n(t,e),t}(c);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(l);var mt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType;return(n=e.call(this)||this).method=o.DELETE,n.path="".concat(u(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return n(t,e),t}(c);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(l);var vt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.category,s=t.userId,u=t.description;return(n=e.call(this)||this).method=o.POST,n.path="".concat(C(a),"/").concat(encodeURIComponent(r)),n.params={report_category:i,reporting_user_id:s,report_description:u},n}return n(t,e),t}(c),_t=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,s=t.category,u=t.userId,c=t.offendingUserId,l=t.description;return(n=e.call(this)||this).method=o.POST,n.path="/report/users/".concat(c),n.params={channel_url:r,channel_type:a===i.OPEN?"open_channels":"group_channels",report_category:s,reporting_user_id:u,report_description:l},n}return n(t,e),t}(c),yt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.category,s=t.userId,u=t.offendingUserId,c=t.messageId,l=t.description;return(n=e.call(this)||this).method=o.POST,n.path="".concat(C(a),"/").concat(encodeURIComponent(r),"/messages/").concat(c),n.params={report_category:i,reporting_user_id:s,report_description:l,offending_user_id:u},n}return n(t,e),t}(c),gt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.reactionKey,s=e.call(this)||this;return s.method=o.POST,s.path="".concat(u(n),"/").concat(encodeURIComponent(r),"/messages/").concat(a,"/reactions"),s.params={reaction:i},s}return n(t,e),t}(c),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new E(n),r}return n(t,e),t}(l),Tt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.reactionKey,s=e.call(this)||this;return s.method=o.DELETE,s.path="".concat(u(n),"/").concat(encodeURIComponent(r),"/messages/").concat(a,"/reactions"),s.params={reaction:i},s}return n(t,e),t}(c),Ut=function(e){function t(t,n){var a=e.call(this,t,n)||this;return a.reactionEvent=new E(r({},n)),a}return n(t,e),t}(l),It=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.translationTargetLanguages,s=e.call(this)||this;return s.method=o.POST,s.path="".concat(u(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(a),"/translation"),s.params={target_langs:i},s}return n(t,e),t}(c),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new f(t,n),r}return n(t,e),t}(l),Nt=function(s){function o(e,t){var n,r,o,u,c=this;return(c=s.call(this,e)||this).url="",c.channelType=i.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c.url=t.channel_url,c.name=null!==(n=t.name)&&void 0!==n?n:"",c.coverUrl=null!==(r=t.cover_url)&&void 0!==r?r:"",c.customType=null!==(o=t.custom_type)&&void 0!==o?o:"",c.data=null!==(u=t.data)&&void 0!==u?u:"",c.isFrozen=!!Y("boolean",t.freeze)&&t.freeze,c.isEphemeral=!!Y("boolean",t.is_ephemeral)&&t.is_ephemeral,c.creator=t.created_by?new a(c._iid,t.created_by):null,c.createdAt=1e3*t.created_at,c._cachedMetaData=new Map,t.metadata&&t.ts&&Object.keys(t.metadata).forEach((function(e){c._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})})),c}return n(o,s),o.payloadify=function(e){return t(r(r({},s.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:a.payloadify(e.creator),created_at:e.createdAt/1e3}))},o.prototype.isGroupChannel=function(){return this.channelType===i.GROUP},o.prototype.isOpenChannel=function(){return this.channelType===i.OPEN},Object.defineProperty(o.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),o.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},o.prototype._removeFromCachedMetaData=function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&Z("string",t)).throw(N.invalidParameters),n=m.of(this._iid).requestQueue,r=new It({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return a=i.sent(),[2,a.as(wt).message]}}))}))},o.prototype.sendFileMessage=function(e){return F(e instanceof x).throw(N.invalidParameters),this._sendFileMessage(e)},o.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=Date.now()),void 0===n&&(n=null);var a=m.of(this._iid).dispatcher,i=j.of(this._iid).fileMessageQueue,s=n,o=new W;return s||(s=this._generateRequestId(),O(2).then((function(){var n=r._createPendingFileMessage(e,s,t);a.dispatch(new Q({messages:[n],source:G.EVENT_MESSAGE_SENT_PENDING})),V((function(){return U(r,void 0,void 0,(function(){return I(this,(function(e){return[2,o._trigger(null,n)]}))}))}))})).catch((function(e){throw e}))),i.request(this,s,e).then((function(e){a.dispatch(new Q({messages:[e],source:G.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return U(r,void 0,void 0,(function(){return I(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(n){if(z(n))throw n;O(2).then((function(){var i=r._createPendingFileMessage(e,s,t);r._markMessageAsFailed(i,n),a.dispatch(new Q({messages:[i],source:i.sendingStatus===L.PENDING?G.REQUEST_RESEND_MESSAGE:G.EVENT_MESSAGE_SENT_FAILED})),V((function(){return U(r,void 0,void 0,(function(){return I(this,(function(e){return[2,o._trigger(n,i)]}))}))}))})).catch((function(e){throw e}))})),o},o.prototype._autoResendFileMessage=function(e){F(e instanceof g).throw(N.invalidParameters);var t=m.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.createdAt,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},o.prototype.sendFileMessages=function(e){var t,n;F(e.every((function(e){return e instanceof x}))).throw(N.invalidParameters);var r=new W;try{for(var a=R(e),i=a.next();!i.done;i=a.next()){var s=i.value;this.sendFileMessage(s).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r},o.prototype.resendFileMessage=function(e,t){var n;return U(this,void 0,void 0,(function(){var r,a;return I(this,(function(i){return F(e instanceof g&&t instanceof Blob).throw(N.invalidParameters),r=new re,a=null!==(n=e.messageParams)&&void 0!==n?n:x._fromFailedFileMessage(e,t),this._sendFileMessage(a).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},o.prototype.updateFileMessage=function(e,t){return U(this,void 0,void 0,(function(){var n,a,i,s,o,u;return I(this,(function(c){switch(c.label){case 0:return F(Y("number",e)&&t instanceof ie).throw(N.invalidParameters),n=m.of(this._iid),a=n.dispatcher,i=n.requestQueue,s=new He(r({channelType:this.channelType,channelUrl:this.url,messageId:e},t)),[4,i.send(s)];case 1:return o=c.sent(),u=o.as(Fe).message,a.dispatch(new Q({messages:[u],source:G.EVENT_MESSAGE_UPDATED})),[2,u]}}))}))},o.prototype.cancelUploadingFileMessage=function(e){return U(this,void 0,void 0,(function(){return I(this,(function(t){return F(Y("string",e)).throw(N.invalidParameters),j.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},o.prototype.copyFileMessage=function(e,t){return U(this,void 0,void 0,(function(){var n,a;return I(this,(function(i){return F(e instanceof o&&t instanceof g&&e.url===t.channelUrl).throw(N.invalidParameters),n=new re,a=new x(r(r({},t),{file:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:t.mentionedUsers.map((function(e){return e.userId})),pushNotificationDeliveryOption:d.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),_requireAuth:t.requireAuth})),e._sendFileMessage(a).onSucceeded((function(e){return n.resolve(e)})).onFailed((function(e){return n.reject(e)})),[2,n.promise]}))}))},o.prototype.deleteMessage=function(e){return U(this,void 0,void 0,(function(){var t,n;return I(this,(function(r){switch(r.label){case 0:return F(e instanceof se).throw(N.invalidParameters),e.messageId>0?(t=m.of(this._iid).requestQueue,n=new Qe({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]}}))}))},o.prototype.addReaction=function(e,t){return U(this,void 0,void 0,(function(){var n,r,a;return I(this,(function(i){switch(i.label){case 0:return F(e instanceof oe&&e.messageId>0&&Y("string",t)).throw(N.invalidParameters),n=m.of(this._iid).requestQueue,r=new gt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return a=i.sent(),[2,a.as(Et).reactionEvent]}}))}))},o.prototype.deleteReaction=function(e,t){return U(this,void 0,void 0,(function(){var n,r,a;return I(this,(function(i){switch(i.label){case 0:return F(e instanceof oe&&e.messageId>0&&Y("string",t)).throw(N.invalidParameters),n=m.of(this._iid).requestQueue,r=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return a=i.sent(),[2,a.as(Ut).reactionEvent]}}))}))},o.prototype._updateMessageMetaArray=function(e,t,n,r){return U(this,void 0,void 0,(function(){var a,i,s,o,u,c;return I(this,(function(l){switch(l.label){case 0:return a=m.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new ke({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{metaArrays:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(qe).message,i.dispatch(new Q({messages:[c],source:G.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},o.prototype.createMessageMetaArrayKeys=function(e,t){return U(this,void 0,void 0,(function(){var n;return I(this,(function(r){return F(e instanceof se&&e.messageId>0&&Z("string",t)).throw(N.invalidParameters),n=t.map((function(e){return new S({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},o.prototype.deleteMessageMetaArrayKeys=function(e,t){return U(this,void 0,void 0,(function(){var n;return I(this,(function(r){return F(e instanceof se&&e.messageId>0&&Z("string",t)).throw(N.invalidParameters),n=t.map((function(e){return new S({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},o.prototype.addMessageMetaArrayValues=function(e,t){return U(this,void 0,void 0,(function(){return I(this,(function(n){return F(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof S}))).throw(N.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},o.prototype.removeMessageMetaArrayValues=function(e,t){return U(this,void 0,void 0,(function(){return I(this,(function(n){return F(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof S}))).throw(N.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},o.prototype.report=function(t,n){return U(this,void 0,void 0,(function(){var r,a,i,s;return I(this,(function(o){switch(o.label){case 0:return F(e(Ge,t)&&Y("string",n)).throw(N.invalidParameters),r=m.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new vt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:t,description:n}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},o.prototype.reportUser=function(t,n,r){return U(this,void 0,void 0,(function(){var i,s,o,u;return I(this,(function(c){switch(c.label){case 0:return F(t instanceof a&&e(Ge,n)&&Y("string",r)).throw(N.invalidParameters),i=m.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new _t({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},o.prototype.reportMessage=function(t,n,r){return U(this,void 0,void 0,(function(){var a,i,s,o;return I(this,(function(u){switch(u.label){case 0:return F(t instanceof se&&e(Ge,n)&&Y("string",r)).throw(N.invalidParameters),a=m.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new yt({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},o}(K);export{Re as A,$e as B,pe as C,Ve as D,Ne as F,Ze as M,Be as O,Ge as R,xe as T,be as U,Nt as a,he as b,le as c,ue as d,Ae as e,Ie as f,Te as g,ce as h,_e as i,ge as j,fe as k,me as l,ze as m,qe as n,Fe as o,Oe as p,Le as q}; diff --git a/__bundle-fd9b6bb9.js b/__bundle-fd9b6bb9.js new file mode 100644 index 0000000..f08e876 --- /dev/null +++ b/__bundle-fd9b6bb9.js @@ -0,0 +1 @@ +import{_ as e,c as t,R as n,g as r,j as s,L as i,U as a,I as o,Q as u,q as c,o as l,d as h,e as d,p as f,M as _,T as p,X as m,Y as v,Z as g,$ as E,a0 as y,a1 as N,a2 as C,a3 as b,a4 as A,S,a5 as M,a6 as T,a7 as I,a8 as U,a9 as w,aa as L,ab as D,b as R,a as O,i as P,ac as x,ad as F,ae as k,af as H,W as V,A as G,f as q,h as B,k as K,ag as z,ah as j,ai as Q,aj as Y,B as J,z as W,ak as X,F as Z,al as $,x as ee,J as te,am as ne,E as re,V as se,an as ie,ao as ae,ap as oe,aq as ue,ar as ce,as as le,at as he,au as de,av as fe,aw as _e,ax as pe,ay as me,az as ve,aA as ge,aB as Ee,aC as ye,aD as Ne,aE as Ce,aF as be,aG as Ae}from"./__bundle-45e61fc8.js";import{b as Se,C as Me,U as Te,e as Ie,F as Ue,f as we,g as Le,h as De,i as Re,j as Oe,k as Pe,l as xe,T as Fe,m as ke,D as He,n as Ve,o as Ge,p as qe,q as Be,A as Ke,a as ze}from"./__bundle-876572c8.js";var je,Qe,Ye,Je,We;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(je||(je={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(Qe||(Qe={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(Ye||(Ye={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(Je||(Je={})),function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited"}(We||(We={}));var Xe,Ze,$e,et=function(i){function a(e,r){var s=i.call(this,e,r)||this;return s.state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=t(We,r.state)?r.state:null,s.role=t(n,r.role)?r.role:null,r.hasOwnProperty("is_muted")&&(s.isMuted=r.is_muted),r.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=r.is_blocked_by_me),r.hasOwnProperty("is_blocking_me")&&(s.isBlockingMe=r.is_blocking_me),s}return e(a,i),a.payloadify=function(e){return e?r(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})):null},a}(Se),tt=function(t){function n(e,n){var r,s,o=this;return(o=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",o.channelType=null!==(s=n.channel_type)&&void 0!==s?s:i.GROUP,o.reader=new a(o._iid,n.user),o.readAt=n.ts,o}return e(n,t),n}(o);!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"}(Xe||(Xe={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Ze||(Ze={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}($e||($e={}));var nt,rt,st,it,at,ot,ut,ct,lt=function(e){switch(e){case Xe.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case Xe.CHRONOLOGICAL:return["-createdAt","syncIndex"];case Xe.CHANNEL_NAME_ALPHABETICAL:return["name"]}};!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(nt||(nt={})),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"}(st||(st={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(it||(it={})),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"}(at||(at={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(ot||(ot={})),function(e){e.AND="AND",e.OR="OR"}(ut||(ut={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(ct||(ct={}));var ht,dt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter="",this.channelNameContainsFilter="",this.memberStateFilter=rt.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=st.ALL,this.publicChannelFilter=nt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=it.ALL,this.hiddenChannelFilter=at.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!!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=ut.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t=new e;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},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 ct.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case ct.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,c=i.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(c){case ut.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case ut.OR:if(a.every((function(e){return!l.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!u(a,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.every((function(e){return!e.nickname.toLowerCase().includes(h)})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.memberStateFilter)switch(this.memberStateFilter){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 at.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case at.HIDDEN:if(!e.isHidden)return!1;break;case at.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case at.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===it.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case nt.PUBLIC:if(!e.isPublic)return!1;break;case nt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case st.SUPER:if(!e.isSuper)return!1;break;case st.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),ft=100,_t="GroupChannel",pt="url",mt="Message",vt="messageId",gt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("GroupChannel"):null},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 Tn.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return c([],l(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=r.sent())return n=this._deserialize(t),this._channels.set(e,n),[2,n];r.label=2;case 2:return[2,null];case 3:return[2,this._channels.get(e)]}}))}))},n.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?100:n,s=e.backward,i=void 0!==s&&s,a=e.filter,o=void 0===a?new dt:a,u=e.order,c=void 0===u?Xe.LATEST_LAST_MESSAGE:u;return h(this,void 0,void 0,(function(){var e,n,s,a,u=this;return d(this,(function(l){switch(l.label){case 0:return this.localCacheEnabled?(e=lt(c),n={where:function(e){if(t)switch(c){case Xe.CHANNEL_NAME_ALPHABETICAL:if(!i&&e.name.localeCompare(t)<0||i&&e.name.localeCompare(t)>0)return!1;break;case Xe.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:d.sent(),d.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return h(this,void 0,void 0,(function(){return d(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 h(this,void 0,void 0,(function(){return d(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=c([],l(this._channels.keys()),!1)),h(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return d(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=f(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=l.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),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}(o),Et=function(){function e(){this.messageTypeFilter=_.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=v.NONE}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e){switch(this.messageTypeFilter){case _.USER:if(e.messageType!==p.USER)return!1;break;case _.FILE:if(e.messageType!==p.FILE)return!1;break;case _.ADMIN:if(e.messageType!==p.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 v.NONE:if(e.parentMessageId>0)return!1;break;case v.ONLY_REPLY_TO_CHANNEL:if(e instanceof m&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest"}(ht||(ht={}));var yt,Nt=function(e){if(e===ht.CHANNEL_LATEST)return["channelUrl","-createdAt","-messageId"]},Ct=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},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){var t=s(s({},e.serialize()),{messageId:"".concat(e.messageId)});if(e instanceof g&&e.messageParams){var n=e.messageParams;t.messageParams=s({},n)}else if(e instanceof E&&e.messageParams){n=e.messageParams;t.messageParams=s({},n)}return t},n.prototype._deserialize=function(e){return e=s(s({},e),{messageId:parseInt(e.messageId)}),y.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t;return d(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,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,s=void 0===r?100:r,i=e.backward,a=void 0!==i&&i,o=e.filter,u=void 0===o?new Et:o,c=e.order,l=void 0===c?ht.CHANNEL_LATEST:c;return h(this,void 0,void 0,(function(){var e,r,i,o=this;return d(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=Nt(l),r={where:{channelUrl:t,"/where":function(e){if(n&&l===ht.CHANNEL_LATEST)if(!a&&e.createdAt>n||a&&e.createdAt0)throw S.invalidParameters;var r=s({},e.serialize());return e instanceof g?r.messageParams=null===(t=e.messageParams)||void 0===t?void 0:t.serialize():e instanceof E&&(r.messageParams=null===(n=e.messageParams)||void 0===n?void 0:n.serialize()),r},n.prototype._deserialize=function(e){return e?(e=s(s({},e),{messageId:parseInt(e.messageId)}),y.of(this._iid).buildMessageFromSerializedData(e)):null},n.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t;return d(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,null]}}))}))},n.prototype.fetch=function(e){var t=e.filter,n=void 0===t?new Et:t,r=e.order,s=void 0===r?ht.CHANNEL_LATEST:r,i=e.channelUrl,a=void 0===i?null:i,o=e.sendingStatus,u=void 0===o?null:o,c=e.backward,l=void 0!==c&&c;return h(this,void 0,void 0,(function(){var e,t,r,i,o=this;return d(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=Nt(s),t={"/where":function(e){return n.match(o._deserialize(e))}},a&&(t.channelUrl=a),u&&(t.sendingStatus=u),r={where:t,index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({})];case 2:return i=c.sent(),[2,Promise.all(i.map((function(e){return h(o,void 0,void 0,(function(){var t,n,r,s;return d(this,(function(i){switch(i.label){case 0:return t=this._deserialize(e),(n=e.messageParams)?(r=y.of(this._iid),t instanceof g?(t.messageParams=r.buildUserMessageCreateParamsFromSerializedData(n,t),[3,4]):[3,1]):[3,4];case 1:return t instanceof E?n.file&&"string"==typeof n.file&&A(n.fileType)?(s=n,[4,this.collection.getBlob(n.file)]):[3,3]:[3,4];case 2:s.file=i.sent(),i.label=3;case 3:t.messageParams=r.buildFileMessageCreateParamsFromSerializedData(n,t),i.label=4;case 4:return[2,t]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.upsert=function(e){return h(this,void 0,void 0,(function(){var t,n=this;return d(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.remove=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a;return d(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=f(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 s=o.sent(),i={error:s},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}return[7];case 8:return[2]}}))}))},n.prototype.removeChannel=function(e){return h(this,void 0,void 0,(function(){return d(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 h(this,void 0,void 0,(function(){return d(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.saveBlobs=function(e){return h(this,void 0,void 0,(function(){var t=this;return d(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return h(t,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return e instanceof E&&e.messageParams&&((t=e.messageParams).file&&b(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.file=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(o),Mt=function(){function e(e,t){var n=t.localCacheEnabled,r=t.messageCache,s=t.unsentMessageCache,i=t.dispatcher,a=t.sdkState,o=t.logger,u=this;this._iid=e,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._messageCache=r,this._unsentMessageCache=s,this._dispatcher=i,this._logger=o,this._sdkState=a,this._localCacheEnabled&&i.on((function(e){if(e instanceof M&&e.stateType===T.CONNECTED)u._isProcessingAutoResend||u.processCachedPendingMessages().then((function(){return u._processNextAutoResend()}))}))}return e.prototype.processCachedPendingMessages=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=u.sent();try{for(t=f(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&I(r.errorCode)?(s=(new Date).getTime(),i=r.createdAt+2592e5,s<=i?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(r.reqId)<0&&this._autoResendQueue.push(r):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(i).toLocaleString()),r.sendingStatus=U.FAILED,this._dispatcher.dispatch(new w({messages:[r],source:L.LOCAL_MESSAGE_FAILED})))):(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=U.FAILED,r.errorCode=D.ACK_TIMEOUT,this._dispatcher.dispatch(new w({messages:[r],source:L.LOCAL_MESSAGE_FAILED})))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled)if(e.sendingStatus===U.SUCCEEDED||e.sendingStatus===U.FAILED&&!I(e.errorCode)){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}else e.sendingStatus===U.PENDING&&I(e.errorCode)&&this._isNotInQueue(e)&&(this._autoResendQueue.push(e),this._isProcessingAutoResend||this._processNextAutoResend())},e.prototype._fetchAllCachedPendingMessages=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.fetch({sendingStatus:U.PENDING,backward:!0})];case 1:return[2,e.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 h(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(r){switch(r.label){case 0:if(!this._localCacheEnabled||"foreground"!==this._sdkState.appState)return[3,6];r.label=1;case 1:return r.trys.push([1,5,,6]),this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._logger.debug("processing auto-resend for message request id: ",e.reqId),[4,Tn.of(this._iid).getChannel(e.channelUrl,!0)]):[3,3];case 2:return t=r.sent(),e instanceof g?t._autoResendUserMessage(e):e instanceof E&&t._autoResendFileMessage(e),[3,4];case 3:this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1,r.label=4;case 4:return[3,6];case 5:return n=r.sent(),this._logger.warn("process auto-resend error: ",n),this._isProcessingAutoResend=!1,[3,6];case 6: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"}(yt||(yt={}));var Tt,It=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,r=n.blocker,s=n.blockee;return{blocker:new a(e,r),blockee:new a(e,s)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new a(e,t)})):[]}},e}(),Ut=function(){this.invitedUserIds=[],this.channelUrl=null,this.coverUrl=null,this.coverImage=null,this.isDistinct=null,this.isSuper=null,this.isBroadcast=null,this.isExclusive=null,this.isPublic=null,this.isDiscoverable=null,this.isStrict=null,this.isEphemeral=null,this.accessCode=null,this.name=null,this.data=null,this.customType=null,this.operatorUserIds=null,this.messageSurvivalSeconds=null},wt=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return R("string",this.invitedUserIds)&&O("string",this.channelUrl,!0)&&O("string",this.coverUrl,!0)&&(P(this.coverImage)||O("string",this.coverImage)||null===this.coverImage)&&O("boolean",this.isDistinct,!0)&&O("boolean",this.isSuper,!0)&&O("boolean",this.isBroadcast,!0)&&O("boolean",this.isExclusive,!0)&&O("boolean",this.isPublic,!0)&&O("boolean",this.isStrict,!0)&&O("boolean",this.isDiscoverable,!0)&&O("boolean",this.isEphemeral,!0)&&O("string",this.accessCode,!0)&&O("string",this.name,!0)&&O("string",this.data,!0)&&O("string",this.customType,!0)&&R("string",this.operatorUserIds,!0)&&O("number",this.messageSurvivalSeconds,!0)},n.prototype.addUserIds=function(e){if(R("string",e))for(var t=e.filter((function(e){return O("string",e)})),n=0;n0})),i=r.filter((function(e){return 0===e.messageId})),s.length>0?[4,t.upsert(s)]:[3,3]):[3,6];case 1:return c.sent(),[4,n.remove(s.map((function(e){return e instanceof m?e.reqId:null})).filter((function(e){return null!==e})))];case 2:c.sent(),this._broadcastUpdateEvent(s,u),c.label=3;case 3:return i.length>0?[4,n.upsert(i)]:[3,5];case 4:c.sent(),this._broadcastUpdateEvent(i,u),c.label=5;case 5:return[3,10];case 6:return e instanceof H?(a=e.messageIds,u=e.source,[4,t.remove(a)]):[3,8];case 7:return c.sent(),this._broadcastRemoveEvent(a,u),[3,10];case 8:return e instanceof k?(o=e.reqId,u=e.source,[4,n.remove([o])]):[3,10];case 9:c.sent(),this._broadcastRemoveUnsentEvent(o,u),c.label=10;case 10:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=f(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=f(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var s=f(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.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}(),Gt=function(t){function n(e,n,r){var s=t.call(this,e,"USEV",r)||this;return s.event=new It(r),s}return e(n,t),n}(V),qt=function(t){function n(e){var n=e.userId,s=e.ts,i=e.token,a=e.filter,o=void 0===a?new Dt:a,u=t.call(this)||this,c=o.customTypes,l=o.includeEmpty,h=o.includeFrozen;return u.method=G.GET,u.path="".concat(q,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s,token:i,custom_types:c,show_empty:l,show_frozen:h}),u}return e(n,t),n}(B),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new xr(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(K),Kt=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=G.GET,s.path="".concat(r?z:j,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(B),zt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new xr(e,n),r}return e(n,t),n}(K),jt=function(t){function n(e){var n=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.memberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,f=e.nicknameContainsFilter,_=e.channelNameContainsFilter,p=e.channelUrlsFilter,m=e.customTypesFilter,v=e.customTypeStartsWithFilter,g=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,y=e.metadataKey,N=e.metadataValues,C=e.metadataValueStartsWith,b=e.includeFrozen,A=e.includeMetaData,S=e.searchFilter,M=e.userIdsFilter;return(n=t.call(this)||this).method=G.GET,n.path="".concat(q,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:c,super_mode:l,public_mode:h,unread_filter:d,members_nickname_contains:f,name_contains:_,channel_urls:p,custom_types:m,custom_type_startswith:v,hidden_mode:g,metadata_order_key:E,metadata_key:y,metadata_values:N,metadata_value_startswith:C,show_frozen:b,show_metadata:A}),S&&S.query&&S.fields&&(n.params.search_query=S.query,n.params.search_fields=S.fields),M&&M.userIds&&M.userIds.length>0&&(M.includeMode?(n.params.members_include_in=M.userIds,n.params.query_type=M.queryType.toUpperCase()):n.params.members_exactly_in=M.userIds),n}return e(n,t),n}(B),Qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new xr(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(K),Yt=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.memberStateFilter;return s.method=G.GET,s.path="".concat(q,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:rt.ALL},s}return e(n,t),n}(B),Jt=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}(K),Wt=function(t){function n(e){var n=this,r=e.userId,s=e.channelUrl,i=e.coverUrl,a=e.coverImage,o=e.isDistinct,u=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,_=e.isDiscoverable,p=e.isStrict,m=e.isEphemeral,v=e.accessCode,g=e.name,E=e.data,y=e.customType,N=e.messageSurvivalSeconds,C=e.invitedUserIds,b=e.operatorUserIds;return(n=t.call(this)||this).method=G.POST,n.path=j,n.params={user_ids:c([r],l(C),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:i,cover_file:a,is_distinct:o,is_super:u,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:_,strict:p,is_ephemeral:m,access_code:v,name:g,data:E,custom_type:y,operator_ids:b,message_survival_seconds:N},n}return e(n,t),n}(B),Xt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new xr(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(K),Zt=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=G.PUT,s.path="".concat(q,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(B);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(K);var $t=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(B),en=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new xr(e,n),r}return e(n,t),n}(K),tn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,l=i.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 et(e,t)})):[new et(e,r.data)],s}return e(n,t),n}(Me),nn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s},n}return e(n,t),n}(B);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(K);var rn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new et(s._iid,r.data),s}return e(n,t),n}(Me),sn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=G.POST,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(B),an=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new xr(e,n),r}return e(n,t),n}(K),on=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,f=i.invitees,_=void 0===f?[]:f;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitees=_.map((function(t){return new et(e,t)})),s}return e(n,t),n}(Me),un=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(B),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new xr(e,n),r.channel.myMemberState=We.NONE,r}return e(n,t),n}(K),ln=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,f=i.invitee,_=void 0===f?null:f;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitee=_?new et(e,_):null,s}return e(n,t),n}(Me),hn=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}(Q),dn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new tt(e,r),s}return e(n,t),n}(V),fn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=G.PUT,i.path="".concat(j,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(B);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(K);var _n,pn=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}(V),mn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.hidePreviousMessages,a=e.allowAutoUnhide;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(B),vn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(K),gn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(V),En=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}(Q),yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(V),Nn=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}(Q),Cn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(V),bn=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}(Q),An=function(n){function r(e,t){var r,s,i,a,o,u,c,l,h,d,f,_,p,m,v,g,E,y,N,C,b=this;return(b=n.call(this,e,t)||this).includeEmpty=!1,b.includeFrozen=!0,b.includeMetaData=!0,b.channelUrlsFilter=null,b.customTypesFilter=null,b.customTypeStartsWithFilter=null,b.nicknameContainsFilter="",b.channelNameContainsFilter="",b.memberStateFilter=rt.ALL,b.unreadChannelFilter=it.ALL,b.superChannelFilter=st.ALL,b.publicChannelFilter=nt.ALL,b.hiddenChannelFilter=at.UNHIDDEN,b.searchFilter={fields:[],query:null},b.userIdsFilter={userIds:[],includeMode:!0,queryType:ut.AND},b.metadataKey=null,b.metadataValues=null,b.metadataOrderKeyFilter=null,b.metadataValueStartsWith=null,b.order=Xe.LATEST_LAST_MESSAGE,b.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,b.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,b.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,b.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,b.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,b.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:"",b.nicknameContainsFilter=null!==(c=t.nicknameContainsFilter)&&void 0!==c?c:"",b.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:"",b.memberStateFilter=null!==(h=t.memberStateFilter)&&void 0!==h?h:rt.ALL,b.unreadChannelFilter=null!==(d=t.unreadChannelFilter)&&void 0!==d?d:it.ALL,b.superChannelFilter=null!==(f=t.superChannelFilter)&&void 0!==f?f:st.ALL,b.publicChannelFilter=null!==(_=t.publicChannelFilter)&&void 0!==_?_:nt.ALL,b.hiddenChannelFilter=null!==(p=t.hiddenChannelFilter)&&void 0!==p?p:at.UNHIDDEN,b.searchFilter=null!==(m=t.searchFilter)&&void 0!==m?m:{fields:[],query:null},b.userIdsFilter=null!==(v=t.userIdsFilter)&&void 0!==v?v:{userIds:[],includeMode:!0,queryType:ut.AND},b.metadataKey=null!==(g=t.metadataKey)&&void 0!==g?g:null,b.metadataValues=null!==(E=t.metadataValues)&&void 0!==E?E:null,b.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,b.metadataValueStartsWith=null!==(N=t.metadataValueStartsWith)&&void 0!==N?N:null,b.order=null!==(C=t.order)&&void 0!==C?C:Xe.LATEST_LAST_MESSAGE,b}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&O("boolean",this.includeEmpty)&&O("boolean",this.includeFrozen)&&O("boolean",this.includeMetaData)&&O("string",this.channelNameContainsFilter)&&R("string",this.channelUrlsFilter,!0)&&R("string",this.customTypesFilter,!0)&&O("string",this.customTypeStartsWithFilter)&&O("string",this.nicknameContainsFilter)&&t(rt,this.memberStateFilter)&&t(st,this.superChannelFilter)&&t(nt,this.publicChannelFilter)&&t(it,this.unreadChannelFilter)&&t(at,this.hiddenChannelFilter)&&R(ct,this.searchFilter.fields)&&O("string",this.searchFilter.query,!0)&&R("string",this.userIdsFilter.userIds)&&O("boolean",this.userIdsFilter.includeMode)&&t(ut,this.userIdsFilter.queryType)&&t(Xe,this.order)&&O("string",this.metadataOrderKeyFilter,!0)&&O("string",this.metadataKey,!0)&&R("string",this.metadataValues,!0)&&O("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return Y(this)},r.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Tn.of(this._iid).getMyGroupChannels(this._token,this,this.limit)]):[3,2]:[3,5];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasNext=!!n,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw S.queryInProgress;case 4:return[3,6];case 5:throw S.invalidParameters;case 6:return[2]}}))}))},r}(J),Sn=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||A.unreadMentionCount>0)&&(A._updateUnreadCount(0,0),this._dispatcher.dispatch(new xt({channels:[A],source:Tt.EVENT_CHANNEL_READ})),Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==A.unreadMessageCount&&0!==A.unreadMentionCount||(this._dispatcher.dispatch(new xt({channels:[A],source:Tt.EVENT_CHANNEL_READ})),Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new xt({channels:[A],source:Tt.EVENT_CHANNEL_READ})),Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),en.label=12;case 12:return[3,71];case 13:return S=e.as(pn),Q=S.channelUrl,M=S.deliveredStateUpdate,T=void 0===M?{}:M,I=this._groupChannelCache.isCachedInMemory(Q),[4,this.getChannel(Q,!0)];case 14:if(U=en.sent(),I)for(D in T)U._updateUndeliveredMemberState(D,T[D]);return this._dispatcher.dispatch(new xt({channels:[U],source:Tt.EVENT_CHANNEL_DELIVERED})),Object.keys(T).some((function(e){return e!==$t._sdkState.userId}))&&Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,71];case 15:return R=e.as(ke),Q=R.channelUrl,O=R.channelType,P=R.event,O!==i.GROUP?[3,18]:[4,this.getChannel(Q,!0)];case 16:return x=en.sent(),[4,this.getMessageFromCache(P.messageId)];case 17:(G=en.sent())&&(G.applyReactionEvent(P),this._dispatcher.dispatch(new w({messages:[G],source:L.EVENT_MESSAGE_REACTION_UPDATED}))),Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(x,P)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),en.label=18;case 18:return[3,71];case 19:return(k=e.as(Fe).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(k.channelUrl,!0)];case 20:return V=en.sent(),[4,this.getMessageFromCache(k.targetMessageId)];case 21:(G=en.sent())&&(G.applyThreadInfoUpdateEvent(k),this._dispatcher.dispatch(new w({messages:[G],source:L.EVENT_MESSAGE_THREADINFO_UPDATED}))),Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(V,k)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),en.label=22;case 22:return[3,71];case 23:q=e.as(xe).groupChannelMemberCounts,B=[],en.label=24;case 24:en.trys.push([24,29,30,31]),K=f(q),z=K.next(),en.label=25;case 25:return z.done?[3,28]:(j=z.value,Q=j.channelUrl,ze=j.memberCount,je=j.joinedMemberCount,Y=j.updatedAt,[4,this.getChannelFromCache(Q)]);case 26:(J=en.sent())&&J._setLatestMemberCount(ze,je,Y)&&B.push(J),en.label=27;case 27:return z=K.next(),[3,25];case 28:return[3,31];case 29:return W=en.sent(),zt={error:W},[3,31];case 30:try{z&&!z.done&&(jt=K.return)&&jt.call(K)}finally{if(zt)throw zt.error}return[7];case 31:return B.length>0&&(this._dispatcher.dispatch(new xt({channels:B,source:Tt.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Z((function(){return h($t,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(B)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,71];case 32:if(!(ee=e.as(Me).event).isGroupChannelEvent)return[3,69];switch(ee.category){case De.CHANNEL_JOIN:return[3,33];case De.CHANNEL_LEAVE:return[3,35];case De.CHANNEL_OPERATOR_UPDATE:return[3,39];case De.CHANNEL_INVITE:return[3,41];case De.CHANNEL_DECLINE_INVITE:return[3,43];case De.TYPING_START:case De.TYPING_END:return[3,45];case De.USER_CHANNEL_MUTE:case De.USER_CHANNEL_UNMUTE:return[3,47];case De.USER_CHANNEL_BAN:return[3,49];case De.USER_CHANNEL_UNBAN:return[3,53];case De.CHANNEL_FREEZE:case De.CHANNEL_UNFREEZE:return[3,55];case De.CHANNEL_HIDE:return[3,57];case De.CHANNEL_UNHIDE:return[3,59];case De.CHANNEL_DELETED:return[3,61];case De.CHANNEL_PROP_CHANGED:return[3,63];case De.CHANNEL_META_DATA_CHANGED:return[3,65];case De.CHANNEL_META_COUNTERS_CHANGED:return[3,67]}return[3,69];case 33:return[4,this.getChannel(ee.channelUrl,!0)];case 34:return te=en.sent(),ne=e.as(tn),re=ne.memberCount,se=ne.joinedMemberCount,ie=ne.members,ae=!1,ie.forEach((function(e){te.isExclusive||te.isSuper||te.isBroadcast?ae=ae||te._setLatestMemberCount(re,se,ee.ts):(e.state=We.JOINED,te.addMember(e,ee.ts),$t._updateJoinedMemberCount(te)),e.userId===$t._sdkState.userId&&(te.myMemberState=We.JOINED)})),this._dispatcher.dispatch(new xt({channels:[te],source:Tt.EVENT_CHANNEL_JOINED})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=f(ie),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(te,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}te.isBroadcast&&ae&&e.onChannelMemberCountChanged([te])})),[2]}))}))})),[3,69];case 35:return(it=this._leftChannels.get(ee.channelUrl))?(ue=it.channel,[3,38]):[3,36];case 36:return[4,this.getChannel(ee.channelUrl,!0)];case 37:ue=en.sent(),en.label=38;case 38:return oe=ue,ce=e.as(rn),ze=ce.memberCount,je=ce.joinedMemberCount,le=ce.member,he=!1,oe.isExclusive||oe.isSuper||oe.isBroadcast?he=oe._setLatestMemberCount(ze,je,ee.ts):(oe.removeMember(le),this._updateJoinedMemberCount(oe)),le.userId===this._sdkState.userId?oe.isPublic?(oe.myMemberState=We.NONE,oe.invitedAt=0,oe.joinedAt=0,oe._updateUnreadCount(0,0),this._dispatcher.dispatch(new xt({channels:[oe],source:Tt.EVENT_CHANNEL_LEFT}))):(this._markAsLeave(oe),this._dispatcher.dispatch(new Ft({channelUrls:[oe.url],source:Tt.EVENT_CHANNEL_LEFT}))):this._dispatcher.dispatch(new xt({channels:[oe],source:Tt.EVENT_CHANNEL_LEFT})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(oe,le),oe.isBroadcast&&he&&e.onChannelMemberCountChanged([oe])})),[2]}))}))})),[3,69];case 39:return[4,this.getChannel(ee.channelUrl,!0)];case 40:de=en.sent(),fe=e.as(Pe).operators,_e=fe.map((function(e){return e.userId}));try{for(pe=f(de.members),me=pe.next();!me.done;me=pe.next())(st=me.value).role=_e.includes(st.userId)?n.OPERATOR:n.NONE}catch(e){Qt={error:e}}finally{try{me&&!me.done&&(Yt=pe.return)&&Yt.call(pe)}finally{if(Qt)throw Qt.error}}return de.myRole=_e.includes(this._sdkState.userId)?n.OPERATOR:n.NONE,this._dispatcher.dispatch(new xt({channels:[de],source:Tt.EVENT_CHANNEL_OPERATOR_UPDATED})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(de,fe)})),[2]}))}))})),[3,69];case 41:return[4,this.getChannel(ee.channelUrl,!0)];case 42:ve=en.sent(),ge=e.as(on),ze=ge.memberCount,je=ge.joinedMemberCount,Ee=ge.inviter,(ye=ge.invitees).forEach((function(e){return e.state=We.INVITED}));try{for(Ne=f(ye),Ce=Ne.next();!Ce.done;Ce=Ne.next())be=Ce.value,ve.isExclusive||ve.isSuper||ve.isBroadcast?ve._setLatestMemberCount(ze,je,ee.ts):ve.addMember(be,ee.ts),this._sdkState.userId===be.userId&&(ve.hiddenState=Dr.UNHIDDEN,ve.myMemberState!==We.JOINED&&(ve.myMemberState=We.INVITED),ve.invitedAt=ee.ts)}catch(e){Jt={error:e}}finally{try{Ce&&!Ce.done&&(Wt=Ne.return)&&Wt.call(Ne)}finally{if(Jt)throw Jt.error}}return this._dispatcher.dispatch(new xt({channels:[ve],source:Tt.EVENT_CHANNEL_INVITED})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(ve,Ee,ye)})),[2]}))}))})),[3,69];case 43:return[4,this.getChannel(ee.channelUrl,!0)];case 44:return Ae=en.sent(),Se=e.as(ln),ze=Se.memberCount,je=Se.joinedMemberCount,Qe=Se.inviter,Ye=Se.invitee,Ae.isExclusive||Ae.isSuper||Ae.isBroadcast?Ae._setLatestMemberCount(ze,je,ee.ts):Ae.removeMember(Ye),this._sdkState.userId===Ye.userId?(Ae.invitedAt=0,Ae.myMemberState=We.NONE,Ae.isPublic?this._dispatcher.dispatch(new xt({channels:[Ae],source:Tt.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Ft({channelUrls:[Ae.url],source:Tt.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new xt({channels:[Ae],source:Tt.EVENT_CHANNEL_DECLINED_INVITE})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Ae,Qe,Ye)})),[2]}))}))})),[3,69];case 45:return[4,this.getChannel(ee.channelUrl,!0)];case 46:return Je=en.sent(),Xe=ee.category===De.TYPING_START,Ze=e.as(Xe?yn:Cn).user,Je._updateTypingStatus(Ze,Xe?ee.ts:0),this._dispatcher.dispatch(new xt({channels:[Je],source:Tt.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(Je)})),[2]}))}))})),[3,69];case 47:return[4,this.getChannel(ee.channelUrl,!0)];case 48:$e=en.sent(),et=ee.category===De.USER_CHANNEL_MUTE,(tt=e.as(et?Re:Oe).user).userId===this._sdkState.userId&&($e.myMutedState=et?Lr.MUTED:Lr.UNMUTED);try{for(nt=f($e.members),rt=nt.next();!rt.done;rt=nt.next())if((st=rt.value).userId===tt.userId){st.isMuted=et;break}}catch(e){Xt={error:e}}finally{try{rt&&!rt.done&&(Zt=nt.return)&&Zt.call(nt)}finally{if(Xt)throw Xt.error}}return this._dispatcher.dispatch(new xt({channels:[$e],source:et?Tt.EVENT_CHANNEL_MUTED:Tt.EVENT_CHANNEL_UNMUTED})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){et?e.onUserMuted($e,tt):e.onUserUnmuted($e,tt)})),[2]}))}))})),[3,69];case 49:return(it=this._leftChannels.get(ee.channelUrl))?(ot=it.channel,[3,52]):[3,50];case 50:return[4,this.getChannel(ee.channelUrl,!0)];case 51:ot=en.sent(),en.label=52;case 52:return at=ot,this._markAsLeave(at),ut=e.as(Le).user,Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(at,ut)})),[2]}))}))})),[3,69];case 53:return[4,this.getChannel(ee.channelUrl,!0)];case 54:return ct=en.sent(),lt=e.as(we).user,Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(ct,lt)})),[2]}))}))})),[3,69];case 55:return[4,this.getChannel(ee.channelUrl,!0)];case 56:return ht=en.sent(),dt=e.as(Ue).freeze,ht.isFrozen=dt,this._dispatcher.dispatch(new xt({channels:[ht],source:dt?Tt.EVENT_CHANNEL_FROZEN:Tt.EVENT_CHANNEL_UNFROZEN})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){dt?e.onChannelFrozen(ht):e.onChannelUnfrozen(ht)})),[2]}))}))})),[3,69];case 57:return[4,this.getChannel(ee.channelUrl,!0)];case 58:return ft=en.sent(),_t=e.as(gn),pt=_t.allowAutoUnhide,mt=_t.hidePreviousMessages,vt=_t.messageOffsetTimestamp,null!==pt&&(ft.hiddenState=pt?Dr.HIDDEN_ALLOW_AUTO_UNHIDE:Dr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==mt&&mt&&ft._updateUnreadCount(0,0),null!==vt&&(ft.messageOffsetTimestamp=vt),this._dispatcher.dispatch(new xt({channels:[ft],source:Tt.EVENT_CHANNEL_HIDDEN})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(ft)})),[2]}))}))})),[3,69];case 59:return[4,this.getChannel(ee.channelUrl,!0)];case 60:return(gt=en.sent()).hiddenState=Dr.UNHIDDEN,this._dispatcher.dispatch(new xt({channels:[gt],source:Tt.EVENT_CHANNEL_UNHIDDEN})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(gt)})),[2]}))}))})),[3,69];case 61:return[4,this.getChannel(ee.channelUrl,!0)];case 62:return Et=en.sent(),this._dispatcher.dispatch(new Ft({channelUrls:[ee.channelUrl],source:Tt.EVENT_CHANNEL_DELETED})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Et.url,Et.channelType)})),[2]}))}))})),[3,69];case 63:return[4,this.getChannelWithoutCache(ee.channelUrl,!0)];case 64:return Nt=en.sent(),this._dispatcher.dispatch(new xt({channels:[Nt],source:Tt.EVENT_CHANNEL_UPDATED})),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Nt)})),[2]}))}))})),[3,69];case 65:return[4,this.getChannel(ee.channelUrl,!0)];case 66:return Ct=en.sent(),bt=e.as(Ie),At=bt.created,St=bt.updated,Mt=bt.deleted,At&&Ct._upsertCachedMetaData(At,ee.ts),St&&Ct._upsertCachedMetaData(St,ee.ts),Mt&&Ct._removeFromCachedMetaData(Mt,ee.ts),Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){At&&e.onMetaDataCreated(Ct,At),St&&e.onMetaDataUpdated(Ct,St),Mt&&e.onMetaDataDeleted(Ct,Mt)})),[2]}))}))})),[3,69];case 67:return[4,this.getChannel(ee.channelUrl,!0)];case 68:return Ut=en.sent(),wt=e.as(Te),Lt=wt.created,Dt=wt.updated,Rt=wt.deleted,Z((function(){return h($t,void 0,void 0,(function(){return d(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Lt&&e.onMetaCounterCreated(Ut,Lt),Dt&&e.onMetaCounterUpdated(Ut,Dt),Rt&&e.onMetaCounterDeleted(Ut,Rt)})),[2]}))}))})),[3,69];case 69:return[3,71];case 70:switch((Ot=e.as(Gt).event).category){case yt.USER_BLOCK:Pt=It.getDataAsUserBlockEvent(this._iid,Ot),Ht=Pt.blocker,Vt=Pt.blockee,this._groupChannelCache.block(Ht.userId,Vt.userId);break;case yt.USER_UNBLOCK:kt=It.getDataAsUserBlockEvent(this._iid,Ot),Ht=kt.blocker,Vt=kt.blockee,this._groupChannelCache.unblock(Ht.userId,Vt.userId)}return[3,71];case 71:return[3,73];case 72:if(qt=en.sent(),X(qt))throw qt;return[3,73];case 73:return[2]}}))}))},e.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)},e.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},e.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},e.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},e.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},e.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},e.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},e.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===We.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),h(this,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:ee(O("string",e)).throw(S.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()]}}))}))},e.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),h(this,void 0,void 0,(function(){var n,r,s,i,a;return d(this,(function(o){switch(o.label){case 0:return ee(O("string",e)).throw(S.invalidParameters),n=new Kt({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(zt).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case wr.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case wr.UNREAD_MENTION_COUNT_ONLY:i=0;break;case wr.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this._groupChannelCache.upsert([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=Tt.REQUEST_CHANNEL),h(this,void 0,void 0,(function(){var i,a,o,u,c;return d(this,(function(l){switch(l.label){case 0:return i=new jt(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(Qt),u=o.channels,c=o.token,this._dispatcher.dispatch(new xt({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s){return void 0===s&&(s=100),h(this,void 0,void 0,(function(){return d(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getAllFailedMessagesFromCache=function(e,t){return h(this,void 0,void 0,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},e.prototype.getCachedMessageCountBetween=function(e,t,n,r){return h(this,void 0,void 0,(function(){return d(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Sn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=Tt.REQUEST_CHANNEL_CHANGELOGS),h(this,void 0,void 0,(function(){var s,i,a,o,u;return d(this,(function(c){switch(c.label){case 0:return ee(O("string",e)&&t instanceof Dt&&t.validate()).throw(S.invalidParameters),s=new qt(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:t})),[4,this._requestQueue.send(s)];case 1:return i=c.sent(),a=i.as(Bt),o=a.updatedChannels,u=a.deletedChannelUrls,o.length>0&&this._dispatcher.dispatch(new xt({channels:o,source:n})),u.length>0&&this._dispatcher.dispatch(new Ft({channelUrls:u,source:n})),[2,a]}}))}))},e.prototype.getGroupChannelCount=function(e){return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return ee(e instanceof Ot&&e.validate()).throw(S.invalidParameters),t=new Yt({userId:this._sdkState.userId,filter:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Jt).groupChannelCount]}}))}))},e.prototype.createChannel=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return d(this,(function(i){switch(i.label){case 0:return ee(e instanceof wt&&e.validate()).throw(S.invalidParameters),e.isPublic||(e.accessCode=null),t=new Wt(s({userId:this._sdkState.userId},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),r=n.as(Xt).channel,[4,this._groupChannelCache.upsert([r])];case 2:return i.sent(),[2,r]}}))}))},e.prototype.markAsReadAll=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return e=Date.now(),ee(e-this._markAsReadAllLastSentAt>=1e3).throw(S.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Zt({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=f(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this._groupChannelCache.upsert(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return d(this,(function(l){switch(l.label){case 0:return t=Date.now(),ee(R("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(S.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Zt({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=f(r),a=i.next();!a.done;a=i.next())o=a.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{a&&!a.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this._groupChannelCache.upsert(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return h(this,void 0,void 0,(function(){return d(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]}}))}))},e}(),In=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Un=new Map,wn=new Map,Ln=new Map,Dn=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,s=void 0===r?2:r,i=t.backOffDelay,a=void 0===i?0:i,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=s,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],In()?(Un[this._holdersKey]||(Un[this._holdersKey]=[]),wn[this._resolversKey]||(wn[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return h(o,void 0,void 0,(function(){var t,n;return d(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(o._resolversKey,JSON.stringify(n)),o._localAcquiredKeys.forEach((function(e){return o.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(In())return this.numLocks-Un[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return In()?wn[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(In())return Ln[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){In()?Ln[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return h(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,ne(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),In()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),h(this,void 0,void 0,(function(){var t,n=this;return d(this,(function(r){return In()?[2,new Promise((function(t){for(var r={key:te(),resolver:function(e){return t(e)},priority:e},s=wn[n._resolversKey],i=-1,a=0;as[a].priority){i=a;break}i>=0?wn[n._resolversKey].splice(i,0,r):wn[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var s=te(),i={key:s,priority:e},a={key:s,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,i),n._localResolversData.splice(o,0,a)):(t.push(i),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(In()){if((t=Un[this._holdersKey].indexOf(e))>=0)return Un[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=c([],l(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(s),!0}}return!1},e.prototype._tryResolve=function(){if(In()){if(Un[this._holdersKey].length=100,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,u.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 3:return a.sent(),[3,5];case 4:t.hasNext=!1,a.label=5;case 5:return[2,t]}}))}))})),this._nextSync=new On(c,(function(e){return h(r,void 0,void 0,(function(){var t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return a.sent(),u.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),[4,y.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(i=null===(s=this._metadata.range)||void 0===s?void 0:s.bottom)&&void 0!==i?i:e,{prevResultSize:0,nextResultSize:100,replyType:v.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},L.SYNC_MESSAGE_BACKGROUND)];case 2:return n=a.sent(),this.extendRange(n),t.hasNext=n.length>=100,t.nextToken=this._metadata.range.bottom,u.debug("message background next sync progress",t),[4,this.saveMetadata()];case 3:return a.sent(),[2,t]}}))}))}))}return e.of=function(t,n){if(Fn[t]||(Fn[t]={}),!Fn[t][n.url]){var r=Fn[t][n.url]=new e({_iid:t,channel:n});se.of(t).dispatcher.on((function(e){if(e instanceof M)if(e.stateType===T.CONNECTED)r.resume();else r.pause()}))}return Fn[t][n.url]},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},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,c([],l(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,c([],l(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return h(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,se.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new Sn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._metadata?[4,se.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.resume=function(){var e,t,n,r;se.of(this._iid).logger.debug("message background sync resume()"),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:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},e.prototype.pause=function(){se.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e}(),Hn={},Vn=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=se.of(this._iid).sdkState;this._metadataKey=(s=a.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var o=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(a.userId,this._channel.url);this._sync=new On(o,(function(){return h(r,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){switch(i.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,8]),[4,y.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:v.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includePollDetails:!0},L.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=i.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return i.sent(),[2,e];case 5:return(s=i.sent())instanceof S&&s.isInvalidTokenError?[4,this.cleatMetadata()]:[3,7];case 6:i.sent(),i.label=7;case 7:return[3,8];case 8:return[2]}}))}))}))}return e.of=function(t,n){if(Hn[t]||(Hn[t]={}),!Hn[t][n.url]){var r=Hn[t][n.url]=new e({_iid:t,channel:n});se.of(t).dispatcher.on((function(e){if(e instanceof M)if(e.stateType===T.CONNECTED)r.resume();else r.pause()}))}return Hn[t][n.url]},e.prototype.loadMetadata=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=se.of(this._iid),t=e.cacheContext,n=e.connectedAt,[4,t.store.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._metadata?[4,se.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.cleatMetadata=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){return se.of(this._iid).cacheContext.store.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),Gn=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=G.GET,c.path="".concat(ie(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),c.params=r({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!==(n=e.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(i=e.messageType)&&void 0!==i?i:null,include_reactions:null===(a=e.includeReactions)||void 0===a||a,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u}),c}return e(n,t),n}(B),qn=function(t){function n(e,n){var r,s,i,a,o=this;return(o=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return ae(e,t)})),o.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,o.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return ae(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(K),Bn=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Kn=function(e,t,n){if(e.length>0){var r=Bn(e,t);if(r<0){for(var s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};s=a+1,a=Math.floor((s+i)/2)}}return{place:zn(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},zn=function(e,t,n){switch(n){case Xe.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 Xe.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Xe.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},jn=function(e,t){if(t instanceof m)return e.findIndex((function(e){return e instanceof m&&t.isIdentical(e)}));e.findIndex((function(e){return e.isIdentical(t)}))},Qn=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(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api",e.API_ONLY="api_only"}(Rn||(Rn={}));var Yn,Jn,Wn=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Z((function(){return h(r,void 0,void 0,(function(){return d(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}(),Xn=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._iid=e,this._key="mc-".concat(te()),this.filter=null!=r?r:new Et,this._channel=n,this._syncRange=new Sn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||100;var o=Tn.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=Bn(e,a._channel);if(o>=0)switch(Z((function(){return h(a,void 0,void 0,(function(){var n;return d(this,(function(r){return n=new Pn(t),this._channel=e[o],this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case Tt.EVENT_CHANNEL_UPDATED:var u=!1;for(var c in a._messages){if((g=a._messages[c]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var l=parseInt(c);if(l>0){var _=a._messages.splice(0,l);a._removeMessagesFromView(_.map((function(e){return e.messageId})),L.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),L.EVENT_MESSAGE_OFFSET_UPDATED);break;case Tt.EVENT_CHANNEL_READ:var p=[];try{for(var m=f(a._messages),v=m.next();!v.done;v=m.next()){var g=v.value;if((N=a._readReceiptMap.get(g.messageId))>0)N!==a._channel.getUnreadMemberCount(g)&&p.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}p.length>0&&a._updateMessagesToView(p,L.EVENT_MESSAGE_READ);break;case Tt.EVENT_CHANNEL_DELIVERED:p=[];try{for(var E=f(a._messages),y=E.next();!y.done;y=E.next()){var N;g=y.value;if((N=a._deliveryReceiptMap.get(g.messageId))>0)N!==a._channel.getUndeliveredMemberCount(g)&&p.push(g)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(i=E.return)&&i.call(E)}finally{if(s)throw s.error}}p.length>0&&a._updateMessagesToView(p,L.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&Z((function(){return h(a,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new Pn(t),this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=f(e),u=o.next();!u.done;u=o.next()){var c=u.value;c.channelUrl===a._channel.url&&(a.filter.match(c)?s.push(c):i.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(oe(t)){if(s.length>0)switch(t){case L.EVENT_MESSAGE_SENT_FAILED:case L.EVENT_MESSAGE_SENT_SUCCESS:case L.EVENT_MESSAGE_UPDATED:case L.EVENT_MESSAGE_THREADINFO_UPDATED:case L.EVENT_MESSAGE_REACTION_UPDATED:case L.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case L.EVENT_MESSAGE_SENT_PENDING:case L.EVENT_MESSAGE_RECEIVED:case L.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)}}),kn.of(this._iid,this._channel).resume(),Vn.of(this._iid,this._channel).resume(),this._prevFill=new On(this._key,(function(e){return h(a,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:L.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this._syncRange.top>n,nextToken:this._syncRange.top}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._nextFill=new On(this._key,(function(e){return h(a,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{nextLimit:this._limit,source:L.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.max.apply(Math,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this._syncRange.bottom=t._channel.messageOffsetTimestamp}))},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=f(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(l.messageId>0){if((p=jn(this._messages,l))<0){var _=Qn(this._messages,l);a.push(l),this._messages.splice(_,0,l)}else o.push(l),this._messages[p]=l;this._readReceiptMap.set(l.messageId,this._channel.getUnreadMemberCount(l)),this._deliveryReceiptMap.set(l.messageId,this._channel.getUndeliveredMemberCount(l))}else{var p;if(l instanceof m)(p=jn(this._unsentMessages,l))<0?jn(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[p]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}oe(t)&&Z((function(){return h(s,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new xn(t),a.length>0&&this._handler.onMessagesAdded(e,this.channel,a),o.length>0&&this._handler.onMessagesUpdated(e,this.channel,o),[2]}))}))}))},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=f(e),o=a.next();!o.done;o=a.next()){var u,c=o.value;if(c.messageId>0)if((u=jn(this._messages,c))>=0)i.push(c),this._messages[u]=c;else{var l=jn(this._unsentMessages,c);if(l>=0){i.push(c),this._unsentMessages.splice(l,1);var _=Qn(this._messages,c);this._messages.splice(_,0,c)}}else if(c instanceof m)(u=jn(this._unsentMessages,c))>=0&&(i.push(c),this._unsentMessages[u]=c)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return oe(t)&&Z((function(){return h(s,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new xn(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(i.push(o._messages[t].messageId),o._messages.splice(t,1))},o=this;try{for(var u=f(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return oe(t)&&i.length>0&&Z((function(){return h(s,void 0,void 0,(function(){var e;return d(this,(function(n){return e=new xn(t),i.length>0&&this._handler.onMessagesDeleted(e,this.channel,i),[2]}))}))})),i},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,i=void 0===s?0:s;return h(this,void 0,void 0,(function(){var t,n,s,a,o,u,h;return d(this,(function(d){switch(d.label){case 0:return t=Tn.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return s=d.sent(),[3,3];case 2:s=[],d.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return o=d.sent(),[3,6];case 5:o=[],d.label=6;case 6:if(a=o,n.length>0&&a.length)for(h in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[h].messageId)){a.splice(parseInt(h),1);break}return[2,c(c([],l(n),!1),l(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?L.REQUEST_MESSAGE:o;return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(i){switch(i.label){case 0:return t=y.of(this._iid),r>0||a>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=[],i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,f,_,p=this;return d(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(e=this.viewTop,t=this._syncRange.top,n=this._syncRange.bottom,r=Number.MAX_SAFE_INTEGER,[4,(i=Tn.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return a=m.sent(),[4,i.getCachedMessageCountBetween(this._channel.url,this.filter,n,r)];case 2:return o=m.sent(),[4,ue((function(){return h(p,void 0,void 0,(function(){var i,u,f,_,p,m,v,g,E,y,N,C,b,A,S,M,T,I=this;return d(this,(function(U){switch(U.label){case 0:return i=se.of(this._iid),u=i.dispatcher,f=i.requestQueue,_=new Gn(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:a,nextStart:n,nextEnd:r,nextCount:o},this.filter)),[4,f.send(_)];case 1:return p=U.sent(),m=p.as(qn),v=m.isHugeGap,g=m.prevMessages,E=void 0===g?[]:g,y=m.prevHasMore,N=m.nextMessages,C=void 0===N?[]:N,b=m.nextHasmore,v?Z((function(){return h(I,void 0,void 0,(function(){return d(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=y,this._hasNext=b,A=this.viewTop,S=this.viewBottom,M=Math.min.apply(Math,c([Number.MAX_SAFE_INTEGER],l(E.map((function(e){return e.createdAt}))),!1)),T=Math.max.apply(Math,c([0],l(C.map((function(e){return e.createdAt}))),!1)),u.dispatch(new w({messages:E,source:L.SYNC_MESSAGE_FILL})),u.dispatch(new w({messages:C,source:L.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,T),AT&&this._nextFill.start(T)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return u=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:u,nextLimit:u,source:L.SYNC_MESSAGE_FILL})];case 5:(f=m.sent()).length>0&&((_=this._syncRange).extends.apply(_,c([],l(f.map((function(e){return e.createdAt}))),!1)),f.length0&&((s=t._syncRange).extends.apply(s,c([],l(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,L.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(X(e))throw e;n._invokeResponse("remote",e,null)}))}));break;case Rn.API_ONLY:this._getRemoteMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){var s,i=t._filterUnderOffsetMessage(e);i.length0&&((s=t._syncRange).extends.apply(s,c([],l(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,L.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(X(e))throw e;n._invokeResponse("remote",e,null)}))}return n},e.prototype.loadPrevious=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s=this;return d(this,(function(i){switch(i.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,F((function(){return h(s,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return i.sent(),n=kn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,F((function(){return h(s,void 0,void 0,(function(){var r,s;return d(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,c([],l(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,L.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,L.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s=this;return d(this,(function(i){switch(i.label){case 0:return e=this.viewBottom,t=[],[4,F((function(){return h(s,void 0,void 0,(function(){var n;return d(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{nextLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),n=kn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,F((function(){return h(s,void 0,void 0,(function(){var r,s;return d(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{nextLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasNext=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,c([],l(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,L.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,c([],l(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,L.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t]}}))}))},e.prototype.removeFailedMessage=function(e){return h(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return[4,Tn.of(this._iid).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=Tn.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},e}(),Zn=function(){this.coverUrl=null,this.coverImage=null,this.isDistinct=null,this.isPublic=null,this.isDiscoverable=null,this.accessCode=null,this.name=null,this.data=null,this.customType=null,this.operatorUserIds=null,this.messageSurvivalSeconds=null},$n=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return O("string",this.coverUrl,!0)&&(P(this.coverImage)||O("string",this.coverImage)||null===this.coverImage)&&O("boolean",this.isDistinct,!0)&&O("boolean",this.isPublic,!0)&&O("boolean",this.isDiscoverable,!0)&&O("string",this.accessCode,!0)&&O("string",this.name,!0)&&O("string",this.data,!0)&&O("string",this.customType,!0)&&R("string",this.operatorUserIds,!0)&&O("number",this.messageSurvivalSeconds,!0)},n}(Zn),er=function(){this.hidePreviousMessages=!1,this.allowAutoUnhide=!0},tr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return O("boolean",this.hidePreviousMessages)&&O("boolean",this.allowAutoUnhide)},n}(er),nr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=G.GET,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,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}(B),rr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.members=[];var s=n.next,i=n.members;return r.token=s,i&&i.length>0&&(r.members=i.map((function(t){return new et(e,t)}))),r}return e(n,t),n}(K);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Yn||(Yn={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Jn||(Jn={}));var sr=function(n){function r(e,t,r){var s,a,o,u,c=this;return(c=n.call(this,e,t,i.GROUP,r)||this).mutedMemberFilter=Yn.ALL,c.memberStateFilter=rt.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=ot.ALL,c.order=Jn.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Yn.ALL,c.memberStateFilter=null!==(a=r.memberStateFilter)&&void 0!==a?a:rt.ALL,c.nicknameStartsWithFilter=null!==(o=r.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=r.order)&&void 0!==u?u:Jn.MEMBER_NICKNAME_ALPHABETICAL,c}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&t(Yn,this.mutedMemberFilter)&&t(rt,this.memberStateFilter)&&(O("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&t(ot,this.operatorFilter)&&t(Jn,this.order)},r.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,a;return d(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=se.of(this._iid).requestQueue,t=new nr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(rr),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw S.queryInProgress;case 4:return[3,6];case 5:throw S.invalidParameters;case 6:return[2]}}))}))},r}(ce),ir=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(B),ar=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new xr(e,n),r.channel.myMemberState=We.JOINED,r}return e(n,t),n}(K),or=function(t){function n(e){var n=this,r=e.channelUrl,s=e.isDistinct,i=e.isPublic,a=e.isDiscoverable,o=e.coverUrl,u=e.coverImage,c=e.accessCode,l=e.name,h=e.data,d=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r)),n.params={is_distinct:s,is_public:i,is_discoverable:a,name:l,data:h,custom_type:d,cover_url:o,cover_file:u,access_code:c,operator_ids:f,message_survival_seconds:_},n}return e(n,t),n}(B),ur=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new xr(e,n),r}return e(n,t),n}(K),cr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=G.DELETE,n.path="".concat(j,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(B);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(K);var lr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=G.DELETE,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(B);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(K);var hr=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=G.GET,r.path="".concat(q,"/").concat(encodeURIComponent(n),"/push_preference"),r}return e(n,t),n}(B),dr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(K),fr=function(t){function n(e){var n=e.userId,r=e.pushTriggerOption,s=t.call(this)||this;return s.method=G.PUT,s.path="".concat(q,"/").concat(encodeURIComponent(n),"/push_preference"),s.params={push_trigger_option:r},s}return e(n,t),n}(B),_r=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(K),pr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=G.PUT,i.path="".concat(q,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(B),mr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=wr[n.count_preference],r}return e(n,t),n}(K),vr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=G.PUT,n.path="".concat(j,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(B),gr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(K),Er=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return new C(this).validate()&&O("number",this.scheduledAt)},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e}return e(n,t),n}(le)),yr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl;return n.method=G.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages"),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(B),Nr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new g(e,n),r}return e(n,t),n}(K),Cr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),Object.defineProperty(n.prototype,"fileUrl",{get:function(){return O("string",this.file)?this.file:null},set:function(e){O("string",e)&&(this.file=e)},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return new _e(this).validate()&&O("number",this.scheduledAt)&&(P(this.file)||O("string",this.fileUrl))&&O("string",this.fileName,!0)&&O("string",this.mimeType,!0)&&O("number",this.fileSize,!0)&&(null===this.thumbnailSizes||this.thumbnailSizes.every((function(e){return O("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e.file=null,e.fileName=null,e.mimeType=null,e.fileSize=null,e.thumbnailSizes=null,e._requireAuth=!1,e}return e(n,t),n}(pe)),br=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl;return n.method=G.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages"),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return me.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(B),Ar=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new E(e,n),r}return e(n,t),n}(K),Sr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),Object.defineProperty(n.prototype,"fileUrl",{get:function(){return O("string",this.file)?this.file:null},set:function(e){O("string",e)&&(this.file=e)},enumerable:!1,configurable:!0}),n.prototype.validate=function(){return new ve(this).validate()&&(O("number",this.scheduledAt)||null===this.scheduledAt)&&(P(this.file)||O("string",this.fileUrl))&&(O("string",this.fileName)||null===this.fileName)&&(O("string",this.mimeType)||null===this.mimeType)&&(O("number",this.fileSize)||null===this.fileSize)&&(null===this.thumbnailSizes||this.thumbnailSizes.every((function(e){return O("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e.file=null,e.fileName=null,e.mimeType=null,e.fileSize=null,e.thumbnailSizes=null,e._requireAuth=!1,e}return e(n,t),n}(ge)),Mr=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return new Ee(this).validate()&&(O("number",this.scheduledAt)||null===this.scheduledAt)},n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.scheduledAt=null,e}return e(n,t),n}(ye)),Tr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=G.PUT,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return me.payloadify(e)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(B),Ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new E(e,n),r}return e(n,t),n}(K),Ur=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=G.PUT,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,sorted_metaarray:e.metaArrays.map((function(e){return de.payloadify(e)})),apple_critical_alert_options:fe.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},n}return e(n,t),n}(B);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new g(e,n),r}e(n,t)}(K);var wr,Lr,Dr,Rr,Or=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=G.DELETE,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(B),Pr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=G.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(B);!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"}(wr||(wr={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(Lr||(Lr={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Dr||(Dr={})),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"}(Rr||(Rr={}));var xr=function(o){function u(e,r){var u,h,d,f,_,p,m,v,g,E,y,N,C,b,A,S,M,T,I=this;return(I=o.call(this,e,r)||this)._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.isAccessCodeRequired=!1,I.isPushEnabled=!1,I.unreadMessageCount=0,I.unreadMentionCount=0,I.members=[],I.memberCount=0,I.joinedMemberCount=0,I.hiddenState=Dr.UNHIDDEN,I.lastMessage=null,I.messageOffsetTimestamp=0,I.messageSurvivalSeconds=-1,I.myMemberState=We.NONE,I.myRole=n.NONE,I.myMutedState=Lr.UNMUTED,I.myLastRead=0,I.myCountPreference=wr.ALL,I.myPushTriggerOption=Qe.DEFAULT,I.inviter=null,I.invitedAt=0,I.joinedAt=0,I.channelType=i.GROUP,I.isDistinct=null!==(h=r.is_distinct)&&void 0!==h&&h,I.isSuper=null!==(d=r.is_super)&&void 0!==d&&d,I.isBroadcast=null!==(f=r.is_broadcast)&&void 0!==f&&f,I.isExclusive=null!==(_=r.is_exclusive)&&void 0!==_&&_,I.isPublic=null!==(p=r.is_public)&&void 0!==p&&p,I.isDiscoverable=null!==(m=r.is_discoverable)&&void 0!==m?m:I.isPublic,I.isAccessCodeRequired=null!==(v=r.is_access_code_required)&&void 0!==v&&v,I.isPushEnabled=null!==(g=r.is_push_enabled)&&void 0!==g&&g,Array.isArray(r.members)&&(u=I.members).push.apply(u,c([],l(r.members.map((function(e){return new et(I._iid,e)}))),!1)),I.memberCount=null!==(E=r.member_count)&&void 0!==E?E:0,I.joinedMemberCount=null!==(y=r.joined_member_count)&&void 0!==y?y:0,I.hiddenState=t(Dr,r.hidden_state)?r.hidden_state:Dr.UNHIDDEN,I.messageOffsetTimestamp=null!==(N=r.ts_message_offset)&&void 0!==N?N:0,I.messageSurvivalSeconds=null!==(C=r.message_survival_seconds)&&void 0!==C?C:-1,I.lastMessage=r.last_message?ae(I._iid,s({channel_type:I.channelType},r.last_message)):null,r.read_receipt&&Object.keys(r.read_receipt).forEach((function(e){O("number",r.read_receipt[e])&&I._updateUnreadMemberState(e,r.read_receipt[e])})),r.delivery_receipt&&Object.keys(r.delivery_receipt).forEach((function(e){O("number",r.delivery_receipt[e])&&I._updateUndeliveredMemberState(e,r.delivery_receipt[e])})),I.myMemberState=t(We,r.member_state)?r.member_state:We.NONE,I.myRole=t(n,r.my_role)?r.my_role:n.NONE,t(Lr,r.is_muted)?I.myMutedState=r.is_muted:O("boolean",r.is_muted)?I.myMutedState=r.is_muted?Lr.MUTED:Lr.UNMUTED:I.myMutedState=Lr.UNMUTED,I.myCountPreference=t(wr,r.count_preference)?r.count_preference:wr.ALL,I.myPushTriggerOption=t(Qe,r.push_trigger_option)?r.push_trigger_option:Qe.ALL,I.myLastRead=null!==(b=r.user_last_read)&&void 0!==b?b:0,I.inviter=r.inviter?new a(I._iid,r.inviter):null,I.invitedAt=null!==(A=r.invited_at)&&void 0!==A?A:0,I.joinedAt=null!==(S=r.joined_ts)&&void 0!==S?S:0,I._updateUnreadCount(null!==(M=r.unread_message_count)&&void 0!==M?M:0,null!==(T=r.unread_mention_count)&&void 0!==T?T:0),I}return e(u,o),Object.defineProperty(u.prototype,"isHidden",{get:function(){return this.hiddenState!==Dr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=l(s.value,2),a=i[0],o=i[1];n[a]=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(u.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=l(s.value,2),a=i[0],o=i[1];n[a]=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}),u.payloadify=function(e){return e?r(s(s({},o.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 et.payloadify(e)})),last_message:Ne(e.lastMessage),inviter:e.inviter?a.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},u.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===wr.ALL||this.myCountPreference===wr.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=se.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===wr.ALL||this.myCountPreference===wr.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},u.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},u.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},u.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},u.prototype.isReadMessage=function(e){var t=se.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},u.prototype.serialize=function(){var e=this;return Y(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},u.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Xn(this._iid,s({channel:this},e))},u.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new sr(this._iid,this.url,e)},u.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===We.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)}},u.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},u.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof m&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=se.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=f(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===We.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&s.push(i))})),s},u.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=se.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=[];return this.members.forEach((function(i){(t||i.userId!==r.userId&&i.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(i.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},u.prototype.refresh=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return e=se.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new Kt({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(zt).channel,n.dispatch(new xt({channels:[i],source:Tt.REQUEST_CHANNEL})),[2,i]}}))}))},u.prototype.freeze=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,o.prototype.freeze.call(this)];case 1:return e.sent(),se.of(this._iid).dispatcher.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},u.prototype.unfreeze=function(){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,o.prototype.unfreeze.call(this)];case 1:return e.sent(),se.of(this._iid).dispatcher.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},u.prototype.updateChannel=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,a,o;return d(this,(function(u){switch(u.label){case 0:return ee(e instanceof $n&&e.validate()).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new or(s({channelUrl:this.url},e)),[4,r.send(i)];case 1:return a=u.sent(),o=a.as(ur).channel,n.dispatch(new xt({channels:[o],source:Tt.EVENT_CHANNEL_UPDATED})),[2,o]}}))}))},u.prototype.invite=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){return ee(e.every((function(e){return e instanceof a}))).throw(S.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},u.prototype.inviteWithUserIds=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a;return d(this,(function(o){switch(o.label){case 0:return ee(R("string",e)).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new sn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(an).channel,n.dispatch(new xt({channels:[a],source:Tt.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},u.prototype.join=function(e){return void 0===e&&(e=null),h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return ee(O("string",e)||null===e).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new $t({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(en).channel).myMemberState=We.JOINED,n.dispatch(new xt({channels:[o],source:Tt.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},u.prototype.leave=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new nn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},u.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return d(this,(function(u){switch(u.label){case 0:return ee(O("string",e)||null===e).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new ir({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(ar).channel).myMemberState=We.JOINED,n.dispatch(new xt({channels:[o],source:Tt.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,o]}}))}))},u.prototype.declineInvitation=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new un({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),(i=s.as(cn).channel).myMemberState=We.NONE,[2,i]}}))}))},u.prototype.sendUserMessage=function(e){var t=this,n=new Ce,r=se.of(this._iid).dispatcher;return o.prototype.sendUserMessage.call(this,e).onPending((function(e){Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){r&&Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r);n._trigger(e,r)})).onSucceeded((function(e){var s=Tn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new xt({channels:[t],source:Tt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendUserMessage=function(e){var t=this,n=new Ce,r=se.of(this._iid).dispatcher;return o.prototype._autoResendUserMessage.call(this,e).onPending((function(e){Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r),n._trigger(e,r)})).onSucceeded((function(e){var s=Tn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new xt({channels:[t],source:Tt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.sendFileMessage=function(e){var t=this,n=new Ce,r=se.of(this._iid).dispatcher;return o.prototype.sendFileMessage.call(this,e).onPending((function(e){Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){r&&Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r);n._trigger(e,r)})).onSucceeded((function(e){var s=Tn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new xt({channels:[t],source:Tt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendFileMessage=function(e){var t=this,n=new Ce,r=se.of(this._iid).dispatcher;return o.prototype._autoResendFileMessage.call(this,e).onPending((function(e){Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,r){Tn.of(t._iid).autoResendManager.completeCurrentAndProcessNextAutoResend(r),n._trigger(e,r)})).onSucceeded((function(e){var s=Tn.of(t._iid);s.autoResendManager.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,s.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new xt({channels:[t],source:Tt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.deleteMessage=function(e){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,o.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&se.of(this._iid).dispatcher.dispatch(new k({reqId:e.reqId,source:L.EVENT_MESSAGE_DELETED})),[2]}}))}))},u.prototype.hide=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return d(this,(function(c){switch(c.label){case 0:return ee(e instanceof tr&&e.validate()).throw(S.invalidParameters),t=se.of(this._iid),n=t.dispatcher,r=t.sdkState,i=t.requestQueue,a=new mn(s({channelUrl:this.url,userId:r.userId},e)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(vn).messageOffsetTimestamp,this.hiddenState=e.allowAutoUnhide?Dr.HIDDEN_ALLOW_AUTO_UNHIDE:Dr.HIDDEN_PREVENT_AUTO_UNHIDE,e.hidePreviousMessages&&this._updateUnreadCount(0,0),u&&(this.messageOffsetTimestamp=u),n.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},u.prototype.unhide=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return e=se.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new lr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=Dr.UNHIDDEN,t.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},u.prototype.delete=function(){return h(this,void 0,void 0,(function(){var e,t;return d(this,(function(n){switch(n.label){case 0:return e=se.of(this._iid).requestQueue,t=new cr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.markAsRead=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return d(this,(function(u){switch(u.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new hn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(dn).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Tn.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_READ})),[2]}}))}))},u.prototype.markAsDelivered=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return d(this,(function(s){switch(s.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new fn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},u.prototype.startTyping=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){return e=se.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new En({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},u.prototype.endTyping=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){return e=se.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Nn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},u.prototype.createScheduledUserMessage=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return d(this,(function(i){switch(i.label){case 0:return ee(e instanceof Er&&e.validate()).throw(S.invalidParameters),t=se.of(this._iid).requestQueue,n=new yr(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e)),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Nr).message]}}))}))},u.prototype.updateScheduledUserMessage=function(e,t){return h(this,void 0,void 0,(function(){var n,r,i;return d(this,(function(a){switch(a.label){case 0:return ee(t instanceof Mr&&t.validate()).throw(S.invalidParameters),n=se.of(this._iid).requestQueue,r=new Ur(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t)),[4,n.send(r)];case 1:return i=a.sent(),[2,i.as(Nr).message]}}))}))},u.prototype.createScheduledFileMessage=function(e){return h(this,void 0,void 0,(function(){var t,n;return d(this,(function(r){switch(r.label){case 0:return ee(e instanceof Cr&&e.validate()).throw(S.invalidParameters),P(e.file)?[4,this._uploadFileAndUpdateParams(e)]:[3,2];case 1:r.sent(),r.label=2;case 2:return t=new br(s(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e._requireAuth})),[4,se.of(this._iid).requestQueue.send(t)];case 3:return n=r.sent(),[2,n.as(Ar).message]}}))}))},u.prototype.updateScheduledFileMessage=function(e,t){return h(this,void 0,void 0,(function(){var n,r;return d(this,(function(i){switch(i.label){case 0:return ee(t instanceof Sr&&t.validate()).throw(S.invalidParameters),P(t.file)?[4,this._uploadFileAndUpdateParams(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return n=new Tr(s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t),{fileUrl:t.fileUrl,requireAuth:t._requireAuth})),[4,se.of(this._iid).requestQueue.send(n)];case 3:return r=i.sent(),[2,r.as(Ir).message]}}))}))},u.prototype.cancelScheduledMessage=function(e){return h(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return t=new Or({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,se.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.sendScheduledMessageNow=function(e){return h(this,void 0,void 0,(function(){var t;return d(this,(function(n){switch(n.label){case 0:return t=new Pr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,se.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.getMyPushTriggerOption=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s;return d(this,(function(i){switch(i.label){case 0:return e=se.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new hr({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(dr).pushTriggerOption]}}))}))},u.prototype.setMyPushTriggerOption=function(e){return h(this,void 0,void 0,(function(){var n,r,s,i,a;return d(this,(function(o){switch(o.label){case 0:return ee(t(Qe,e)).throw(S.invalidParameters),n=se.of(this._iid),r=n.sdkState,s=n.requestQueue,i=new fr({userId:r.userId,pushTriggerOption:e}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(_r).pushTriggerOption]}}))}))},u.prototype.setMyCountPreference=function(e){return h(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return d(this,(function(c){switch(c.label){case 0:return ee(t(wr,e)).throw(S.invalidParameters),n=se.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new pr({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(mr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_CREATED})),[2,u]}}))}))},u.prototype.resetMyHistory=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,s,i;return d(this,(function(a){switch(a.label){case 0:return e=se.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new vr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(gr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new xt({channels:[this],source:Tt.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},u.prototype._uploadFileAndUpdateParams=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return d(this,(function(d){switch(d.label){case 0:return P(e.file)?(t=se.of(this._iid).requestQueue,n=new Ae({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(be),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=c,e._requireAuth=h,d.label=2;case 2:return[2]}}))}))},u}(ze);export{et as $,nt as A,xr as B,Ze as C,kt as D,xt as E,$e as F,Xe as G,An as H,Ot as I,wt as J,wr as K,Lt as L,ht as M,_t as N,Ut as O,Ye as P,Rt as Q,tr as R,st as S,Sn as T,Rr as U,er as V,ct as W,$n as X,Zn as Y,at as Z,Dr as _,pt as a,Jn as a0,sr as a1,We as a2,rt as a3,Xn as a4,Wn as a5,Rn as a6,xn as a7,Et as a8,Lr as a9,ot as aa,ut as ab,tt as ac,it as ad,mt as b,vt as c,Nt as d,bt as e,At as f,lt as g,Gt as h,yt as i,It as j,je as k,dr as l,hr as m,_r as n,Qe as o,fr as p,Je as q,On as r,Tn as s,Tt as t,Dt as u,Kn as v,Pt as w,dt as x,ft as y,Pn as z}; diff --git a/groupChannel.js b/groupChannel.js index 2ecc7b2..d46aa8d 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{d as e,e as n,V as a,ae as r,af as i,S as s,q as o,o as l,p as h,F as c,J as d,j as p,a6 as m,_ as f,n as v,A as y,ab as g,g as b,h as w,k,a as F,b as M,c as E,B as T,t as N,ao as P,s as D,M as j,x as q,aY as ee}from"./__bundle-368767fc.js";export{ai as MessageEventSource}from"./__bundle-368767fc.js";import{r as te,s as ne,G as ae,t as re,T as ie,u as se,v as oe,w as ue,x as le,y as he,z as ce,A as de,B as pe,S as me,C as fe,E as ve,F as _e,H as ye,I as ge,J as Ce}from"./__bundle-083b498b.js";export{K as CountPreference,B as GroupChannel,u as GroupChannelChangeLogsParams,L as GroupChannelChangeLogsParamsProperties,I as GroupChannelCountParams,Q as GroupChannelCountParamsProperties,J as GroupChannelCreateParams,O as GroupChannelCreateParamsProperties,z as GroupChannelEventContext,t as GroupChannelEventSource,x as GroupChannelFilter,R as GroupChannelHideParams,V as GroupChannelHideParamsProperties,G as GroupChannelListOrder,H as GroupChannelListQuery,W as GroupChannelSearchField,X as GroupChannelUpdateParams,Y as GroupChannelUpdateParamsProperties,Z as HiddenChannelFilter,_ as HiddenState,$ as Member,a0 as MemberListOrder,a1 as MemberListQuery,a2 as MemberState,a3 as MemberStateFilter,a4 as MessageCollection,a5 as MessageCollectionInitHandler,a6 as MessageCollectionInitPolicy,a7 as MessageEventContext,a8 as MessageFilter,a9 as MutedState,aa as OperatorFilter,A as PublicChannelFilter,C as PublicGroupChannelListOrder,ab as QueryType,ac as ReadStatus,S as SuperChannelFilter,ad as UnreadChannelFilter,U as UnreadItemKey}from"./__bundle-083b498b.js";import{B as be}from"./__bundle-96ae73c1.js";import"./__bundle-72d7e125.js";var we,ke={},Fe=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadata=null,this._iid=r;var u,h=a.of(this._iid),c=h.sdkState,d=h.logger;this._metadataKey=(u=c.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new te(p,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i,u;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(n.sent(),d.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:ae.CHRONOLOGICAL},100,re.SYNC_CHANNEL_BACKGROUND)];case 3:return t=n.sent(),a=t.channels,r=t.token,e.hasNext=a.length>=100&&!!r,e.nextToken=r,this._metadata.token=r,(u=this._metadata.range).extends.apply(u,o([],l(a.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:n.sent(),n.label=7;case 7:return[3,8];case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",n.label=10;case 10:return[2,e]}}))}))}))}return t.of=function(e){if(!ke[e]){var n=ke[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return ke[e]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new ie(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,a.of(this._iid).cacheContext.store.remove(this._metadataKey)];case 1:return e.sent(),[2]}}))}))},t.prototype.resume=function(){var e,t;a.of(this._iid).logger.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:"")},t.prototype.pause=function(){a.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t}(),Me={},Le=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=r;var o,u=a.of(this._iid).sdkState;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new te(l,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,new se,re.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=n.sent(),a=t.hasMore,r=t.token,e.hasNext=a,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:n.sent(),n.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return t.of=function(e){if(!Me[e]){var n=Me[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return Me[e]},t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:""},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return a.of(this._iid).cacheContext.store.remove(this._metadataKey),[2]}))}))},t.prototype.resume=function(){this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t}(),Se=function(){function t(e,t){var n=t.filter,r=t.order,i=t.limit,s=this;this.channels=[],this._iid=e,this._key="gcc-".concat(d()),this.filter=null!=n?n:new le,this.order=null!=r?r:ae.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=i?i:he,Fe.of(e).resume(),Le.of(e).resume();var o=a.of(this._iid).sdkState;ne.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return s.filter.match(e,o.userId)})),a=e.filter((function(e){return!s.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),a.length>0&&s._removeChannelsFromView(a,t)},onRemove:function(e,t){s._removeChannelsFromView(e,t)}})}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,a,r){var i,s,o=this;void 0===r&&(r=!1);var u=[],l=[];try{for(var d=h(t),p=d.next();!p.done;p=d.next()){var m=p.value,f=oe(this.channels,m,this.order),v=f.place;if(f.contains)switch(l.push(m),a){case re.EVENT_CHANNEL_UPDATED:case re.EVENT_MESSAGE_RECEIVED:this.channels.splice(v,1);var _=oe(this.channels,m,this.order).place;this.channels.splice(_,0,m);break;default:this.channels[v]=m}else if(v===this.channels.length){var y=Fe.of(this._iid);(r||y.completed)&&(u.push(m),this.channels.push(m))}else u.push(m),this.channels.splice(v,0,m)}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}ue(a)&&c((function(){return e(o,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),u.length>0&&this._handler.onChannelsAdded(e,u),l.length>0&&this._handler.onChannelsUpdated(e,l),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,a){var r,i,s=this,o=[],u=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var d=h(t),p=d.next();!p.done;p=d.next()){u(p.value)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}return ue(a)&&o.length>0&&c((function(){return e(s,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),this._handler.onChannelsDeleted(e,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,ne.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,a;return n(this,(function(n){switch(n.label){case 0:return[4,ne.of(this._iid).getMyGroupChannels(this._token,p(p({},this.filter),{order:this.order}),this._limit)];case 1:return e=n.sent(),t=e.channels,a=e.token,this._token=a,[2,t]}}))}))},t.prototype.loadMore=function(){return e(this,void 0,void 0,(function(){var t,a=this;return n(this,(function(r){switch(r.label){case 0:return this._hasMore?(t=[],[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,3];case 1:return r.sent(),[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))];case 2:return r.sent(),this._addChannelsToView(t,re.REQUEST_CHANNEL,!0),[2,t];case 3:return[2,[]]}}))}))},t.prototype.dispose=function(){ne.of(this._iid).unsubscribeGroupChannelEvent(this._key)},t}(),Ge=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 f(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=v,t.onUserLeft=v,t.onUserReceivedInvitation=v,t.onUserDeclinedInvitation=v,t.onChannelHidden=v,t.onUnreadMemberStatusUpdated=v,t.onUndeliveredMemberStatusUpdated=v,t.onTypingStatusUpdated=v,t}return f(t,e),t}(be)),Ee=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,u=t.channelNameContainsFilter,l=t.channelUrlsFilter,h=t.customTypesFilter,c=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,m=t.metadataKey,f=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,C=t.includeMetaData;return(n=e.call(this)||this).method=y.GET,n.path=g,n.params=b({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:de.PUBLIC,public_membership_mode:o,name_contains:u,channel_urls:l,custom_types:h,custom_type_startswith:c,super_mode:d,metadata_order_key:p,metadata_key:m,metadata_values:f,metadata_value_startswith:v,show_frozen:_,show_metadata:C}),n}return f(t,e),t}(w),Te=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.channels=[],a.ts=null;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 pe(t,e)}))),a.ts="number"==typeof s?s:null,a}return f(t,e),t}(k);!function(e){e.ALL="all",e.JOINED="joined"}(we||(we={}));var xe=function(t){function r(e,n){var a,r,i,s,o,u,l,h,c,d,p,m,f,v,_=this;return(_=t.call(this,e,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.nicknameContainsFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=we.ALL,_.superChannelFilter=me.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=fe.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!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,_.channelNameContainsFilter=null!==(l=n.channelNameContainsFilter)&&void 0!==l?l:null,_.membershipFilter=null!==(h=n.membershipFilter)&&void 0!==h?h:we.ALL,_.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:me.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(m=n.metadataOrderKeyFilter)&&void 0!==m?m:null,_.metadataValueStartsWith=null!==(f=n.metadataValueStartsWith)&&void 0!==f?f:null,_.order=null!==(v=n.order)&&void 0!==v?v:fe.CHRONOLOGICAL,_}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("boolean",this.includeEmpty)&&F("boolean",this.includeFrozen)&&F("boolean",this.includeMetaData)&&F("string",this.channelNameContainsFilter,!0)&&M("string",this.channelUrlsFilter,!0)&&M("string",this.customTypesFilter,!0)&&F("string",this.customTypeStartsWithFilter,!0)&&E(we,this.membershipFilter)&&E(me,this.superChannelFilter)&&E(fe,this.order)&&F("string",this.metadataOrderKeyFilter,!0)&&F("string",this.metadataKey,!0)&&M("string",this.metadataValues,!0)&&F("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u,l,h,c;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=a.of(this._iid),r=t.requestQueue,i=t.dispatcher,o=new Ee(p(p({},this),{token:this._token})),[4,r.send(o)]):[3,2]):[3,5];case 1:return u=n.sent(),l=u.as(Te),h=l.channels,c=l.token,this._token=c,this._hasNext=!!c,i.dispatch(new ve({channels:h,source:re.REQUEST_CHANNEL})),this._isLoading=!1,[2,h];case 2:return[2,e];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ne=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,u=t.messageTypeFilter,l=t.scheduledStatus;return(n=e.call(this)||this).method=y.GET,n.path="".concat(N),n.params=b({limit:r,reverse:s,channel_url:o,order:i,status:l}),a&&(n.params.token=a),u&&(n.params.message_type_filter=u),n}return f(t,e),t}(w),Pe=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return P(t,e)})),a}return f(t,e),t}(k),Ae=function(t){function r(e,n){var a,r,i,s,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=j.ALL,u.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,u.order=null!==(r=n.order)&&void 0!==r?r:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:j.ALL,u}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("string",this.channelUrl,!0)&&(E(_e,this.order)||null===this.order)&&F("boolean",this.reverse)&&(M(D,this.scheduledStatus)||null===this.scheduledStatus)&&E(j,this.messageTypeFilter)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=a.of(this._iid).requestQueue,t=new Ne(p(p({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=n.sent(),i=r.as(Pe),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ue=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return f(a,t),a.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new ne(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},a.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Se(this._iid,e)},a.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ye(this._iid,e)},a.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},a.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ae(this._iid,e)},a.prototype.addGroupChannelHandler=function(e,t){q(F("string",e)&&t instanceof Ge).throw(s.invalidParameters),this._manager.addHandler(e,t)},a.prototype.removeGroupChannelHandler=function(e){q(F("string",e)).throw(s.invalidParameters),this._manager.removeHandler(e)},a.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},a.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},a.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},a.prototype.getChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannel(t)]}))}))},a.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},a.prototype.getMyGroupChannelChangeLogsByToken=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("number",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof ge&&t.validate()).throw(s.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},a.prototype.createChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),[2,this._manager.createChannel(t)]}))}))},a.prototype.createDistinctChannelIfNotExist=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},a.prototype.createChannelWithUserIds=function(t,a,r,i,s,o){return void 0===a&&(a=!1),void 0===r&&(r=null),void 0===i&&(i=null),void 0===s&&(s=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=new Ce).addUserIds(t),e.isDistinct=a,e.name=r,e.data=s,e.customType=o,"string"==typeof i?e.coverUrl=i:e.coverImage=i,[2,this.createChannel(e)]}))}))},a.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},a.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(M("string",t)).throw(s.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},a.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)).throw(s.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},a}(ee);export{Se as GroupChannelCollection,Ge as GroupChannelHandler,Ue as GroupChannelModule,xe as PublicGroupChannelListQuery}; +import{d as e,e as n,V as a,a5 as r,a6 as i,S as s,q as o,o as l,p as h,F as c,J as d,j as p,ad as m,_ as f,n as v,A as y,ah as g,g as b,h as w,k,a as F,b as M,c as E,B as T,t as N,ao as P,s as D,M as j,x as q,aZ as ee}from"./__bundle-45e61fc8.js";export{aa as MessageEventSource}from"./__bundle-45e61fc8.js";import{r as te,s as ne,G as ae,t as re,T as ie,u as se,v as oe,w as ue,x as le,y as he,z as ce,A as de,B as pe,S as me,C as fe,E as ve,F as _e,H as ye,I as ge,J as Ce}from"./__bundle-fd9b6bb9.js";export{K as CountPreference,B as GroupChannel,u as GroupChannelChangeLogsParams,L as GroupChannelChangeLogsParamsProperties,I as GroupChannelCountParams,Q as GroupChannelCountParamsProperties,J as GroupChannelCreateParams,O as GroupChannelCreateParamsProperties,z as GroupChannelEventContext,t as GroupChannelEventSource,x as GroupChannelFilter,R as GroupChannelHideParams,V as GroupChannelHideParamsProperties,G as GroupChannelListOrder,H as GroupChannelListQuery,W as GroupChannelSearchField,X as GroupChannelUpdateParams,Y as GroupChannelUpdateParamsProperties,Z as HiddenChannelFilter,_ as HiddenState,$ as Member,a0 as MemberListOrder,a1 as MemberListQuery,a2 as MemberState,a3 as MemberStateFilter,a4 as MessageCollection,a5 as MessageCollectionInitHandler,a6 as MessageCollectionInitPolicy,a7 as MessageEventContext,a8 as MessageFilter,a9 as MutedState,aa as OperatorFilter,A as PublicChannelFilter,C as PublicGroupChannelListOrder,ab as QueryType,ac as ReadStatus,S as SuperChannelFilter,ad as UnreadChannelFilter,U as UnreadItemKey}from"./__bundle-fd9b6bb9.js";import{B as be}from"./__bundle-2ae23ac6.js";import"./__bundle-876572c8.js";var we,ke={},Fe=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadata=null,this._iid=r;var u,h=a.of(this._iid),c=h.sdkState,d=h.logger;this._metadataKey=(u=c.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new te(p,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i,u;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(n.sent(),d.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:ae.CHRONOLOGICAL},100,re.SYNC_CHANNEL_BACKGROUND)];case 3:return t=n.sent(),a=t.channels,r=t.token,e.hasNext=a.length>=100&&!!r,e.nextToken=r,this._metadata.token=r,(u=this._metadata.range).extends.apply(u,o([],l(a.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:n.sent(),n.label=7;case 7:return[3,8];case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",n.label=10;case 10:return[2,e]}}))}))}))}return t.of=function(e){if(!ke[e]){var n=ke[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return ke[e]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new ie(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,a.of(this._iid).cacheContext.store.remove(this._metadataKey)];case 1:return e.sent(),[2]}}))}))},t.prototype.resume=function(){var e,t;a.of(this._iid).logger.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:"")},t.prototype.pause=function(){a.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t}(),Me={},Le=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=r;var o,u=a.of(this._iid).sdkState;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new te(l,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,new se,re.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=n.sent(),a=t.hasMore,r=t.token,e.hasNext=a,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:n.sent(),n.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return t.of=function(e){if(!Me[e]){var n=Me[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return Me[e]},t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:""},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return a.of(this._iid).cacheContext.store.remove(this._metadataKey),[2]}))}))},t.prototype.resume=function(){this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t}(),Se=function(){function t(e,t){var n=t.filter,r=t.order,i=t.limit,s=this;this.channels=[],this._iid=e,this._key="gcc-".concat(d()),this.filter=null!=n?n:new le,this.order=null!=r?r:ae.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=i?i:he,Fe.of(e).resume(),Le.of(e).resume();var o=a.of(this._iid).sdkState;ne.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return s.filter.match(e,o.userId)})),a=e.filter((function(e){return!s.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),a.length>0&&s._removeChannelsFromView(a,t)},onRemove:function(e,t){s._removeChannelsFromView(e,t)}})}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,a,r){var i,s,o=this;void 0===r&&(r=!1);var u=[],l=[];try{for(var d=h(t),p=d.next();!p.done;p=d.next()){var m=p.value,f=oe(this.channels,m,this.order),v=f.place;if(f.contains)switch(l.push(m),a){case re.EVENT_CHANNEL_UPDATED:case re.EVENT_MESSAGE_RECEIVED:this.channels.splice(v,1);var _=oe(this.channels,m,this.order).place;this.channels.splice(_,0,m);break;default:this.channels[v]=m}else if(v===this.channels.length){var y=Fe.of(this._iid);(r||y.completed)&&(u.push(m),this.channels.push(m))}else u.push(m),this.channels.splice(v,0,m)}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}ue(a)&&c((function(){return e(o,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),u.length>0&&this._handler.onChannelsAdded(e,u),l.length>0&&this._handler.onChannelsUpdated(e,l),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,a){var r,i,s=this,o=[],u=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var d=h(t),p=d.next();!p.done;p=d.next()){u(p.value)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}return ue(a)&&o.length>0&&c((function(){return e(s,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),this._handler.onChannelsDeleted(e,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,ne.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,a;return n(this,(function(n){switch(n.label){case 0:return[4,ne.of(this._iid).getMyGroupChannels(this._token,p(p({},this.filter),{order:this.order}),this._limit)];case 1:return e=n.sent(),t=e.channels,a=e.token,this._token=a,[2,t]}}))}))},t.prototype.loadMore=function(){return e(this,void 0,void 0,(function(){var t,a=this;return n(this,(function(r){switch(r.label){case 0:return this._hasMore?(t=[],[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,3];case 1:return r.sent(),[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))];case 2:return r.sent(),this._addChannelsToView(t,re.REQUEST_CHANNEL,!0),[2,t];case 3:return[2,[]]}}))}))},t.prototype.dispose=function(){ne.of(this._iid).unsubscribeGroupChannelEvent(this._key)},t}(),Ge=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 f(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=v,t.onUserLeft=v,t.onUserReceivedInvitation=v,t.onUserDeclinedInvitation=v,t.onChannelHidden=v,t.onUnreadMemberStatusUpdated=v,t.onUndeliveredMemberStatusUpdated=v,t.onTypingStatusUpdated=v,t}return f(t,e),t}(be)),Ee=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,u=t.channelNameContainsFilter,l=t.channelUrlsFilter,h=t.customTypesFilter,c=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,m=t.metadataKey,f=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,C=t.includeMetaData;return(n=e.call(this)||this).method=y.GET,n.path=g,n.params=b({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:de.PUBLIC,public_membership_mode:o,name_contains:u,channel_urls:l,custom_types:h,custom_type_startswith:c,super_mode:d,metadata_order_key:p,metadata_key:m,metadata_values:f,metadata_value_startswith:v,show_frozen:_,show_metadata:C}),n}return f(t,e),t}(w),Te=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.channels=[],a.ts=null;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 pe(t,e)}))),a.ts="number"==typeof s?s:null,a}return f(t,e),t}(k);!function(e){e.ALL="all",e.JOINED="joined"}(we||(we={}));var xe=function(t){function r(e,n){var a,r,i,s,o,u,l,h,c,d,p,m,f,v,_=this;return(_=t.call(this,e,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.nicknameContainsFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=we.ALL,_.superChannelFilter=me.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=fe.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!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,_.channelNameContainsFilter=null!==(l=n.channelNameContainsFilter)&&void 0!==l?l:null,_.membershipFilter=null!==(h=n.membershipFilter)&&void 0!==h?h:we.ALL,_.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:me.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(m=n.metadataOrderKeyFilter)&&void 0!==m?m:null,_.metadataValueStartsWith=null!==(f=n.metadataValueStartsWith)&&void 0!==f?f:null,_.order=null!==(v=n.order)&&void 0!==v?v:fe.CHRONOLOGICAL,_}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("boolean",this.includeEmpty)&&F("boolean",this.includeFrozen)&&F("boolean",this.includeMetaData)&&F("string",this.channelNameContainsFilter,!0)&&M("string",this.channelUrlsFilter,!0)&&M("string",this.customTypesFilter,!0)&&F("string",this.customTypeStartsWithFilter,!0)&&E(we,this.membershipFilter)&&E(me,this.superChannelFilter)&&E(fe,this.order)&&F("string",this.metadataOrderKeyFilter,!0)&&F("string",this.metadataKey,!0)&&M("string",this.metadataValues,!0)&&F("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u,l,h,c;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=a.of(this._iid),r=t.requestQueue,i=t.dispatcher,o=new Ee(p(p({},this),{token:this._token})),[4,r.send(o)]):[3,2]):[3,5];case 1:return u=n.sent(),l=u.as(Te),h=l.channels,c=l.token,this._token=c,this._hasNext=!!c,i.dispatch(new ve({channels:h,source:re.REQUEST_CHANNEL})),this._isLoading=!1,[2,h];case 2:return[2,e];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ne=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,u=t.messageTypeFilter,l=t.scheduledStatus;return(n=e.call(this)||this).method=y.GET,n.path="".concat(N),n.params=b({limit:r,reverse:s,channel_url:o,order:i,status:l}),a&&(n.params.token=a),u&&(n.params.message_type_filter=u),n}return f(t,e),t}(w),Pe=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return P(t,e)})),a}return f(t,e),t}(k),Ae=function(t){function r(e,n){var a,r,i,s,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=j.ALL,u.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,u.order=null!==(r=n.order)&&void 0!==r?r:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:j.ALL,u}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("string",this.channelUrl,!0)&&(E(_e,this.order)||null===this.order)&&F("boolean",this.reverse)&&(M(D,this.scheduledStatus)||null===this.scheduledStatus)&&E(j,this.messageTypeFilter)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=a.of(this._iid).requestQueue,t=new Ne(p(p({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=n.sent(),i=r.as(Pe),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ue=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return f(a,t),a.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new ne(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},a.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Se(this._iid,e)},a.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ye(this._iid,e)},a.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},a.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ae(this._iid,e)},a.prototype.addGroupChannelHandler=function(e,t){q(F("string",e)&&t instanceof Ge).throw(s.invalidParameters),this._manager.addHandler(e,t)},a.prototype.removeGroupChannelHandler=function(e){q(F("string",e)).throw(s.invalidParameters),this._manager.removeHandler(e)},a.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},a.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},a.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},a.prototype.getChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannel(t)]}))}))},a.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},a.prototype.getMyGroupChannelChangeLogsByToken=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("number",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof ge&&t.validate()).throw(s.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},a.prototype.createChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),[2,this._manager.createChannel(t)]}))}))},a.prototype.createDistinctChannelIfNotExist=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},a.prototype.createChannelWithUserIds=function(t,a,r,i,s,o){return void 0===a&&(a=!1),void 0===r&&(r=null),void 0===i&&(i=null),void 0===s&&(s=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=new Ce).addUserIds(t),e.isDistinct=a,e.name=r,e.data=s,e.customType=o,"string"==typeof i?e.coverUrl=i:e.coverImage=i,[2,this.createChannel(e)]}))}))},a.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},a.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(M("string",t)).throw(s.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},a.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)).throw(s.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},a}(ee);export{Se as GroupChannelCollection,Ge as GroupChannelHandler,Ue as GroupChannelModule,xe as PublicGroupChannelListQuery}; diff --git a/index.d.ts b/index.d.ts index a199b29..6032b47 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,3 @@ - export { ApplicationUserListQuery, ApplicationUserListQueryParams, diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index 3c41a84..c7204bc 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -97,8 +97,8 @@ declare class BaseChannel { isEphemeral: boolean; creator: User; createdAt: number; - get isGroupChannel(): boolean; - get isOpenChannel(): boolean; + isGroupChannel(): this is GroupChannel; + isOpenChannel(): this is OpenChannel; get cachedMetaData(): object; isIdentical(channel: BaseChannel): boolean; isEqual(channel: BaseChannel): boolean; @@ -181,6 +181,7 @@ declare class BaseMessage { customType?: string; mentionType?: MentionType; mentionedUsers?: User[]; + mentionedUserIds?: string[]; mentionedMessageTemplate?: string; threadInfo?: ThreadInfo; reactions?: Reaction[]; @@ -192,9 +193,9 @@ declare class BaseMessage { scheduledInfo?: ScheduledInfo; isIdentical(message: BaseMessage): boolean; isEqual(message: BaseMessage): boolean; - get isUserMessage(): boolean; - get isFileMessage(): boolean; - get isAdminMessage(): boolean; + isUserMessage(): this is UserMessage; + isFileMessage(): this is FileMessage; + isAdminMessage(): this is AdminMessage; serialize(): object; getMetaArraysByKeys(keys: string[]): MessageMetaArray[]; applyThreadInfoUpdateEvent(threadInfoUpdateEvent: ThreadInfoUpdateEvent): boolean; @@ -274,6 +275,13 @@ declare enum ConnectionState { CLOSED = 'CLOSED', } +declare enum CountPreference { + ALL = 'all', + UNREAD_MESSAGE_COUNT_ONLY = 'unread_message_count_only', + UNREAD_MENTION_COUNT_ONLY = 'unread_mention_count_only', + OFF = 'off', +} + declare interface DoNotDisturbPreference { doNotDisturbOn: boolean; startHour?: number; @@ -338,6 +346,8 @@ declare class FileMessageCreateParams extends FileMessageCreateParamsProperties constructor(props?: FileMessageCreateParamsProperties); get fileUrl(): string; set fileUrl(value: string); + get mentionedUsers(): User[]; + set mentionedUsers(users: User[]); validate(): boolean; } @@ -351,6 +361,8 @@ declare class FileMessageCreateParamsProperties extends BaseMessageCreateParamsP declare class FileMessageUpdateParams extends FileMessageUpdateParamsProperties { constructor(props?: FileMessageUpdateParamsProperties); + get mentionedUsers(): User[]; + set mentionedUsers(users: User[]); validate(): boolean; } @@ -377,6 +389,160 @@ declare class FriendListQuery extends BaseListQuery { type FriendListQueryParams = BaseListQueryParams; +declare class GroupChannel extends BaseChannel { + readonly isDistinct: boolean; + readonly isSuper: boolean; + readonly isBroadcast: boolean; + readonly isExclusive: boolean; + readonly isPublic: boolean; + readonly isDiscoverable: boolean; + readonly isAccessCodeRequired: boolean; + readonly isPushEnabled: boolean; + unreadMessageCount: number; + unreadMentionCount: number; + members: Member[]; + memberCount: number; + joinedMemberCount: number; + hiddenState: HiddenState; + lastMessage: BaseMessage; + messageOffsetTimestamp: number; + messageSurvivalSeconds: number; + myMemberState: MemberState; + myRole: Role; + myMutedState: MutedState; + myLastRead: number; + myCountPreference: CountPreference; + myPushTriggerOption: PushTriggerOption; + inviter: User; + invitedAt: number; + joinedAt: number; + get isHidden(): boolean; + get isTyping(): boolean; + get cachedUnreadMemberState(): object; + get cachedUndeliveredMemberState(): object; + isReadMessage(message: BaseMessage): boolean; + serialize(): object; + createMessageCollection(params?: MessageCollectionParams): MessageCollection; + createMemberListQuery(params?: MemberListQueryParams): MemberListQuery; + addMember(member: Member, ts?: number): void; + removeMember(member: Member): boolean; + getUnreadMemberCount(message: BaseMessage): number; + getUndeliveredMemberCount(message: BaseMessage): number; + getReadMembers(message: SendableMessage, includeAllMembers?: boolean): Member[]; + getUnreadMembers(message: SendableMessage, includeAllMembers?: boolean): Member[]; + getReadStatus(includeAllMembers?: boolean): { + [key: string]: ReadStatus; + }; + getTypingUsers(): Member[]; + invalidateTypingStatus(): boolean; + refresh(): Promise; + freeze(): Promise; + unfreeze(): Promise; + updateChannel(params: GroupChannelUpdateParams): Promise; + invite(users: User[]): Promise; + inviteWithUserIds(userIds: string[]): Promise; + join(accessCode?: string): Promise; + leave(): Promise; + acceptInvitation(accessCode?: string): Promise; + declineInvitation(): Promise; + sendUserMessage(params: UserMessageCreateParams): MessageRequestHandler; + sendFileMessage(params: FileMessageCreateParams): MessageRequestHandler; + deleteMessage(message: SendableMessage): Promise; + hide(params: GroupChannelHideParams): Promise; + unhide(): Promise; + delete(): Promise; + markAsRead(): Promise; + markAsDelivered(): Promise; + startTyping(): Promise; + endTyping(): Promise; + createScheduledUserMessage(params: ScheduledUserMessageCreateParams): Promise; + updateScheduledUserMessage( + scheduledMessageId: number, + params: ScheduledUserMessageUpdateParams, + ): Promise; + createScheduledFileMessage(params: ScheduledFileMessageCreateParams): Promise; + updateScheduledFileMessage( + scheduledMessageId: number, + params: ScheduledFileMessageUpdateParams, + ): Promise; + cancelScheduledMessage(scheduledMessageId: number): Promise; + sendScheduledMessageNow(scheduledMessageId: number): Promise; + getMyPushTriggerOption(): Promise; + setMyPushTriggerOption(option: PushTriggerOption): Promise; + setMyCountPreference(preference: CountPreference): Promise; + resetMyHistory(): Promise; +} + +declare class GroupChannelEventContext { + readonly source: GroupChannelEventSource; +} + +declare enum GroupChannelEventSource { + UNKNOWN = 'UNKNOWN', + EVENT_CHANNEL_CREATED = 'EVENT_CHANNEL_CREATED', + EVENT_CHANNEL_UPDATED = 'EVENT_CHANNEL_UPDATED', + EVENT_CHANNEL_DELETED = 'EVENT_CHANNEL_DELETED', + EVENT_CHANNEL_READ = 'EVENT_CHANNEL_READ', + EVENT_CHANNEL_DELIVERED = 'EVENT_CHANNEL_DELIVERED', + EVENT_CHANNEL_INVITED = 'EVENT_CHANNEL_INVITED', + EVENT_CHANNEL_JOINED = 'EVENT_CHANNEL_JOINED', + EVENT_CHANNEL_LEFT = 'EVENT_CHANNEL_LEFT', + EVENT_CHANNEL_ACCEPTED_INVITE = 'EVENT_CHANNEL_ACCEPTED_INVITE', + EVENT_CHANNEL_DECLINED_INVITE = 'EVENT_CHANNEL_DECLINED_INVITE', + EVENT_CHANNEL_OPERATOR_UPDATED = 'EVENT_CHANNEL_OPERATOR_UPDATED', + EVENT_CHANNEL_MUTED = 'EVENT_CHANNEL_MUTED', + EVENT_CHANNEL_UNMUTED = 'EVENT_CHANNEL_UNMUTED', + EVENT_CHANNEL_FROZEN = 'EVENT_CHANNEL_FROZEN', + EVENT_CHANNEL_UNFROZEN = 'EVENT_CHANNEL_UNFROZEN', + EVENT_CHANNEL_HIDDEN = 'EVENT_CHANNEL_HIDDEN', + EVENT_CHANNEL_UNHIDDEN = 'EVENT_CHANNEL_UNHIDDEN', + EVENT_CHANNEL_RESET_HISTORY = 'EVENT_CHANNEL_RESET_HISTORY', + EVENT_CHANNEL_TYPING_STATUS_UPDATE = 'EVENT_CHANNEL_TYPING_STATUS_UPDATE', + EVENT_CHANNEL_MEMBER_COUNT_UPDATED = 'EVENT_CHANNEL_MEMBER_COUNT_UPDATED', + EVENT_MESSAGE_SENT = 'EVENT_MESSAGE_SENT', + EVENT_MESSAGE_RECEIVED = 'EVENT_MESSAGE_RECEIVED', + EVENT_MESSAGE_UPDATED = 'EVENT_MESSAGE_UPDATED', + REQUEST_CHANNEL = 'REQUEST_CHANNEL', + REQUEST_CHANNEL_CHANGELOGS = 'REQUEST_CHANNEL_CHANGELOGS', + SYNC_CHANNEL_BACKGROUND = 'SYNC_CHANNEL_BACKGROUND', + SYNC_CHANNEL_CHANGELOGS = 'SYNC_CHANNEL_CHANGELOGS', +} + +declare class GroupChannelHideParams extends GroupChannelHideParamsProperties { + constructor(props?: GroupChannelHideParamsProperties); + validate(): boolean; +} + +declare class GroupChannelHideParamsProperties { + hidePreviousMessages?: boolean; + allowAutoUnhide?: boolean; +} + +declare class GroupChannelUpdateParams extends GroupChannelUpdateParamsProperties { + constructor(props?: GroupChannelUpdateParamsProperties); + validate(): boolean; +} + +declare class GroupChannelUpdateParamsProperties { + coverUrl?: string; + coverImage?: FileCompat; + isDistinct?: boolean; + isPublic?: boolean; + isDiscoverable?: boolean; + accessCode?: string; + name?: string; + data?: string; + customType?: string; + operatorUserIds?: string[]; + messageSurvivalSeconds?: number; +} + +declare enum HiddenState { + UNHIDDEN = 'unhidden', + HIDDEN_ALLOW_AUTO_UNHIDE = 'hidden_allow_auto_unhide', + HIDDEN_PREVENT_AUTO_UNHIDE = 'hidden_prevent_auto_unhide', +} + declare interface InvitationPreference { autoAccept: boolean; } @@ -390,6 +556,50 @@ declare enum LogLevel { ERROR = 5, } +declare class Member extends RestrictedUser { + state: MemberState; + role: Role; + isMuted: boolean; + isBlockedByMe: boolean; + isBlockingMe: boolean; +} + +declare enum MemberListOrder { + MEMBER_NICKNAME_ALPHABETICAL = 'member_nickname_alphabetical', + OPERATOR_THEN_MEMBER_ALPHABETICAL = 'operator_then_member_alphabetical', +} + +declare class MemberListQuery extends ChannelDataListQuery { + readonly mutedMemberFilter: MutedMemberFilter; + readonly memberStateFilter: MemberStateFilter; + readonly nicknameStartsWithFilter: string; + readonly operatorFilter: OperatorFilter; + readonly order: MemberListOrder; + next(): Promise; +} + +declare interface MemberListQueryParams extends ChannelDataListQueryParams { + mutedMemberFilter?: MutedMemberFilter; + memberStateFilter?: MemberStateFilter; + nicknameStartsWithFilter?: string; + operatorFilter?: OperatorFilter; + order?: MemberListOrder; +} + +declare enum MemberState { + NONE = 'none', + JOINED = 'joined', + INVITED = 'invited', +} + +declare enum MemberStateFilter { + ALL = 'all', + JOINED = 'joined_only', + INVITED = 'invited_only', + INVITED_BY_FRIEND = 'invited_by_friend', + INVITED_BY_NON_FRIEND = 'invited_by_non_friend', +} + declare class MemoryStore implements BaseStore { dbname: string; itemSizeLimit: number; @@ -441,6 +651,88 @@ declare class MessageChangeLogsParamsProperties { includePollDetails?: boolean; } +declare class MessageCollection { + readonly filter: MessageFilter; + get channel(): GroupChannel; + get succeededMessages(): BaseMessage[]; + get failedMessages(): BaseMessage[]; + get pendingMessages(): BaseMessage[]; + get hasPrevious(): boolean; + get hasNext(): boolean; + setMessageCollectionHandler(handler: MessageCollectionEventHandler): void; + initialize(policy: MessageCollectionInitPolicy): MessageCollectionInitHandler; + loadPrevious(): Promise; + loadNext(): Promise; + removeFailedMessage(reqId: string): Promise; + dispose(): void; +} + +declare interface MessageCollectionEventHandler { + onChannelUpdated: (context: GroupChannelEventContext, channel: GroupChannel) => void; + onChannelDeleted: (context: GroupChannelEventContext, channelUrl: string) => void; + onMessagesAdded: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => void; + onMessagesUpdated: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => void; + onMessagesDeleted: (context: MessageEventContext, channel: GroupChannel, messageIds: number[]) => void; + onHugeGapDetected: () => void; +} + +declare class MessageCollectionInitHandler { + onCacheResult(handler: MessageCollectionInitResultHandler): MessageCollectionInitHandler; + onApiResult(handler: MessageCollectionInitResultHandler): MessageCollectionInitHandler; +} + +declare enum MessageCollectionInitPolicy { + CACHE_AND_REPLACE_BY_API = 'cache_and_replace_by_api', + API_ONLY = 'api_only', +} + +declare type MessageCollectionInitResultHandler = (err: Error, messages: BaseMessage[]) => void; + +declare interface MessageCollectionParams { + filter?: MessageFilter; + startingPoint?: number; + limit?: number; +} + +declare class MessageEventContext { + readonly source: MessageEventSource_2; +} + +declare enum MessageEventSource_2 { + UNKNOWN = 'UNKNOWN', + EVENT_MESSAGE_SENT_SUCCESS = 'EVENT_MESSAGE_SENT_SUCCESS', + EVENT_MESSAGE_SENT_FAILED = 'EVENT_MESSAGE_SENT_FAILED', + EVENT_MESSAGE_SENT_PENDING = 'EVENT_MESSAGE_SENT_PENDING', + EVENT_MESSAGE_RECEIVED = 'EVENT_MESSAGE_RECEIVED', + EVENT_MESSAGE_UPDATED = 'EVENT_MESSAGE_UPDATED', + EVENT_MESSAGE_DELETED = 'EVENT_MESSAGE_DELETED', + EVENT_MESSAGE_READ = 'EVENT_MESSAGE_READ', + EVENT_MESSAGE_DELIVERED = 'EVENT_MESSAGE_DELIVERED', + EVENT_MESSAGE_REACTION_UPDATED = 'EVENT_MESSAGE_REACTION_UPDATED', + EVENT_MESSAGE_THREADINFO_UPDATED = 'EVENT_MESSAGE_THREADINFO_UPDATED', + EVENT_MESSAGE_OFFSET_UPDATED = 'EVENT_MESSAGE_OFFSET_UPDATED', + REQUEST_MESSAGE = 'REQUEST_MESSAGE', + REQUEST_RESEND_MESSAGE = 'REQUEST_RESEND_MESSAGE', + REQUEST_THREADED_MESSAGE = 'REQUEST_THREADED_MESSAGE', + REQUEST_MESSAGE_CHANGELOGS = 'REQUEST_MESSAGE_CHANGELOGS', + SYNC_MESSAGE_FILL = 'SYNC_MESSAGE_FILL', + SYNC_MESSAGE_BACKGROUND = 'SYNC_MESSAGE_BACKGROUND', + SYNC_MESSAGE_CHANGELOGS = 'SYNC_MESSAGE_CHANGELOGS', + LOCAL_MESSAGE_PENDING_CREATED = 'LOCAL_MESSAGE_PENDING_CREATED', + LOCAL_MESSAGE_FAILED = 'LOCAL_MESSAGE_FAILED', + LOCAL_MESSAGE_CANCELED = 'LOCAL_MESSAGE_CANCELED', + LOCAL_MESSAGE_RESEND_STARTED = 'LOCAL_MESSAGE_RESEND_STARTED', +} + +declare class MessageFilter { + messageTypeFilter: MessageTypeFilter; + customTypesFilter: string[]; + senderUserIdsFilter: string[]; + replyType: ReplyType; + clone(): MessageFilter; + match(message: BaseMessage): boolean; +} + declare type MessageHandler = (message: SendableMessage) => void; declare class MessageListParams extends MessageListParamsProperties { @@ -574,6 +866,17 @@ declare interface MutedInfo { description: string; } +declare enum MutedMemberFilter { + ALL = 'all', + MUTED = 'muted', + UNMUTED = 'unmuted', +} + +declare enum MutedState { + MUTED = 'muted', + UNMUTED = 'unmuted', +} + declare class MutedUserListQuery extends ChannelDataListQuery { next(): Promise; } @@ -596,12 +899,57 @@ declare class OGMetaData { readonly defaultImage: OGImage; } +export declare class OpenChannel extends BaseChannel { + participantCount: number; + operators: User[]; + serialize(): object; + isOperator(userOrUserId: string | User): boolean; + createParticipantListQuery(params: ParticipantListQueryParams): ParticipantListQuery; + refresh(): Promise; + enter(): Promise; + exit(): Promise; + updateChannel(params: OpenChannelUpdateParams): Promise; + updateChannelWithOperatorUserIds( + name: string, + coverUrlOrImageFile: FileCompat | string, + data: string, + operatorUserIds: string[], + customType: string, + ): Promise; + delete(): Promise; +} + +export declare class OpenChannelUpdateParams extends OpenChannelUpdateParamsProperties { + constructor(props?: OpenChannelUpdateParamsProperties); + validate(): boolean; +} + +export declare class OpenChannelUpdateParamsProperties { + name?: string; + coverUrlOrImage?: FileCompat | string; + data?: string; + customType?: string; + operatorUserIds?: string[]; +} + +declare enum OperatorFilter { + ALL = 'all', + OPERATOR = 'operator', + NONOPERATOR = 'nonoperator', +} + declare class OperatorListQuery extends ChannelDataListQuery { next(): Promise; } type OperatorListQueryParams = ChannelDataListQueryParams; +export declare class ParticipantListQuery extends ChannelDataListQuery { + next(): Promise; +} + +type ParticipantListQueryParams = ChannelDataListQueryParams; + declare class Plugin_2 { readonly type: string; readonly vendor: string; @@ -692,6 +1040,13 @@ declare enum ReactionEventOperation { DELETE = 'delete', } +declare class ReadStatus { + readonly channelUrl: string; + readonly channelType: string; + readonly reader: User; + readonly readAt: number; +} + declare enum ReplyType { ALL = 'all', NONE = 'none', @@ -725,6 +1080,38 @@ declare enum Role { NONE = 'none', } +declare class ScheduledFileMessageCreateParams extends ScheduledFileMessageCreateParamsProperties { + constructor(props: ScheduledFileMessageCreateParamsProperties); + get fileUrl(): string; + set fileUrl(value: string); + validate(): boolean; +} + +declare class ScheduledFileMessageCreateParamsProperties extends BaseMessageCreateParamsProperties { + scheduledAt: number; + file: FileParams; + fileName?: string; + mimeType?: string; + fileSize?: number; + thumbnailSizes?: ThumbnailSize[]; +} + +declare class ScheduledFileMessageUpdateParams extends ScheduledFileMessageUpdateParamsProperties { + constructor(props?: ScheduledFileMessageUpdateParamsProperties); + get fileUrl(): string; + set fileUrl(value: string); + validate(): boolean; +} + +declare class ScheduledFileMessageUpdateParamsProperties extends BaseMessageUpdateParamsProperties { + scheduledAt?: number; + file: FileParams; + fileName?: string; + mimeType?: string; + fileSize?: number; + thumbnailSizes?: ThumbnailSize[]; +} + declare interface ScheduledInfo { scheduledMessageId: number; scheduledAt: number; @@ -747,12 +1134,29 @@ declare enum ScheduledStatus { CANCELED = 'canceled', } +declare class ScheduledUserMessageCreateParams extends ScheduledUserMessageCreateParamsProperties { + constructor(props?: ScheduledUserMessageCreateParamsProperties); + validate(): boolean; +} + +declare class ScheduledUserMessageCreateParamsProperties extends UserMessageCreateParamsProperties { + scheduledAt: number; +} + +declare class ScheduledUserMessageUpdateParams extends ScheduledUserMessageUpdateParamsProperties { + constructor(props?: ScheduledUserMessageUpdateParamsProperties); + validate(): boolean; +} + +declare class ScheduledUserMessageUpdateParamsProperties extends UserMessageUpdateParamsProperties { + scheduledAt?: number; +} + declare class SendableMessage extends BaseMessage { sender: Sender; reqId: string; replyToChannel: boolean; sendingStatus: SendingStatus; - requestedMentionUserIds: string[]; errorCode: number; get isResendable(): boolean; isIdentical(message: SendableMessage): boolean; @@ -1079,6 +1483,8 @@ declare class UserMessage extends SendableMessage { declare class UserMessageCreateParams extends UserMessageCreateParamsProperties { constructor(props?: UserMessageCreateParamsProperties); + get mentionedUsers(): User[]; + set mentionedUsers(users: User[]); validate(): boolean; } @@ -1089,6 +1495,8 @@ declare class UserMessageCreateParamsProperties extends BaseMessageCreateParamsP declare class UserMessageUpdateParams extends UserMessageUpdateParamsProperties { constructor(props?: UserMessageUpdateParamsProperties); + get mentionedUsers(): User[]; + set mentionedUsers(users: User[]); validate(): boolean; } @@ -1114,32 +1522,6 @@ declare class UserUpdateParamsProperties { nickname?: string; } -declare interface Schedule { - year: number; - month: number; - day: number; - hour?: number; - min?: number; - timezone?: string; -} - -export declare class ScheduledUserMessageParams extends ScheduledUserMessageParamsProperties { - constructor(props?: ScheduledUserMessageParamsProperties); - get scheduledDateTimeString(): string; - set scheduledDateTimeString(value: string); - setSchedule(schedule: Schedule): void; - validate(): boolean; -} - -export declare class ScheduledUserMessageParamsProperties extends UserMessageCreateParamsProperties { - year: number; - month: number; - day: number; - hour?: number; - min?: number; - timezone?: string; -} - declare abstract class BaseChannelHandlerParams { onUserMuted?: (channel: BaseChannel, user: RestrictedUser) => void; onUserUnmuted?: (channel: BaseChannel, user: User) => void; @@ -1165,97 +1547,6 @@ declare abstract class BaseChannelHandlerParams { onThreadInfoUpdated?: (channel: BaseChannel, threadInfoUpdateEvent: ThreadInfoUpdateEvent) => void; } -export declare enum CountPreference { - ALL = 'all', - UNREAD_MESSAGE_COUNT_ONLY = 'unread_message_count_only', - UNREAD_MENTION_COUNT_ONLY = 'unread_mention_count_only', - OFF = 'off', -} - -export declare class GroupChannel extends BaseChannel { - readonly isDistinct: boolean; - readonly isSuper: boolean; - readonly isBroadcast: boolean; - readonly isExclusive: boolean; - readonly isPublic: boolean; - readonly isDiscoverable: boolean; - readonly isAccessCodeRequired: boolean; - readonly isPushEnabled: boolean; - unreadMessageCount: number; - unreadMentionCount: number; - members: Member[]; - memberCount: number; - joinedMemberCount: number; - hiddenState: HiddenState; - lastMessage: BaseMessage; - messageOffsetTimestamp: number; - messageSurvivalSeconds: number; - myMemberState: MemberState; - myRole: Role; - myMutedState: MutedState; - myLastRead: number; - myCountPreference: CountPreference; - myPushTriggerOption: PushTriggerOption; - inviter: User; - invitedAt: number; - joinedAt: number; - get isHidden(): boolean; - get isTyping(): boolean; - get cachedUnreadMemberState(): object; - get cachedUndeliveredMemberState(): object; - isReadMessage(message: BaseMessage): boolean; - serialize(): object; - createMessageCollection(params?: MessageCollectionParams): MessageCollection; - createMemberListQuery(params?: MemberListQueryParams): MemberListQuery; - addMember(member: Member, ts?: number): void; - removeMember(member: Member): boolean; - getUnreadMemberCount(message: BaseMessage): number; - getUndeliveredMemberCount(message: BaseMessage): number; - getReadMembers(message: SendableMessage, includeAllMembers?: boolean): Member[]; - getUnreadMembers(message: SendableMessage, includeAllMembers?: boolean): Member[]; - getReadStatus(includeAllMembers?: boolean): { - [key: string]: ReadStatus; - }; - getTypingUsers(): Member[]; - invalidateTypingStatus(): boolean; - refresh(): Promise; - freeze(): Promise; - unfreeze(): Promise; - updateChannel(params: GroupChannelUpdateParams): Promise; - invite(users: User[]): Promise; - inviteWithUserIds(userIds: string[]): Promise; - join(accessCode?: string): Promise; - leave(): Promise; - acceptInvitation(accessCode?: string): Promise; - declineInvitation(): Promise; - sendUserMessage(params: UserMessageCreateParams): MessageRequestHandler; - sendFileMessage(params: FileMessageCreateParams): MessageRequestHandler; - deleteMessage(message: SendableMessage): Promise; - hide(params: GroupChannelHideParams): Promise; - unhide(): Promise; - delete(): Promise; - markAsRead(): Promise; - markAsDelivered(): Promise; - startTyping(): Promise; - endTyping(): Promise; - createScheduledUserMessage(params: ScheduledUserMessageCreateParams): Promise; - updateScheduledUserMessage( - scheduledMessageId: number, - params: ScheduledUserMessageUpdateParams, - ): Promise; - createScheduledFileMessage(params: ScheduledFileMessageCreateParams): Promise; - updateScheduledFileMessage( - scheduledMessageId: number, - params: ScheduledFileMessageUpdateParams, - ): Promise; - cancelScheduledFileMessage(scheduledMessageId: number): Promise; - sendScheduledMessageNow(scheduledMessageId: number): Promise; - getMyPushTriggerOption(): Promise; - setMyPushTriggerOption(option: PushTriggerOption): Promise; - setMyCountPreference(preference: CountPreference): Promise; - resetMyHistory(): Promise; -} - export declare interface GroupChannelChangelogs { updatedChannels: GroupChannel[]; deletedChannelUrls: string[]; @@ -1330,42 +1621,7 @@ export declare class GroupChannelCreateParamsProperties { data?: string; customType?: string; operatorUserIds?: string[]; - messageSurvivalSeconds?: number; -} - -export declare class GroupChannelEventContext { - readonly source: GroupChannelEventSource; -} - -export declare enum GroupChannelEventSource { - UNKNOWN = 'UNKNOWN', - EVENT_CHANNEL_CREATED = 'EVENT_CHANNEL_CREATED', - EVENT_CHANNEL_UPDATED = 'EVENT_CHANNEL_UPDATED', - EVENT_CHANNEL_DELETED = 'EVENT_CHANNEL_DELETED', - EVENT_CHANNEL_READ = 'EVENT_CHANNEL_READ', - EVENT_CHANNEL_DELIVERED = 'EVENT_CHANNEL_DELIVERED', - EVENT_CHANNEL_INVITED = 'EVENT_CHANNEL_INVITED', - EVENT_CHANNEL_JOINED = 'EVENT_CHANNEL_JOINED', - EVENT_CHANNEL_LEFT = 'EVENT_CHANNEL_LEFT', - EVENT_CHANNEL_ACCEPTED_INVITE = 'EVENT_CHANNEL_ACCEPTED_INVITE', - EVENT_CHANNEL_DECLINED_INVITE = 'EVENT_CHANNEL_DECLINED_INVITE', - EVENT_CHANNEL_OPERATOR_UPDATED = 'EVENT_CHANNEL_OPERATOR_UPDATED', - EVENT_CHANNEL_MUTED = 'EVENT_CHANNEL_MUTED', - EVENT_CHANNEL_UNMUTED = 'EVENT_CHANNEL_UNMUTED', - EVENT_CHANNEL_FROZEN = 'EVENT_CHANNEL_FROZEN', - EVENT_CHANNEL_UNFROZEN = 'EVENT_CHANNEL_UNFROZEN', - EVENT_CHANNEL_HIDDEN = 'EVENT_CHANNEL_HIDDEN', - EVENT_CHANNEL_UNHIDDEN = 'EVENT_CHANNEL_UNHIDDEN', - EVENT_CHANNEL_RESET_HISTORY = 'EVENT_CHANNEL_RESET_HISTORY', - EVENT_CHANNEL_TYPING_STATUS_UPDATE = 'EVENT_CHANNEL_TYPING_STATUS_UPDATE', - EVENT_CHANNEL_MEMBER_COUNT_UPDATED = 'EVENT_CHANNEL_MEMBER_COUNT_UPDATED', - EVENT_MESSAGE_SENT = 'EVENT_MESSAGE_SENT', - EVENT_MESSAGE_RECEIVED = 'EVENT_MESSAGE_RECEIVED', - EVENT_MESSAGE_UPDATED = 'EVENT_MESSAGE_UPDATED', - REQUEST_CHANNEL = 'REQUEST_CHANNEL', - REQUEST_CHANNEL_CHANGELOGS = 'REQUEST_CHANNEL_CHANGELOGS', - SYNC_CHANNEL_BACKGROUND = 'SYNC_CHANNEL_BACKGROUND', - SYNC_CHANNEL_CHANGELOGS = 'SYNC_CHANNEL_CHANGELOGS', + messageSurvivalSeconds?: number; } export declare class GroupChannelFilter { @@ -1404,16 +1660,6 @@ declare abstract class GroupChannelHandlerParams extends BaseChannelHandlerParam onTypingStatusUpdated?: (channel: GroupChannel) => void; } -export declare class GroupChannelHideParams extends GroupChannelHideParamsProperties { - constructor(props?: GroupChannelHideParamsProperties); - validate(): boolean; -} - -export declare class GroupChannelHideParamsProperties { - hidePreviousMessages?: boolean; - allowAutoUnhide?: boolean; -} - export declare enum GroupChannelListOrder { LATEST_LAST_MESSAGE = 'latest_last_message', CHRONOLOGICAL = 'chronological', @@ -1519,25 +1765,6 @@ export declare interface GroupChannelSearchFilter { fields?: GroupChannelSearchField[]; } -export declare class GroupChannelUpdateParams extends GroupChannelUpdateParamsProperties { - constructor(props?: GroupChannelUpdateParamsProperties); - validate(): boolean; -} - -export declare class GroupChannelUpdateParamsProperties { - coverUrl?: string; - coverImage?: FileCompat; - isDistinct?: boolean; - isPublic?: boolean; - isDiscoverable?: boolean; - accessCode?: string; - name?: string; - data?: string; - customType?: string; - operatorUserIds?: string[]; - messageSurvivalSeconds?: number; -} - export declare interface GroupChannelUserIdsFilter { userIds: string[]; includeMode: boolean; @@ -1552,160 +1779,11 @@ export declare enum HiddenChannelFilter { HIDDEN_PREVENT_AUTO_UNHIDE = 'hidden_prevent_auto_unhide', } -export declare enum HiddenState { - UNHIDDEN = 'unhidden', - HIDDEN_ALLOW_AUTO_UNHIDE = 'hidden_allow_auto_unhide', - HIDDEN_PREVENT_AUTO_UNHIDE = 'hidden_prevent_auto_unhide', -} - -export declare class Member extends RestrictedUser { - state: MemberState; - role: Role; - isMuted: boolean; - isBlockedByMe: boolean; - isBlockingMe: boolean; -} - -export declare enum MemberListOrder { - MEMBER_NICKNAME_ALPHABETICAL = 'member_nickname_alphabetical', - OPERATOR_THEN_MEMBER_ALPHABETICAL = 'operator_then_member_alphabetical', -} - -export declare class MemberListQuery extends ChannelDataListQuery { - readonly mutedMemberFilter: MutedMemberFilter; - readonly memberStateFilter: MemberStateFilter; - readonly nicknameStartsWithFilter: string; - readonly operatorFilter: OperatorFilter; - readonly order: MemberListOrder; - next(): Promise; -} - -declare interface MemberListQueryParams extends ChannelDataListQueryParams { - mutedMemberFilter?: MutedMemberFilter; - memberStateFilter?: MemberStateFilter; - nicknameStartsWithFilter?: string; - operatorFilter?: OperatorFilter; - order?: MemberListOrder; -} - declare enum MembershipFilter { ALL = 'all', JOINED = 'joined', } -export declare enum MemberState { - NONE = 'none', - JOINED = 'joined', - INVITED = 'invited', -} - -export declare enum MemberStateFilter { - ALL = 'all', - JOINED = 'joined_only', - INVITED = 'invited_only', - INVITED_BY_FRIEND = 'invited_by_friend', - INVITED_BY_NON_FRIEND = 'invited_by_non_friend', -} - -export declare class MessageCollection { - readonly filter: MessageFilter; - get channel(): GroupChannel; - get succeededMessages(): BaseMessage[]; - get failedMessages(): BaseMessage[]; - get pendingMessages(): BaseMessage[]; - get hasPrevious(): boolean; - get hasNext(): boolean; - setMessageCollectionHandler(handler: MessageCollectionEventHandler): void; - initialize(policy: MessageCollectionInitPolicy): MessageCollectionInitHandler; - loadPrevious(): Promise; - loadNext(): Promise; - removeFailedMessage(reqId: string): Promise; - dispose(): void; -} - -export declare interface MessageCollectionEventHandler { - onChannelUpdated: (context: GroupChannelEventContext, channel: GroupChannel) => void; - onChannelDeleted: (context: GroupChannelEventContext, channelUrl: string) => void; - onMessagesAdded: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => void; - onMessagesUpdated: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => void; - onMessagesDeleted: (context: MessageEventContext, channel: GroupChannel, messageIds: number[]) => void; - onHugeGapDetected: () => void; -} - -export declare class MessageCollectionInitHandler { - onCacheResult(handler: MessageCollectionInitResultHandler): MessageCollectionInitHandler; - onApiResult(handler: MessageCollectionInitResultHandler): MessageCollectionInitHandler; -} - -export declare enum MessageCollectionInitPolicy { - CACHE_AND_REPLACE_BY_API = 'cache_and_replace_by_api', - API_ONLY = 'api_only', -} - -declare type MessageCollectionInitResultHandler = (err: Error, messages: BaseMessage[]) => void; - -declare interface MessageCollectionParams { - filter?: MessageFilter; - startingPoint?: number; - limit?: number; -} - -export declare class MessageEventContext { - readonly source: MessageEventSource_2; -} - -declare enum MessageEventSource_2 { - UNKNOWN = 'UNKNOWN', - EVENT_MESSAGE_SENT_SUCCESS = 'EVENT_MESSAGE_SENT_SUCCESS', - EVENT_MESSAGE_SENT_FAILED = 'EVENT_MESSAGE_SENT_FAILED', - EVENT_MESSAGE_SENT_PENDING = 'EVENT_MESSAGE_SENT_PENDING', - EVENT_MESSAGE_RECEIVED = 'EVENT_MESSAGE_RECEIVED', - EVENT_MESSAGE_UPDATED = 'EVENT_MESSAGE_UPDATED', - EVENT_MESSAGE_DELETED = 'EVENT_MESSAGE_DELETED', - EVENT_MESSAGE_READ = 'EVENT_MESSAGE_READ', - EVENT_MESSAGE_DELIVERED = 'EVENT_MESSAGE_DELIVERED', - EVENT_MESSAGE_REACTION_UPDATED = 'EVENT_MESSAGE_REACTION_UPDATED', - EVENT_MESSAGE_THREADINFO_UPDATED = 'EVENT_MESSAGE_THREADINFO_UPDATED', - EVENT_MESSAGE_OFFSET_UPDATED = 'EVENT_MESSAGE_OFFSET_UPDATED', - REQUEST_MESSAGE = 'REQUEST_MESSAGE', - REQUEST_RESEND_MESSAGE = 'REQUEST_RESEND_MESSAGE', - REQUEST_THREADED_MESSAGE = 'REQUEST_THREADED_MESSAGE', - REQUEST_MESSAGE_CHANGELOGS = 'REQUEST_MESSAGE_CHANGELOGS', - SYNC_MESSAGE_FILL = 'SYNC_MESSAGE_FILL', - SYNC_MESSAGE_BACKGROUND = 'SYNC_MESSAGE_BACKGROUND', - SYNC_MESSAGE_CHANGELOGS = 'SYNC_MESSAGE_CHANGELOGS', - LOCAL_MESSAGE_PENDING_CREATED = 'LOCAL_MESSAGE_PENDING_CREATED', - LOCAL_MESSAGE_FAILED = 'LOCAL_MESSAGE_FAILED', - LOCAL_MESSAGE_CANCELED = 'LOCAL_MESSAGE_CANCELED', - LOCAL_MESSAGE_RESEND_STARTED = 'LOCAL_MESSAGE_RESEND_STARTED', -} - -export declare class MessageFilter { - messageTypeFilter: MessageTypeFilter; - customTypesFilter: string[]; - senderUserIdsFilter: string[]; - replyType: ReplyType; - clone(): MessageFilter; - match(message: BaseMessage): boolean; -} - -declare enum MutedMemberFilter { - ALL = 'all', - MUTED = 'muted', - UNMUTED = 'unmuted', -} - -export declare enum MutedState { - MUTED = 'muted', - UNMUTED = 'unmuted', -} - -export declare enum OperatorFilter { - ALL = 'all', - OPERATOR = 'operator', - NONOPERATOR = 'nonoperator', -} - export declare enum PublicChannelFilter { ALL = 'all', PUBLIC = 'public', @@ -1759,45 +1837,6 @@ export declare enum QueryType { OR = 'OR', } -export declare class ReadStatus { - readonly channelUrl: string; - readonly channelType: string; - readonly reader: User; - readonly readAt: number; -} - -declare class ScheduledFileMessageCreateParams extends ScheduledFileMessageCreateParamsProperties { - constructor(props: ScheduledFileMessageCreateParamsProperties); - get fileUrl(): string; - set fileUrl(value: string); - validate(): boolean; -} - -declare class ScheduledFileMessageCreateParamsProperties extends BaseMessageCreateParamsProperties { - scheduledAt: number; - file: FileParams; - fileName?: string; - mimeType?: string; - fileSize?: number; - thumbnailSizes?: ThumbnailSize[]; -} - -declare class ScheduledFileMessageUpdateParams extends ScheduledFileMessageUpdateParamsProperties { - constructor(props?: ScheduledFileMessageUpdateParamsProperties); - get fileUrl(): string; - set fileUrl(value: string); - validate(): boolean; -} - -declare class ScheduledFileMessageUpdateParamsProperties extends BaseMessageUpdateParamsProperties { - scheduledAt?: number; - file: FileParams; - fileName?: string; - mimeType?: string; - fileSize?: number; - thumbnailSizes?: ThumbnailSize[]; -} - declare enum ScheduledMessageListOrder { CREATED_AT = 'created_at', SCHEDULED_AT = 'scheduled_at', @@ -1820,24 +1859,6 @@ declare interface ScheduledMessageListQueryParams extends BaseListQueryParams { messageTypeFilter?: MessageTypeFilter; } -declare class ScheduledUserMessageCreateParams extends ScheduledUserMessageCreateParamsProperties { - constructor(props?: ScheduledUserMessageCreateParamsProperties); - validate(): boolean; -} - -declare class ScheduledUserMessageCreateParamsProperties extends UserMessageCreateParamsProperties { - scheduledAt: number; -} - -declare class ScheduledUserMessageUpdateParams extends ScheduledUserMessageUpdateParamsProperties { - constructor(props?: ScheduledUserMessageUpdateParamsProperties); - validate(): boolean; -} - -declare class ScheduledUserMessageUpdateParamsProperties extends UserMessageUpdateParamsProperties { - scheduledAt?: number; -} - export declare type SendbirdGroupChat = SendbirdChat & { groupChannel: GroupChannelModule; }; @@ -1847,26 +1868,6 @@ export declare enum UnreadChannelFilter { UNREAD_MESSAGE = 'unread_message', } -export declare class OpenChannel extends BaseChannel { - participantCount: number; - operators: User[]; - serialize(): object; - isOperator(userOrUserId: string | User): boolean; - createParticipantListQuery(params: ParticipantListQueryParams): ParticipantListQuery; - refresh(): Promise; - enter(): Promise; - exit(): Promise; - updateChannel(params: OpenChannelUpdateParams): Promise; - updateChannelWithOperatorUserIds( - name: string, - coverUrlOrImageFile: FileCompat | string, - data: string, - operatorUserIds: string[], - customType: string, - ): Promise; - delete(): Promise; -} - export declare class OpenChannelCreateParams extends OpenChannelCreateParamsProperties { constructor(props?: OpenChannelCreateParamsProperties); validate(): boolean; @@ -1927,25 +1928,6 @@ export declare class OpenChannelModule extends Module { ): Promise; } -export declare class OpenChannelUpdateParams extends OpenChannelUpdateParamsProperties { - constructor(props?: OpenChannelUpdateParamsProperties); - validate(): boolean; -} - -export declare class OpenChannelUpdateParamsProperties { - name?: string; - coverUrlOrImage?: FileCompat | string; - data?: string; - customType?: string; - operatorUserIds?: string[]; -} - -export declare class ParticipantListQuery extends ChannelDataListQuery { - next(): Promise; -} - -type ParticipantListQueryParams = ChannelDataListQueryParams; - export declare type SendbirdOpenChat = SendbirdChat & { openChannel: OpenChannelModule; }; diff --git a/message.d.ts b/message.d.ts index 2225e33..a6c138f 100644 --- a/message.d.ts +++ b/message.d.ts @@ -31,8 +31,6 @@ export { ReactionEvent, ReactionEventOperation, ReplyType, - ScheduledUserMessageParams, - ScheduledUserMessageParamsProperties, Sender, SendingStatus, ThreadedMessageListParams, diff --git a/message.js b/message.js index 39cf203..15538a9 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{aJ as AdminMessage,av as AppleCriticalAlertOptions,aX as BaseMessage,$ as FileMessage,a1 as FileMessageCreateParams,a$ as FileMessageCreateParamsProperties,aW as FileMessageUpdateParams,b0 as FileMessageUpdateParamsProperties,aG as MentionType,aU as MessageChangeLogsParams,b1 as MessageChangeLogsParamsProperties,aT as MessageListParams,b2 as MessageListParamsProperties,au as MessageMetaArray,K as MessageModule,aD as MessageRequestHandler,b3 as MessageRetrievalParams,b4 as MessageRetrievalParamsProperties,b5 as MessageSearchOrder,y as MessageSearchQuery,T as MessageType,M as MessageTypeFilter,b6 as OGImage,b7 as OGMetaData,aP as PreviousMessageListQuery,aH as PushNotificationDeliveryOption,b8 as Reaction,aL as ReactionEvent,b9 as ReactionEventOperation,Y as ReplyType,ba as ScheduledUserMessageParams,bb as ScheduledUserMessageParamsProperties,aQ as Sender,ah as SendingStatus,bc as ThreadInfo,aM as ThreadInfoUpdateEvent,bd as ThreadedMessageListParams,be as ThreadedMessageListParamsProperties,ay as Thumbnail,Z as UserMessage,a2 as UserMessageCreateParams,as as UserMessageCreateParamsProperties,aA as UserMessageUpdateParams,aB as UserMessageUpdateParamsProperties}from"./__bundle-368767fc.js"; +export{aK as AdminMessage,av as AppleCriticalAlertOptions,aY as BaseMessage,$ as FileMessage,a1 as FileMessageCreateParams,b0 as FileMessageCreateParamsProperties,aX as FileMessageUpdateParams,b1 as FileMessageUpdateParamsProperties,aH as MentionType,aV as MessageChangeLogsParams,b2 as MessageChangeLogsParamsProperties,aU as MessageListParams,b3 as MessageListParamsProperties,au as MessageMetaArray,K as MessageModule,aE as MessageRequestHandler,b4 as MessageRetrievalParams,b5 as MessageRetrievalParamsProperties,b6 as MessageSearchOrder,y as MessageSearchQuery,T as MessageType,M as MessageTypeFilter,b7 as OGImage,b8 as OGMetaData,aQ as PreviousMessageListQuery,aI as PushNotificationDeliveryOption,b9 as Reaction,aM as ReactionEvent,ba as ReactionEventOperation,Y as ReplyType,aR as Sender,a8 as SendingStatus,bb as ThreadInfo,aN as ThreadInfoUpdateEvent,bc as ThreadedMessageListParams,bd as ThreadedMessageListParamsProperties,ay as Thumbnail,Z as UserMessage,a2 as UserMessageCreateParams,as as UserMessageCreateParamsProperties,aB as UserMessageUpdateParams,aC as UserMessageUpdateParamsProperties}from"./__bundle-45e61fc8.js"; diff --git a/openChannel.js b/openChannel.js index cad7e1c..f37dd87 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as n,d as e,e as t,I as r,b as a,a as i,i as s,A as o,aZ as u,a_ as c,h as l,k as h,ac as d,U as p,W as f,ae as v,af as C,p as _,z as y,ak as m,F as g,L as U,al as E,x as w,S as T,ar as N,V as H,j as I,ad as M,g as O,a0 as b,n as x,B as D,aY as A}from"./__bundle-368767fc.js";import{U as P,e as L,F as k,h as R,g as F,f as S,i as q,j as Q,k as z,C as K,l as W,T as j,m as B,D as G,n as X,o as Z,p as V,q as Y,A as $,a as J}from"./__bundle-72d7e125.js";import{B as nn}from"./__bundle-96ae73c1.js";var en=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),tn=function(){this.channelUrl=null,this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},rn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)&&(i("string",this.channelUrl)&&/^\w+$/.test(this.channelUrl)||null===this.channelUrl)},t}(tn),an=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),sn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new En(n,t),r}return n(t,e),t}(h),on=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params={channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}n(t,e)}(h);var un=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),cn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),ln=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),hn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),dn={},pn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof f)i._handleEvent(n);else if(n instanceof v&&n.stateType===C.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=_(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),dn[n]=this}return n.of=function(n){return dn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=y(n);return new En(e._iid,En.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=_(n),r=e.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=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,v,C,y,w,T,N,H,I,M,O,b,x,D,A,J,nn,en,tn,rn,an,sn,on,un,ln,dn,pn,fn,vn,Cn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,In,Mn,On,bn,xn,Dn,An,Pn,Ln=this;return t(this,(function(kn){switch(kn.label){case 0:switch(kn.trys.push([0,51,,52]),n.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"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(Y):"FILE"===n.code?s=n.as(E):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==U.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r)}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),kn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(X):"FEDI"===n.code?s=n.as(Z):"AEDI"===n.code&&(s=n.as(V)),s?(o=s.message).channelType!==U.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(u.url)&&r.onMessageUpdated(u,o)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=6;case 6:return[3,50];case 7:return c=n.as(G),M=c.channelUrl,p=c.channelType,l=c.messageId,p!==U.OPEN?[3,9]:[4,this.getChannel(M,!0)];case 8:h=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=9;case 9:return[3,50];case 10:return d=n.as(B),M=d.channelUrl,p=d.channelType,f=d.event,p!==U.OPEN?[3,12]:[4,this.getChannel(M,!0)];case 11:v=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onReactionUpdated(v,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=12;case 12:return[3,50];case 13:return(C=n.as(j).event).channelType!==U.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:y=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onThreadInfoUpdated(y,C)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=15;case 15:return[3,50];case 16:w=n.as(W).openChannelMemberCounts,T=[],kn.label=17;case 17:kn.trys.push([17,22,23,24]),N=_(w),H=N.next(),kn.label=18;case 18:return H.done?[3,21]:(I=H.value,M=I.channelUrl,an=I.participantCount,O=I.updatedAt,[4,this.getChannelFromCache(M)]);case 19:(b=kn.sent())&&b._updateParticipantCount(an,O)&&T.push(b),kn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return x=kn.sent(),An={error:x},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=26;case 26:return[3,50];case 27:if(!(D=n.as(K).event).isOpenChannelEvent)return[3,49];switch(D.category){case R.CHANNEL_ENTER:return[3,28];case R.CHANNEL_EXIT:return[3,30];case R.CHANNEL_OPERATOR_UPDATE:return[3,32];case R.USER_CHANNEL_MUTE:case R.USER_CHANNEL_UNMUTE:return[3,34];case R.USER_CHANNEL_BAN:case R.USER_CHANNEL_UNBAN:return[3,36];case R.CHANNEL_FREEZE:case R.CHANNEL_UNFREEZE:return[3,38];case R.CHANNEL_DELETED:return[3,40];case R.CHANNEL_PROP_CHANGED:return[3,43];case R.CHANNEL_META_DATA_CHANGED:return[3,45];case R.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(D.channelUrl,!0)];case 29:return A=kn.sent(),J=n.as(cn),an=J.participantCount,nn=J.user,en=A._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(D.channelUrl,!0)];case 31:return tn=kn.sent(),rn=n.as(hn),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(D.channelUrl,!0)];case 33:return un=kn.sent(),ln=n.as(z).operators,un.operators=ln,this.upsertChannelsToCache([un]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(un,ln)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(D.channelUrl,!0)];case 35:return dn=kn.sent(),pn=D.category===R.USER_CHANNEL_MUTE,fn=n.as(pn?q:Q).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(D.channelUrl,!0)];case 37:return vn=kn.sent(),Cn=D.category===R.USER_CHANNEL_BAN,_n=n.as(Cn?F:S).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Cn?n.onUserBanned(vn,_n):n.onUserUnbanned(vn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(D.channelUrl,!0)];case 39:return yn=kn.sent(),mn=n.as(k).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(D.channelUrl,!0)];case 41:return gn=kn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(D.channelUrl,!0)];case 44:return Un=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(D.channelUrl,!0)];case 46:return En=kn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,D.ts),Nn&&En._upsertCachedMetaData(Nn,D.ts),Hn&&En._removeFromCachedMetaData(Hn,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(D.channelUrl,!0)];case 48:return In=kn.sent(),Mn=n.as(P),On=Mn.created,bn=Mn.updated,xn=Mn.deleted,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(In,On),bn&&n.onMetaCounterUpdated(In,bn),xn&&n.onMetaCounterDeleted(In,xn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(Dn=kn.sent(),m(Dn))throw Dn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:w(i("string",n)).throw(T.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return w(i("string",n)).throw(T.invalidParameters),e=new an({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(sn).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof rn&&n.validate()).throw(T.invalidParameters),e=new on(n),[4,this._requestQueue.send(e)];case 1:return r=t.sent(),a=r.as(sn).channel,this.upsertChannelsToCache([a]),[2,a]}}))}))},n}(),fn=function(){this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},vn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)},t}(fn),Cn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),_n=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new p(n,e)})),r}return n(t,e),t}(h),yn=function(r){function a(n,e,t){return r.call(this,n,e,U.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Cn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(_n),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},a}(N),mn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params={cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l),gn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}return n(t,e),t}(h),Un=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var En=function(r){function a(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=U.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new p(n,e)})):[],a}return n(a,r),a.payloadify=function(n){return n?O(I(I({},J.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return p.payloadify(n)}))})):null},a.prototype.serialize=function(){return M(this)},a.prototype.isOperator=function(n){return n instanceof p?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},a.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},a.prototype.createParticipantListQuery=function(n){return new yn(this._iid,this.url,n)},a.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,pn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},a.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new un({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(cn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setEnteredToCache(this),[2]}}))}))},a.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new ln({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(hn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setExitedToCache(this),b.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},a.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof vn&&n.validate()).throw(T.invalidParameters),e=H.of(this._iid).requestQueue,r=new mn(I({channelUrl:this.url},n)),[4,e.send(r)];case 1:return a=t.sent(),i=a.as(gn).channel,[4,pn.of(this._iid).upsertChannelsToCache([i])];case 2:return t.sent(),[2,i]}}))}))},a.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new vn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this.updateChannel(e)]}))}))},a.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new Un({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,pn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},a}(J),wn=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=x,n.onUserExited=x,n.onChannelParticipantCountChanged=x,n}return n(t,e),t}(nn)),Tn=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=O({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),Nn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new En(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Hn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Tn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Nn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,pn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw T.queryInProgress;case 5:return[3,7];case 6:throw T.invalidParameters;case 7:return[2]}}))}))},s}(D),In=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new pn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Hn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new rn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{En as OpenChannel,rn as OpenChannelCreateParams,tn as OpenChannelCreateParamsProperties,wn as OpenChannelHandler,Hn as OpenChannelListQuery,In as OpenChannelModule,vn as OpenChannelUpdateParams,fn as OpenChannelUpdateParamsProperties,yn as ParticipantListQuery}; +import{_ as n,d as e,e as t,I as r,b as a,a as i,i as s,A as o,a_ as u,a$ as c,h as l,k as h,ai as d,U as p,W as f,a5 as v,a6 as C,p as _,z as y,ak as m,F as g,L as U,al as E,x as w,S as T,ar as N,V as H,j as I,aj as M,g as O,a0 as b,n as x,B as D,aZ as A}from"./__bundle-45e61fc8.js";import{U as P,e as L,F as k,h as R,g as F,f as S,i as q,j as Q,k as z,C as K,l as j,T as W,m as B,D as G,n as X,o as Z,p as V,q as $,A as Y,a as J}from"./__bundle-876572c8.js";import{B as nn}from"./__bundle-2ae23ac6.js";var en=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),tn=function(){this.channelUrl=null,this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},rn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)&&(i("string",this.channelUrl)&&/^\w+$/.test(this.channelUrl)||null===this.channelUrl)},t}(tn),an=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),sn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new En(n,t),r}return n(t,e),t}(h),on=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params={channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}n(t,e)}(h);var un=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),cn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),ln=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),hn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),dn={},pn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof f)i._handleEvent(n);else if(n instanceof v&&n.stateType===C.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=_(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),dn[n]=this}return n.of=function(n){return dn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=y(n);return new En(e._iid,En.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=_(n),r=e.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=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,v,C,y,w,T,N,H,I,M,O,b,x,D,A,J,nn,en,tn,rn,an,sn,on,un,ln,dn,pn,fn,vn,Cn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,In,Mn,On,bn,xn,Dn,An,Pn,Ln=this;return t(this,(function(kn){switch(kn.label){case 0:switch(kn.trys.push([0,51,,52]),n.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"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as($):"FILE"===n.code?s=n.as(E):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as(Y)),s?(r=s.message,a=s.isMentioned,r.channelType!==U.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r)}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),kn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(X):"FEDI"===n.code?s=n.as(Z):"AEDI"===n.code&&(s=n.as(V)),s?(o=s.message).channelType!==U.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(u.url)&&r.onMessageUpdated(u,o)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=6;case 6:return[3,50];case 7:return c=n.as(G),M=c.channelUrl,p=c.channelType,l=c.messageId,p!==U.OPEN?[3,9]:[4,this.getChannel(M,!0)];case 8:h=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=9;case 9:return[3,50];case 10:return d=n.as(B),M=d.channelUrl,p=d.channelType,f=d.event,p!==U.OPEN?[3,12]:[4,this.getChannel(M,!0)];case 11:v=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onReactionUpdated(v,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=12;case 12:return[3,50];case 13:return(C=n.as(W).event).channelType!==U.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:y=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onThreadInfoUpdated(y,C)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=15;case 15:return[3,50];case 16:w=n.as(j).openChannelMemberCounts,T=[],kn.label=17;case 17:kn.trys.push([17,22,23,24]),N=_(w),H=N.next(),kn.label=18;case 18:return H.done?[3,21]:(I=H.value,M=I.channelUrl,an=I.participantCount,O=I.updatedAt,[4,this.getChannelFromCache(M)]);case 19:(b=kn.sent())&&b._updateParticipantCount(an,O)&&T.push(b),kn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return x=kn.sent(),An={error:x},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=26;case 26:return[3,50];case 27:if(!(D=n.as(K).event).isOpenChannelEvent)return[3,49];switch(D.category){case R.CHANNEL_ENTER:return[3,28];case R.CHANNEL_EXIT:return[3,30];case R.CHANNEL_OPERATOR_UPDATE:return[3,32];case R.USER_CHANNEL_MUTE:case R.USER_CHANNEL_UNMUTE:return[3,34];case R.USER_CHANNEL_BAN:case R.USER_CHANNEL_UNBAN:return[3,36];case R.CHANNEL_FREEZE:case R.CHANNEL_UNFREEZE:return[3,38];case R.CHANNEL_DELETED:return[3,40];case R.CHANNEL_PROP_CHANGED:return[3,43];case R.CHANNEL_META_DATA_CHANGED:return[3,45];case R.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(D.channelUrl,!0)];case 29:return A=kn.sent(),J=n.as(cn),an=J.participantCount,nn=J.user,en=A._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(D.channelUrl,!0)];case 31:return tn=kn.sent(),rn=n.as(hn),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(D.channelUrl,!0)];case 33:return un=kn.sent(),ln=n.as(z).operators,un.operators=ln,this.upsertChannelsToCache([un]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(un,ln)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(D.channelUrl,!0)];case 35:return dn=kn.sent(),pn=D.category===R.USER_CHANNEL_MUTE,fn=n.as(pn?q:Q).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(D.channelUrl,!0)];case 37:return vn=kn.sent(),Cn=D.category===R.USER_CHANNEL_BAN,_n=n.as(Cn?F:S).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Cn?n.onUserBanned(vn,_n):n.onUserUnbanned(vn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(D.channelUrl,!0)];case 39:return yn=kn.sent(),mn=n.as(k).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(D.channelUrl,!0)];case 41:return gn=kn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(D.channelUrl,!0)];case 44:return Un=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(D.channelUrl,!0)];case 46:return En=kn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,D.ts),Nn&&En._upsertCachedMetaData(Nn,D.ts),Hn&&En._removeFromCachedMetaData(Hn,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(D.channelUrl,!0)];case 48:return In=kn.sent(),Mn=n.as(P),On=Mn.created,bn=Mn.updated,xn=Mn.deleted,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(In,On),bn&&n.onMetaCounterUpdated(In,bn),xn&&n.onMetaCounterDeleted(In,xn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(Dn=kn.sent(),m(Dn))throw Dn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:w(i("string",n)).throw(T.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return w(i("string",n)).throw(T.invalidParameters),e=new an({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(sn).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof rn&&n.validate()).throw(T.invalidParameters),e=new on(n),[4,this._requestQueue.send(e)];case 1:return r=t.sent(),a=r.as(sn).channel,this.upsertChannelsToCache([a]),[2,a]}}))}))},n}(),fn=function(){this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},vn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)},t}(fn),Cn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),_n=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new p(n,e)})),r}return n(t,e),t}(h),yn=function(r){function a(n,e,t){return r.call(this,n,e,U.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Cn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(_n),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},a}(N),mn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params={cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l),gn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}return n(t,e),t}(h),Un=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var En=function(r){function a(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=U.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new p(n,e)})):[],a}return n(a,r),a.payloadify=function(n){return n?O(I(I({},J.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return p.payloadify(n)}))})):null},a.prototype.serialize=function(){return M(this)},a.prototype.isOperator=function(n){return n instanceof p?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},a.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},a.prototype.createParticipantListQuery=function(n){return new yn(this._iid,this.url,n)},a.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,pn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},a.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new un({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(cn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setEnteredToCache(this),[2]}}))}))},a.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new ln({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(hn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setExitedToCache(this),b.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},a.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof vn&&n.validate()).throw(T.invalidParameters),e=H.of(this._iid).requestQueue,r=new mn(I({channelUrl:this.url},n)),[4,e.send(r)];case 1:return a=t.sent(),i=a.as(gn).channel,[4,pn.of(this._iid).upsertChannelsToCache([i])];case 2:return t.sent(),[2,i]}}))}))},a.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new vn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this.updateChannel(e)]}))}))},a.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new Un({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,pn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},a}(J),wn=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=x,n.onUserExited=x,n.onChannelParticipantCountChanged=x,n}return n(t,e),t}(nn)),Tn=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=O({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),Nn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new En(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Hn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Tn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Nn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,pn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw T.queryInProgress;case 5:return[3,7];case 6:throw T.invalidParameters;case 7:return[2]}}))}))},s}(D),In=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new pn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Hn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new rn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{En as OpenChannel,rn as OpenChannelCreateParams,tn as OpenChannelCreateParamsProperties,wn as OpenChannelHandler,Hn as OpenChannelListQuery,In as OpenChannelModule,vn as OpenChannelUpdateParams,fn as OpenChannelUpdateParamsProperties,yn as ParticipantListQuery}; diff --git a/package.json b/package.json index 3aa9484..7dedd51 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/sendbird.js b/sendbird.js index 5f05ec4..5a489bf 100644 --- a/sendbird.js +++ b/sendbird.js @@ -1 +1 @@ -import{_ as e,i as t,a as n,b as r,c as i,n as s,I as u,E as l,d as h,e as f,A as p,f as _,g as v,h as m,U as y,j as g,k as E,l as I,m as w,B as T,S as x,V as A,o as D,p as F,q as K,D as j,r as V,s as G,M as z,t as Q,u as W,v as Y,w as J,C as X,x as Z,y as $,z as ee,W as te,F as ne,G as re,H as ie,J as se,K as oe}from"./__bundle-368767fc.js";export{L as ChannelType,C as ConnectionState,N as LogLevel,P as Plugin,R as Role,H as SendbirdChatOptions,S as SendbirdError,U as User,O as UserOnlineState}from"./__bundle-368767fc.js";import{U as ae,S as ue,N as ce,a as le,g as he,G as de,b as fe,c as pe,d as _e,M as ve,e as me,f as ye,P as be,h as ge,i as Ee,j as Ie,D as we,k as Ne,l as ke,m as Te,n as Oe,o as Se,p as Ce,q as xe}from"./__bundle-083b498b.js";export{q as PushTemplate,k as PushTokenRegistrationState,P as PushTokenType,o as PushTriggerOption}from"./__bundle-083b498b.js";export{B as BannedUserListQuery,a as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,b as RestrictedUser,c as RestrictionInfo,d as RestrictionType}from"./__bundle-72d7e125.js";var Re=function(){this.profileImage=null,this.profileUrl=null,this.nickname=null},Ae=function(r){function i(e){var t=r.call(this)||this;if(e)for(var n in e)t.hasOwnProperty(n)&&(t[n]=e[n]);return t}return e(i,r),i.prototype.validate=function(){return t(this.profileImage,!0)&&n("string",this.profileUrl,!0)&&n("string",this.nickname,!0)},i}(Re),Pe=function(){},Le=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return r(ae,this.keys)},n}(Pe),De=function(){this.channelCustomTypesFilter=[],this.superChannelFilter=ue.ALL},Ue=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return r("string",this.channelCustomTypesFilter)&&i(ue,this.superChannelFilter)},n}(De),Me=function(){this.onSessionExpired=s,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=s,this.onSessionRefreshed=s,this.onSessionClosed=s},qe=function(){this.onConnected=s,this.onReconnectStarted=s,this.onReconnectSucceeded=s,this.onReconnectFailed=s,this.onDisconnected=s},Fe=function(){this.onFriendsDiscovered=s,this.onTotalUnreadMessageCountUpdated=s};!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(u);var Be=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._pauseDelayTimer=null,e._currentState="visible",e}return e(n,t),Object.defineProperty(n.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener},enumerable:!1,configurable:!0}),n.prototype._toggleState=function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},n.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},n.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},n}(l),Ke=function(){function e(e){var t=e.logger,n=e.connectionDelegate;this.logger=t,this.connectionDelegate=n}return Object.defineProperty(e.prototype,"isAvailable",{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._onlineWorker=function(){this.connectionDelegate.reconnect()},e.prototype._offlineWorker=function(){this.connectionDelegate.disconnect()},e.prototype.start=function(){this.isAvailable&&(window.addEventListener("online",this._onlineWorker),window.addEventListener("offline",this._offlineWorker))},e.prototype.stop=function(){this.isAvailable&&(window.removeEventListener("online",this._onlineWorker,!1),window.removeEventListener("offline",this._offlineWorker,!1))},e.prototype.isOnline=function(){return h(this,void 0,void 0,(function(){return f(this,(function(e){return this.isAvailable?[2,navigator.onLine]:[2,new Promise((function(e,t){fetch("https://www.google.com",{method:p.GET}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),je=function(t){function n(e){var n=e.userId,r=e.nickname,i=void 0===r?null:r,s=e.profileUrl,o=void 0===s?null:s,a=e.profileImage,u=void 0===a?null:a,c=e.preferredLanguages,l=void 0===c?null:c,h=t.call(this)||this;return h.method=p.PUT,h.path="".concat(_,"/").concat(encodeURIComponent(n)),h.params=v({nickname:i,profile_url:o,profile_file:u,preferred_languages:l}),h}return e(n,t),n}(m),Ve=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=null,r.user=new y(e,g({},n)),r}return e(n,t),n}(E),He=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var Ge=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var ze=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new y(e,n.user),r}e(n,t)}(E);var Qe=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new y(e,n.user),r}e(n,t)}(E);var We=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.DELETE,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/apns"),r}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var Ye=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.DELETE,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var Je=function(t){function n(e){var n=e.userId,r=e.type,i=e.token,s=e.ts,o=t.call(this)||this;return o.method=p.GET,o.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return e(n,t),n}(m),Xe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTokens={type:n.type?be[n.type.toLowerCase()]:be.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return e(n,t),n}(E),Ze=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return e(n,t),n}(m),$e=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(E),et=function(t){function n(e){var n=e.userId,r=e.willAutoAccept,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return e(n,t),n}(m),tt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(E),nt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),r}return e(n,t),n}(m),rt=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),it=function(t){function n(e){var n=e.userId,r=e.doNotDisturbOn,i=e.startHour,s=e.startMin,o=e.endHour,a=e.endMin,u=e.timezone,c=t.call(this)||this;return c.method=p.PUT,c.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:u},c}return e(n,t),n}(m),st=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),ot=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),r}return e(n,t),n}(m),at=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),ut=function(t){function n(e){var n=e.userId,r=e.snoozeOn,i=e.startTs,s=e.endTs,o=t.call(this)||this;return o.method=p.PUT,o.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return e(n,t),n}(m),ct=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),lt=function(t){function n(e){var n=e.userId,r=e.blockedUserId,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=new y(e,n),r}e(n,t)}(E);var ht=function(t){function n(e){var n=e.userId,r=e.unblockedUserId,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var dt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/template"),r}return e(n,t),n}(m),ft=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(E),pt=function(t){function n(e){var n=e.userId,r=e.templateName,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return e(n,t),n}(m),_t=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(E),vt=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.GET,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return e(n,t),n}(m),mt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.changelogs={addedUsers:n.added.map((function(t){return new y(e,t)})),updatedUsers:n.updated.map((function(t){return new y(e,t)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return e(n,t),n}(E),yt=function(t){function n(e){var n=e.userId,r=e.discoveries,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").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 e(n,t),n}(m),bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return e(n,t),n}(E),gt=function(t){function n(e){var n=e.userId,r=e.discoveryKeys,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var Et=function(t){function n(e){var n=e.userId,r=e.userIds,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return e(n,t),n}(m),It=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new y(e,t)})),r}return e(n,t),n}(E),wt=function(t){function n(e){var n=e.userId,r=e.userIds,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var Nt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return e(n,t),n}(m),kt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return e(n,t),n}(E),Tt=function(t){function n(e){var n=e.userId,r=e.allowFriendDiscovery,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var Ot,St=function(t){function n(e){var n=e.userId,r=e.filter,i=t.call(this)||this,s=r.keys;return i.method=p.GET,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params={item_keys:s},i}return e(n,t),n}(m),Ct=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[ae.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[ae.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[ae.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[ae.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[ae.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[ae.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[ae.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[ae.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[ae.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[ae.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[ae.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[ae.SUPER_INVITATION_COUNT]),"number"==typeof n[ae.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[ae.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[ae.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[ae.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[ae.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[ae.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(E),xt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(m),Rt=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}(E),At=function(t){function n(e){var n=e.userId,r=e.filter,i=t.call(this)||this,s=r.channelCustomTypesFilter,o=r.superChannelFilter;return i.method=p.GET,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=o?o:ue.ALL,custom_types:s},i}return e(n,t),n}(m),Pt=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}(E),Lt=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Dt=function(e){var t,n,r;this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(t=e.id)&&void 0!==t?t:0,this.name=null!==(n=e.name)&&void 0!==n?n:"",this.url=null!==(r=e.url)&&void 0!==r?r:"",this.emojis=e.emojis?e.emojis.map((function(e){return new Lt(e)})):[]},Ut=function(e){this.emojiHash=null,this.emojiCategories=[],this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new Dt(e)})):[]},Mt=function(t){function n(){var e=t.call(this)||this;return e.method=p.GET,e.path=I,e}return e(n,t),n}(m),qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiContainer=new Ut(n),r}return e(n,t),n}(E),Ft=function(t){function n(e){var n=e.categoryId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(I,"/").concat(n),r}return e(n,t),n}(m),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiCategory=new Dt(n),r}return e(n,t),n}(E),Kt=function(t){function n(e){var n=e.key,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(w,"/").concat(n),r}return e(n,t),n}(m),jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emoji=new Lt(n),r}return e(n,t),n}(E),Vt=function(t){function n(e){var n=e.limit,r=e.token,i=e.userIdsFilter,s=e.metaDataKeyFilter,o=e.metaDataValuesFilter,a=e.nicknameStartsWithFilter,u=t.call(this)||this;return u.method=p.GET,u.path=_,u.params=v({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return e(n,t),n}(m),Ht=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new y(e,t)})),r.next=n.next,r}return e(n,t),n}(E),Gt=function(t){function i(e,n){var r,i,s,o=this;return(o=t.call(this,e,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return e(i,t),i.prototype._validate=function(){return t.prototype._validate.call(this)&&r("string",this.userIdsFilter,!0)&&n("string",this.metaDataKeyFilter,!0)&&r("string",this.metaDataValuesFilter,!0)&&n("string",this.metaDataKeyFilter,!0)},i.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,s;return f(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=A.of(this._iid).requestQueue,t=new Vt(g(g({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ht),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},i}(T),zt=function(t){function n(e){var n=e.userId,r=e.limit,i=e.token,s=e.userIdsFilter,o=t.call(this)||this;return o.method=p.GET,o.path="".concat(_,"/").concat(n,"/block"),o.params=v({limit:r,token:i,user_ids:s}),o}return e(n,t),n}(m),Qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new y(e,t)})),r.next=n.next,r}return e(n,t),n}(E),Wt=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)&&r("string",this.userIdsFilter,!0)},n.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Qt),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},n}(T),Yt=function(t){function n(e){var n=e.userId,r=e.limit,i=e.token,s=t.call(this)||this;return s.method=p.GET,s.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return e(n,t),n}(m),Jt=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 y(e,t)})),r.next=n.next,r}return e(n,t),n}(E),Xt=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 h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yt(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Jt),o=s.users,a=s.hasMore,u=s.next,this._token=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},n}(T),Zt={},$t=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,o=e.blockHashBase,a=void 0===o?2:o,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,p=e.disableLogger,_=void 0!==p&&p;return Zt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=_,Zt[t]=this),Zt[t]}return e.get=function(e){return Zt[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_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"}(Ot||(Ot={}));var en,tn=function(t){function n(e){var r=e.code,i=void 0===r?Ot.UNKNOWN_ERROR:r,s=e.message,o=void 0===s?"Unknown error occurred.":s,a=t.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,n.prototype),a}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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:Ot.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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:Ot.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:Ot.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:Ot.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:Ot.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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:Ot.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:Ot.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:Ot.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:Ot.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:Ot.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:Ot.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:Ot.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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"}(en||(en={}));var nn,rn=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw tn.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return rn(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]=rn(e[r],t);return t.delete(e),n}return e},sn=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw tn.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},on=function(e,t){for(var n=0,r=0;r>>0)%t},an=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},un=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!un(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!un(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((o=t[r])!==(a=i[s]))return!1;break;case"/neq":case"!=":if((o=t[r])===(a=i[s]))return!1;break;case"/gt":case">":var o=t[r],a=i[s];if(!(sn(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(sn(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(sn(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(sn(o,a)<=0))return!1;break;case"/in":o=t[r];if(!(a=i[s]).includes(o))return!1;break;case"/nin":o=t[r];if((a=i[s]).includes(o))return!1;break;case"/contain":o=t[r],a=i[s];if(!o.includes(a))return!1;break;case"/regex":o=t[r];if(!(a=i[s]).test(o))return!1;break;case"/where":o=t[r];if(!(0,i[s])(o))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)},cn=function(){},ln=function(){return Promise.resolve()},hn=function(e){return e},dn=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(nn||(nn={}));var fn,pn,_n,vn=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,o=e.map,a=void 0===o?hn:o,u=e.backward,c=void 0===u?ln:u,l=e.forward,h=void 0===l?ln:l,d=e.complete,f=void 0===d?cn:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=c,this._forward=h,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 h(this,void 0,void 0,(function(){var e,t,n;return f(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 h(this,void 0,void 0,(function(){var e,t,n;return f(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}(),mn=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,o=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=o}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],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"==typeof this.condition[s]){var a=o>0?n:t;for(var u in this.condition[s])if(a.includes(u))for(var c=r;c>=0;c--)if(o*sn(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*sn(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 h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(o){if((s>0?t:n).includes(o))for(var a=l;a=0){l=a;break}}));else for(var o=l;o=0){l=o;break}},d=this,i=0;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],o=0;o0))return[3,6];o=0,c.label=1;case 1:return o0))return[3,2];for(s=0;s-1){var r=this._items[n];return t===_n.PERSISTENT&&(r.state=pn.PERSISTENT),t!==_n.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)Tn.includes(this._items[r].state)&&Tn.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===pn.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=F(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===pn.VOLATILE&&s>0?s--:o.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this._items=o}}}},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!==pn.VOLATILE}))},e}(),Cn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,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(gn(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(gn(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=[]),h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,K([],D(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=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],u=a.data;n[u.key]||(s.unshift(a),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return f(this,(function(h){switch(h.label){case 0:n=Sn.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 g(g({},e.data),{generation:r})})))];case 2:for(o=h.sent(),a=0;a0))return[3,4];for(t=[],n={},a=e.length-1;a>=0;a--)r=e[a],c=r.data,n[c.key]||(n[c.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=f.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(f.sent(),o=Sn.get(this.dbname),a=0;a0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=o.sent())&&(s=xn.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];o.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return h(this,void 0,void 0,(function(){var t;return f(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 h(this,void 0,void 0,(function(){var n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return n=$t.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,Sn.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?xn.createFromCacheItem(s):new xn({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return h(this,void 0,void 0,(function(){var t;return f(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 h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return e=In(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=c.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:c.sent(),r=Sn.get(this.dbname);try{for(i=F(n),s=i.next();!s.done;s=i.next())o=s.value,r.remove(o)}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}}return[2]}}))}))},e}(),An=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,o=e.store,a=this;this._origin=[],this._table=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(gn(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=o,this._transaction.on(fn.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(fn.ERROR,this.indexerKey,(function(){return a.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=D(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=D(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 o=F(this.fields),a=o.next();!a.done;a=o.next()){var u=a.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 tn.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}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=sn(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 h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,h,d,p,_,v,m;return f(this,(function(f){switch(f.label){case 0:return[4,(e=Sn.get(this.dbname)).find(this._store,this.indexerKey,_n.PERSISTENT)];case 1:return(t=f.sent())?[3,11]:(n=In(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=f.sent(),f.label=3;case 3:f.trys.push([3,8,9,10]),i=F(r),s=i.next(),f.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,_n.NO_CACHE)]:[3,6];case 5:a=f.sent(),u=xn.createFromCacheItem(a);try{for(v=void 0,c=F(u.items),l=c.next();!l.done;l=c.next())h=l.value,this._addItem(h)}catch(e){v={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(v)throw v.error}}f.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return d=f.sent(),p={error:d},[3,10];case 9:try{s&&!s.done&&(_=i.return)&&_.call(i)}finally{if(p)throw p.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=rn(this._origin),f.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return h(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return Sn.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return h(this,void 0,void 0,(function(){return f(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 h(this,void 0,void 0,(function(){return f(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return h(this,void 0,void 0,(function(){return f(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=rn(this._origin)},e.prototype.abort=function(){this._table=rn(this._origin)},e}(),Pn="undefined"!=typeof document&&"undefined"!=typeof navigator;Pn&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var Ln=Pn&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");Pn&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),Pn&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),Pn&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var Dn,Un,Mn=Pn&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),qn=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"}(Dn||(Dn={})),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"}(Un||(Un={}));var Fn,Bn={},Kn=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Dn.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Bn[e]&&!t.forceCreate||(this.nodeId=qn(),this.key=e,Pn&&(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,o=i.requestId,a=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&a===n.key)switch(u){case Un.NEWNODE:n._sendSync();break;case Un.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Un.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,h=l.currentItemRequestId,d=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:Un.REQUEST_LOCK,ts:e.ts})};try{for(var p=F(d),_=p.next();!_.done;_=p.next()){f(_.value)}}catch(e){t={error:e}}finally{try{_&&!_.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===h})),n._completeSync()}break;case Un.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Un.REQUEST_LOCK:n._requestLock(i);break;case Un.ACQUIRE_LOCK:var v=n._queue.find((function(e){return e.requestId===o}));n._acquire(v);break;case Un.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Un.REMOVENODE)}))),Bn[e]=this),Bn[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==Dn.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:qn(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return Pn&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Un.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(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(Un.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(Un.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 h(this,void 0,void 0,(function(){var e=this;return f(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=Dn.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Un.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Un.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Un.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),jn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,o=e.store,a=this;this._state=en.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=K([[r]],D(s.filter((function(e){return An.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Kn(function(e,t){return"".concat(gn(e,t),".lock")}(t,n)),this._blobContainer=new kn({dbname:t,collectionName:n,store:o}),this._transaction=new Cn({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return h(this,void 0,void 0,(function(){var r;return f(this,(function(i){switch(i.label){case 0:return r=En(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}),e.prototype.init=function(){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,p,_,v=this;return f(this,(function(f){switch(f.label){case 0:return[4,this._mutex.lock()];case 1:f.sent(),f.label=2;case 2:return f.trys.push([2,9,,10]),t=$t.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=f.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:f.sent(),this._blockManager=new Rn({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=K([],D(this.indexes),!1),i=[],s=r.map((function(e){return An.createKey(e)})),o=n?n.indexes.map((function(e){return An.createKey(e)})):[];try{for(a=F(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(An.parseKey(c))}catch(e){p={error:e}}finally{try{u&&!u.done&&(_=a.return)&&_.call(a)}finally{if(p)throw p.error}}return(l=[]).push.apply(l,K([],D(r.map((function(e){var t=new An({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store});return v._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,K([],D(i.map((function(e){return new An({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return f.sent(),[4,this._transaction.commit()];case 6:return f.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(h=En(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata,generation:1})]);case 7:f.sent(),f.label=8;case 8:return this._state=en.READY,this._mutex.unlock(),[3,10];case 9:throw d=f.sent(),this._mutex.unlock(),d;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=en.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=An.createKey(e);try{for(var i=F(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===An.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=En(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return a.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return a.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return a.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:a.sent(),a.label=5;case 5:a.trys.push([5,10,11,12]),n=F(this._indexers),r=n.next(),a.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:a.sent(),a.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=a.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw tn.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,p;return f(this,(function(f){switch(f.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=f.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return f.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return f.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:f.sent(),f.label=5;case 5:f.trys.push([5,10,11,12]),r=F(this._indexers),i=r.next(),f.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:f.sent(),f.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=f.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.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:f.sent(),f.label=15;case 15:f.trys.push([15,21,22,23]),o=F(this._indexers),a=o.next(),f.label=16;case 16:return a.done?[3,20]:0===(u=a.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return f.sent(),[4,u.addItem(e)];case 18:f.sent(),f.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=f.sent(),d={error:c},[3,23];case 22:try{a&&!a.done&&(p=o.return)&&p.call(o)}finally{if(d)throw d.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return f(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=F(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 o=c.sent(),a={error:o},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(a)throw a.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=a.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:a.sent(),a.label=3;case 3:a.trys.push([3,8,9,10]),n=F(this._indexers),r=n.next(),a.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=a.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(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=F(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 h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return this._state!==en.READY?[3,6]:[4,this._mutex.lock()];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,rn(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw tn.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this._state===en.READY?new yn({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw tn.collectionKeyNotGiven;return[4,this._requestInsert(rn(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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return f(this,(function(c){switch(c.label){case 0:return this._state!==en.READY?[3,15]:[4,this._mutex.lock()];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 tn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=F(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(rn(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(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.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 tn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw tn.collectionKeyNotGiven;return[4,this._requestUpsert(rn(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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return f(this,(function(c){switch(c.label){case 0:return this._state!==en.READY?[3,15]:[4,this._mutex.lock()];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 tn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=F(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(rn(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(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.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 tn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw tn.collectionKeyNotGiven;return[4,this._requestUpdate(rn(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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l,d,p,_,v,m,y=this;return f(this,(function(b){switch(b.label){case 0:return this._state!==en.READY?[3,16]:[4,this._mutex.lock()];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,o=e.backward,a=void 0!==o&&o,u=[],[4,new mn({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return h(y,void 0,void 0,(function(){var n,i;return f(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,un(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:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),c=F(u),l=c.next(),b.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(rn(d))]);case 6:b.sent(),b.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return p=b.sent(),v={error:p},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,u];case 13:return _=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),_;case 15:return[3,17];case 16:throw this._transaction.clear(),tn.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,d,p,_,v,m=this;return f(this,(function(y){switch(y.label){case 0:return this._state!==en.READY?[3,15]:[4,this._mutex.lock()];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,o=void 0!==s&&s,a=[],[4,new mn({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return h(m,void 0,void 0,(function(){var t,r;return f(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,un(n,t)&&(r=t[this.keyName],a.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=F(a),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(),_={error:d},[3,11];case 10:try{c&&!c.done&&(v=u.return)&&v.call(u)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw p=y.sent(),this._mutex.unlock(),p;case 14:return[3,16];case 15:throw this._transaction.clear(),tn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return h(this,void 0,void 0,(function(){return f(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 void 0===t&&(t=null),h(this,void 0,void 0,(function(){return f(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 h(this,void 0,void 0,(function(){return f(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 h(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Vn={},Hn=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,o=void 0===s?j:s;this._encryption=o,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return Vn[this.dbname]},set:function(e){Vn[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:this.dbname=e,Vn[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get(V.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify(V.value))throw tn.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set(V)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return h(this,void 0,void 0,(function(){return f(this,(function(e){return[2,Object.keys(Vn[this.dbname]).filter((function(e){return e!==V.key}))]}))}))},e.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return[4,an(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,Vn[this.dbname][e]?this._encryption.decrypt(Vn[this.dbname][e]):null]}}))}))},e.prototype.set=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return[4,an(this.delay)];case 1:if(a.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(s=this._encryption.encrypt(n),o=JSON.stringify(s),t===V.key||o.lengths.ts){if(s.all!==t.all&&(o=!0),s.all=t.all>=0?t.all:0,t.customTypes)for(var u in t.customTypes)s.customTypes[u]!==t.customTypes[u]&&(o=!0),s.customTypes[u]=t.customTypes[u];o=o&&s.ts>0,s.ts=a}o&&ne((function(){return h(r,void 0,void 0,(function(){return f(this,(function(e){return[2,p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)}))]}))}))}))}}))}return e.init=function(t){var n=t.appId,r=t.appVersion,i=void 0===r?null:r,s=t.modules,o=void 0===s?[]:s,a=t.options,u=void 0===a?new ie:a,c=t.debugMode,l=void 0!==c&&c,h=t.customApiHost,d=t.customWebSocketHost,f=t.newInstance,p=void 0!==f&&f,_=t.logLevel,v=t.localCacheEnabled,m=void 0!==v&&v,y=t.localCacheEncryption,b=t.useAsyncStorageStore,g=void 0===b?null:b;if(!er||p){var E="su-".concat(se()),I=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},w=new Hn({encryption:I});l||(w=g?new zn({AsyncStorage:g,encryption:I}):new Gn({encryption:I})),new A(E,{appId:n,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:w,encryption:I,logLevel:_,localCacheEnabled:m,debugMode:l});var N=new e(E,u,K(K([],D(o),!1),[new oe],!1));return er||(er=N),N}return er},Object.defineProperty(e,"instance",{get:function(){return er},enumerable:!1,configurable:!0}),Object.defineProperty(e,"version",{get:function(){return Y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appId",{get:function(){return A.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appVersion",{get:function(){var e;return null!==(e=A.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMode",{get:function(){return A.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"logLevel",{get:function(){return A.of(this._iid).logger.level},set:function(e){A.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCacheEnabled",{get:function(){return A.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ekey",{get:function(){return J(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentUser",{get:function(){var e;return null!==(e=A.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){var e=A.of(this._iid).connectionManager;return e.isConnected?X.OPEN:e.isConnecting?X.CONNECTING:X.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastConnectedAt",{get:function(){var e=A.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),e.prototype.getMemoryStoreForDebugging=function(){var e=A.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Hn?n.store:null;throw x.debugModeRequired},e.prototype.addExtension=function(e,t){var n=A.of(this._iid).sdkState;["sb_uikit","sb_syncmanager"].indexOf(e)>-1&&(n.extensions[e]=t)},e.prototype.initializeCache=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return f(this,(function(u){switch(u.label){case 0:return t=A.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,3]:[4,i.logout()];case 1:return u.sent(),n.userId=e,r.localCacheEnabled?(o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.nestdb&&r.nestdb.state!==Fn.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new Yn({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:1,store:r.store})).on("upgrade",function(e){return function(t,n){0===t?e.commitSchema([{collectionName:ce,keyName:le,index:[he(de.LATEST_LAST_MESSAGE),he(de.CHRONOLOGICAL),he(de.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:fe,keyName:pe,index:[_e(ve.CHANNEL_LATEST)]},{collectionName:me,keyName:ye,index:[_e(ve.CHANNEL_LATEST)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return n()})).catch((function(e){return n(e)})):n()}}(a)),[4,a.open()])):[3,3];case 2:u.sent(),s.dispatch(new we(this._iid,{userId:e})),u.label=3;case 3:return[2]}}))}))},e.prototype.clearCache=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return(e=A.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?(e.nestdb.close(),[4,e.nestdb.reset()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.connect=function(e,t){return void 0===t&&(t=null),h(this,void 0,void 0,(function(){var n,r,i,s;return f(this,(function(o){switch(o.label){case 0:n=A.of(this._iid).connectionManager,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return o.sent(),[3,4];case 3:return o.sent(),r=A.of(this._iid),i=r.cacheContext,s=r.logger,i.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,n.connect(t)];case 5:return o.sent(),this._appStateChangeDetector.start(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},e.prototype.reconnect=function(){var e=A.of(this._iid),t=e.connectionManager,n=e.sessionManager.auth.hasSession;return n&&t.reconnect().catch((function(){})),n},e.prototype.disconnect=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return e=A.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCache()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},e.prototype.setBackgroundState=function(){var e=A.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())},e.prototype.setForegroundState=function(){var e=A.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.reconnect())},e.prototype.setSessionHandler=function(e){Z(e instanceof Me).throw(x.invalidParameters),A.of(this._iid).sessionManager.handler=e},e.prototype.addUserEventHandler=function(e,t){Z(n("string",e)&&t instanceof Fe).throw(x.invalidParameters),A.of(this._iid).userEventHandlers.set(e,t)},e.prototype.removeUserEventHandler=function(e){A.of(this._iid).userEventHandlers.delete(e)},e.prototype.removeAllUserEventHandler=function(){A.of(this._iid).userEventHandlers.clear()},e.prototype.addConnectionHandler=function(e,t){Z(n("string",e)&&t instanceof qe).throw(x.invalidParameters),A.of(this._iid).connectionHandlers.set(e,t)},e.prototype.removeConnectionHandler=function(e){A.of(this._iid).connectionHandlers.delete(e)},e.prototype.removeAllConnectionHandler=function(){A.of(this._iid).connectionHandlers.clear()},e.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Gt(this._iid,e)},e.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Wt(this._iid,e)},e.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Xt(this._iid,e)},e.prototype.createMessageSearchQuery=function(e){return new $(this._iid,e)},e.prototype.buildUserFromSerializedData=function(e){var t=ee(e);return new y(this._iid,y.payloadify(t))},e.prototype.updateCurrentUserInfo=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(e instanceof Ae&&e.validate()).throw(x.invalidParameters),this.currentUser?(t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new je(g({userId:n.userId},e)),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(Ve).user,this.currentUser&&(e.nickname&&(this.currentUser.nickname=o.nickname),(e.profileUrl||e.profileImage)&&(this.currentUser.plainProfileUrl=o.profileUrl)),[2,o];case 2:throw x.connectionRequired}}))}))},e.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s,o,a;return f(this,(function(u){switch(u.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),this.currentUser?(t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new je({userId:n.userId,preferredLanguages:e}),[4,i.send(s)]):[3,2];case 1:return o=u.sent(),a=o.as(Ve).user,this.currentUser&&(this.currentUser.preferredLanguages=a.preferredLanguages),[2,a];case 2:throw x.connectionRequired}}))}))},e.prototype.registerFCMPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new Ge({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new Qe({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ye({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.registerAPNSPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new He({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new ze({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new We({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.getChannelInvitationPreference=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ze({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as($e).autoAccept}]}}))}))},e.prototype.setChannelInvitationPreference=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(n("boolean",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new et({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(tt).autoAccept}]}}))}))},e.prototype.getDoNotDisturb=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(rt).preference]}}))}))},e.prototype.setDoNotDisturb=function(e,t,r,i,s,o){return void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=""),h(this,void 0,void 0,(function(){var a,u,c,l,h;return f(this,(function(d){switch(d.label){case 0:return Z(n("boolean",e)&&n("number",t)&&n("number",r)&&n("number",i)&&n("number",s)&&n("string",o)).throw(x.invalidParameters),a=A.of(this._iid),u=a.sdkState,c=a.requestQueue,l=new it({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:r,endHour:i,endMin:s,timezone:o}),[4,c.send(l)];case 1:return h=d.sent(),[2,h.as(st).preference]}}))}))},e.prototype.getSnoozePeriod=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ot({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(at).snoozePeriod]}}))}))},e.prototype.setSnoozePeriod=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=0),h(this,void 0,void 0,(function(){var i,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return Z(n("boolean",e)&&n("number",t)&&n("number",r)).throw(x.invalidParameters),i=A.of(this._iid),s=i.sdkState,o=i.requestQueue,a=new ut({userId:s.userId,snoozeOn:e,startTs:t,endTs:r}),[4,o.send(a)];case 1:return u=c.sent(),[2,u.as(ct).snoozePeriod]}}))}))},e.prototype.getMyPushTokensByToken=function(e,t){return h(this,void 0,void 0,(function(){var r,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return Z(n("string",e)&&i(be,t)).throw(x.invalidParameters),r=A.of(this._iid),s=r.sdkState,o=r.requestQueue,a=new Je({userId:s.userId,type:t,token:e}),[4,o.send(a)];case 1:return u=c.sent(),[2,u.as(Xe).pushTokens]}}))}))},e.prototype.getPushTriggerOption=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Te({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ke).pushTriggerOption]}}))}))},e.prototype.setPushTriggerOption=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(o){switch(o.label){case 0:return Z(i(Se,e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Ce({userId:n.userId,pushTriggerOption:e}),[4,r.send(s)];case 1:return[2,o.sent().as(Oe).pushTriggerOption]}}))}))},e.prototype.getPushTemplate=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new dt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ft).name]}}))}))},e.prototype.setPushTemplate=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(o){switch(o.label){case 0:return Z(i(xe,e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new pt({userId:n.userId,templateName:e}),[4,r.send(s)];case 1:return[2,o.sent().as(_t).name]}}))}))},e.prototype.blockUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(e instanceof y||n("string",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new lt({userId:r.userId,blockedUserId:e instanceof y?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.blockUserWithUserId=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.blockUser(e)]}))}))},e.prototype.unblockUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(e instanceof y||n("string",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new ht({userId:r.userId,unblockedUserId:e instanceof y?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.unblockUserWithUserId=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.unblockUser(e)]}))}))},e.prototype.getFriendChangeLogsByToken=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(n("string",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new vt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(mt).changelogs]}}))}))},e.prototype.getAllowFriendDiscovery=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(kt).allowFriendDiscovery]}}))}))},e.prototype.setAllowFriendDiscovery=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(n("boolean",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new Tt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},e.prototype.uploadFriendDiscoveries=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s;return f(this,(function(o){switch(o.label){case 0:return t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new yt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(bt).friendDiscoveryRequestId]}}))}))},e.prototype.deleteFriendDiscovery=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},e.prototype.deleteFriendDiscoveries=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new gt({userId:n.userId,discoveryKeys:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.addFriends=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new Et({userId:n.userId,userIds:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(It).users]}}))}))},e.prototype.deleteFriend=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.deleteFriends([e])]}))}))},e.prototype.deleteFriends=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new wt({userId:n.userId,userIds:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.getAllEmoji=function(){return h(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:return e=A.of(this._iid).requestQueue,t=new Mt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(qt).emojiContainer]}}))}))},e.prototype.getEmojiCategory=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(i){switch(i.label){case 0:return t=A.of(this._iid).requestQueue,n=new Ft({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Bt).emojiCategory]}}))}))},e.prototype.getEmoji=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(i){switch(i.label){case 0:return t=A.of(this._iid).requestQueue,n=new Kt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(jt).emoji]}}))}))},e.prototype.getUnreadItemCount=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return Z(e instanceof Le&&e.validate()).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,filter:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Rt).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(e instanceof Ue&&e.validate()).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new At({userId:n.userId,filter:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Pt).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(i){switch(i.label){case 0:return Z(e instanceof Jn&&e.validate()).throw(x.invalidParameters),t=A.of(this._iid).requestQueue,n=new Xn(e),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Zn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=A.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=A.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},e.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=A.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e}();export{Gt as ApplicationUserListQuery,Wt as BlockedUserListQuery,qe as ConnectionHandler,Lt as Emoji,Dt as EmojiCategory,Ut as EmojiContainer,Xt as FriendListQuery,Hn as MemoryStore,Me as SessionHandler,Ue as TotalUnreadMessageCountParams,De as TotalUnreadMessageCountParamsProperties,Le as UnreadItemCountParams,Pe as UnreadItemCountParamsProperties,Fe as UserEventHandler,Ae as UserUpdateParams,Re as UserUpdateParamsProperties,tr as default}; +import{_ as e,i as t,a as n,b as r,c as i,n as s,I as u,E as l,d as h,e as f,A as p,f as _,g as v,h as m,U as y,j as g,k as E,l as I,m as w,B as T,S as x,V as A,o as D,p as F,q as K,D as j,r as V,s as G,M as z,t as Q,u as W,v as Y,w as J,C as X,x as Z,y as $,z as ee,W as te,F as ne,G as re,H as ie,J as se,K as oe}from"./__bundle-45e61fc8.js";export{L as ChannelType,C as ConnectionState,N as LogLevel,P as Plugin,R as Role,H as SendbirdChatOptions,S as SendbirdError,U as User,O as UserOnlineState}from"./__bundle-45e61fc8.js";import{U as ae,S as ue,N as ce,a as le,g as he,G as de,b as fe,c as pe,d as _e,M as ve,e as me,f as ye,P as be,h as ge,i as Ee,j as Ie,D as we,k as Ne,l as ke,m as Te,n as Oe,o as Se,p as Ce,q as xe}from"./__bundle-fd9b6bb9.js";export{q as PushTemplate,k as PushTokenRegistrationState,P as PushTokenType,o as PushTriggerOption}from"./__bundle-fd9b6bb9.js";export{B as BannedUserListQuery,a as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,b as RestrictedUser,c as RestrictionInfo,d as RestrictionType}from"./__bundle-876572c8.js";var Re=function(){this.profileImage=null,this.profileUrl=null,this.nickname=null},Ae=function(r){function i(e){var t=r.call(this)||this;if(e)for(var n in e)t.hasOwnProperty(n)&&(t[n]=e[n]);return t}return e(i,r),i.prototype.validate=function(){return t(this.profileImage,!0)&&n("string",this.profileUrl,!0)&&n("string",this.nickname,!0)},i}(Re),Pe=function(){},Le=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return r(ae,this.keys)},n}(Pe),De=function(){this.channelCustomTypesFilter=[],this.superChannelFilter=ue.ALL},Ue=function(t){function n(e){var n=t.call(this)||this;if(e)for(var r in e)n.hasOwnProperty(r)&&(n[r]=e[r]);return n}return e(n,t),n.prototype.validate=function(){return r("string",this.channelCustomTypesFilter)&&i(ue,this.superChannelFilter)},n}(De),Me=function(){this.onSessionExpired=s,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=s,this.onSessionRefreshed=s,this.onSessionClosed=s},qe=function(){this.onConnected=s,this.onReconnectStarted=s,this.onReconnectSucceeded=s,this.onReconnectFailed=s,this.onDisconnected=s},Fe=function(){this.onFriendsDiscovered=s,this.onTotalUnreadMessageCountUpdated=s};!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(u);var Be=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._pauseDelayTimer=null,e._currentState="visible",e}return e(n,t),Object.defineProperty(n.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener},enumerable:!1,configurable:!0}),n.prototype._toggleState=function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},n.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},n.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},n}(l),Ke=function(){function e(e){var t=e.logger,n=e.connectionDelegate;this.logger=t,this.connectionDelegate=n}return Object.defineProperty(e.prototype,"isAvailable",{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._onlineWorker=function(){this.connectionDelegate.reconnect()},e.prototype._offlineWorker=function(){this.connectionDelegate.disconnect()},e.prototype.start=function(){this.isAvailable&&(window.addEventListener("online",this._onlineWorker),window.addEventListener("offline",this._offlineWorker))},e.prototype.stop=function(){this.isAvailable&&(window.removeEventListener("online",this._onlineWorker,!1),window.removeEventListener("offline",this._offlineWorker,!1))},e.prototype.isOnline=function(){return h(this,void 0,void 0,(function(){return f(this,(function(e){return this.isAvailable?[2,navigator.onLine]:[2,new Promise((function(e,t){fetch("https://www.google.com",{method:p.GET}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),je=function(t){function n(e){var n=e.userId,r=e.nickname,i=void 0===r?null:r,s=e.profileUrl,o=void 0===s?null:s,a=e.profileImage,u=void 0===a?null:a,c=e.preferredLanguages,l=void 0===c?null:c,h=t.call(this)||this;return h.method=p.PUT,h.path="".concat(_,"/").concat(encodeURIComponent(n)),h.params=v({nickname:i,profile_url:o,profile_file:u,preferred_languages:l}),h}return e(n,t),n}(m),Ve=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=null,r.user=new y(e,g({},n)),r}return e(n,t),n}(E),He=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var Ge=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var ze=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new y(e,n.user),r}e(n,t)}(E);var Qe=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new y(e,n.user),r}e(n,t)}(E);var We=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.DELETE,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/apns"),r}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var Ye=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.DELETE,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?be[n.type.toLowerCase()]:be.UNKNOWN,r.user=new y(e,n.user),r}e(n,t)}(E);var Je=function(t){function n(e){var n=e.userId,r=e.type,i=e.token,s=e.ts,o=t.call(this)||this;return o.method=p.GET,o.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return e(n,t),n}(m),Xe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTokens={type:n.type?be[n.type.toLowerCase()]:be.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return e(n,t),n}(E),Ze=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return e(n,t),n}(m),$e=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(E),et=function(t){function n(e){var n=e.userId,r=e.willAutoAccept,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return e(n,t),n}(m),tt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(E),nt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),r}return e(n,t),n}(m),rt=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),it=function(t){function n(e){var n=e.userId,r=e.doNotDisturbOn,i=e.startHour,s=e.startMin,o=e.endHour,a=e.endMin,u=e.timezone,c=t.call(this)||this;return c.method=p.PUT,c.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:u},c}return e(n,t),n}(m),st=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),ot=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),r}return e(n,t),n}(m),at=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),ut=function(t){function n(e){var n=e.userId,r=e.snoozeOn,i=e.startTs,s=e.endTs,o=t.call(this)||this;return o.method=p.PUT,o.path="".concat(_,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return e(n,t),n}(m),ct=function(t){function n(e,n){var r=t.call(this,e,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 e(n,t),n}(E),lt=function(t){function n(e){var n=e.userId,r=e.blockedUserId,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return e(n,t),n}(m);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=new y(e,n),r}e(n,t)}(E);var ht=function(t){function n(e){var n=e.userId,r=e.unblockedUserId,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var dt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/template"),r}return e(n,t),n}(m),ft=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(E),pt=function(t){function n(e){var n=e.userId,r=e.templateName,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return e(n,t),n}(m),_t=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(E),vt=function(t){function n(e){var n=e.userId,r=e.token,i=t.call(this)||this;return i.method=p.GET,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return e(n,t),n}(m),mt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.changelogs={addedUsers:n.added.map((function(t){return new y(e,t)})),updatedUsers:n.updated.map((function(t){return new y(e,t)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return e(n,t),n}(E),yt=function(t){function n(e){var n=e.userId,r=e.discoveries,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").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 e(n,t),n}(m),bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return e(n,t),n}(E),gt=function(t){function n(e){var n=e.userId,r=e.discoveryKeys,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var Et=function(t){function n(e){var n=e.userId,r=e.userIds,i=t.call(this)||this;return i.method=p.POST,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return e(n,t),n}(m),It=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new y(e,t)})),r}return e(n,t),n}(E),wt=function(t){function n(e){var n=e.userId,r=e.userIds,i=t.call(this)||this;return i.method=p.DELETE,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var Nt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return e(n,t),n}(m),kt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return e(n,t),n}(E),Tt=function(t){function n(e){var n=e.userId,r=e.allowFriendDiscovery,i=t.call(this)||this;return i.method=p.PUT,i.path="".concat(_,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return e(n,t),n}(m);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(E);var Ot,St=function(t){function n(e){var n=e.userId,r=e.filter,i=t.call(this)||this,s=r.keys;return i.method=p.GET,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params={item_keys:s},i}return e(n,t),n}(m),Ct=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[ae.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[ae.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[ae.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[ae.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[ae.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[ae.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[ae.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[ae.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[ae.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[ae.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[ae.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[ae.SUPER_INVITATION_COUNT]),"number"==typeof n[ae.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[ae.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[ae.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[ae.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[ae.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[ae.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(E),xt=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(_,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(m),Rt=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}(E),At=function(t){function n(e){var n=e.userId,r=e.filter,i=t.call(this)||this,s=r.channelCustomTypesFilter,o=r.superChannelFilter;return i.method=p.GET,i.path="".concat(_,"/").concat(encodeURIComponent(n),"/unread_message_count"),i.params={super_mode:null!=o?o:ue.ALL,custom_types:s},i}return e(n,t),n}(m),Pt=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}(E),Lt=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Dt=function(e){var t,n,r;this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(t=e.id)&&void 0!==t?t:0,this.name=null!==(n=e.name)&&void 0!==n?n:"",this.url=null!==(r=e.url)&&void 0!==r?r:"",this.emojis=e.emojis?e.emojis.map((function(e){return new Lt(e)})):[]},Ut=function(e){this.emojiHash=null,this.emojiCategories=[],this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new Dt(e)})):[]},Mt=function(t){function n(){var e=t.call(this)||this;return e.method=p.GET,e.path=I,e}return e(n,t),n}(m),qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiContainer=new Ut(n),r}return e(n,t),n}(E),Ft=function(t){function n(e){var n=e.categoryId,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(I,"/").concat(n),r}return e(n,t),n}(m),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiCategory=new Dt(n),r}return e(n,t),n}(E),Kt=function(t){function n(e){var n=e.key,r=t.call(this)||this;return r.method=p.GET,r.path="".concat(w,"/").concat(n),r}return e(n,t),n}(m),jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emoji=new Lt(n),r}return e(n,t),n}(E),Vt=function(t){function n(e){var n=e.limit,r=e.token,i=e.userIdsFilter,s=e.metaDataKeyFilter,o=e.metaDataValuesFilter,a=e.nicknameStartsWithFilter,u=t.call(this)||this;return u.method=p.GET,u.path=_,u.params=v({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return e(n,t),n}(m),Ht=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new y(e,t)})),r.next=n.next,r}return e(n,t),n}(E),Gt=function(t){function i(e,n){var r,i,s,o=this;return(o=t.call(this,e,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return e(i,t),i.prototype._validate=function(){return t.prototype._validate.call(this)&&r("string",this.userIdsFilter,!0)&&n("string",this.metaDataKeyFilter,!0)&&r("string",this.metaDataValuesFilter,!0)&&n("string",this.metaDataKeyFilter,!0)},i.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,s;return f(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=A.of(this._iid).requestQueue,t=new Vt(g(g({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ht),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},i}(T),zt=function(t){function n(e){var n=e.userId,r=e.limit,i=e.token,s=e.userIdsFilter,o=t.call(this)||this;return o.method=p.GET,o.path="".concat(_,"/").concat(n,"/block"),o.params=v({limit:r,token:i,user_ids:s}),o}return e(n,t),n}(m),Qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new y(e,t)})),r.next=n.next,r}return e(n,t),n}(E),Wt=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)&&r("string",this.userIdsFilter,!0)},n.prototype.next=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return f(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Qt),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},n}(T),Yt=function(t){function n(e){var n=e.userId,r=e.limit,i=e.token,s=t.call(this)||this;return s.method=p.GET,s.path="".concat(_,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return e(n,t),n}(m),Jt=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 y(e,t)})),r.next=n.next,r}return e(n,t),n}(E),Xt=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 h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yt(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Jt),o=s.users,a=s.hasMore,u=s.next,this._token=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},n}(T),Zt={},$t=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,o=e.blockHashBase,a=void 0===o?2:o,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,p=e.disableLogger,_=void 0!==p&&p;return Zt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=_,Zt[t]=this),Zt[t]}return e.get=function(e){return Zt[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_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"}(Ot||(Ot={}));var en,tn=function(t){function n(e){var r=e.code,i=void 0===r?Ot.UNKNOWN_ERROR:r,s=e.message,o=void 0===s?"Unknown error occurred.":s,a=t.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,n.prototype),a}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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:Ot.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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:Ot.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:Ot.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:Ot.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:Ot.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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:Ot.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:Ot.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:Ot.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:Ot.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:Ot.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:Ot.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:Ot.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:Ot.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:Ot.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:Ot.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"}(en||(en={}));var nn,rn=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw tn.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return rn(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]=rn(e[r],t);return t.delete(e),n}return e},sn=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw tn.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},on=function(e,t){for(var n=0,r=0;r>>0)%t},an=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},un=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!un(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!un(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((o=t[r])!==(a=i[s]))return!1;break;case"/neq":case"!=":if((o=t[r])===(a=i[s]))return!1;break;case"/gt":case">":var o=t[r],a=i[s];if(!(sn(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(sn(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(sn(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(sn(o,a)<=0))return!1;break;case"/in":o=t[r];if(!(a=i[s]).includes(o))return!1;break;case"/nin":o=t[r];if((a=i[s]).includes(o))return!1;break;case"/contain":o=t[r],a=i[s];if(!o.includes(a))return!1;break;case"/regex":o=t[r];if(!(a=i[s]).test(o))return!1;break;case"/where":o=t[r];if(!(0,i[s])(o))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)},cn=function(){},ln=function(){return Promise.resolve()},hn=function(e){return e},dn=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(nn||(nn={}));var fn,pn,_n,vn=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,o=e.map,a=void 0===o?hn:o,u=e.backward,c=void 0===u?ln:u,l=e.forward,h=void 0===l?ln:l,d=e.complete,f=void 0===d?cn:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=c,this._forward=h,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 h(this,void 0,void 0,(function(){var e,t,n;return f(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 h(this,void 0,void 0,(function(){var e,t,n;return f(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}(),mn=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,o=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=o}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],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"==typeof this.condition[s]){var a=o>0?n:t;for(var u in this.condition[s])if(a.includes(u))for(var c=r;c>=0;c--)if(o*sn(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*sn(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 h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(o){if((s>0?t:n).includes(o))for(var a=l;a=0){l=a;break}}));else for(var o=l;o=0){l=o;break}},d=this,i=0;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],o=0;o0))return[3,6];o=0,c.label=1;case 1:return o0))return[3,2];for(s=0;s-1){var r=this._items[n];return t===_n.PERSISTENT&&(r.state=pn.PERSISTENT),t!==_n.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)Tn.includes(this._items[r].state)&&Tn.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===pn.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=F(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===pn.VOLATILE&&s>0?s--:o.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this._items=o}}}},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!==pn.VOLATILE}))},e}(),Cn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,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(gn(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(gn(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=[]),h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,K([],D(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=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],u=a.data;n[u.key]||(s.unshift(a),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return f(this,(function(h){switch(h.label){case 0:n=Sn.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 g(g({},e.data),{generation:r})})))];case 2:for(o=h.sent(),a=0;a0))return[3,4];for(t=[],n={},a=e.length-1;a>=0;a--)r=e[a],c=r.data,n[c.key]||(n[c.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=f.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(f.sent(),o=Sn.get(this.dbname),a=0;a0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=o.sent())&&(s=xn.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];o.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return h(this,void 0,void 0,(function(){var t;return f(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 h(this,void 0,void 0,(function(){var n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return n=$t.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,Sn.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?xn.createFromCacheItem(s):new xn({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return h(this,void 0,void 0,(function(){var t;return f(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 h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return e=In(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=c.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:c.sent(),r=Sn.get(this.dbname);try{for(i=F(n),s=i.next();!s.done;s=i.next())o=s.value,r.remove(o)}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}}return[2]}}))}))},e}(),An=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,o=e.store,a=this;this._origin=[],this._table=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(gn(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=o,this._transaction.on(fn.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(fn.ERROR,this.indexerKey,(function(){return a.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=D(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=D(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 o=F(this.fields),a=o.next();!a.done;a=o.next()){var u=a.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 tn.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}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=sn(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 h(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,h,d,p,_,v,m;return f(this,(function(f){switch(f.label){case 0:return[4,(e=Sn.get(this.dbname)).find(this._store,this.indexerKey,_n.PERSISTENT)];case 1:return(t=f.sent())?[3,11]:(n=In(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=f.sent(),f.label=3;case 3:f.trys.push([3,8,9,10]),i=F(r),s=i.next(),f.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,_n.NO_CACHE)]:[3,6];case 5:a=f.sent(),u=xn.createFromCacheItem(a);try{for(v=void 0,c=F(u.items),l=c.next();!l.done;l=c.next())h=l.value,this._addItem(h)}catch(e){v={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(v)throw v.error}}f.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return d=f.sent(),p={error:d},[3,10];case 9:try{s&&!s.done&&(_=i.return)&&_.call(i)}finally{if(p)throw p.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=rn(this._origin),f.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return h(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return Sn.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return h(this,void 0,void 0,(function(){return f(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 h(this,void 0,void 0,(function(){return f(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return h(this,void 0,void 0,(function(){return f(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=rn(this._origin)},e.prototype.abort=function(){this._table=rn(this._origin)},e}(),Pn="undefined"!=typeof document&&"undefined"!=typeof navigator;Pn&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var Ln=Pn&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");Pn&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),Pn&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),Pn&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var Dn,Un,Mn=Pn&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),qn=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"}(Dn||(Dn={})),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"}(Un||(Un={}));var Fn,Bn={},Kn=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Dn.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Bn[e]&&!t.forceCreate||(this.nodeId=qn(),this.key=e,Pn&&(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,o=i.requestId,a=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&a===n.key)switch(u){case Un.NEWNODE:n._sendSync();break;case Un.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Un.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,h=l.currentItemRequestId,d=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:Un.REQUEST_LOCK,ts:e.ts})};try{for(var p=F(d),_=p.next();!_.done;_=p.next()){f(_.value)}}catch(e){t={error:e}}finally{try{_&&!_.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===h})),n._completeSync()}break;case Un.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Un.REQUEST_LOCK:n._requestLock(i);break;case Un.ACQUIRE_LOCK:var v=n._queue.find((function(e){return e.requestId===o}));n._acquire(v);break;case Un.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Un.REMOVENODE)}))),Bn[e]=this),Bn[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==Dn.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:qn(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return Pn&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Un.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(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(Un.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(Un.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 h(this,void 0,void 0,(function(){var e=this;return f(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=Dn.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Un.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Un.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Un.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),jn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,o=e.store,a=this;this._state=en.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=K([[r]],D(s.filter((function(e){return An.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Kn(function(e,t){return"".concat(gn(e,t),".lock")}(t,n)),this._blobContainer=new kn({dbname:t,collectionName:n,store:o}),this._transaction=new Cn({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return h(this,void 0,void 0,(function(){var r;return f(this,(function(i){switch(i.label){case 0:return r=En(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}),e.prototype.init=function(){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,p,_,v=this;return f(this,(function(f){switch(f.label){case 0:return[4,this._mutex.lock()];case 1:f.sent(),f.label=2;case 2:return f.trys.push([2,9,,10]),t=$t.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=f.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:f.sent(),this._blockManager=new Rn({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=K([],D(this.indexes),!1),i=[],s=r.map((function(e){return An.createKey(e)})),o=n?n.indexes.map((function(e){return An.createKey(e)})):[];try{for(a=F(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(An.parseKey(c))}catch(e){p={error:e}}finally{try{u&&!u.done&&(_=a.return)&&_.call(a)}finally{if(p)throw p.error}}return(l=[]).push.apply(l,K([],D(r.map((function(e){var t=new An({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store});return v._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,K([],D(i.map((function(e){return new An({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return f.sent(),[4,this._transaction.commit()];case 6:return f.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(h=En(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata,generation:1})]);case 7:f.sent(),f.label=8;case 8:return this._state=en.READY,this._mutex.unlock(),[3,10];case 9:throw d=f.sent(),this._mutex.unlock(),d;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=en.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=An.createKey(e);try{for(var i=F(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===An.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return e=En(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return a.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return a.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return a.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:a.sent(),a.label=5;case 5:a.trys.push([5,10,11,12]),n=F(this._indexers),r=n.next(),a.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:a.sent(),a.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=a.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw tn.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,p;return f(this,(function(f){switch(f.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=f.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return f.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return f.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:f.sent(),f.label=5;case 5:f.trys.push([5,10,11,12]),r=F(this._indexers),i=r.next(),f.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:f.sent(),f.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=f.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.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:f.sent(),f.label=15;case 15:f.trys.push([15,21,22,23]),o=F(this._indexers),a=o.next(),f.label=16;case 16:return a.done?[3,20]:0===(u=a.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return f.sent(),[4,u.addItem(e)];case 18:f.sent(),f.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=f.sent(),d={error:c},[3,23];case 22:try{a&&!a.done&&(p=o.return)&&p.call(o)}finally{if(d)throw d.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return f(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=F(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 o=c.sent(),a={error:o},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(a)throw a.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=a.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:a.sent(),a.label=3;case 3:a.trys.push([3,8,9,10]),n=F(this._indexers),r=n.next(),a.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=a.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(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=F(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 h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return this._state!==en.READY?[3,6]:[4,this._mutex.lock()];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,rn(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw tn.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this._state===en.READY?new yn({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw tn.collectionKeyNotGiven;return[4,this._requestInsert(rn(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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return f(this,(function(c){switch(c.label){case 0:return this._state!==en.READY?[3,15]:[4,this._mutex.lock()];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 tn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=F(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(rn(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(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.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 tn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw tn.collectionKeyNotGiven;return[4,this._requestUpsert(rn(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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return f(this,(function(c){switch(c.label){case 0:return this._state!==en.READY?[3,15]:[4,this._mutex.lock()];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 tn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=F(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(rn(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(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.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 tn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw tn.collectionKeyNotGiven;return[4,this._requestUpdate(rn(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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l,d,p,_,v,m,y=this;return f(this,(function(b){switch(b.label){case 0:return this._state!==en.READY?[3,16]:[4,this._mutex.lock()];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,o=e.backward,a=void 0!==o&&o,u=[],[4,new mn({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return h(y,void 0,void 0,(function(){var n,i;return f(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,un(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:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),c=F(u),l=c.next(),b.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestUpdate(rn(d))]);case 6:b.sent(),b.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return p=b.sent(),v={error:p},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,u];case 13:return _=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),_;case 15:return[3,17];case 16:throw this._transaction.clear(),tn.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,d,p,_,v,m=this;return f(this,(function(y){switch(y.label){case 0:return this._state!==en.READY?[3,15]:[4,this._mutex.lock()];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,o=void 0!==s&&s,a=[],[4,new mn({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return h(m,void 0,void 0,(function(){var t,r;return f(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,un(n,t)&&(r=t[this.keyName],a.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=F(a),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(),_={error:d},[3,11];case 10:try{c&&!c.done&&(v=u.return)&&v.call(u)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw p=y.sent(),this._mutex.unlock(),p;case 14:return[3,16];case 15:throw this._transaction.clear(),tn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._state!==en.READY?[3,8]:[4,this._mutex.lock()];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 tn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return h(this,void 0,void 0,(function(){return f(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 void 0===t&&(t=null),h(this,void 0,void 0,(function(){return f(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 h(this,void 0,void 0,(function(){return f(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 h(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Vn={},Hn=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,o=void 0===s?j:s;this._encryption=o,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return Vn[this.dbname]},set:function(e){Vn[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return h(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:this.dbname=e,Vn[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get(V.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify(V.value))throw tn.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set(V)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return h(this,void 0,void 0,(function(){return f(this,(function(e){return[2,Object.keys(Vn[this.dbname]).filter((function(e){return e!==V.key}))]}))}))},e.prototype.get=function(e){return h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return[4,an(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,Vn[this.dbname][e]?this._encryption.decrypt(Vn[this.dbname][e]):null]}}))}))},e.prototype.set=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return[4,an(this.delay)];case 1:if(a.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(s=this._encryption.encrypt(n),o=JSON.stringify(s),t===V.key||o.lengths.ts){if(s.all!==t.all&&(o=!0),s.all=t.all>=0?t.all:0,t.customTypes)for(var u in t.customTypes)s.customTypes[u]!==t.customTypes[u]&&(o=!0),s.customTypes[u]=t.customTypes[u];o=o&&s.ts>0,s.ts=a}o&&ne((function(){return h(r,void 0,void 0,(function(){return f(this,(function(e){return[2,p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)}))]}))}))}))}}))}return e.init=function(t){var n=t.appId,r=t.appVersion,i=void 0===r?null:r,s=t.modules,o=void 0===s?[]:s,a=t.options,u=void 0===a?new ie:a,c=t.debugMode,l=void 0!==c&&c,h=t.customApiHost,d=t.customWebSocketHost,f=t.newInstance,p=void 0!==f&&f,_=t.logLevel,v=t.localCacheEnabled,m=void 0!==v&&v,y=t.localCacheEncryption,b=t.useAsyncStorageStore,g=void 0===b?null:b;if(!er||p){var E="su-".concat(se()),I=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},w=new Hn({encryption:I});l||(w=g?new zn({AsyncStorage:g,encryption:I}):new Gn({encryption:I})),new A(E,{appId:n,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:w,encryption:I,logLevel:_,localCacheEnabled:m,debugMode:l});var N=new e(E,u,K(K([],D(o),!1),[new oe],!1));return er||(er=N),N}return er},Object.defineProperty(e,"instance",{get:function(){return er},enumerable:!1,configurable:!0}),Object.defineProperty(e,"version",{get:function(){return Y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appId",{get:function(){return A.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appVersion",{get:function(){var e;return null!==(e=A.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMode",{get:function(){return A.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"logLevel",{get:function(){return A.of(this._iid).logger.level},set:function(e){A.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCacheEnabled",{get:function(){return A.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ekey",{get:function(){return J(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentUser",{get:function(){var e;return null!==(e=A.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){var e=A.of(this._iid).connectionManager;return e.isConnected?X.OPEN:e.isConnecting?X.CONNECTING:X.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastConnectedAt",{get:function(){var e=A.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),e.prototype.getMemoryStoreForDebugging=function(){var e=A.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Hn?n.store:null;throw x.debugModeRequired},e.prototype.addExtension=function(e,t){var n=A.of(this._iid).sdkState;["sb_uikit","sb_syncmanager"].indexOf(e)>-1&&(n.extensions[e]=t)},e.prototype.initializeCache=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return f(this,(function(u){switch(u.label){case 0:return t=A.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,3]:[4,i.logout()];case 1:return u.sent(),n.userId=e,r.localCacheEnabled?(o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.nestdb&&r.nestdb.state!==Fn.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new Yn({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:1,store:r.store})).on("upgrade",function(e){return function(t,n){0===t?e.commitSchema([{collectionName:ce,keyName:le,index:[he(de.LATEST_LAST_MESSAGE),he(de.CHRONOLOGICAL),he(de.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:fe,keyName:pe,index:[_e(ve.CHANNEL_LATEST)]},{collectionName:me,keyName:ye,index:[_e(ve.CHANNEL_LATEST)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return n()})).catch((function(e){return n(e)})):n()}}(a)),[4,a.open()])):[3,3];case 2:u.sent(),s.dispatch(new we(this._iid,{userId:e})),u.label=3;case 3:return[2]}}))}))},e.prototype.clearCache=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return(e=A.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?(e.nestdb.close(),[4,e.nestdb.reset()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.connect=function(e,t){return void 0===t&&(t=null),h(this,void 0,void 0,(function(){var n,r,i,s;return f(this,(function(o){switch(o.label){case 0:n=A.of(this._iid).connectionManager,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return o.sent(),[3,4];case 3:return o.sent(),r=A.of(this._iid),i=r.cacheContext,s=r.logger,i.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,n.connect(t)];case 5:return o.sent(),this._appStateChangeDetector.start(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},e.prototype.reconnect=function(){var e=A.of(this._iid),t=e.connectionManager,n=e.sessionManager.auth.hasSession;return n&&t.reconnect().catch((function(){})),n},e.prototype.disconnect=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return e=A.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCache()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},e.prototype.setBackgroundState=function(){var e=A.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())},e.prototype.setForegroundState=function(){var e=A.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.reconnect())},e.prototype.setSessionHandler=function(e){Z(e instanceof Me).throw(x.invalidParameters),A.of(this._iid).sessionManager.handler=e},e.prototype.addUserEventHandler=function(e,t){Z(n("string",e)&&t instanceof Fe).throw(x.invalidParameters),A.of(this._iid).userEventHandlers.set(e,t)},e.prototype.removeUserEventHandler=function(e){A.of(this._iid).userEventHandlers.delete(e)},e.prototype.removeAllUserEventHandler=function(){A.of(this._iid).userEventHandlers.clear()},e.prototype.addConnectionHandler=function(e,t){Z(n("string",e)&&t instanceof qe).throw(x.invalidParameters),A.of(this._iid).connectionHandlers.set(e,t)},e.prototype.removeConnectionHandler=function(e){A.of(this._iid).connectionHandlers.delete(e)},e.prototype.removeAllConnectionHandler=function(){A.of(this._iid).connectionHandlers.clear()},e.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Gt(this._iid,e)},e.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Wt(this._iid,e)},e.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Xt(this._iid,e)},e.prototype.createMessageSearchQuery=function(e){return new $(this._iid,e)},e.prototype.buildUserFromSerializedData=function(e){var t=ee(e);return new y(this._iid,y.payloadify(t))},e.prototype.updateCurrentUserInfo=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(e instanceof Ae&&e.validate()).throw(x.invalidParameters),this.currentUser?(t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new je(g({userId:n.userId},e)),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(Ve).user,this.currentUser&&(e.nickname&&(this.currentUser.nickname=o.nickname),(e.profileUrl||e.profileImage)&&(this.currentUser.plainProfileUrl=o.profileUrl)),[2,o];case 2:throw x.connectionRequired}}))}))},e.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s,o,a;return f(this,(function(u){switch(u.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),this.currentUser?(t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new je({userId:n.userId,preferredLanguages:e}),[4,i.send(s)]):[3,2];case 1:return o=u.sent(),a=o.as(Ve).user,this.currentUser&&(this.currentUser.preferredLanguages=a.preferredLanguages),[2,a];case 2:throw x.connectionRequired}}))}))},e.prototype.registerFCMPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new Ge({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new Qe({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ye({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.registerAPNSPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new He({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:if(Z(n("string",e)).throw(x.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new ze({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,Ne.SUCCESS];case 3:return o.sent(),[2,Ne.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ne.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new We({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.getChannelInvitationPreference=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ze({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as($e).autoAccept}]}}))}))},e.prototype.setChannelInvitationPreference=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(n("boolean",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new et({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(tt).autoAccept}]}}))}))},e.prototype.getDoNotDisturb=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(rt).preference]}}))}))},e.prototype.setDoNotDisturb=function(e,t,r,i,s,o){return void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=""),h(this,void 0,void 0,(function(){var a,u,c,l,h;return f(this,(function(d){switch(d.label){case 0:return Z(n("boolean",e)&&n("number",t)&&n("number",r)&&n("number",i)&&n("number",s)&&n("string",o)).throw(x.invalidParameters),a=A.of(this._iid),u=a.sdkState,c=a.requestQueue,l=new it({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:r,endHour:i,endMin:s,timezone:o}),[4,c.send(l)];case 1:return h=d.sent(),[2,h.as(st).preference]}}))}))},e.prototype.getSnoozePeriod=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ot({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(at).snoozePeriod]}}))}))},e.prototype.setSnoozePeriod=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=0),h(this,void 0,void 0,(function(){var i,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return Z(n("boolean",e)&&n("number",t)&&n("number",r)).throw(x.invalidParameters),i=A.of(this._iid),s=i.sdkState,o=i.requestQueue,a=new ut({userId:s.userId,snoozeOn:e,startTs:t,endTs:r}),[4,o.send(a)];case 1:return u=c.sent(),[2,u.as(ct).snoozePeriod]}}))}))},e.prototype.getMyPushTokensByToken=function(e,t){return h(this,void 0,void 0,(function(){var r,s,o,a,u;return f(this,(function(c){switch(c.label){case 0:return Z(n("string",e)&&i(be,t)).throw(x.invalidParameters),r=A.of(this._iid),s=r.sdkState,o=r.requestQueue,a=new Je({userId:s.userId,type:t,token:e}),[4,o.send(a)];case 1:return u=c.sent(),[2,u.as(Xe).pushTokens]}}))}))},e.prototype.getPushTriggerOption=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Te({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ke).pushTriggerOption]}}))}))},e.prototype.setPushTriggerOption=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(o){switch(o.label){case 0:return Z(i(Se,e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Ce({userId:n.userId,pushTriggerOption:e}),[4,r.send(s)];case 1:return[2,o.sent().as(Oe).pushTriggerOption]}}))}))},e.prototype.getPushTemplate=function(){return h(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(i){switch(i.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new dt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ft).name]}}))}))},e.prototype.setPushTemplate=function(e){return h(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(o){switch(o.label){case 0:return Z(i(xe,e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new pt({userId:n.userId,templateName:e}),[4,r.send(s)];case 1:return[2,o.sent().as(_t).name]}}))}))},e.prototype.blockUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(e instanceof y||n("string",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new lt({userId:r.userId,blockedUserId:e instanceof y?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.blockUserWithUserId=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.blockUser(e)]}))}))},e.prototype.unblockUser=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(e instanceof y||n("string",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new ht({userId:r.userId,unblockedUserId:e instanceof y?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.unblockUserWithUserId=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.unblockUser(e)]}))}))},e.prototype.getFriendChangeLogsByToken=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(n("string",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new vt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(mt).changelogs]}}))}))},e.prototype.getAllowFriendDiscovery=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(kt).allowFriendDiscovery]}}))}))},e.prototype.setAllowFriendDiscovery=function(e){return h(this,void 0,void 0,(function(){var t,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(n("boolean",e)).throw(x.invalidParameters),t=A.of(this._iid),r=t.sdkState,i=t.requestQueue,s=new Tt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},e.prototype.uploadFriendDiscoveries=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s;return f(this,(function(o){switch(o.label){case 0:return t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new yt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(bt).friendDiscoveryRequestId]}}))}))},e.prototype.deleteFriendDiscovery=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},e.prototype.deleteFriendDiscoveries=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new gt({userId:n.userId,discoveryKeys:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.addFriends=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s,o;return f(this,(function(a){switch(a.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new Et({userId:n.userId,userIds:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(It).users]}}))}))},e.prototype.deleteFriend=function(e){return h(this,void 0,void 0,(function(){return f(this,(function(t){return[2,this.deleteFriends([e])]}))}))},e.prototype.deleteFriends=function(e){return h(this,void 0,void 0,(function(){var t,n,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(r("string",e)).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,i=t.requestQueue,s=new wt({userId:n.userId,userIds:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},e.prototype.getAllEmoji=function(){return h(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:return e=A.of(this._iid).requestQueue,t=new Mt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(qt).emojiContainer]}}))}))},e.prototype.getEmojiCategory=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(i){switch(i.label){case 0:return t=A.of(this._iid).requestQueue,n=new Ft({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Bt).emojiCategory]}}))}))},e.prototype.getEmoji=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(i){switch(i.label){case 0:return t=A.of(this._iid).requestQueue,n=new Kt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(jt).emoji]}}))}))},e.prototype.getUnreadItemCount=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return Z(e instanceof Le&&e.validate()).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,filter:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return f(this,(function(s){switch(s.label){case 0:return e=A.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Rt).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,s;return f(this,(function(o){switch(o.label){case 0:return Z(e instanceof Ue&&e.validate()).throw(x.invalidParameters),t=A.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new At({userId:n.userId,filter:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Pt).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(i){switch(i.label){case 0:return Z(e instanceof Jn&&e.validate()).throw(x.invalidParameters),t=A.of(this._iid).requestQueue,n=new Xn(e),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Zn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=A.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=A.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},e.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=A.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e}();export{Gt as ApplicationUserListQuery,Wt as BlockedUserListQuery,qe as ConnectionHandler,Lt as Emoji,Dt as EmojiCategory,Ut as EmojiContainer,Xt as FriendListQuery,Hn as MemoryStore,Me as SessionHandler,Ue as TotalUnreadMessageCountParams,De as TotalUnreadMessageCountParamsProperties,Le as UnreadItemCountParams,Pe as UnreadItemCountParamsProperties,Fe as UserEventHandler,Ae as UserUpdateParams,Re as UserUpdateParamsProperties,tr as default};